1
$\begingroup$

I have the following polynomials:

pol = {x^2 + 2 x^3 + 4 x^7, x + 2 x^5 + 4 x^6, 3 x^6 + 2 x^9};

and following list

val = {{2, 3}, {4}, {7, 8}};

both pol and val has length of 3 and they should be looked as one-to-one. Now I want to replace val[[1]] into pol[[1]] for each value and so on and so forth. I did:

pol /. x -> val 

but this simply takes all values in val and replace them, but I want this to be one to one meaning {2, 3} shall only be replaces in x^2 + 2 x^3 + 4 x^7 then {4} must be replaced in x + 2 x^5 + 4 x^6 and so on.

$\endgroup$
2
$\begingroup$
MapThread[# /. x -> #2 &, {pol, val}]

{{532, 8811}, {18436}, {81060161, 269221888}}

Also

# /. x -> #2 & @@@ Transpose[{pol, val}]

{{532, 8811}, {18436}, {81060161, 269221888}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.