4
$\begingroup$

Solve the equation to obtain such a result form;

Reduce[a x1 + x1^2 - a x2 - x2^2 - Log[x1] + Log[x2] == 0, 
  a] // Simplify

(*a\[Equal](-x1^2+x2^2+Log[x1]-Log[x2])/(x1-x2)||x1\[Equal]x2*)

How to obtain this form, that is, if a part can be omitted, it can be omitted

a == -x1 - x2 + (Log[x1] - Log[x2])/(x1 - x2)

want to get this result as following picture

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Reduce[a x1 + x1^2 - a x2 - x2^2 - Log[x1] + Log[x2] == 0, a] // Simplify // First $\endgroup$
    – eldo
    Commented Sep 5, 2023 at 15:12
  • 1
    $\begingroup$ The part cannot be omitted, without hypothesis (classic student error, in the US, at least). Solve deletes full-dimension components, since it's less rigorous, as shown in current answers. Or@@And@@@Apply[Equal,Solve[{x^2+y^2==4,x==y}],{2}] converts to Reduce form. $\endgroup$
    – Michael E2
    Commented Sep 5, 2023 at 15:55

3 Answers 3

2
$\begingroup$
expr = Solve[a x1 + x1^2 - a x2 - x2^2 - Log[x1] + Log[x2] == 0, a][[1, 1]]

enter image description here

Apart[expr, x1]

enter image description here

TeXForm @ %

$a\to \frac{\log (\text{x1})-\log (\text{x2})}{\text{x1}-\text{x2}}-\text{x1}-\text{x2}$

$\endgroup$
6
$\begingroup$
expr = First@
  Solve[a x1 + x1^2 - a x2 - x2^2 - Log[x1] + Log[x2] == 0, a]

$\left\{a\to \frac{-\text{x1}^2+\log (\text{x1})+\text{x2}^2-\log (\text{x2})}{\text{x1}-\text{x2}}\right\}$

r1 = Log[a_] - Log[b_] :> Log[a/b];
r2 = Log[a_/b_] :> Log[a] - Log[b];

(expr  /. r1 // Apart) /. r2

$\left\{a\to \frac{\log (\text{x1})-\log (\text{x2})}{\text{x1}-\text{x2}}-\text{x1}-\text{x2}\right\}$

$\endgroup$
2
  • $\begingroup$ (+1) Nice and simpler! $\endgroup$ Commented Sep 5, 2023 at 15:35
  • 1
    $\begingroup$ I am on v12.2.0 on Win7-x64, $\endgroup$
    – Syed
    Commented Sep 5, 2023 at 18:01
5
$\begingroup$

Try this:

expr1 = Solve[a x1 + x1^2 - a x2 - x2^2 - Log[x1] + Log[x2] == 0, 
    a][[1, 1]];

a -> ((-x1^2 + x2^2 + Log[x1] - Log[x2])/(
      x1 - x2) /. -x1^2 + x2^2 -> Factor[-x1^2 + x2^2] /. 
     x1 - x2 -> z // Expand) /. z -> x1 - x2

a -> -x1 - x2 + Log[x1]/(x1 - x2) - Log[x2]/(x1 - x2)

Have fun!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.