user1454550
user1454550

Reputation: 3

Graphing the result of NSolve

I'm trying to plot a parametric equation that was partially obtained using NSolve. Here's my attempted code:

VolumeDiff[v_] = 1.7 - v
SolveR[ v_] = 
 Re[NSolve[16 v^2 - 16 v*(r^3) + 3 (r^2) + 1 == 0, r, Reals]]
EnergyPos[r_] = r/2 (r + Sqrt[r^2 - 1])
EnergyNet[r_] = EnergyPos[SolveR[r]] + EnergyPos[SolveR[VolumeDiff[r]]]
ParametricPlot[{Re[EnergyNet[x]], 1.7 - 2. x}, {x, .1, 1.6}]

Basically, I have a cubic with two variables, I solve for one given the other and try to plot two parametric equations based on that original given variable. This is supposed to be a graph of energy vs. volume difference of two bubbles attached together. However, my axis are blank. I used NSolve to isolate the real root of the cubic equation and I guess Mathematica has a problem graphing with NSolve involved. I looked all over the internet but I couldn't find any answers to this. thanks for any help! David

Upvotes: 0

Views: 869

Answers (1)

Dr. belisarius
Dr. belisarius

Reputation: 61016

Several errors corrected. You should read about how SetDelayed ( := ) and Solve[] work.

VolumeDiff[v_] := 1.7 - v
SolveR[v_] := NSolve[16 v^2 - 16 v*(r^3) + 3 (r^2) + 1 == 0, r, Reals][[1]]
EnergyPos[r_] := r/2 (r + Sqrt[r^2 - 1])
EnergyNet[r_] := EnergyPos[r /. SolveR[r]]+EnergyPos[r /. SolveR[VolumeDiff[r]]]
ParametricPlot[{EnergyNet[x], 1.7 - 2. x}, {x, .1, 2}]

enter image description here

Upvotes: 3

Related Questions