# Solving an equation with terms that require double summation and products

2 visualizzazioni (ultimi 30 giorni)
GS76 il 19 Gen 2020
Commentato: GS76 il 22 Gen 2020
I need to solve the following equation.
I wrote the following code based on the above equation, but I believe I have made a mistake as the final answer is large.
I have attached the *.mat file for reference.
Any assistance would be much appreciated.
% Condition number for the optimal distribution of the hole-drilling depth increments, base on the "Integral Method" for the non-uniform hole-drilling residual stress measurement technique
% Determination of the condition number for the optimal distribution of the hole-drilling depth increments,
% base on the "Integral Method" for the non-uniform hole-drilling residual stress measurement technique.
% The following equation as referenced from this source (see below) is used
% for this determination.
% Develop the terms of the equation
% The individual terms of the equation will be developed individually and then brought together.
aij = anp.aij
% Length of array
N = length(aij)
% Summation of matrix
aij_2 = aij^2
y1 = sum(aij_2(:))
% Product of the matrix
aii = diag(aij)
aii_2 = aii.^2
% Product of the square of the diagonal of the matrix
y2 = 4*prod(aii_2,"all")
% The complete equation is as follows:
K_A = (y1 + (y1.^2-y2).^0.5)./y2
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

David Goodmanson il 20 Gen 2020
Modificato: David Goodmanson il 20 Gen 2020
Hi GS,
I reproduced your results and then calculated the equation using for loops, just to make sure, and got 1.8767e37, same as the second way. Anyway,
aij_2 = aij^2
can't really be correct since it squares the entire matrix as a matrix product, but both
aij_2 = aij.^2
and the for loop way of doing things proceed element-by-element.
Such a large result as 10^37, is that expected? The expression depends on the scaling of the matrix, i.e. if every element in the matrix were multiplied by 2, the result would be different. If the result is supposed to be a dimensionless condition number, I would think there would have to be some kind of normalization done on aij before using the expression that you have.
Here's Matlab cond:
cond(aij)
ans = 51.3232
##### 9 CommentiMostra 7 commenti meno recentiNascondi 7 commenti meno recenti
David Goodmanson il 21 Gen 2020
Hi GS, the code looks good, although I think replacing ^0.5 with sqrt looks cleaner, and you don't need N
aij_2 = aij.^2;
y1 = sum(aij_2(:))
aii = diag(aij);
aii_2 = aii.^2;
y2 = 4*prod(aii_2);
K_A = (y1 + sqrt(y1^2-y2))/y2
I probably would have used
y1 = sum(sum(aij_2))
just by personal preference, since it emphasizes that there is a 2d sum, but that's neither here nor there.
Incidentally, abbreviating the supposed condition number K_A by c, then c is one of the solutions to the quadratic
y2*c^2 - 2*y1*c + 1 = 0
I wonder what that means?
GS76 il 22 Gen 2020
Thank you for your valued response and confirmation of my maths.
I like you thinking with regards the quadratic equation! The paper discusses the "minimising" the condition number.
Unfortunately, no response from the author as of yet.

Accedi per commentare.

### Più risposte (1)

David Goodmanson il 19 Gen 2020
Modificato: David Goodmanson il 19 Gen 2020
Hi GS, try
aij_2 = aij.^2
Since y1 and y2 are scalars, there are three dots in the last equation that you can drop. I usually do this because it's neater and provides an extra clue to what the variables are. That's a net savings of two dots, which you can use in another equation sometime.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
GS76 il 20 Gen 2020
Hi David,
So for the above code, K_A = 6.1743e37.
And for the follwoing code as you suggested (I hope I got it right), K_A = 1.8767e37.
I am going to look into this further as I believe I am not getting the "double summation" and "product" of this series correct.
%% Condition number for the optimal distribution of the hole-drilling depth increments, base on the "Integral Method" for the non-uniform hole-drilling residual stress measurement technique
%% Introduction
% Determination of the condition number for the optimal distribution of the
% hole-drilling depth increments, base on the "Integral Method" for the non-uniform
% hole-drilling residual stress measurement technique.
%
% The following equation as referenced from this source (see below) is used
% for this determination.
%
%
%% Develop the terms of the equation
% The individual terms of the equation will be developed individually and the
% brought together.
aij = anp.aij
%%
% Length of elements
% Length of array
N = length(aij)
% Double summation
% Summation of matrix
aij_2 = aij.^2
y1 = sum(aij_2(:))
% Product
% Product of the matrix
aii = diag(aij)
aii_2 = aii.^2
% Product of the square of the diagonal of the matrix
y2 = 4*prod(aii_2,"all")
%% Complete equation
% The complete equation is described as follows:
%
%
% The complete equation is as follows:
K_A = (y1 + (y1^2-y2)^0.5)/y2

Accedi per commentare.

### Categorie

Scopri di più su Mathematics in Help Center e File Exchange

R2019b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by