1 | initial version |
Hello, @Cyrille! For this problem, you can exploit the very excellent and comfortable facilities that Sage provides for defining symbolic functions.
In the case of your first piece of code, after you define
A = 1000
g(x) = x^2
f = piecewise([[[1, 1], A/12],
[[2, 2], A/(12 - 1) - 1*10],
[[3, 3], A/(12 - 2) - 2*10]])
you just need to define fg(x) = g(f(x))
in order to have the composition. As for your second piece of code, you could do something like fgh(x) = h(x) * fg(x)
or, equivalently, fgh(x) = h(x) * g(f(x))
.
I hope this helps!