Essentially my issue is that, in the algorithm im working on, I construct a polynomial by taking factors out of a list and multiplying them. For example, i have

f=(1 + t + 3 t^2 + t^3) (6 + 3 t + 2 t^2 + t^4)

How can I now replace t with say, a number or another polynomial? And how can I do this for any polynomial f?

=================

=================

2 Answers

2

=================

One standard way to do this is to define your polynomial in the first place as a function:

f[t_] := (1 + t + 3 t^2 + t^3) (6 + 3 t + 2 t^2 + t^4)

Now you can evaluate this at any number using f[3] and with any other argument:

f[x^2 + 2]

Then apply Expand or Simplify if desired.

Clear[f, t, x]

f = (1 + t + 3 t^2 + t^3) (6 + 3 t + 2 t^2 + t^4);

You can replace t with a number using ReplaceAll:

f /. t :> 3

6612

Or replace it with another polynomial and (optionally) expand it:

f /. t :> (x^2 + 1) // Expand

72 + 186 x^2 + 230 x^4 + 182 x^6 + 105 x^8 + 42 x^10 + 10 x^12 + x^14

Or replace with another polynomial and then with a number:

f /. t :> (x^2 + 1) /. x :> 3

13419396