# Getting to the Root of Things….

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:

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:

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.

What’s going on?  Just to make sure I’m not losing my mind, I made a quick 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:

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

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

and

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.

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!

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.

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

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.

This entry was posted in Mathcad, Mathcad A to Z, Puzzles, Tips & Tricks and tagged , , , , , , , , . Bookmark the permalink.

## 8 thoughts on “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.

1. 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.

1. That’s great feedback. We do try to document as best we can, but sometimes we might (unintentionally) leave out a detail here or there. In this particular case, the documentation does reflect the difference between the two notations:

3. Tony Cupolo says:

Hi Roger,

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.

1. Hi, Tony. Take a look at our signal processing functions: http://www.ptc.com/cs/help/mathcad_hc/prime2_hc/index.jspx?id=resourceid-131-EB1CAF0F&action=show
Let us know if there are specific things you are looking for.

1. 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?

PS: Please delete the post below in error, thanks.

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?