## #2736 Bug in solving equation

None
closed
5
2016-10-04
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]);
```

## Discussion

• 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 - 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 - 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 - 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 - 2014-06-06

if you do:
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:
(%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

• Tomio Arisaka - 2014-06-07

Hi,

It makes me notice that the function to_poly_solve calls the function poly_reduced_grobner and the algsys.

• status: open --> closed

• Fixed by commit [2986fc] See [bugs:#3208] for details.

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

5/2                   3/2
3    - 10        (- 2 3   ) - 15
(%o1) [[x = - ---------, y = - ---------------],
26                  26
5/2                3/2
3    + 10        2 3    - 15
[x = ---------, y = - -----------]]
26                26
```

#### Related

Last edit: David Billinghurst 2016-10-02
• status: closed --> open
• assigned_to: David Billinghurst

• Reopen as the issues in the second post are not fixed.

• Closing this. Issues in the second post fixed by commit [640ca7]. I will add the problem to maxima testsuite

```(%i1) display2d:false\$

(%i2) eqs:[x*y=p,x-y=3];

(%o2) [x*y = p,x-y = 3]
(%i3) algsys(subst(p=1/(1-cos(1)),eqs),[x,y]);

(%o3) [[x = ((-sqrt(9*cos(1)^2-22*cos(1)+13))+3*cos(1)-3)/(2*cos(1)-2),
y = -(sqrt(9*cos(1)^2-22*cos(1)+13)+3*cos(1)-3)/(2*cos(1)-2)],
[x = (sqrt(9*cos(1)^2-22*cos(1)+13)+3*cos(1)-3)/(2*cos(1)-2),
y = -((-sqrt(9*cos(1)^2-22*cos(1)+13))+3*cos(1)-3)/(2*cos(1)-2)]]
(%i4) float(%);

(%o4) [[x = 3.603649840080336,y = 0.603649840080336],
[x = -0.603649840080336,y = -3.603649840080336]]
(%i5) float(algsys(subst(p=float(1/(1-cos(1))),eqs),[x,y]));

(%o5) [[x = -0.6036497963666444,y = -3.603649796366644],
[x = 3.603649796366644,y = 0.6036497963666444]]
```

#### Related

• status: open --> closed