Logical False before subs then Logical True?

I am trying to verify if 2 equations are symbolically equivalent. I did a logical check and it return false. When I solve these equations in terms of S/K by using a variable substitution, i.e. Z=S/K -> K=S*K, the logical is true. I can't seem to figure out why this is so.
syms S K r_x Z D
Solution=solve(0 == -S*(r_x)^2 + 2*(K+S)*r_x -S,r_x )
Expanded_Solution=expand(Solution(2,1))
%Sections=children(Expanded_Solution)
D=1 + (K/S) - sqrt( (1+(K/S))^2 -1)
Boolen_check_1=logical(D == Expanded_Solution)
% Z=K/S --> K = Z*S
new_1=subs(Expanded_Solution,K, (Z*S) )
new_2=subs(D,K, (Z*S))
trial_1=solve(new_1 - r_x == 0, Z)
trial_2=solve(new_2 - r_x == 0, Z)
Boolen_check_2 = logical(trial_1 == trial_2)

 Accepted Answer

madhan ravi
madhan ravi on 10 Nov 2018
Edited: madhan ravi on 10 Nov 2018
You can’t prove two symbolic equations which are in different form that are equal (matlab won’t recognise), the last thing which you did by substituting is the appropriate way
simple try :
fplot(subs(Expanded_Solution,K,2 ))
hold on
fplot(subs(D,K,2))
and see the difference between the graph when you change the form of an equation the behaviour is totally different
Always use isequaln()(link) to compare symbolic equations.

1 Comment

Can you expand on why one can't prove two symbolic equations which are in different forms are equal and why substitution worked?

Sign in to comment.

More Answers (1)

isAlways(trial_1 == trial_2)

1 Comment

I tried this and nothing changed, still returns a true while the statement above gets a false.

Sign in to comment.

Products

Release

R2018b

Community Treasure Hunt

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

Start Hunting!