Re: Taylor Series Reversion error: 'quotient' by 'zero'

Barton Willis via Maxima-discuss <[email protected]>
Newsgroups gmane.comp.mathematics.maxima.general
Message-ID <SN6PR07MB7952EA5AB9C11EE43160FE2BB6D92@SN6PR07MB7952.namprd07.prod.outlook.com>
Correct--looking at the source code (located in /share/calculus/) it's clear that the first argument to 'revert` must be a Taylor polynomial whose lowest power is one.

Changes:


  1.
Reformated the source code,
  2.
Inserted  few checks for valid arguments,
  3.
Used taylorinfo to find n, not the highest power
  4.
 Algorithmically, modified the code as Viktor suggested

revert(exp, t) := block([f, n, m, v, w, r1, g],

    if not taylorp(exp) then (
        error("The first argument to exp must be a Taylor polynomial; found ~M ~%", exp)),

    /* Lowest and highest powers of t in exp */
    m : lopow(exp, t),
    n : last(first(taylorinfo(exp))),

    if not integerp(m) or not integerp(n) then
        error("Unable to find the lowest or highest powers of ", t, " in the expression ", exp),

    if n < 0 then
       error("The highest power of ", t, " in the expression ", exp, " must be positive"),


    /* If lowest power is not 1, normalize: exp -> taylor(exp^(1/m),t,0,n) */
    g : if m = 1 then exp
        else taylor(exp^(1/m),t,0,n),

    /* Allocate arrays */
    array([v, w], n),

    /* Leading coefficient normalization */
    r1 : 1 / ratcoef(g, t, 1),
    v[1] : 1,

    /* Build v[k] and initial w[k] */
    for k : 2 thru n do (
      v[k] : ratcoef(g, t, k) * r1,
      w[k] : -v[k]
    ),
    w[1] : 1,

    /* Define update function */
    f : lambda([j],
          for i from j + 1 thru n do
            w[i] : w[i] - w[j] * v[i - j + 1]
        ),

    /* First sweep */
    for j from 2 thru n - 1 do
      apply(f, [j]),

    /* Second sweep */
    for k from 2 thru n - 1 do
      (for j from k thru n - 1 do
         apply(f, [j])
      ),

    /* Accumulate final polynomial for g^{-1}(t) */
    f : 0,
    for k thru n do
      f : f + w[k] * (t * r1)^k,

    subst(t^(1/m),t,f)
  )$

The code mutates f from a lambda form to a polynomial accumulator—that's okay, but it's a bit weird. Also, I think that v and w need to be declared local.

This  code was only lightly tested.

(%i24) load(revert)$

(%i25) eq : 1/x^2+x^4 + x^6;

(%o25) x^6+x^4+1/x^2
(%i26) revert(taylor(eq,x,0,12),x);

(%o26) (2/sqrt(x)+1/x^(7/2)+1/x^(9/2))/2
(%i27) subst(x=eq,%);

(%o27) (2/sqrt(x^6+x^4+1/x^2)+1/(x^6+x^4+1/x^2)^(7/2)+1/(x^6+x^4+1/x^2)^(9/2))/2
(%i28) taylor(%,x,0,14);

(%o28) x-(11*x^13)/8

________________________________
From: Michel Gosse <[email protected]>
Sent: Saturday, August 15, 2026 4:54 AM
To: Justin Jensen <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: [Maxima-discuss] Taylor Series Reversion error: 'quotient' by 'zero'

Caution: Non-NU Email

It seems that revert needs a term in t within the taylor serie.
For eq, the t coefficient is 0, so the error quotient by zero appears.
I have tried this to have a linear term, but don't know if the result is correct
ser2:subst(u^(1/3),t,ser);
sol:revert(ser2,u);
subst(t^3,u,sol);
i get
\[\frac{{{\ensuremath{\pi} }^{3}} {{t}^{9}}}{2240}\mathop{+}\frac{3 \ensuremath{\pi}  {{t}^{3}}}{4}\]

Le sam. 15 août 2026 à 10:45, Justin Jensen <[email protected]<mailto:[email protected]>> a écrit :
I'm new to Maxima and Computer Algebra Systems in general. So far Maxima seems to be exactly what I need right now.

As part of a side project I'm trying to find the inverse of a function. It has no closed-form function, at least in the general case, so I'm approximating it with a Taylor series. Note that the series has coefficients of 0 for the 0th, 1st, and 2nd terms. When I try to do a reversion of series using the `revert` command, it fails and gives the error: "'quotient' by 'zero'" (see below). How do I resolve this? Once upon a time, I used Mathematica to find the inverse of a very similar series and it worked fine. How do I do this with Maxmia?

(%i1) eq: (2*t-sin(2*t))/%pi;
eq (2*t-sin(2*t))/%pi
(%i9) ser: taylor(eq,t,0,9);
ser (4*t^3)/(3*%pi)-(4*t^5)/(15*%pi)+(8*t^7)/(315*%pi)-(4*t^9)/(2835*%pi)+...
(%i10) revert(ser,t);
(%o10) revert(-((4*t^9)/(2835*%pi))+(8*t^7)/(315*%pi)-(4*t^5)/(15*%pi)+(4*t^3)/(3*%pi),t)
(%i11) load("revert")$
(%i61) revert(ser,t);
`quotient' by `zero'

 -- an error. To debug this try: debugmode(true);


Thanks in advance,

--
Justin
_______________________________________________
Maxima-discuss mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/maxima-discuss<https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/maxima-discuss__;!!PvXuogZ4sRB2p-tU!AaLiMFWH52pN9V6ZzKztvrA2MQXISJxriaAuZ1fuo9sIikMLYWXaZR5_sSm0fjukriwqDk4JNYFPdA$>

_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.