Ask Your Question
1

Can I expand a composite function symbolically in sage

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

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
2

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

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

Comments

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

nerak99 gravatar imagenerak99 ( 2022-02-03 10:56:19 +0100 )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

Stats

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

Seen: 223 times

Last updated: Feb 03 '22