Int() returning incorrect answer

조회 수: 2 (최근 30일)
Jennifer Hansen
Jennifer Hansen 2022년 11월 26일
댓글: Steven Lord 2022년 11월 27일
I need to solve a double integral, using symbolic variables. My code is as follows:
stiff = transpose(B)*E*B*t*detJ;
K = int(int(stiff,zeta,-1,1),eta,-1,1)
where zeta and eta have been defined as symbolic variables and stiff is an 8x8 matrix.
I have been given the precise answers, so I know that everything leading up to the K calculation is correct. However, K doesn't match at all. Does anyone have insight on why the integral isn't correct?
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 11월 26일
The stiff variable you show us does not depend on zeta or eta so there is not much to go wrong...
Jennifer Hansen
Jennifer Hansen 2022년 11월 26일
Ah, it does, I just didn't include the rest because I know it's correct. Thank you for your response! I actually did something very silly and used a constant E instead of my E matrix, which I named something else. I was concerned I was misunderstanding how to use int().

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

채택된 답변

Walter Roberson
Walter Roberson 2022년 11월 26일
Especially in the case of trig expressions or expressions that integrate to trig (such as ones that integrate to arctan), then int() is permitted to return any mathematically equivalent expression. You should subtract the returned expression from the known answer and evaluate at several points to determine whether the expressions are equivalent.
For example if you integrate sin() you will not necessarily get back an expression in cos: you might get back something based on the fact that sin-squared plus cos-squared equals 1.
  댓글 수: 1
Steven Lord
Steven Lord 2022년 11월 27일
Instead of evaluating at several points to do a probabilistic equivalence test, I recommend using the isAlways function.
syms x
f1 = sin(2*x)
f1 = 
f2 = 2*sin(x)*cos(x)
f2 = 
isAlways(f1 == f2)
ans = logical
f3 = cos(x).^2-sin(x).^2 % cos(2*x)
f3 = 
f4 = cos(2*x)
f4 = 
isAlways(f1 == f3)
Warning: Unable to prove 'sin(2*x) == cos(x)^2 - sin(x)^2'.
ans = logical
isAlways(f3 == f4)
ans = logical

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

추가 답변 (0개)


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




Community Treasure Hunt

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

Start Hunting!

Translated by