@Pepini @Carl Love @acer

I would like to have your opinion about the following idea: Is it intersting, or is it stupid white elephant?

Let's start with this code

f := a -> x -> a*x*(1 - x);
g := n -> a -> x -> (f(a)@@n)(x):
a -> x -> a x (1 - x)
r := [seq(3..4, 0.01)]:
iter := 10:
expr := eval(diff(g(iter)(a)(x), x), x=x0):

My first idea to enhance the computational time was to convert **expr** into its Horner form in order to reduce the number of operations.

This approach speeds up the computation while** iter <=8** but Maple (2015) seems to fail in finding the Horner form for higher values of **iter**.

So I thought to that: **CodeGeneration** (here **CodeGeneration:-Matlab**) enables building an optimal representation of an expression (here a simple polynomial).

I then do that

expr := CodeTools:-Usage( eval(diff(g(11)(a)(x), x), x=x0) ):
writeto(cat(currentdir(), "/opt")):
CodeGeneration:-Matlan(expr, optimize):
writeto(terminal):
0
# Open file "opt"
# Change " ^ " into "^"
# In this worksheet:
# type ftn := proc(a)
# copy paste the content of file "opt"
# add "return=%:"
# add "end proc":

Here are the computational times for iter=10 and 101 pts between 3 and 4.

restart;
with(plots):
M := 100;
r := evalf([seq(a/M, a = 3*M .. 4*M)]):
x := t -> t;
x0 := 0.2;
100
t -> t
0.2
f := a -> x -> a*x*(1 - x);
g := n -> a -> x -> (f(a)@@n)(x):
a -> x -> a x (1 - x)
r := [seq(3..4, 0.01)]:
iter := 10:
t0 := time():
expr := eval(diff(g(iter)(a)(x), x), x=x0):
phi := unapply(expr, a):
L := phi~(r):
lambda := (ln@abs)~(L)/~iter:
time()-t0;
1.308

versus

t0 := time():
L := ftn~(r):
lambda := (ln@abs)~(L)/~iter:
time()-t0;
0.018

Computing **1001** pts with **iter=20** requires only **0.675** seconds (plus 20 s to generate the optimized MATLAB code and ... let's say half of a minute to transfom it into Maple code)

Lyapounov_2.mw

**Example:**

Of course it is a very cumbersome and partly manual strategy.It could be improved if it was possible to generate the MATLAB code, not of expr itself, but of a procedure **ftn** like **ftn := unapply(expr, a)**, and after simply use **Matlab:-FromMFile** to automatically create the MAPLE code of **ftn**.

But it seems that **CodeGeneration:-Matlab** doesn't handle operator forms like **ftn**?

Does it exist a procedure like **CodeGeneration:-Matlab(expr, optimize)** which transforms a Maple expression into another whose the number of operations is minimal?

I've seen recently some answers concerning **simplify/size**, but it seems this function is extremely slow compared to **CodeGeneration:-Matlab(expr, optimize)**?

Do you think that this approach could be useful in computing this Lyapounov exponent, or do you think it's a dead end do-it-yourself?