Opened 6 years ago

Last modified 3 years ago

#15499 new defect

Regression in solve command

Reported by: ppurka Owned by:
Priority: major Milestone: sage-6.4
Component: calculus Keywords: regression
Cc: kcrisman, jakobkroeker Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps: wrongAnswerMarker

Description (last modified by jakobkroeker)

From google spreadsheet which no one reads X-(

The following is a vector calculus example. It supposedly should solve the critical point equations for the given function (symbolically, where possible, otherwise numerically):

x,y=var('x,y')
f(x,y)=((x-1)^2+(y-3)^2)*((x+1)^2+(y+2)^2)/(x^2+y^2+1)
solve([f.gradient()[0]==0,f.gradient()[1]==0],x,y)

Works with 5.5.rc0 (assuming answer is correct)

sage: solve([f.gradient()[0]==0,f.gradient()[1]==0],x,y)
[[x == (0.45 + 1.65*I), y == (-11/20*I + 27/20)], [x == (0.45 - 1.65*I), y == (11/20*I + 27/20)], [x == (2.14624170747e-08 + 2.50000000895*I), y == (-I + 1/2)], [x == (-2.14624155595e-08 + 2.49999999105*I), y == (-I + 1/2)], [x == (-1.22085882983e-09 - 2.49999999706*I), y == (I + 1/2)], [x == (1.22085741408e-09 - 2.50000000294*I), y == (I + 1/2)], [x == 0.108848345629, y == 0.064959221634], [x == 2.0690897184, y == -0.785458685751], [x == -2.08897196262, y == 0.935164613209], [x == (0.00551694210392 + 1.15257220423*I), y == (-0.0573325779446 + 2.78408620946*I)], [x == (0.00551694210392 - 1.15257220423*I), y == (-0.0573325779446 - 2.78408620946*I)], [x == (-0.4 + 1.2*I), y == (-3/5*I - 4/5)], [x == (-0.4 - 1.2*I), y == (3/5*I - 4/5)], [x == -1, y == -2], [x == 1, y == 3]]

Breaks with 5.5

sage: solve([f.gradient()[0]==0,f.gradient()[1]==0],x,y)
[2*(x - 1)*((y + 2)^2 + (x + 1)^2)/(x^2 + y^2 + 1) + 2*(x + 1)*((y - 3)^2 + (x - 1)^2)/(x^2 + y^2 + 1) - 2*((y + 2)^2 + (x + 1)^2)*((y - 3)^2 + (x - 1)^2)*x/(x^2 + y^2 + 1)^2 == 0, 2*(y - 3)*((y + 2)^2 + (x + 1)^2)/(x^2 + y^2 + 1) + 2*(y + 2)*((y - 3)^2 + (x - 1)^2)/(x^2 + y^2 + 1) - 2*((y + 2)^2 + (x + 1)^2)*((y - 3)^2 + (x - 1)^2)*y/(x^2 + y^2 + 1)^2 == 0]

Update: it works again with sage 7.6.beta4, but not all results are correct

Change History (6)

comment:1 Changed 6 years ago by kcrisman

  • Cc kcrisman added

Could be a change in how Maxima does these.

comment:2 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:4 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 4 years ago by rws

With 6.8:

sage: solve([f.gradient()[0]==0,f.gradient()[1]==0],x,y)
[[x == (0.4500000000000001 + 1.65*I), y == (-11/20*I + 27/20)], [x == (0.4499999999999998 - 1.65*I), y == (11/20*I + 27/20)], [x == (2.1462417074716e-08 + 2.500000008950185*I), y == (-I + 1/2)], [x == (-2.146241555952319e-08 + 2.499999991049815*I), y == (-I + 1/2)], [x == (-1.220858829829863e-09 - 2.499999997056549*I), y == (I + 1/2)], [x == (1.220857414076436e-09 - 2.500000002943449*I), y == (I + 1/2)], [x == 0.1088483456288377, y == 0.06495922163399628], [x == 2.069089718402096, y == -0.7854586857514639], [x == -2.088971962616823, y == 0.9351646132094527], [x == (0.005516942103919547 + 1.152572204234338*I), y == (-0.05733257794463129 + 2.784086209457084*I)], [x == (0.00551694210391972 - 1.152572204234338*I), y == (-0.05733257794463129 - 2.784086209457084*I)], [x == (-0.4 + 1.2*I), y == (-3/5*I - 4/5)], [x == (-0.4000000000000001 - 1.2*I), y == (3/5*I - 4/5)], [x == -1, y == -2], [x == 1, y == 3]]
sage: f.gradient()[0](0.45+1.65*I, (-11/20*I + 27/20))
-1.21597189939003e16 - 3.60287970189640e14*I
sage: f.gradient()[1](0.45+1.65*I, (-11/20*I + 27/20))
-8.89911286368410e16 - 8.92613446144832e16*I

Doesn't look correct...

comment:6 Changed 3 years ago by jakobkroeker

  • Cc jakobkroeker added
  • Description modified (diff)
  • Stopgaps set to wrongAnswerMarker
Note: See TracTickets for help on using tickets.