# Plotting of NSolve solutions

I am sorry for such an easy question, but I am still not very good at Mathematica. I would like to plot the solution of

NSolve[(-p^2 v1^2 + (E1 - Ce) (E1 + gam1 - Ce)) (E1^2 -
p^2 v1^2 + Ce (gam1 + Ce) -
E1 (gam1 + 2 Ce)) ==
0, E, {p, -10^-7, 10^-7, 0.0000001}]


on one figure. I would be grateful for the help.

• NSolve is a numerical procedure and needs numerical input, i.e. you need to give values to the parameteres p, v1 etc. And I guess you meant the lonely E to be E1 - E is a built-in symbol being the basis of the natural logarithm $e\approx 2.72$. Also, how do you want to plot a solutions of an algebraic equation? It's not a function but a list of values E1 satisfying the eq. Like $x=\pm 1$ are solutions to x^2-1==0. Nov 11, 2016 at 10:28
• Your question is badly formulated. You have an equation that looks like an algebraic. However, you use a syntax that partially applies to algebraic, and partially - to differential equations. Second, you have a number of parameters. To plot the solution you have to fix most of them. Third, E is reserved in Mma for the exponential. I suggest that you might edit your question making clear all these points. Nov 11, 2016 at 10:31
• OK, I am sorry I didn't provide full data the question is how to plot {{{E -> -0.413317}, {E-> -0.0233172}, {E -> 0.0233172}, {E -> 0.413317}}, {{E-> -0.39}, {E -> 0.}, {E-> 0.}, {E -> 0.39}}, {{E-> -0.413317}, {E -> \ -0.0233172}, {E -> 0.0233172}, {E -> 0.413317}}} as a function of {p, -10^-7, 10^-7, 0.0000001} Nov 11, 2016 at 10:44
• How did you get that output? Please provide a full code; and see my previous comment. Nov 11, 2016 at 10:50
• Yes, exactly that is the output taking into the consideration all of data i do have. I know that this is a list of the value, the question is how to plot an list of the solutions as a function of some variable? I would be grateful for n answer Nov 11, 2016 at 11:12

To Solve the algebraic equation for E1:

sol = Solve[(-p^2 v1^2 + (E1 - Ce) (E1 + gam1 - Ce)) (E1^2 -
p^2 v1^2 + Ce (gam1 + Ce) - E1 (gam1 + 2 Ce)) == 0, E1] Substitute given values of p:

sol2 = Table[sol /. p -> i, {i, -10^-7, 10^-7, 10^-7}] Give numerical values to the parameters:

y = E1 /. sol2 /. {Ce -> 1, gam1 -> 1, v1 -> 1} // N // Chop


{{0, 1., 1., 2.}, {0, 1., 1., 2.}, {0, 1., 1., 2.}}

x = N@Table[i, {i, -10^-7, 10^-7, 10^-7}]


{-1.*10^-7, 0., 1.*10^-7}

Plot the pairs of points:

ListPlot[#, Frame -> True, PlotStyle -> {Red, PointSize[Large]}] &@
Flatten[#, 1] &@Diagonal@Outer[List, x, y, 1, 2]
(* or *)
ListPlot[#, Frame -> True, PlotStyle -> {Red, PointSize[Large]}] &@
Flatten[#, 2] &@MapThread[Outer[List, {#1}, #2] &, {x, y}] • Dear corey979 thank you for answer it is very helpful Nov 11, 2016 at 19:29
• @ArthurAltman Glad it helped. If you find it useful, you might want to consider accepting/upvoting it. Nov 11, 2016 at 19:42