I am currently trying to see if I can accelerate my code around series 
expansions. I really like that series are lazy in FriCAS, but I wonder 
what impact multiple iterated operations on the series (or the underlying 
stream), like integration etc. have. I would assume that up to memory 
requirements that "save" all the performed operations, there should be no 
performance penalty compared to a non-lazy evaluation.

Anyway, while testing I came up with this example, where some expression
is series expanded in two different ways. 

)clear completely
)set mes tim on

x := taylor(x');
s1 := x^2 + cos(x) + x^8/ sqrt(x-1);

s2 := taylor(y^2 + cos(y) + y^8/ sqrt(y-1),y=0);

approximate(s1,450);
approximate(s2,450);

approximate(s1,450);
approximate(s2,450);


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).

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 would have expected that the ExpressionToUnivariatePowerSeries package
does something like "subst(expression, x=series('x))", symbolically 
speaking, but then it should be just as fast.

In principle I see two ways to do the series expansions: Compute the 
expansion as a whole for the whole expression (for example by taking 
derivatives for a Taylor series). Or do it for each function separately, 
and use the Cauchy product to multiply the individual series together, or 
add them, etc. For the first series expansion example this is clearly 
done, but maybe not for ExpressionToUnivariatePowerSeries and this could 
be the difference?

Thanks,
Tobias


---- running the code: 

approximate(s1,450);


                                                    Type: 
Expression(Integer)
                                 Time: 0 (IN) + 2.20 (EV) + 0 (OT) = 2.20 
sec
approximate(s2,450);


                                                    Type: 
Expression(Integer)
                           Time: 0.00 (IN) + 6.12 (EV) + 0.00 (OT) = 6.13 
sec

approximate(s1,450);


                                                    Type: 
Expression(Integer)
                                 Time: 0 (IN) + 1.36 (EV) + 0 (OT) = 1.36 
sec
approximate(s2,450);


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

-- 
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 fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/s3049r%24u6u%241%40ciao.gmane.io.

Reply via email to