First time here? Check out the FAQ!

Ask Your Question
1

Can I expand a composite function symbolically in sage

asked 3 years ago

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)

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 3 years ago

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
Preview: (hide)
link

Comments

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

nerak99 gravatar imagenerak99 ( 3 years ago )

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

Stats

Asked: 3 years ago

Seen: 236 times

Last updated: Feb 03 '22