Skip to main content
19-Tanzanite
October 4, 2024
Solved

Why root function does not find the second imaginary solution?

  • October 4, 2024
  • 4 replies
  • 4317 views

Hi,

Why is it not found also this solution by the root function?

Cornel_1-1728048982114.png

 

Cornel_0-1728048956282.png

Cornel_2-1728049105967.png

Cornel_3-1728049115953.png

Best answer by Werner_E

I was a bit surprised to see that root would even return non-real results with real guesses.

Here are my 2 Cents, using random non-real guesses.

Werner_E_0-1728101568290.png

 

 

4 replies

23-Emerald V
October 4, 2024

y runs from -50.  Indices have to start from ORIGIN.

 

2024 10 04 F.png

 

Stuart

Cornel19-TanzaniteAuthor
19-Tanzanite
October 4, 2024

Ok, but still one solution is missing:

The second imaginary solution:

Cornel_1-1728052117461.png

I don't know why this solution it is not catched/found it...

Cornel_0-1728052302577.png

23-Emerald V
October 4, 2024

Try polyroots.  root's algorithm (without a search range) doesn't cover all complex results).

 

StuartBruff_0-1728052723748.png

 

Stuart

 

Cornel19-TanzaniteAuthor
19-Tanzanite
October 4, 2024

I understand. Also, I can use solve command and received all 3 solutions.

But I want to understand why in the way as I shown above (with x as a range, and with root function), this way does not find the second imaginary solution as I should be the case.

23-Emerald V
October 4, 2024

I enjoy conversations where messages cross each other—so much more fun than a strictly linear thread. 😊 

 

You'd have to dig into the code to understand why Ridder's (or Brent's) algorithm returns one complex root and not the other.  It would help if one could specify a complex range.  Perhaps somebody could write a wrapper function around f(x) that allows root to stray further into the complex plane.  Alternatively, somebody could write a new root function.  I've got vague memories of rolling my own Levenberg–Marquardt solver to better understand what it did.

 

Stuart

23-Emerald V
October 4, 2024

As to why, ...

 

Mathcad Help:

 

The root of a function is the value at which the function equals zero.
 
polyroots(v)—Returns a vector containing the roots of the polynomial whose coefficients are in v.
 
By default, polyroots uses the LaGuerre method which is iterative and searches for solutions in the complex plane. If you want to use the Companion Matrix method instead, right-click on the polyroots function and select the method from the menu. The Companion Matrix method converts the equations into an eigenvalue problem. Learn more about choosing a solving algorithm for the polyroots function here.
 
root(f(var1, var2, ...), var1, [a, b])—Returns the value of var1 to make the function f equal to zero. If a and b are specified, root finds var1 on the interval [a, b]. Otherwise, var1 must be defined with a guess value before root is called. When a guess value is used, root uses the secant or Mueller’s method; in the case where root bracketing is used, root uses Ridder’s or Brent’s method.
 
Stuart
 
I have a strange feeling of deja vu, as if this subject has been discussed in the not too distant past.
Werner_E25-Diamond IAnswer
25-Diamond I
October 4, 2024

I was a bit surprised to see that root would even return non-real results with real guesses.

Here are my 2 Cents, using random non-real guesses.

Werner_E_0-1728101568290.png

 

 

23-Emerald V
October 5, 2024

Now that's interesting.  When I tried that, Mathcad squawked like a parrot on a sugar high.  "No, take that nasty complexity out right now! Honestly, some people. Pieces of Eight. Who's a pretty CAS. The horror, The horror ...".  

 

The local definition I used above arose from such an attempt. However, with freshly typed expressions this time, the parrot was rather quiet.

 

2024 10 05 A.png

 

Reducing the range over which root searched gave better (for values of "better") results.

 

2024 10 05 B.png

 

2024 10 05 C.png

 

I blame any typos, logical errors and programming mistakes on it being Oh Dark O'Clock and sleep deprivation taking its toll.

 

Stuart