Solving an equation with terms that require double summation and products

조회 수: 3 (최근 30일)
I need to solve the following equation.
Opt.JPG
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.
% https://link.springer.com/article/10.1007/BF02331114
% Develop the terms of the equation
% The individual terms of the equation will be developed individually and then brought together.
% Loading the files
% Loading the required variables.
% Loading of the required *.mat file and then the variable.
anp = load("191231_GS_0295_10.mat","aij");
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

채택된 답변

David Goodmanson
David Goodmanson 2020년 1월 20일
편집: David Goodmanson 2020년 1월 20일
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
David Goodmanson
David Goodmanson 2020년 1월 21일
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
GS76 2020년 1월 22일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

David Goodmanson
David Goodmanson 2020년 1월 19일
편집: David Goodmanson 2020년 1월 19일
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
GS76
GS76 2020년 1월 20일
Hi David,
Thank you for your input.
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.
%
% <https://link.springer.com/article/10.1007/BF02331114 https://link.springer.com/article/10.1007/BF02331114>
%
%% Develop the terms of the equation
% The individual terms of the equation will be developed individually and the
% brought together.
% Loading the files
% Loading the required variables.
% Loading of the required *.mat file and then the variable.
anp = load("191231_GS_0295_10.mat","aij");
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by