Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Dear all,
I computed the roots of the quadratic equation by using two different methods,
1. square root function
2. Polyroots function
I found the values of the 2 functions are same.
But, when I try to plot the values of Imaginary part , I am getting different
plots for square root and polyroot function.
1. What is the reason behind that ?
2. How to get the similar result, which I got for square root function by using polyroot function?
I explained clearly in the attached code,
Thanks.
Solved! Go to Solution.
I think the mixing up of signs is due to the choice of solver for polyroots. The default is an iterative LaGuerre method. However, there is a companion matrix solver (right-click on polyroots) for polyroots as well, and this seems to pick only one root.
Stuart
The square root approach calculates all the positive roots separately from the negative roots. The polyroots approach mixes them up, so the plot switches from positive to negative a lot, filling in gaps. You could overcome this by choosing to plot points instead of lines, or adopt the more involved approach shown in the attached.
Alan
I think the mixing up of signs is due to the choice of solver for polyroots. The default is an iterative LaGuerre method. However, there is a companion matrix solver (right-click on polyroots) for polyroots as well, and this seems to pick only one root.
Stuart
Dear Stuart,
Thank you for your comments.
Your method seems to be much easier.
Dear Alen,
Thank you for your comments.
I understand clearly from your plot.
Could you please suggest me some any other easier method
to compute polyroots which does not involves any for loop.
As was already noted the reason is the "arbitrary" way the solutions are arranged by polyroot:
Its the effect I already mentioned in your former thread with the third root.
I was not aware of the possibility to change the algorithm used as was pointed out by Stuart and that changing it would cure the problem in that elegant way.
My suggestion would have been a user written Sort routine like the following (its a quick hack and won't work for multiple real solutions):
Werner
Dear Werner,
Thank you for your comments.