Anonymous symbolic functions? [closed]
I'd like to be able to define symbolic functions recursively, for instance like the following:
f(0)(a, b) = a * b
f(n)(a, b) = f(n-1)(a + 2*b, a - b)
g = f(5)
print(g(1, 2))
The above program doesn't run because "f(...)(...) = <expression>" isn't valid sage code.
How do I achieve something similar in sage?
Essentially I want:
f(0)(a, b) = a * b
f(1)(a, b) = (a+b) * (a-b)
f(2)(a, b) = ((a+b) + (a-b)) * ((a+b) - (a-b))
...
I am not very familiar with Sage, and am open to different ways of approaching this. Is there some other abstraction I should look into when I want to work with a recursively defined sequence of functions?
Thank you!
Duplicate of https://ask.sagemath.org/question/347... see the answer there.