Mathematica Real Part of Solve output

In summary, the Solve function in Mathematica can be difficult to use when solving equations of a higher order.
  • #1
trow4
2
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
  • #2
Try:

Limit[xroot1,y->100]
 
  • #3
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:
  • #4
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.
 
  • #5



I would first analyze the problem and the provided Mathematica output to understand the issue at hand. In this case, the problem involves solving an equation for x when y is a real number and positive. The desired solution is x= 1- 0.63 ((100-y)/y)^(1/3), which is a real number for all values of y.

The Mathematica output provides three roots, which are complex numbers. This is because the equation has three solutions, and the complex numbers represent the real and imaginary parts of each solution. The error occurs when trying to evaluate the first root at y=100, as it involves division by zero.

To drop the imaginary part of the first root, we can use the Re function in Mathematica, which extracts the real part of a complex number. So, we can modify the code to:

xroot1 = Re[x /. sol[[1]]]

This will give us the real part of the first root, which can then be evaluated at y=100 without any errors. Similarly, we can use the Re function for the other two roots as well.

Another approach would be to use the Reduce function in Mathematica, which can handle complex numbers and provide a simplified solution. So, we can modify the code to:

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

This will give us a simplified solution without any complex numbers. We can then use the x= 1- 0.63 ((100-y)/y)^(1/3) equation to find the corresponding values of x for different values of y.

In conclusion, as a scientist, it is important to analyze and understand the output of any software or tool used in research. In this case, we were able to identify the issue and find a solution by utilizing the functions available in Mathematica.
 

Related to Mathematica Real Part of Solve output

1. What is the "Real Part" of a Solve output in Mathematica?

The "Real Part" of a Solve output in Mathematica refers to the real solutions to the equation or system of equations being solved. These solutions are expressed in terms of real numbers, as opposed to complex numbers which also have an imaginary component.

2. How do I access the Real Part of a Solve output in Mathematica?

To access the Real Part of a Solve output in Mathematica, you can use the command "Re[sol]" where "sol" is the name of your solution output. This will return the real solutions in a list format.

3. Can I use the Real Part of a Solve output in further calculations?

Yes, you can use the Real Part of a Solve output in further calculations just like any other numerical data in Mathematica. You can manipulate, plot, or use these solutions in any way you need for your analysis.

4. What if my Solve output does not have any real solutions?

If your Solve output does not have any real solutions, the Real Part will return an empty list. This indicates that there are no real solutions to the equation or system of equations being solved.

5. Can the Real Part of a Solve output be used to verify the accuracy of the solutions?

Yes, the Real Part of a Solve output can be used to verify the accuracy of the solutions. If the Real Part returns a list of real numbers, this indicates that the solutions are accurate. However, if the Real Part returns an empty list, it could mean that there are no real solutions or the solutions may be inaccurate.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
75
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
594
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
291
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
742
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
Back
Top