I want to find all the non-negative roots of the product of the following polynomials:
So, I did the following:
poly1 = @(x)x;
poly2 = @(x)x-1;
poly3 = @(x)x.^2-3*x+1;
poly4 = @(x)x.^4-7*x.^3+13*x.^2-7*x+1;
poly5 = @(x)x.^8-15*x.^7+83*x.^6-220*x.^5+303*x.^4-220*x.^3+83*x.^2-15*x+1;
poly6 = @(x)x.^3-5*x.^2+6*x-1;
poly7 = @(x)x.^3-6*x.^2+5*x-1;
poly8 = @(x)x.^4-7*x.^3+14*x.^2-8*x+1;
poly9 = @(x)x.^4-8*x.^3+14*x.^2-7*x+1;
polyproduct = @(x)poly1(x).*poly2(x).*poly3(x).*poly4(x).*poly5(x).* ...
poly6(x).*poly7(x).*poly8(x).*poly9(x);
eqn = polyproduct == 0
S = solve(eqn)
I understand that I can directly set up the equation without calling functions, but later I will do something else with those functions --- including plug in specific x, so I want to restore them first. (And I really don't want to restore each one in a seperate file..)
However, Matlab gives the following error:
>> Replication
Operator '==' is not supported for operands of type 'function_handle'.
Error in Replication (line 13)
eqn = polyproduct == 0
If I use the following code instead:
sym x
eqn = polyproduct(x) == 0
S = solve(eqn,x)
Then, it will give the following error:
Unrecognized function or variable 'x'.
Error in Replication (line 14)
eqn = polyproduct(x) == 0
I am not sure what to do instead. I am sorry if this question is dumb... Thank you so much!