# How to subtract these two equations?

There are two equations:

eq1 = x1^2/a^2 + y1^2/b^2 == 1;
eq2 = x2^2/a^2 + y2^2/b^2 == 1;


How to get this result by subtracting two equations?

the result

((x1 - x2) (x1 + x2))/a^2 + ((y1 - y2) (y1 + y2))/b^2 == 0


subtracting two equations?

You can use SubtractSides which is designed for this sort of operation.

ClearAll["Global*"]
eq1 = x1^2/a^2 + y1^2/b^2 == 1
eq2 = x2^2/a^2 + y2^2/b^2 == 1
SubtractSides[eq1, eq2]


To simplify it more

SubtractSides[eq1, eq2] // Simplify


Without using this command, there are other ways to do this. See Subtracting equations from each other? for more options.

(eq1 - eq2 /. Equal -> List // Equal @@ # & //
Collect[#, {a, b}] &) /. (a_^2 - b_^2) :> (a + b) (a - b)


$$\frac{(\text{x1}-\text{x2}) (\text{x1}+\text{x2})}{a^2}+\frac{(\text{y1}-\text{y2}) (\text{y1}+\text{y2})}{b^2}$$

• Could you have a look at my SDE question: mathematica.stackexchange.com/questions/276606/…. Thank you!
– Math
Commented Jan 30, 2023 at 12:52
• @Math, I don't have enough expertise in that area. The most qualified participants have already looked at it. If you have another question, it is best to start a fresh post. Thanks.
– Syed
Commented Jan 30, 2023 at 13:30
• No problem, Thank you anyway :)
– Math
Commented Jan 30, 2023 at 13:46

Try also this:

eq1 = x1^2/a^2 + y1^2/b^2 == 1;
eq2 = x2^2/a^2 + y2^2/b^2 == 1;

expr=Equal @@ MapThread[Subtract, {List @@ eq1, List @@ eq2}] // Simplify

(*  (x1^2 - x2^2)/a^2 + (y1^2 - y2^2)/b^2 == 0  *)


If you need them factorized:

MapAt[Factor, expr, {{1, 1}, {1, 2}}]

(*  ((x1 - x2) (x1 + x2))/a^2 + ((y1 - y2) (y1 + y2))/b^2 == 0  *)


Have fun!

Another way to do this is as follows:

FullSimplify[Thread[#[[1]] == #[[2]]] &@(#[[1]] - #[[2]] & /@
Transpose[Level[#, {1}] & /@ {eq1, eq2}])]


eq1 = x1^2/a^2 + y1^2/b^2 == 1;
eq2 = x2^2/a^2 + y2^2/b^2 == 1;


Original way

eq1 - eq2 // Thread[#, Equals] & // Simplify
(* (x1^2-x2^2)/a^2+(y1^2-y2^2)/b^2==0 *)


If you use EqualThread found at https://library.wolfram.com/infocenter/MathSource/4491, then it will be seamless.

eq1 - eq2//Simplify
`