taylor() confused by full_simplify()?

16 views
Skip to first unread message

Dan Drake

unread,
Sep 20, 2011, 3:24:56 AM9/20/11
to sage-support
This is strange:

sage: x, y =var('x y')
sage: foo = 1/2*(x^3*y + 2*x + sqrt(x^6*y^2 + x^6 + 2*x^5 - 7*x^4 +
6*x^3 - 2*(x^6 + x^5 - 2*x^4 + x^3)*y + 2*x^2 - 4*x + 1) - x^3 - x^2 -
1)/(x^3 - x^2)

sage: foo.taylor(x,0,5)
3*(3*y + 4)*x^5 + 3*(y + 2)*x^4 + (y + 3)*x^3 + 2*x^2 + x + 1

Okay, but if I do a full_simplify(), then taylor() is confused:

sage: foo.full_simplify().taylor(x,0,5)
-(10*y + 11)*x^5 - (4*y + 5)*x^4 - 2*(y + 1)*x^3 - (y + 1)*x^2 - x*y -
1/x + 1/x^2 - 1

I'm certain that the function is analytic at zero, and has coefficients
that are polynomials in y with nonnegative coefficients. So the second
one is definitely wrong.

However, when I look at the difference between foo and
foo.full_simplify(), all I see is that the square root gets factored and
split into two:

sqrt(x^6*y^2 + x^6 + 2*x^5 - 7*x^4 + 6*x^3 - 2*(x^6 + x^5 - 2*x^4 +
x^3)*y + 2*x^2 - 4*x + 1)

becomes, after full_simplify(),

sqrt(x^3*y - x^3 + x^2 - 1)*sqrt(x^3*y - x^3 - 3*x^2 + 4*x - 1)

and indeed, if you factor what's under the first square root, you get
the two factors in the second pair of roots.

What is going on? Is taylor() unreliable? Or is it full_simplify()?

Thanks!

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

kcrisman

unread,
Sep 20, 2011, 10:02:48 AM9/20/11
to sage-support
> However, when I look at the difference between foo and
> foo.full_simplify(), all I see is that the square root gets factored and
> split into two:
>
> sqrt(x^6*y^2 + x^6 + 2*x^5 - 7*x^4 + 6*x^3 - 2*(x^6 + x^5 - 2*x^4 +
> x^3)*y + 2*x^2 - 4*x + 1)
>
> becomes, after full_simplify(),
>
> sqrt(x^3*y - x^3 + x^2 - 1)*sqrt(x^3*y - x^3 - 3*x^2 + 4*x - 1)
>
> and indeed, if you factor what's under the first square root, you get
> the two factors in the second pair of roots.

Dan,

This is because full_simplify() calls lots of things, in particular
simplify_radical(), which is Maxima's radcan().

DETAILS: This uses the Maxima radcan() command. From the Maxima
documentation: "All functionally equivalent forms are mapped
into a
unique form. For a somewhat larger class of expressions,
produces a
regular form. Two equivalent expressions in this class do not
necessarily have the same appearance, but their difference can
be
simplified by radcan to zero. For some expressions radcan is
quite
time consuming. This is the cost of exploring certain
relationships
among the components of the expression for simplifications
based on
factoring and partial fraction expansions of exponents."

Whenever you multiply two square roots to one square root, weird
things can happen if the inputs aren't all positive - we've seen this
on the Sage list with questions as well as the Maxima list.

> What is going on? Is taylor() unreliable? Or is it full_simplify()?

From the Maxima taylor doc:


`taylor (<expr>, <x>, <a>, <n>)' expands the expression <expr> in
a truncated Taylor or Laurent series in the variable <x> around
the point <a>, containing terms through `(<x> - <a>)^<n>'.

which is also essentially in Sage's doc. So maybe those square roots
by themselves over x^3-x^2 somehow are done individually and that
causes the problem? You should try smaller versions of your function
in Maxima directly to debug this.

- kcrisman
Reply all
Reply to author
Forward
0 new messages