Ask Your Question

Can I expand a composite function symbolically in sage

asked 2022-02-03 08:36:50 +0200

nerak99 gravatar image

The title says it all really. I think I can use ‘expand’ but can’t work out the syntax. Eg, given f(x) = a polynomial and g(x) = some other bit of algebra can I expand fg(x)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2022-02-03 10:45:57 +0200

rburing gravatar image

Yes, for example using callable symbolic expressions:

sage: f(x) = x^3
sage: g(x) = sin(x)+1
sage: f(g(x)).expand()
sin(x)^3 + 3*sin(x)^2 + 3*sin(x) + 1

Or using expression substitution:

sage: f = x^3
sage: g = sin(x)+1
sage: f.subs({x : g}).expand()
sin(x)^3 + 3*sin(x)^2 + 3*sin(x) + 1
edit flag offensive delete link more


Thank you for your prompt response. I will have a go later on today.

nerak99 gravatar imagenerak99 ( 2022-02-03 10:56:19 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-02-03 08:36:50 +0200

Seen: 40 times

Last updated: Feb 03