Search code examples
matlabsymbolic-math

Matlab symbolic


I am trying to compare two simple expressions using Matlab symbolic toolbox. For some reason, the code returns 0. Any idea ?

syms a b c
A = (a/b)^c
B = a^c/b^c
isequal(A,B)

Solution

  • In general what you wrote isn't true, under the right "assumptions" it becomes true: for example, assuming c is an integer you can trick MATLAB into expanding A

    clc; clear all;
    syms a 
    syms b 
    syms c integer
    A = (a/b)^c;
    B = simplify((a^c)/(b^c));
    disp(isequal(A,B));
    disp(A);
    disp(B);
    

    1

    a^c/b^c
    a^c/b^c