> I would assume that up to memory requirements that "save" or delay
> all the performed operations, there should be no performance penalty
> compared to a non-lazy evaluation.

Well... I programmed something with Laurent series and just by creating
my series more intelligently could speed up the computation of the
coefficients. Understand that "lazy" actually means that with each
operation on series, you build up a data structure. This data structure
must be evaluated to get the next coefficient when you need it.

Unfortunately, one cannot say anything generic, but for special series
that might make a difference.

> When running the code (see below) the first method of evaluation is
> three times faster than the second. (A second evaluation runs in the
> same time for both cases, probably because the results are cached,
> but that's not relevant for me).

Strange, on my computer it doesn't show this.

(4) -> approximate(s1,450);

                                                    Type:
Expression(Integer)
                           Time: 0.01 (IN) + 5.99 (EV) + 0.01 (OT) =
6.01 sec
(5) -> approximate(s1,450);

                                                    Type:
Expression(Integer)
                           Time: 0.00 (IN) + 4.84 (EV) + 0.00 (OT) =
4.84 sec
(6) -> approximate(s2,450);

                                                    Type:
Expression(Integer)
                              Time: 0 (IN) + 6.51 (EV) + 0.00 (OT) =
6.51 sec
(7) -> approximate(s2,450);

                                                    Type:
Expression(Integer)
                              Time: 0 (IN) + 1.99 (EV) + 0.00 (OT) =
1.99 sec


Not that I first use s1 twice and then s2 twice.

Anyway, I am somehow pretty sure you do not want to call "approximate"
anyway. Not that the result is no longer a series, but an element of the
coefficient domain (Expression(Integer)).

> In my case I start with an Expression(Integer), so I (obviously) can
> only use the second version from the
> ExpressionToUnivariatePowerSeries package. But my idea is that maybe
> I can improve the performance if I understand why the first method is
> so much faster.

I did not really get what you are up to, but if I were you, I would try
to construct my series and then work in a series domain instead of going
back and forth between Expression(Integer) and the series domain.

Try this...

E ==> AlgebraicNumber
x := monomial(1,1)$UnivariatePuiseuxSeries(E, 'x, 0)
s1 := x^2 + cos(x) + x^8/ sqrt(x-1);
l1 := [s1.i for i in 0..450];

Evaluate the last line a second time. Then you see what caching is.

And as a hint... look here...

https://github.com/fricas/fricas/blob/master/src/algebra/puiseux.spad#L366

There are a certain number of functions that are already known to the
FriCAS series domains.

Ralf

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/b2b8f4a8-5791-1d96-24ae-ec7f13028147%40hemmecke.org.

Reply via email to