Menu ▾ ▴

#2038 Elementary Algsys/Solve bug

None
closed
7
2016-10-04
2010-07-24
No

eqs: [y^2+x^2-(400-400/(2/q+1))^2 = 0,(-y-400/(2/q+1)+400)^2+x^2-640000/(2/q+1)^2 = 0]
solve(eqs,[x,y]) gives correct solution, but solve(subst(sqrt(3),q,eqs),[x,y]) yields []!

A possibly related case:
eqt: [y^2+x^2-1,y^2+(1-sqrt(3))*y+x^2+2]
algsys(eqt,[x,y]) => good solutions
solve(eqt,[x,y]) => []

Related

Bugs: #3208

Discussion

  • Stavros Macrakis

    observed in
    Maxima 5.21.1 http://maxima.sourceforge.net
    using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)

     
  • Barton Willis

    Barton Willis - 2010-07-24

    Setting algebraic to true is *not* a workaround.

    Maxima is unable to even solve a triangular form of these equations; of course,
    the triangular form may have spurious solutions. This is a high priority bug.

    (%i1) algebraic : true$
    (%i2) load(to_poly_solver)$

    (%i3) eqs: [y^2+x^2-(400-400/(2/q+1))^2 = 0,(-y-400/(2/q+1)+400)^2+x^2-640000/(2/q+1)^2 = 0]$
    (%i4) eqs : subst(q = sqrt(3),eqs)$

    (%i5) eqs : radcan(ratnumer(eqs));
    (%o5) [y^2+x^2+2560000*sqrt(3)-4480000=0,y^2+(1600*sqrt(3)-3200)*y+x^2+5120000*sqrt(3)-8960000=0]
    (%i6) eqs : elim(eqs,[y,x]);
    (%o6) [[],[4*sqrt(3)*y^2-7*y^2+4000*3^(3/2)*y-20800*y+8960000*sqrt(3)-15520000,y^2+x^2+2560000*sqrt(3)-4480000]]

    (%i7) eqs : second(eqs);
    (%o7) [4*sqrt(3)*y^2-7*y^2+4000*3^(3/2)*y-20800*y+8960000*sqrt(3)-15520000,y^2+x^2+2560000*sqrt(3)-4480000]

    (%i8) solve(eqs,[x,y]);
    (%o8) []

    (%i9) solve(first(eqs),y);
    (%o9) [y=400*sqrt(3)-800]

     
  • Stavros Macrakis

    Just plain solve(eqs) and solve(eqt) work fine.

     
  • sslavi

    sslavi - 2015-06-19

    For what it's worth for debuggers:

    Oddly, the problem is not present when the equations are written in a more general form like this one:

    (%i1) eq: [y^2+x^2-1,y^2+k*y+x^2+a]$
    solve(eq,[x,y]);
    (%o1) [[x=-sqrt(k^2-a^2-2a-1)/k,y=-(a+1)/k],[x=sqrt(k^2-a^2-2a-1)/k,y=-(a+1)/k]]

    But as soon as we insert the numerical value for K, the solutions disappear:

    (%i2) k:1-sqrt(3)$
    solve(eq,[x,y]);
    (%o2) []

    System info:
    Maxima 5.36.1
    SBCL 1.2.7
    Win 8.1 64-bit

     
  • sslavi

    sslavi - 2015-06-19

    Some more IMO interesting info for debuggers:
    1) The bug does not occur with the following set of equations:

    y^2+x^2-a=0
    y^2+x^2+k*x+b=0

    2) but it does occur with this set of equations:

    y^2+x^2-a=0
    y^2+x^2+k*y+b=0

    In the latter case, following things happen:

    1) When k is substituted with a numerical value of the form sqrt(number), the problem does not occur and a set of numerical solutions are found.

    2) When k is substituted with a symbolic expression of the form sqrt(C), the problem does not occur and a set of symbolic solutions are found.

    3) When k is substituted with a numerical value of the form number+sqrt(number) Maxima returns a void set.

    4) When k is substituted with a symbolic expression of the form B+sqrt(C) Maxima hangs.

    See the attached screenshot.

    Cheers

     

    Last edit: sslavi 2015-06-19
  • David Billinghurst

    • assigned_to: David Billinghurst
    • Group: --> None
     
  • David Billinghurst

    The original issue is fixed by commit [2986fc]. I will leave this open as some of the cases in the previous post aren't resolved.

    (%i1) display2d:false;
    (%o1) false
    
    (%i2) eqs: [y^2+x^2-(400-400/(2/q+1))^2 = 0,
    (-y-400/(2/q+1)+400)^2+x^2-640000/(2/q+1)^2 = 0]$
    
    (%i3) solve(eqs,[x,y]);
    
    (%o3) [[x = -400*q*sqrt(2/(q+2)-q/(q+2)),y = -(400*q^2-800)/(q+2)],
           [x = 400*q*sqrt(2/(q+2)-q/(q+2)),y = -(400*q^2-800)/(q+2)]]
    (%i4) solve(eqs,[x,y]),q=sqrt(3);
    
    (%o4) [[x = -400*(2-sqrt(3))*sqrt(3),
            y = (sqrt(3)+2)*(1600*3^(3/2)-8400)-800*sqrt(3)+1600],
           [x = 400*(2-sqrt(3))*sqrt(3),
            y = (sqrt(3)+2)*(1600*3^(3/2)-8400)-800*sqrt(3)+1600]]
    

    See [bugs:#3208] for details.

     

    Related

    Bugs: #3208
    Commit: [2986fc]

  • David Billinghurst

    • status: open --> closed
     
  • David Billinghurst

    Commits [2986fc] and [640ca7] has improved this significantly. Most of the problems above can now be solved. Some problems are too general for algsys, as it needs to know the sign and ordering of some quantities to correctly simplify them.

    I will add some of the test cases above to the maxima testsuite in rtest_algsys.mac. They broke some of my "improvements' in interesting ways.

    (%i1) display2d:false$
    
    (%i2) eqs:[y^2+x^2-a=0,y^2+x^2+k*x+b=0]$
    
    (%i3) algsys(eqs,[x,y]),k=sqrt(3.0);
    
    (%o3) [[x = -(2131*b+2131*a)/3691,
            y = -sqrt((-4541161*b^2)+a*(13623481-9082322*b)-4541161*a^2)/3691],
           [x = -(2131*b+2131*a)/3691,
            y = sqrt((-4541161*b^2)+a*(13623481-9082322*b)-4541161*a^2)/3691]]
    (%i4) algsys(eqs,[x,y]),k=sqrt(3);
    
    (%o4) [[x = -(sqrt(3)*b+sqrt(3)*a)/3,y = -sqrt((-b^2)+a*(3-2*b)-a^2)/sqrt(3)],
           [x = -(sqrt(3)*b+sqrt(3)*a)/3,y = sqrt((-b^2)+a*(3-2*b)-a^2)/sqrt(3)]]
    (%i5) algsys(eqs,[x,y]),k=2+sqrt(3);
    
    (%o5) [[x = (sqrt(3)-2)*b+(sqrt(3)-2)*a,
            y = -sqrt((4*sqrt(3)-7)*b^2+a*((8*sqrt(3)-14)*b+1)
                                       +(4*sqrt(3)-7)*a^2)],
           [x = (sqrt(3)-2)*b+(sqrt(3)-2)*a,
            y = sqrt((4*sqrt(3)-7)*b^2+a*((8*sqrt(3)-14)*b+1)+(4*sqrt(3)-7)*a^2)]]
    (%i6) algsys(eqs,[x,y]),k=1-sqrt(3);
    
    (%o6) [[x = ((sqrt(3)+1)*b+(sqrt(3)+1)*a)/2,
            y = -sqrt(((-sqrt(3))-2)*b^2+a*(((-2*sqrt(3))-4)*b+2)
                                        +((-sqrt(3))-2)*a^2)
              /sqrt(2)],
           [x = ((sqrt(3)+1)*b+(sqrt(3)+1)*a)/2,
            y = sqrt(((-sqrt(3))-2)*b^2+a*(((-2*sqrt(3))-4)*b+2)
                                       +((-sqrt(3))-2)*a^2)
              /sqrt(2)]]
    
     

    Related

    Commit: [2986fc]
    Commit: [640ca7]


Log in to post a comment.