Mathematica Real Part of Solve output

  • Context: Mathematica 
  • Thread starter Thread starter trow4
  • Start date Start date
  • Tags Tags
    Mathematica Output
Click For Summary

Discussion Overview

The discussion revolves around solving polynomial equations using Mathematica, specifically focusing on extracting real roots from the output of the Solve function. Participants explore issues related to complex roots and numerical accuracy in different versions of Mathematica.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant attempts to solve the equation 0.125 + 0.5 (1-x)^3 - (12.5/y) == 0 for x, noting that Mathematica's Solve yields three roots, including complex components.
  • The same participant encounters an "Infy" error when evaluating one of the roots at y=100 due to division by zero and seeks a method to eliminate the imaginary part of the function.
  • Another participant suggests using the Limit function to evaluate the root as y approaches 100, which the first participant confirms resolves the issue.
  • The first participant raises a new problem when trying to solve a higher-order polynomial 0.1 + 0.5 (1-x)^4 - (1/y) == 0, noting discrepancies in the real parts of the roots compared to expected values.
  • A later reply proposes that numerical round-off error may be affecting results, suggesting that using exact fractions instead of decimal numbers could mitigate this issue.
  • The participant using Mathematica 7.0.1 observes that the problem may be specific to that version, as results appear correct in Mathematica 8.

Areas of Agreement / Disagreement

Participants express differing views on the cause of discrepancies in root evaluation, with some attributing it to numerical round-off error while others suggest potential issues with the Solve algorithm in earlier versions of Mathematica. No consensus is reached on the underlying cause of the observed behavior.

Contextual Notes

Limitations include potential numerical round-off errors in Mathematica, dependence on the version of the software, and the handling of complex roots in polynomial equations. The discussion does not resolve these issues.

trow4
Messages
2
Reaction score
0
I am trying to solve 0.125 + 0.5 (1-x)^3 - (12.5/y)==0 for x, when y is real and y>0. I thus want to find x= 1- 0.63 ((100-y)/y)^(1/3), so that if y=100, x=1. Mathematica's Solve yields 3 roots:

sol=Solve[0.125 + 0.5 (1 - x)^3 - (12.5/y) == 0, x]

Root 1:
1.+((0.+0. I) y^(1/3))/(-100.+1. y)^(1/3)-((0.31498+0.545562 I) (-100.+1. y)^(1/3))/y^(1/3),

Root 2:
1.+((0.+0. I) y^(1/3))/(-100.+1. y)^(1/3)-((0.31498-0.545562 I) (-100.+1. y)^(1/3))/y^(1/3),

Root 3:
1.+(0. y^(1/3))/(-100.+1. y)^(1/3)+(0.629961 (-100.+1. y)^(1/3))/y^(1/3)



If I now evaluate root 1 at y=100, I get an Infy error because of division by zero. How can I drop the imaginary part of this function? I have tried (without succes) a bunch of things such as:

xroot1=x/.sol[[1]]

*ComplexExpand[xroot1]

*Assuming[p > 0, {Simplify[xroot1]}]
 
Physics news on Phys.org
Try:

Limit[xroot1,y->100]
 
Marvelous, that indeed does the trick. However, if the polynomial is of a higher order (see below) I again run into trouble.

For instance, if I want to find the real root of 0.1 + 0.5 (1-x)^4 - (1/y)=0, (which you can easily solve for x=1- [ 2 (1-0.1 y ) / y ]^(1/4) ), I again use

sol = Solve[0.1 + 0.5 (1 - x)^4 - (1/y) == 0, x];

If I now plot the real part of these roots, none of them look like the one found above.

e.g. Plot[Re[(x /. sol[[1]])], {y, 0, 10}]

Is the solve algorithm not suited for solving equations of this order or am I doing something very very wrong?

EDIT1: It seems to be a Mathematica 7 problem. In Mathematica 8 the plots are just fine. Is this a known bug?
 
Last edited:
Interesting. I think what you are looking at is numerical round-off error. When you use a number like 0.1 in Mathematica, it only keeps a certain number of digits, I think 6. However, if you use the number 1/10, then it treats it as an exact mathematical quantity and there is no round-off error. If I use:

sol = Solve[1/10 + 1/2 (1 - x)^4 - (1/y) == 0, x]
Plot[Re[(x /. sol[[1]])], {y, 0, 10}]

Then everything looks fine. i am using Mathematica 7.0.1.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K