# Writing System of Equations == 0

I have a system of equations and would like to retrieve the Jacobain w.r.t. to some variables. Now I see that this would be best done if I wrote the equations in a form == 0. Is there an easy way to do the latter? (or simply, retrieve the jacobian of this system of equations?).

Example below:

systemEq = {x1 == 2 x2 - 1,x1^2 == x2^2 - 4}


To make use of the D[] function, I imagine that we would have to rewrite this system as:

systemEqD = {x1 - ( 2 x2 - 1),x1^2 - ( x2^2 - 4)}


where implicitly I am aware that the equations ==0.

Is there an easy way to proceed? (ideally I would like to scale this for a larger number of equations). Many thanks.

Cases[systemEq, Equal[lhs_, rhs_] :> lhs - rhs]


{1 + x1 - 2 x2, 4 + x1^2 - x2^2}

• Perfect, just what I wanted. Many thanks. Commented Jul 15, 2018 at 20:30
• You're welcome. Commented Jul 15, 2018 at 20:30
• Probably simpler: Equal -> Subtract? (untested) Commented Jul 15, 2018 at 22:01

You can also try SubtractSides designed for this sort of thing

ClearAll[x1,x2]
systemEq = {x1==2 x2-1,x1^2==x2^2-4};

First@SubtractSides[#] &/ @systemEq


And,

systemEq = {x1 == 2 x2 - 1, x1^2 == x2^2 - 4};

#[[1]] - #[[-1]] == 0 & /@ systemEq

(* {1 + x1 - 2 x2 == 0, 4 + x1^2 - x2^2 == 0} *)