Combining symbolic integral expressions
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!