5
$\begingroup$

Consider the following equation with rational expressions:

$$\frac{5}{x+4}=4+\frac{3}{x-2}$$

We will look at the plot. We will use the Solve command to check our answer.

Plot[{5/(x + 4), 4 + 3/(x - 2)}, {x, -4, 2}]
Solve[5/(x + 4) == 4 + 3/(x - 2), x]

Now, if the answer provided by the Solve command does not agree with the students' hand calculations, I'd like to use Mathematica to help students find where they made their mistakes.

I've been studying a number of replies on the Mathematica Stack Exchange site (e.g. Alexei Boulbitch's response at Solving equations using algebra.

So consider this start:

eqn = 5/(x + 4) == 4 + 3/(x - 2)

Then:

Map[#  (x + 4) (x - 2) &, eqn]

Then:

Map[Expand[#] &, %]

I would like a result like

$$5(x-2)=4(x+4)(x-2)+3(x+4).$$

Any thoughts on how I could produce what I would like, or something close to what I would like?

Instead, I get a very strange result out of my last command.

enter image description here

Not sure why the fractions were not cleared.

I was able to simplify (kinda weird that it factored the left-hand side of the equation):

Map[Simplify[#] &, %]

enter image description here

But this doesn't show whether the student hand calculated error was made with the $4(x+4)(x-2)$ piece or the $3(x+4)$ piece.

And, by the way, I was able to finish my problem check with the following additional steps.

Map[Expand[#] &, %]
Map[# - %[[1]] &, %]
Map[#/2 &, %]
Map[Simplify[#] &, %]
Map[Factor[#] &, %]

Putting it all together looks like this:

eqn = 5/(x + 4) == 4 + 3/(x - 2)
Map[#  (x + 4) (x - 2) &, eqn]
Map[Expand[#] &, %]
Map[Expand[#] &, %]
Map[# - %[[1]] &, %]
Map[#/2 &, %]
Map[Simplify[#] &, %]
Map[Factor[#] &, %]

Update: Some thoughts regarding help from Alexei Boulbitch.

(4 + x) (-5 + 4 x) === 4 (x + 4) (x - 2) + 3 (x + 4)

Yields "False."

Then I tried:

(4 + x) (-5 + 4 x) == 4 (x + 4) (x - 2) + 3 (x + 4) // Simplify

Which yielded True. I looked up the === sign in the Documentation and it said "lhs === rhs yields True if the expression lhs is identical to rhs, and yields False otherwise."

Consider also:

Expand[(4 + x) (-5 + 4 x)]

Which yields:

(* -20 + 11 x + 4 x^2 *)

Consider:

Expand[4 (x + 4) (x - 2) + 3 (x + 4)]

Which also yields:

(* -20 + 11 x + 4 x^2 *)

So, what is going on with that === thing?

$\endgroup$

marked as duplicate by m_goldberg, user9660, MarcoB, Öskå, Yves Klett Jan 15 '16 at 19:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ This is not exactly an answer (hence comment) but one can enter WolframAlpha["5/(x+4)\[Equal]4+3/(x-2)"] and click on "Step-by-step solution" at upper right of the "Solutions" pane. $\endgroup$ – Daniel Lichtblau Jan 14 '16 at 22:03
  • $\begingroup$ @DanielLichtblau And the graphic it gave is amazing! $\endgroup$ – David Jan 15 '16 at 1:38
7
$\begingroup$
WolframAlpha["Solve[5/(x+4)\[Equal]4+3/(x-2),x]", {{"Result", 3}, 
  "Content"}, PodStates -> {"Result__Step-by-step solution"}]

enter image description here

$\endgroup$
5
$\begingroup$

David, using the approach I have shown some time ago, one may do the following. This is the equation:

eq1 = 5/(x + 4) == 4 + 3/(x - 2);

First let us multiply it by the factor (4 + x)*(-2 + x):

eq2 = Map[Times[#, (4 + x)*(-2 + x)] &, eq1]

(*  5 (-2 + x) == (4 + 3/(-2 + x)) (-2 + x) (4 + x)  *)

Now let us expand the right-hand part:

eq3 = MapAt[Expand, eq2, {2}]

(*  5 (-2 + x) == -32 - 24/(-2 + x) + 8 x + (6 x)/(-2 + x) + 4 x^2 + (
  3 x^2)/(-2 + x)  *)

Now let us factor the right-hand part:

    eq4 = MapAt[Factor, eq3, {2}]

(*  5 (-2 + x) == (4 + x) (-5 + 4 x)  *)

Done.

I am very sorry,but expression 4 (x + 4)*(x - 2) + 3 (x + 4) in the right-hand part as you wanted is incorrect. Indeed,

 4 (x + 4)*(x - 2) + 3 (x + 4) === (4 + x) (-5 + 4 x)

(*  False  *)

Have fun and let your students have fun!

$\endgroup$
  • $\begingroup$ Thanks for the introduction to the MapAt command. However, the triple equal thing returning False is extremely puzzling. See my update to my original post up above. $\endgroup$ – David Jan 15 '16 at 19:20
3
$\begingroup$

I usually find it easier to do this kind of manual equation munging by first converting the equation to a list, carrying out the operations on the list (convenient because math operations thread over lists), and then converting back to equation form when done.

In this case, trying to keep the steps at the middle-school level, it would go like this.

p[0] = {5/(x + 4), 4 + 3/(x - 2)}

{5/(4 + x), 4 + 3/(-2 + x)}

p[1] = 1/# & /@ p[0] // Simplify

{(4 + x)/5, (-2 + x)/(-5 + 4 x)}

p[2] = (-5 + 4 x) p[1] // Expand

{-4 + (11 x)/5 + (4 x^2)/5, -2 + x}

p[3] = 5 p[2] - p[2][[2]] // Expand

{-18 + 10 x + 4 x^2, -8 + 4 x}

p[4] = (p[3] - p[3][[2]])/2 // Expand

{-5 + 3 x + 2 x^2, 0}

p[5] = Factor /@ p[4]

{(-1 + x) (5 + 2 x), 0}

The two linear equations are now obvious. I think the next step is more easily performed manually than not.

p[6, 1] = {-1 + x, 0}; p[6, 2] = {5 + 2 x, 0};

Proceeding to put the two solutions into equation form.

p[7, 1] = p[6, 1] + 1

{x, 1}

p[7, 2] = (p[6, 2] - 5)/2

{x, -(5/2)}

Equal @@@ {p[7, 1], p[7, 2]}

{x == 1, x == -(5/2)}

$\endgroup$
2
$\begingroup$

My first thought was to use Distribute, which does exactly what it says it does. Unfortunately, it does too much too make it worthwhile in this case without some finagling:

(x + a) (y + b) // Distribute
(* a b + b x + a y + x y *)

when we would want the result to be, perhaps

(* b (a + x) + (a + x) y *)

So we force it to do what we want. Instead of Mapping (x - 2)#& over the expression, we map a#&:

Clear[eqn, x, a, b]
eqn = 5/(x + 4) == 4 + 3/(x - 2)
a # & /@ eqn
MapAt[Distribute, %, 2]
% /. a -> x - 2
b # & /@ %
MapAt[Distribute, %, 2]
% /. b -> x + 4

enter image description here

$\endgroup$
  • $\begingroup$ Interesting way to get exactly what I wanted. Nice answer. $\endgroup$ – David Jan 15 '16 at 19:31

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