Getting to the Root of Things….

roots math

This problem is probably better suited for the PTC Mathcad Community Page, but I’m going to post it here anyway, just because I think it’s a cool problem.

A math teacher wrote to us asking about the following problem.  In case you want to solve it yourself first, I’ll just show the problem before I talk about his specific question.

Find ‘x’ for:  find x

To prevent you from seeing the spoiler, scroll down to see the specific question.


So if you solved this problem, you’ll know that it has two solutions.  ‘x’ can be 27 or -8.  You can check that it’s the answer by plugging in the values into the equation above.  The aforementioned math teacher wanted to double-check his results with Mathcad, so he plugged it in and got:

double check results

Hmmmm, well, that’s suspicious.  Why is there only one answer?  I tried using a solve block, hoping to force the second answer by using an initial guess close to the -8 root that I want, and I still only get 27.

use a solve block

What’s going on?  Just to make sure I’m not losing my mind, I made a quick substitution:substitution

And this gives me: 

As expected, I get two answers here.  And because , then  , and I get:

This is what I expect.  So what’s wrong with the original method?  Let’s see what happens when we define a function, F:

define a function

Plugging what we know the roots to be, we get:

plug in the roots

So F(27)=0, as we expect.  But F(-8) is…, what?  Complex?  Let’s probe a bit deeper.

10_neg8root and 11_neg8root

So even though you expect the two expressions above to be the same, they’re not!  Using the radical sign gives you -2, and using the fractional exponent gives you a complex number.  If we take those two results and include the complex conjugate of the complex result, we see that cubing each of those will give you -8.

include the complex conjugate of the complex result

That is to say, -8 has three cube roots, which we would expect.  [NB: I now use ‘root’ in a different sense.  I am no longer referring to the roots of the function, F, but to a number, in this case, -8.] The issue is that depending on the notation we use to find the root of a number, Mathcad might return different results.  Using the fractional exponent notation gives us the principal root.  Using the radical sign gives us a real root, if one exists.  For a refresher on roots, see Wikipedia.  Of course, when the principal root is real, then the results are the same.  That is why the two notations will be equivalent for all positive numbers.  For negative numbers, it depends!
principal root

As you see here, the left-hand side example gives the same root as there are no real roots.  The right-hand side example (as seen in our problem) returns two different results.

So going back to the original problem, is there a way to get the two roots (of the function, F) without having to break the problem into two with substitution?  Well, if you know you are looking for real roots, then use the radical symbol.

 use the radical symbol

And the solve block will also now return the negative root, depending on the initial guess.

the solve block will return the negative root

Now you’re probably thinking to yourself, “Wow, that was a lot of work to find the answer to what seemed like a relatively easy problem!”  A better way to think about it is that Mathcad is a great tool, but it does not necessarily and automatically make you the know-it-all engineer or scientist.  You still need to have an understanding of the problem and therefore, a rough idea of the answer you are expecting.

As the math teacher pointed out, he was using Mathcad to verify his work, and in doing so, stumbled across an interesting implementation issue (using fractional exponents to take roots).  For him, understanding the problem (and the results) allowed him to understand better how Mathcad operates.

Worksheet used to generate the images.

About Roger Yeh @ PTC

Roger is a mechanical engineer by training. He studied non-Newtonian fluid mechanics (specifically the extensional flow of polymer solutions) in graduate school. Since graduating, he has dabbled in systems engineering (integrating hardware and software components on a radar program) and test and measurement applications (across all industries). He joined PTC in March 2011 as an application engineer in the Mathcad Business Unit.
This entry was posted in Mathcad, Mathcad A to Z, Puzzles, Tips & Tricks and tagged , , , , , , , , . Bookmark the permalink.

8 Responses to Getting to the Root of Things….

  1. Virgil PANUS says:

    “For him, understanding the problem (and the results) allowed him to understand better how Mathcad operates”.

    So, we need to be at least math teachers, in order to discover how Mathcad operates?

    You just told us that Mathcad does not calculates correctly = the results are different for the same equation which is written differently?

    In this case you should make Mathcad Prime opensource and freeware.
    No money = no responsibility.

  2. I would word it differently. I don’t expect Mathcad to make you a math expert. This problem is an example where knowing the math helps you realize that Mathcad may not always behave the way you think it might. Maybe I should have said:

    “…understanding the math allowed him to better understand some of the intricacies of Mathcad.”

    Even though the two representations return different results, that’s not Mathcad being wrong. You could say Mathcad is being inconsistent. (You could argue inconsistent is wrong.) Ideally, you might expect Mathcad to return all the roots. But from a usability standpoint, that may not be the best approach either.

    • Virgil PANUS says:

      “Ideally, you might expect Mathcad to return all the roots.
      But from a usability standpoint, that may not be the best approach either.”

      OK. In this case I kindly ask you to add to Mathcad documentation the functions for which Mathcad does not give the complete result.
      Thank you.

  3. Tony Cupolo says:

    Hi Roger,

    Don’t see your email address so I thought I would contact you on this blog. I found a previous blog article of yours, “Mathcad A-Z: J is for Jazz”, that introduces MathCad features for audio processing.

    Is there some documentation available that more fully covers MathCad’s audio capabilities. I used MathCad for a long time but stopped using it a few years back If it has what I need, I’d love to use it again for my current audio research project.

  4. Tony Cupolo says:

    Hi Roger,

    I clicked on that link but I was told that I don’t have permission. Is there some other way I can get access to the document?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s