Non integral exponent for taylor expansion using sage

422 Views Asked by At

This is my function

var('h,r')
f=r^2*arccos((r-h)/r)-(r-h)*sqrt(2*r*h-h^2)

taylor(f,h,0,3)

Result:

-1/5*sqrt(2)*h^(5/2)/sqrt(r) + 4/3*sqrt(2)*h^(3/2)*sqrt(r)

I expected an expression of the form ax^3+bx^2+cx+d but I got 5/2 and 3/2 as exponents for h. Why is that?

2

There are 2 best solutions below

6
On BEST ANSWER

This is essentially directly using Maxima, so

(%i11) display2d: false;

(%o11) false
(%i12) f:r^2*acos((r-h)/r)-(r-h)*sqrt(2*r*h-h^2);

(%o12) r^2*acos((r-h)/r)-(r-h)*sqrt(2*h*r-h^2)
(%i13) taylor(f,h,0,3);

(%o13) 4*sqrt(r)*sqrt(2)*h^(3/2)/3-sqrt(r)*sqrt(2)*h^(5/2)/(5*r)

Expanding around other points gives what we expect, so I guess this is some kind of bug (or undocumented feature) in Maxima.

(%i22) taylor(sqrt(x),x,0,5);

(%o22) +sqrt(x)
(%i23) powerseries(sqrt(x),x,0);

(%o23) sqrt(x)

Maybe they like Puiseux series? I've reported this at https://sourceforge.net/p/maxima/bugs/2850/

Edit: Of course, there is the problem that the square root function is not particularly well-behaved at zero! But still one would expect something else, I think.

1
On

The problem seems to be in two parts.

  1. The program in Maxima is more general than might be implied by the name (taylor). In fact it returns other kinds of series when a taylor series does not exist. This includes Laurent series (negative exponents) and non-integer powers. Try, for example, taylor(sqrt(1/sin(x)),x,0,5).

This can be fixed by changing the name of the command to (say) series(). Although there may still be a naming issue because there are other kinds of series in the world, and you might want (say) an asymptotic series of some kind.

  1. The original poster and some commentary seems to suggest that Maxima should follow a strict discipline of doing only and exactly what is specified by the nature of the command. And if the system cannot do what the command does, it should give an error message. That's not really what Maxima does. For a very simple example, if you type f(3), and f is undefined, some systems might say "error, f is undefined". Maxima returns f(3), because under the circumstances, f(3) is a reasonable result that might allow you to proceed further. As a second example, integration of some form that Maxima does not know how to integrate results in a formula with an integral sign. Not an error "can't integrate...".

A general comment: if you are using Sage to access only the facilities in Maxima, you might find it convenient to just use Maxima, a computer algebra system with its own user interface wxmaxima and plotting routines etc.