# [Maxima] how to solve x,y in R, |x-2|+|2x+y-4|=0

Richard Hennessy rich.hennessy at verizon.net
Sat Oct 10 14:17:53 CDT 2009

There are 2 equations so solve for 2 unknowns.  I think this is a weirdness in solve because solving for just one of the unknowns that you are interested in does not work and new users try that a lot and get frustrated with Maxima because of this.  It happened to me when I first discovered Maxima.  FWIW

(%i1) eq1:x-2=0;
(%o1)                                                                              x - 2 = 0
(%i2) eq2:2*x+y-4=0;
(%o2)                                                                           y + 2 x - 4 = 0
(%i3) solve(eq1);
(%o3)                                                                               [x = 2]
(%i4) solve([eq1,eq2],[x,y]);
(%o4)                                                                          [[x = 2, y = 0]]
(%i5)

Rich

----- Original Message -----
From: ¶À ¸Î¶¯
Sent: Saturday, October 10, 2009 2:05 PM
Subject: [Maxima] how to solve x,y in R, |x-2|+|2x+y-4|=0

how to solve x,y in R,  |x-2|+|2x+y-4|=0
that is clearly, x=2,y=0.
I try to solve in maxima
eq1:x-2=0;
eq2:2*x+y-4=0;
solve(eq1);

(%o1) x-2=0
(%i2)
(%o2) y+2*x-4=0
(%o3) [x=2]

how to use the solve of x and input eq2 to solve y=0?

> From: maxima-request at math.utexas.edu
> Subject: Maxima Digest, Vol 39, Issue 30
> To: maxima at math.utexas.edu
> Date: Sat, 10 Oct 2009 12:00:05 -0500
>
> Send Maxima mailing list submissions to
> maxima at math.utexas.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://www.math.utexas.edu/mailman/listinfo/maxima
> or, via email, send a message with subject or body 'help' to
> maxima-request at math.utexas.edu
>
> You can reach the person managing the list at
> maxima-owner at math.utexas.edu
>
> than "Re: Contents of Maxima digest..."
>
>
> Today's Topics:
>
> 1. Further code to improve the assume database (Dieter Kaiser)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 10 Oct 2009 17:43:53 +0200
> From: Dieter Kaiser <drdieterkaiser at web.de>
> Subject: [Maxima] Further code to improve the assume database
> To: "maxima at math.utexas.edu" <maxima at math.utexas.edu>
> Message-ID: <1255189433.3499.2.camel at dieter-laptop>
> Content-Type: text/plain
>
> We have the known bug ID: 1045920 "a>1 and b>1, is a+b>2?"
>
> (%i2) assume(a>1,b>1);
> (%o2) [a > 1,b > 1]
>
> (%i3) sign(a+b-2);
> (%o3) pnz
>
> I have a routine sign-shift which will correct this result:
>
> (%o4) "sign-shift.lisp"
>
> (%i5) sign(a+b-2);
> (%o5) p! os
&g t;
> It will work for a lot of more cases too:
>
> (%i8) assume(a > 1,b > 1,c > 2)\$
>
> (%i2) is(b+a > 2)
> (%o2) true
>
> (%i4) is(b+2*a > 3)
> (%o4) true
>
> (%i6) is(c^2+b+2*a > 7)
> (%o6) true
>
> It works for negative bounds too:
>
> (%i8) assume(x < -1,y < -2,z < -2)\$
>
> (%i10) is(y+x < -3)
> (%o10) true
>
> (%i12) is(y+2*x < -4)
> (%o12) true
>
> z^2 is positive and the following sign is unknown:
>
> (%i14) is(z^2+y+2*x < -7)
> (%o14) unknown
>
> z^3 is negative and the test will give true again:
>
> (%i16) is(z^3+y+2*x < -12)
> (%o16) true
>
> I have no problems with the testsuite and the share_testsuite with the
> exception of one example:
>
> ********************** Problem 40 ***************
> Input:
> fourier_elim(fourier_elim(eqs, [y, x, z]), [z, y, x])
>
>
> Result:
> [0 < z, z < min(4, - y - x + 4), 0 < y, y < 1, 0 < x, x < 1]
>
> This differed from the expected result:
> [0 < z, z < 4 - x - y, 0 < y, y < 1, 0 < x, x < 1]
>
> 124/125 tests passed (not counting 5 expected errors).
>
>
> I know nothing about the code of fourier_elim. My question is, if the
> new result is really an error or if we can accept it. Perhaps
> fourier_elim can be improved to take advantage of the extended
> functionality of \$sign?
>
> This is the code of sign-shift:
>
> (defun sign-shift (expr)
> (do ((l (append (cdr (facts1 '\$learndata)) (cdr (facts1 \$context)))
> (cdr l))
> (e expr)
> (flag) (fact) (num))
> ((null l) (if flag (\$expand e) expr))
> (setq fact (car l))
> (when (eq (caar fact) 'mgreaterp)> ;; Do we have something like a>2 or a<-1 on the list of facts?
> (cond ((and (symbolp (cadr fact))
> (not (\$freeof (cadr fact) e))
> (not (member (cadr fact) '(\$%pi \$%e \$%gamma \$%phi)))
> (mnump (setq num (caddr fact)))
> (not (zerop1 num)))
> (setq flag t)
> (if (mminusp num) (setq num (mul -1 num)))
> fact) e)))
> (not (\$freeof (caddr fact) e))
> (not (member (caddr fact) '(\$%pi \$%e \$%gamma \$%phi)))
> (mnump (setq num (cadr fact)))
> (not (zerop1 num)))
> (setq flag t)
> (if (mminusp num) (setq num (mul -1 num)))
> (setq e (maxima-substitute
>
>
> The routine sign-shift has to be called in the routine signsum in
> compar.lisp:
>
> (defun signsum (x)
> (setq x (sign-shift x))
> ;; x might be simplified to an atom in sign-shift
> (when (atom x) (setq x (cons '(mplus) (list x))))
>
>
> Dieter Kaiser
>
>
>
> ------------------------------
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
> End of Maxima Digest, Vol 39, Issue 30
> **************************************

------------------------------------------------------------------------------
¤U¸ü Windows Live Messenger 9.0¡A¦h¤¸·¾³q¡BºÉ±¡¤À¨É¡A©M§Y®É³q°T¦n¤Í½u¤W¦P¼Ö¡I¡X ¥ß§Y¤U¸ü

------------------------------------------------------------------------------

_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.math.utexas.edu/pipermail/maxima/attachments/20091010/48abe47e/attachment.htm