I wrote:
> 
> Martin R wrote:
> > 
> > Nasser found the following interesting bug at 
> > https://trac.sagemath.org/ticket/25905:
> > 
> > (1) -> f := (I*a*tan(d*x + c) + a)^3*tan(d*x + c)
> > 
> >    (1)
> >       3 3            4      2 3            3        3            2
> >      I a tan(d x + c)  + 3 I a tan(d x + c)  + 3 I a tan(d x + c)
> >    + 
> >       3
> >      a tan(d x + c)
> >                                                     Type: 
> > Expression(Integer)
> > (2) -> F := integrate(f, x)
> > 
> >    (2)
> >            2      3            1               3 3            3
> >        (9 I  - 3)a log(-----------------) + 2 I a tan(d x + c)
> >                                    2
> >                        tan(d x + c)  + 1
> >      + 
> >           2 3            2         3         3                   3         3
> >        9 I a tan(d x + c)  + (- 6 I  + 18 I)a tan(d x + c) + (6 I  - 18 I)a 
> > d x
> >   /
> >      6 d
> >                                          Type: 
> > Union(Expression(Integer),...)
> > (3) -> D(eval(F, I =%i), x)-eval(f, I=%i)
> > 
> >    (3)  0
> >                                            Type: 
> > Expression(Complex(Integer))
> > (4) -> F := integrate(eval(f, I=%i), x)
> >  
> >    >> System error:
> >    arithmetic error DIVISION-BY-ZERO signalled
> > Operation was (/ -2 0).
> > 
> > Any ideas?
> 
> This is old confusion between real and complex.  We create
> Complex(Complex(Integer)) and loose.

Thinking loudly.  In order to integrate trigonometric
functions we need imaginary unit. So, if not present we
need to add it, that is extend the original field.  Currently
this is done by changing base ring from R to Complex(R).
OTOH if imaginary unit is present we should use it.

There is extra complication, namely normalization works differently
when imaginary unit is present.

Now, adding imaginary unit when one is already present
is an error: it causes zero divisors which may lead to
wrong answer or crash.  Also, algebraic quantities
complicate computations so for efficiency reasons we
would like to avoid adding imaginary unit when it
is not necessary.

One solution could be a wrapper which test for presence
of imaginary unit and produces to new domains: "complex_R"
and "Expression(complex_R)".  "complex_R" should
be the same as R when R has imaginary unit, otherwise
"complex_R" should be "Complex(R)".  We need convertion
between those domains, which currently use "Complex(Expression(R))",
so we need extra domain to use in itermediate stage.

Main integration routine could take five domains above
and imaginary unit in "complex_R" as parameters and
depending on presence (or absence) of trigonometric
functions convert to "Expression(complex_R)".

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to