# write a polynomial answer in one operand

3 views (last 30 days)

Show older comments

### Answers (2)

Steven Lord
on 8 Nov 2021

What do you mean by "solve" in this context? Do you want to find values of s that when substituted into those polynomials gives a result of 0? Or do you want to compute the derivative of the product and quotient of those polynomials?

For the former see fzero as dpb suggested. Or you could use roots on the numerator and denominator and exclude those values that would result in division by 0 or especially 0/0.

For the latter use sym to create the symbolic variable s then use diff on the symbolic expression that uses s.

##### 1 Comment

John D'Errico
on 8 Nov 2021

Edited: John D'Errico
on 8 Nov 2021

John D'Errico
on 8 Nov 2021

I assume that is a prime outside of the parens, which makes no sense unless you intend it as the complex conjugate. But even there, it is meaningless, since if you are looking for a root, then if x'==0, then it is always true that x==0 too.

If you need to find all roots of such a RATIONAL polynomial, then all that matters is you need to find the roots of the numerator, as long as that is not also a root of the denominator. Of course, at such a point, there are still issues. For example, if S is a root of the denominator, then it is still a root of the fraction if it is a DOUBLE root of the numerator. But any root finding method will have serious issues for such singular problems. That is, 0 is not a root of the rational polynomial (s/s). But it IS a root of the polynomial (s^2/s). (And, while you may claim this is obvious to diagnose, suppose the multiple roots were something more complicated that is not so trivial to identify? Consider this rational polynomial:

syms x

P = (x^6 - x^5 + 2*x^4 - x^3 + 2*x^2 - x + 1)/(x^4 - 2*x^3 + 3*x^2 - 2*x + 1)

Is it obvious what are the roots? Note that even vpasolve fails to recognize that P here can be simply factored, and then reduced to eliminate 4 of the replicated roots. In fact, P only has 2 true roots.

vpasolve(P)

factor(P)

In general, a simple solution will not exist in one trivial line to solve all such general rational polynomial problems, and to do so perfectly well with no problems, with no failures.

Of course it matters if you want to solve this in the symbolic form, or if you must work in double precision. vpasolve is pretty good in this respect.

(By the way, a picture of an equation makes it more difficult to help you, since then I need to type in your problem from scratch.)

syms s

P2 = (1.5*s^4 + 3*s^3 + 2*s^2 + s)*(3*s^2-1)/((2*s^2 + 3*s + 5)*(s+1))

See that vpasolve does find roots.

vpasolve(P2)

Could i have done this using double precision computations? Well yes. But it would take more effort. I might use a tool like roots on the numerator, but then I would need to check to see if any of those roots found also kill off the denominator. And I would need to worry about replicated roots.

##### 0 Comments

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!