       • To: mathgroup at smc.vnet.net
• Subject: [mg4190] Re: [mg4139] Help with this!!!! please
• From: Allan Hayes <hay at haystack.demon.co.uk>
• Date: Thu, 13 Jun 1996 23:08:53 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```"Erick Houli Katz" <ehk at netpoint.net>
writes

>How can I solve this exercise???
>
>|1-2X|+|3X+1|=2

Erick:
|a|  = a when a >= 0 and  -a when a <=0 (or -a>=0)
So there are any solutin of your equation will satisfy one of the
following linear equations

-1 (1-2x) + -1(3x+1) == 2  ,     -1(1-2x) + 1 (3x+1) == 2 ,
1 (1-2x) +  -1(3x+1) == 2 ,      -1(1-2x) + -1 (3x+1) == 2

One method is to solve all of these and then keep only those
solutions that satisfy the original equation.

eqn = Abs[1-2x]+Abs[3x+1]==2;
lst = {1-2x, 3x+1};
mult = Flatten[Outer[List,{-1,1},{-1,1}],1] (*pairs of -1's and 1's*)
{{-1, -1}, {-1, 1}, {1, -1}, {1, 1}}

redeqs = (lst.# == 2)&/@mult (*all the linear equations*)
{-2 - x == 2, 5 x == 2, -5 x == 2, 2 + x == 2}

pos = Solve/@red (*solutions of equations redeqs*)
2             2
{{{x -> -4}}, {{x -> -}}, {{x -> -(-)}}, {{x -> 0}}}
5             5

Cases[pos, s_/;(eqn/.s} == {True}] (*keep those that satisfy eqn*)
2
{{{x -> -(-)}}, {{x -> 0}}}
5
We can put the last few steps together:
Cases[
Solve[lst.# == 2]&/@Flatten[Outer[List,{-1,1},{-1,1}],1],
s_/;(eqn/.s) == {True}
]
2
{{{x -> -(-)}}, {{x -> 0}}}
5

A second way is based on the following idea
Let R[-1,-1] be the region of the real line where
-1(1-2x) >=0 and -1 (3x+1) >=0
Any solution to eqn in this region will be a solution to
-1(1-2x) + -1 (3x+1) = 2
The only solution to the last equation is -4.
But  -1(1-2 (-4)) = -9, which is  <0; so there is no solution to
eqn in this region.

Let R[1,-1] the region of the real line where
1(1-2x) >=0 and -1 (3x+1) >=0
Any solution to eqn in this part will be a solution to
1(1-2x) + -1 (3x+1) = 2
The only solution to the last equation is -2/5.
Now  1(1-2 (-2/5)) = 9/5,  and   -1 (3(-2/5)+1) = 1/5; so -2/5 is a
solution of eqn in this region

Similarly for the anologously defined R[-1,1] and R[1,1].
Since these  four regions cover the line we will in this way find
all the solutions of eqn. .

The  work can be done by Mathematica:

If[
Min[(lst #)/.(sl = Solve[lst.# == 2,x])]>=0,
sl,
Unevaluated[Sequence[]]     (*empty sequence*)
]&/@Flatten[Outer[List,{-1,1},{-1,1}],1]
2
{{{x -> -(-)}}, {{x -> 0}}}
5
Allan Hayes
hay at haystack.demon.co.uk
08-06-96

==== [MESSAGE SEPARATOR] ====

```

• Prev by Date: Re: Help with this!!!! please
• Next by Date: Re: Help with this!!!! please (fwd)