#2736 Bug in solving equation

None
open
nobody
solve (13)
5
2014-06-06
2014-05-26
idlerlestat
No

In Maxima 5.32.1, solving this equation fails.

(%i1) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=9],[x,y]);

which gives []. But a similar equation solves without problem

(%i2) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=10],[x,y]);

Related

Bugs: #2736

Discussion

  • Goran Igaly

    Goran Igaly - 2014-05-28

    (Maxima 5.31.2)

    Similarly, when trying to solve system of equations given below, the wrong result is given. Instead of (x1,y1) and (x2,y2), the correct solution should be (x1,y2) and (x2,y1):

    (%i78) p:1/(1-cos(1));
    (%o78) 1/(1-cos(1))
    (%i82) solution_1:float(solve([x*y=p,x-y=3],[x,y]));
    (%o82) [[x=3.603649840080336,y=-3.603649840080335],[x=-0.60364984008034,y=0.60364984008034]]


    But, if we convert p to float before solving the system of equations, the result will be correct:

    (%i80) solution_2:float(solve([x*y=float(p),x-y=3],[x,y]));
    rat: replaced -2.17534264967002 by -8846603/4066763 = -2.17534264967002
    (%o80) [[x=-0.60364984008034,y=-3.603649840080335],[x=3.603649840080335,y=0.60364984008034]]

     
    Last edit: Goran Igaly 2014-05-28
    • Tomio Arisaka

      Tomio Arisaka - 2014-06-06

      Hi,

      It seems the simple expression is best.
      So that another solution is as follows:

      (%i9) kill (p,x,y);
      (%o9)                                done
      (%i10) solve ( [x*y=p,x-y=3],[x,y] );
                     sqrt(4 p + 9) - 3        sqrt(4 p + 9) + 3
      (%o10) [[x = - -----------------, y = - -----------------], 
                             2                        2
                                           sqrt(4 p + 9) + 3      sqrt(4 p + 9) - 3
                                      [x = -----------------, y = -----------------]]
                                                   2                      2
      (%i11) subst (p = 1/(1-cos(1)), %);
                              4                               4
                     sqrt(---------- + 9) - 3        sqrt(---------- + 9) + 3
                          1 - cos(1)                      1 - cos(1)
      (%o11) [[x = - ------------------------, y = - ------------------------], 
                                2                               2
                                      4                             4
                             sqrt(---------- + 9) + 3      sqrt(---------- + 9) - 3
                                  1 - cos(1)                    1 - cos(1)
                        [x = ------------------------, y = ------------------------]]
                                        2                             2
      (%i12) float (%);
      (%o12) [[x = - 0.6036498400803354, y = - 3.603649840080335], 
                                     [x = 3.603649840080335, y = 0.6036498400803354]]
      

      My environment:
      Maxima version: "5.33.0"
      Maxima build date: "2014-04-20 04:11:32"
      Host type: "x86_64-apple-darwin10.8.0"
      Lisp implementation type: "SBCL"
      Lisp implementation version: "1.1.17"

       
  • Robert Dodier

    Robert Dodier - 2014-06-05
    • labels: --> solve
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,7 @@
     In Maxima 5.32.1, solving this equation fails.
    -(%i1) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=9],[x,y]);
    +
    +    (%i1) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=9],[x,y]);
    +
     which gives []. But a similar equation solves without problem
    -(%i2) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=10],[x,y]);
    +
    +    (%i2) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=10],[x,y]);
    
     
  • Tomio Arisaka

    Tomio Arisaka - 2014-06-06

    Hi,

    (%i1) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=9],[x,y]);
    (%o1)                                 []
    (%i2) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=10],[x,y]);
                                                 5       12
    (%o2)                [[x = 1, y = 0], [x = - --, y = --]]
                                                 13      13
    (%i3) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=8],[x,y]);
                                12      5
    (%o3)                 [[x = --, y = --], [x = 0, y = 1]]
                                13      13
    

    It seems that the function 'solve' can return the answer if x or y is equal to 0.
    I think it is a weakness in the function algsys called by the function solve.

    Anyway we can get the answer as follows:

    (%i1) load (to_poly_solve);
    (%o1)    /sw/share/maxima/5.33.0/share/to_poly_solve/to_poly_solve.mac
    (%i2) to_poly_solve ([x^2+y^2=1, (x-2)^2+(y-3)^2=9], [x,y], 'use_grobner = true);
                         5/2              5/2
                        3    - 10      2 3    + 45
    (%o2) %union([x = - ---------, y = -----------], 
                           26              78
                                                      5/2                5/2
                                                     3    + 10        2 3    - 45
                                                [x = ---------, y = - -----------])
                                                        26                78
    (%i3) float (%);
    (%o3) %union([x = - 0.2149406641584574, y = 0.9766271094389715], 
                                  [x = 0.9841714333892265, y = 0.1772190444071823])
    

    My environment:
    Maxima version: "5.33.0"
    Maxima build date: "2014-04-20 04:11:32"
    Host type: "x86_64-apple-darwin10.8.0"
    Lisp implementation type: "SBCL"
    Lisp implementation version: "1.1.17"

     
    • Hisham Sueyllam

      Hisham Sueyllam - 2014-06-06

      if you do:
      load(grobner);
      poly_reduced_grobner([x^2+y^2-1,(x-2)^2+(y-3)^2-9],[x,y]);
      algsys(%,[x,y]);
      you get the solution
      float(%)
      gives the float values
      hisham...


      On Fri, 6/6/14, Tomio Arisaka tomio-arisaka@users.sf.net wrote:

      Subject: [maxima:bugs] #2736 Bug in solving equation
      To: "[maxima:bugs]" 2736@bugs.maxima.p.re.sf.net
      Date: Friday, June 6, 2014, 8:34 AM

      Hi,
      (%i1) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=9],[x,y]);
      (%o1)
      []
      (%i2) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=10],[x,y]);
      5 12
      (%o2) [[x = 1, y = 0], [x = - --, y = --]]
      13 13
      (%i3) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=8],[x,y]);
      12 5
      (%o3) [[x = --, y = --], [x = 0, y = 1]]
      13 13

      It seems that the function 'solve' can return the
      answer if x or y is equal to 0.

      I think it is a weakness in the function algsys called by
      the function solve.
      Anyway we can get the answer as follows:
      (%i1) load (to_poly_solve);
      (%o1) /sw/share/maxima/5.33.0/share/to_poly_solve/to_poly_solve.mac
      (%i2) to_poly_solve ([x^2+y^2=1, (x-2)^2+(y-3)^2=9], [x,y], 'use_grobner = true);
      5/2 5/2
      3
      - 10 2 3 + 45
      (%o2) %union([x = - ---------, y = -----------],
      26 78
      5/2 5/2
      3 + 10 2 3 - 45
      [x = ---------, y = - -----------])
      26 78
      (%i3) float (%);
      (%o3) %union([x = - 0.2149406641584574, y = 0.9766271094389715],
      [x = 0.9841714333892265, y = 0.1772190444071823])

      My environment:

      Maxima version: "5.33.0"

      Maxima build date: "2014-04-20 04:11:32"

      Host type: "x86_64-apple-darwin10.8.0"

      Lisp implementation type: "SBCL"

      Lisp implementation version: "1.1.17"

      [bugs:#2736]
      Bug in solving equation
      Status: open

      Group: None

      Labels: solve

      Created: Mon May 26, 2014 06:45 AM UTC by
      idlerlestat

      Last Updated: Thu Jun 05, 2014 03:09 AM
      UTC

      Owner: nobody
      In Maxima 5.32.1, solving this equation fails.
      (%i1) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=9],[x,y]);

      which gives []. But a similar equation solves without
      problem
      (%i2) solve([x^2+y^2=1,(x-2)^2+(y-3)^2=10],[x,y]);

      Sent from sourceforge.net because you indicated interest
      in https://sourceforge.net/p/maxima/bugs/2736/
      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #2736

      • Tomio Arisaka

        Tomio Arisaka - 2014-06-07

        Hi,

        Thank you for your response.
        It makes me notice that the function to_poly_solve calls the function poly_reduced_grobner and the algsys.
        It is helpful for me.

         

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks