Karim BELABAS on Wed, 9 Oct 2002 19:58:23 +0200 (MEST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: gp: x^(1/2) and (1/x)^(1/2) and sqrt(x)


On Sat, 5 Oct 2002, Michael Somos wrote:
> ? (1/x)^(1/2)
>   ***   log is not analytic at 0.
> ? x^(1/2)
>   ***   not an integer exponent for non invertible series in gpow.
> ? sqrt(x)
>   ***   odd exponent in gsqrt
>
> It seems to me that this is a confusing variety of error messages.
> Perhaps there might be a way to make them more comparable?  It
> is further interesting that :
>
> ? (1/x^2)^(1/2)
>   ***   log is not analytic at 0.
> ? (x^2)^(1/2)
>   ***   not an integer exponent for non invertible series in gpow.
> ? sqrt(x^2)
> %3 = x + O(x^15)

While investigating this, I stumbled on an embarassing mess with conversion
to power series.

1) Ser automatically converts the variable to 'x' (or its second argument),
which does not look like the right thing to do, and has a few funny
consequences like:

(19:30) gp > Ser(a/b)
%1 = 1/b*x + O(x^17)

(19:30) gp > Ser(b/a)
%2 = 1 + O(x^16) \\ x = Ser(b) / Ser(a) = (x + O(x^17)) / (x + O(x^17))

2) seriesprecision is documented (see \ps n) as "sets series precision to n
significant terms". This is consistent with \p (number of significant digits
computed in a floating point computation with exact inputs) and is what
Ser(p) does.

On the other hand, due to (inefficient and, in my opinion, incorrect)
internal conversions, a transcendental functions f computes f(p) as
f(p + O(x^seriesprecision)) instead, which is quite different when val(p) != 0.

(19:30) gp > Ser(x)
%3 = x + O(x^17)

(19:30) gp > sin(x)
%4 = x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 - 1/39916800*x^11 +
1/6227020800*x^13 - 1/1307674368000*x^15 + O(x^16)

(19:30) gp > sin(Ser(x))
%5 = x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 - 1/39916800*x^11 + 1/6227020800*x^13 - 1/1307674368000*x^15 + O(x^17)

[ %4 has 15 significant terms, not 16. %5 is correct ]

I'm fixing the relevant portions of trans[123].c.

    Karim.
-- 
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathematiques, Bat. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
--
PARI/GP Home Page: http://www.parigp-home.de/