A simple symbolic expression in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter Dr_Pill
  • Start date Start date
  • Tags Tags
    Expression Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 4K views
Dr_Pill
Messages
41
Reaction score
0
I tried to check

x²-1 = (x+1)(x--1)

So I did the following:

syms x

f = x^2 - 1
g = (x+1)*(x-1)

logical(f == g)

Matlab returns 0.

Any suggestions? :)

(Matlab beginner by the way)
 
Physics news on Phys.org
Maybe this? From

http://www.mathworks.com/help/symbolic/logical.html

"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:
...
To test the validity of equations and inequalities that require simplification or mathematical transformations, use isAlways:

isAlways(sin(x)/cos(x) == tan(x))
ans = 1"
 
Dr_Pill said:
I tried to check

x²-1 = (x+1)(x--1)

So I did the following:
Matlab returns 0.

Any suggestions? :)

(Matlab beginner by the way)

If I'm interpreting the result correctly,
0 is a legit answer, if x = 0, f = -1 and g= -1, so f=g.

Never used the symbolic toolbox, just thought I'd point that out.