Opened 11 years ago

Closed 5 years ago

#3520 closed defect (duplicate)

inconsistency in simplify_radical

Reported by: wdj Owned by: gfurnish
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords:
Cc: burcin, AlexGhitza, mjo Merged in:
Authors: Reviewers: Michael Orlitzky, Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

This is a problem:

sage: f = sqrt(25-x)*sqrt(1+1/(4*(25-x)))
sage: f.integral(x,9,16)
integrate(sqrt(1/(4*(25 - x)) + 1)*sqrt(25 - x), x, 9, 16)
sage: f.nintegral(x,9,16)
(24.9153783348643, 2.7661626694613149e-13, 21, 0)
sage: g = f.simplify_radical()
sage: g.integral(x,9,16)
I*(65*sqrt(65)*I/6 - 37*sqrt(37)*I/6)/2
sage: ans = g.integral(x,9,16)
sage: ans.real()
(37*sqrt(37)/6 - 65*sqrt(65)/6)/2
sage: RR(ans.real())
-24.9153783348643

Change History (19)

comment:1 Changed 11 years ago by schilly

Just for reference, the same with MMA6:

In[3]:=
f[x_] := Sqrt[25 - x]*Sqrt[1 + 1/(4*(25 - x))]

In[16]:=
g[x_] := Integrate[f[x], x]; FullSimplify[g[x]]

Out[16]=
(-(1/12))*(4 + 1/(25 - x))^(3/2)*(25 - x)^(3/2)

In[15]:=
FullSimplify[D[g[x], x] - f[x]]

Out[15]=
0

In[6]:=
Integrate[f[x], {x, 9, 16}]

Out[6]=
(1/12)*(-37*Sqrt[37] + 65*Sqrt[65])

In[8]:=
NIntegrate[f[x], {x, 9, 16}, WorkingPrecision -> 40]

Out[8]=
24.915378334864299909236795241439053518882655529789`40.

comment:2 Changed 10 years ago by kcrisman

With the new symbolics and Maxima 5.19.1:

sage: sqrt(25-x)*sqrt(1+1/(4*(25-x)))
sqrt(-1/4/(x - 25) + 1)*sqrt(-x + 25)
sage: f = _
sage: f.integral(x)
1/12*(4*I*x - 101*I)*sqrt(4*x - 101)
sage: f.integral(x,9,16)
-37/12*sqrt(37) + 65/12*sqrt(65)
sage: f.nintegral(x,9,16)
(24.9153783348643, 2.7661626694613149e-13, 21, 0)
sage: g = f.simplify_radical()
sage: g.integral(x,9,16)
37/12*sqrt(37) - 65/12*sqrt(65)
sage: ans = g.integral(x,9,16)
sage: ans.real()
37/12*sqrt(37) - 65/12*sqrt(65)
sage: RR(ans.real())
-24.9153783348643

Maxima can now integrate the original one, but still gives the wrong simplification (?) of f. It seems to be choosing the wrong square root of negative one, as it were, since

sage: j = -g
sage: j.integrate(x,9,16)
-37/12*sqrt(37) + 65/12*sqrt(65)

So the real problem is in simplify_radical().

comment:3 Changed 10 years ago by burcin

  • Cc burcin added

comment:4 Changed 10 years ago by kcrisman

  • Cc AlexGhitza added

One may want to check the latest CVS of Maxima, where I believe some definitions relating to this have changed.

comment:5 Changed 10 years ago by kcrisman

  • Component changed from calculus to symbolics
  • Report Upstream set to N/A
  • Summary changed from bug in integrating sqrt to inconsistency in simplify_radical

Just updating. This is still in 5.20.1, but it's not clear whether this is really a bug, since radical simplifications will in their nature sometimes change which square root of -1 they use, and perhaps it's not possible to do so consistently across multiplication or division. Comments?

comment:6 Changed 10 years ago by kcrisman

Maxima devs have been discussing some things related to this, so it could be worth checking whether this has changed again in their CVS.

comment:7 Changed 8 years ago by kcrisman

What is really going on here is that simplify_radical uses radcan under the hood, which treats things as symbolic expressions, not functions, and just chooses a branch - consistently, but arbitrarily. At least I think that is what is here. See the Maxima list thread starting here.

comment:8 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:9 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:10 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:11 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:12 follow-up: Changed 5 years ago by kcrisman

  • Cc mjo added

It seems to be that this is probably a dup of #14305, #11912, and/or other such tickets. Thoughts?

comment:13 in reply to: ↑ 12 ; follow-up: Changed 5 years ago by mjo

Replying to kcrisman:

It seems to be that this is probably a dup of #14305, #11912, and/or other such tickets. Thoughts?

Indeed, #11912 "fixes" it by renaming simplify_radical and updating its documentation so that it's very clear that this might happen.

comment:14 in reply to: ↑ 13 ; follow-up: Changed 5 years ago by kcrisman

  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

It seems to be that this is probably a dup of #14305, #11912, and/or other such tickets. Thoughts?

Indeed, #11912 "fixes" it by renaming simplify_radical and updating its documentation so that it's very clear that this might happen.

In which case perhaps this integration example could be added there.

comment:15 in reply to: ↑ 14 ; follow-up: Changed 5 years ago by mjo

Replying to kcrisman:

In which case perhaps this integration example could be added there.

There are a lot of examples of problems with simplify_radical, but this one isn't particularly clear. It's not like someone is going to see the example in the description and go "oh, that affects me!"

I think this ultimately comes down to sqrt(x^2) anyway, and that is included as an example.

That was my reasoning anyway. If it will help get it reviewed faster, I'll add whatever you want =)

comment:16 in reply to: ↑ 15 Changed 5 years ago by kcrisman

In which case perhaps this integration example could be added there.

That was my reasoning anyway. If it will help get it reviewed faster, I'll add whatever you want =)

Well, I think that pointing out that things you might not think would be affected is not bad.

comment:17 follow-up: Changed 5 years ago by mjo

Ok, I've just added this example to the branch at #11912.

comment:18 in reply to: ↑ 17 Changed 5 years ago by kcrisman

  • Reviewers set to Michael Orlitzky, Karl-Dieter Crisman
  • Status changed from needs_review to positive_review

Ok, I've just added this example to the branch at #11912.

Sweet.

comment:19 Changed 5 years ago by vbraun

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.