Combining symbolic integral expressions

조회 수: 1 (최근 30일)
Randolf Scholz
Randolf Scholz 2018년 9월 4일
댓글: Randolf Scholz 2018년 9월 10일
Consider the example
syms a b x y f(x) g(x)
I = @(x)int( f(x), x, a, b)
J = @(x)int( g(x), x, a, b)
K = combine(I(x)*I(y) + J(y)*J(x),'int')
L = int(int(f(x)*f(y) + g(x)*g(y),x,a,b),y,a,b)
How can I get matlab to simplify K such that it results in L? Also I noticed that matlab seems to think that the two are different since
logical(K == L)
returns 0; on the other hand it thinks they are the same since
simplify(K-L,100)
also returns 0.

답변 (1개)

Naman Chaturvedi
Naman Chaturvedi 2018년 9월 7일
Hi Randolf,
To check the validity of K==L, you must expand the equation and then simplify it as shown:
>> logical(simplify(expand(K))==simplify(expand(L)))
ans =
logical
1
As stated in this doc of 'logical'.
Do not use logical to check equations and inequalities that require simplification or mathematical transformations. For such equations and inequalities, logical might return unexpected results. For example, logical does not recognize mathematical equivalence of these expressions:
syms x
logical(sin(x)/cos(x) == tan(x))
ans =
logical
0
To test the validity of equations and inequalities that require simplification or mathematical transformations, use isAlways:
isAlways(sin(x)/cos(x) == tan(x))
ans =
logical
1
Using isAlways to check K and L,
isAlways((K) == (L))
ans =
logical
1
HTH
  댓글 수: 1
Randolf Scholz
Randolf Scholz 2018년 9월 10일
Dear Naman, thank you for your reply. Unfortunately it doesn't answer my main question which is how can I get MATLAB to simplify the expression K towards the expression L. Ideally I would like it to automatically simplify sums of squares of integrals.

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

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by