There seems to be some funamental differences between Sympy's integration
algorithm an other ones (say Sage, Maxima, Giac, Fricas or Mathematica).
Sympy :
```
>>> from sympy import *
>>> x=symbols("x", positive=True)
>>> f=Lambda((x), (x**6+2)/(8*x**2))
>>> integrate(sqrt(f(x).diff(x)**2+1)*f(x))
(Integral(2*Abs(x**4 - x**2 + 1)/x**5, x) + Integral(2*Abs(x**4 - x**2 +
1)/x**3, x) + Integral(x*Abs(x**4 - x**2 + 1), x) + Integral(x**3*Abs(x**4
- x**2 + 1), x))/16
```
Sage (either via Maxima's or Giac's integrators) :
```
sage: x=var("x", domain="positive")
sage: f(x)=(x^6+2)/(8*x^2)
sage: integrate((f(x).diff(x)^2+1).sqrt()*f(x),x)
1/128*x^8 + 1/32*x^2 + 1/32*(2*x^6 - 1)/x^4
```
BTW, calling these integrators from Sage :
```
sage: [[(u/v).full_simplify() for v in L] for u in L]
[[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
1]]
sage: S=integrate((f(x).diff(x)^2+1).sqrt()*f(x),x) ; S
1/128*x^8 + 1/32*x^2 + 1/32*(2*x^6 - 1)/x^4
sage: G=integrate((f(x).diff(x)^2+1).sqrt()*f(x),x, algorithm="giac") ; G
1/128*x^8*sgn(x^9 + x^3) + 3/32*x^2*sgn(x^9 + x^3) - 1/32*sgn(x^9 + x^3)/x^4
sage: F=integrate((f(x).diff(x)^2+1).sqrt()*f(x),x, algorithm="fricas") ; F
1/128*(x^12 + 12*x^6 - 4)/x^4
sage: Ma=integrate((f(x).diff(x)^2+1).sqrt()*f(x),x, algorithm="maxima") ;
Ma
1/128*x^8 + 1/32*x^2 + 1/32*(2*x^6 - 1)/x^4
sage:
M=mathematica.Refine(mathematica.Integrate((f(x).diff(x)^2+1).sqrt()*f(x),x).sage(),
x>0).sage() ; Ma
1/128*x^8 + 1/32*x^2 + 1/32*(2*x^6 - 1)/x^4
sage: L=[S,G,F,Ma,M]
sage: [[(u/v).full_simplify() for v in L] for u in L]
[[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[1, 1, 1, 1, (x^6 + 1)/sqrt(x^12 + 2*x^6 + 1)],
[sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
sqrt(x^12 + 2*x^6 + 1)/(x^6 + 1),
1]]
```
It *seems* that all these integrators, *except Sympy's*, use the fact that
`x>0`. But this might also come from different forms of the integrand.
Sympy :
```
>>> sqrt(f(x).diff(x)**2+1)*f(x)
(x**6 + 2)*sqrt((3*x**3/4 - (x**6 + 2)/(4*x**3))**2 + 1)/(8*x**2)
```
Sage :
```
sage: sqrt(f(x).diff(x)^2+1)*f(x)
1/32*(x^6 + 2)*sqrt((3*x^3 - (x^6 + 2)/x^3)^2 + 16)/x^2
```
HTH,
Le lundi 23 janvier 2023 à 18:23:45 UTC+1, [email protected] a écrit :
> EDIT: In general, the square root does *not* simplify.
>
> On Monday, January 23, 2023 at 7:22:01 PM UTC+2 Kalevi Suominen wrote:
>
>> The derivative should actually be squared in the square root expression:
>> sqrt(1 + f'(x)^2) (see e.g.
>> https://en.wikipedia.org/wiki/Surface_of_revolution), which then
>> simplifies to a rational function (x^6 + 1)/(2*x^3) (unless I made a
>> mistake).
>> Hence the integrand will be rational and SymPy should be able to handle
>> it.
>>
>> In general, the square root does simplify. In that case the result will
>> be a hyperelliptic integral, which is non-elementary and cannot be
>> represented by means of common special functions. There is no support in
>> SymPy for such integrals.
>>
>> Kalevi Suominen
>> On Saturday, January 21, 2023 at 4:32:16 PM UTC+2 Oscar wrote:
>>
>>> On Sunday, 15 January 2023 at 07:36:14 UTC [email protected] wrote:
>>> Hi all,
>>>
>>> I have a question: why SymPy (in JULIA and PYthon) unable to get the
>>> numerical answer for area of surface of revolution?
>>>
>>> Is it impossible?
>>>
>>> This is my question posted today on Julia Discourse:
>>>
>>>
>>> https://discourse.julialang.org/t/area-of-surface-of-revolution-integral-too-hard-to-be-computed-by-julia-sympy-and-python-sympy/92981
>>>
>>> Please ask questions here rather than posting a link to somewhere else.
>>>
>>> You can numerically evaluate integrals using evalf:
>>>
>>> In [*1*]: x = symbols("x")
>>>
>>> ...:
>>>
>>> ...: f = (x**6 + 2)/(8*x**2)
>>>
>>> ...: g = sqrt(1 + diff(f,x))
>>>
>>> ...:
>>>
>>> ...: h = 2*pi*Integral(((x**6 + 2)/(8*x**2))*sqrt(1 + diff(f,x)), (x,
>>> 1, 3))
>>>
>>>
>>> In [*2*]: h
>>>
>>> Out[*2*]:
>>>
>>> 3
>>>
>>> ⌠
>>>
>>> ⎮ ___________________
>>>
>>> ⎮ ╱ 3 6
>>>
>>> ⎮ ⎛ 6 ⎞ ╱ 3⋅x x + 2
>>>
>>> ⎮ ⎝x + 2⎠⋅ ╱ ──── + 1 - ──────
>>>
>>> ⎮ ╱ 4 3
>>>
>>> ⎮ ╲╱ 4⋅x
>>>
>>> 2⋅π⋅⎮ ────────────────────────────────── dx
>>>
>>> ⎮ 2
>>>
>>> ⎮ 8⋅x
>>>
>>> ⌡
>>>
>>> 1
>>>
>>>
>>> In [*3*]: h.evalf()
>>> Out[*3*]: 116.281297293490
>>>
>>>
>>>
>>> --
>>> Oscar
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/b4df39b0-6710-4842-86e6-b61abdb19d31n%40googlegroups.com.