Search code examples
matlabsymengine

Symbolic: Rearrange so one side is zero


I have the equation:

syms x y
A= 5*x - 100*y == x

I want it to be rearranged in the form:

A = 0 == 4*x-100y

How can I do it?


Solution

  • Use children() to split A in two parts:

    • Left Hand Side: LHS
    • Right Hand Side: RHS

    Then compute A = 0 == LHS - RHS

    The code is as follows

    syms x y
    
    A = 5*x - 100*y == x;
    
    A_as_Array = children(A);
    
    A_Left_Hand_Side = A_as_Array(1) ;
    
    A_Right_Hand_Side = A_as_Array(2); 
    
    A = 0 == A_Left_Hand_Side - A_Right_Hand_Side; 
    
    % A = 0 == 4*x - 100*y