# Solving and plotting a non-linear and polynomial equations of degree 3 and higher

I'm doing the following and cannot plot the function, could anyone spot a problem please

0<=a<=1 ; 0 <= ρ <= 1; 0 <= b <= 3

eq = 0.1 (20 - 70 a) + (1 - ρ)^(-1-b) . ρ . (2 - 2 ρ + b ρ)==0;

soln = Solve[eq && 0 <= ρ <= 1 && 0 <= b <= 1 && 0 <= a <= 1, ρ, Reals];

Plot3D[Solve[eq && 0 <= ρ <= 1 && 0 <= b <= 1 && 0 <= a <= 1, ρ, Reals],
{b, 0, 1}, {a, 0, 1}, PlotRange -> {0.2, 1}, AxesLabel -> (Style[#, 16] &
/@ {"b", "a", "ρ"}), ColorFunction -> Automatic]


Thanks

• There are numerous syntax errors. After that, b seems to be Real, is not it? If yes, is not the equation of degree 3, but the transcendental one. As a rule it then cannot be solved by Solve . – Alexei Boulbitch May 13 '15 at 18:52
• @Alexei Boulbitch Yes b is real. So how can i solve/plot it then? – Baboda May 13 '15 at 18:54
• You might succeed with a numerical approach, say, with FindRoot. But you need first to fix all syntatic errors. They are much too many to point out each. – Alexei Boulbitch May 13 '15 at 18:57
• @Alexei Boulbitch thanks for your reply. My main aim is to plot a graph of with respect to different values of b and a. do you think FindRoot would help? – Baboda May 13 '15 at 19:23

As pointed out by Alexei Boukbitch, Solve cannot solve eq for ρ. Although FindRoot can obtain numerical solutions, a more straightforward to obtain the desired plot is to use Solve to obtain a instead, which then can be plotted. With extraneous code eliminated,

eq = (2 - 7 a) + (1 - ρ)^(-1 - b) ρ (2 - 2 ρ + b ρ) == 0;
soln = First@ Solve[eq, a];
Plot3D[a /. soln, {b, 0, 1}, {ρ, 0, 1}, PlotRange -> {0, 1}, BoxRatios -> {1, 1, 1},
AxesLabel -> (Style[#, 16] & /@ {"b", "ρ", "a"})]


Incidentally, an alternative way to plot the desired surface that has ρ more obviously the third dimension is

ParametricPlot3D[{a /. soln, b, ρ}, {b, 0, 1}, {ρ, 0, 1}, PlotRange -> {0, 1},
AxesLabel -> (Style[#, 16] &   /@ {"a", "b", "ρ"})]


In answer to a question posed by Saman in a comment below, ρ = 0 can be plotted for a < 2/7 as follows.

Show[ParametricPlot3D[{a /. soln, b, ρ}, {b, 0, 3}, {ρ, 0, 1},
PlotRange -> {{0, 1}, {0, 3}, {0, 1}},
AxesLabel -> (Style[#, 16] & /@ {"a", "b", "ρ"})],
ParametricPlot3D[{a, b, 0}, {a, 0, 2/7}, {b, 0, 3}]]


Note that the range of b has been increased to {0, 3}, also at the request of Salam.

• thanks for your answer. however when I change the interval of "b" to 0<= b<=3 the plot wont change (does not calculate for b>=1 ). Also is there any way to show in the plot that for low value of "a" (e.g. a< 0.3) ρ become flat in the graph. just to show for a< 0.3 ρ is always 0. – Baboda May 14 '15 at 9:12
• The range of b actually does increase to 0<= b<=3 for Plot3D. To achieve the same for ParametricPlot3D, use PlotRange -> {{0, 1}, {0, 3}, {0, 1}}. I do not believe it is true that for a< 0.3, ρ is always 0. Actually, for a<2/7, ρ<0. – bbgodfrey May 14 '15 at 13:29
• Thanks a lot, yes you are right! but what I meant was because ρ is bounded between 0 and 1 i want to show in the graph that for all ρ<0 we should have ρ=0 (instead of having it blank in the graph). Also could you guide me how to plot a function with the values ρ that I get from solving the eq. (e.g. I have another function of ρ and I want to see how that function behave with respect to the value of ρ that I already got). Sorry about these questions i'm new to the mathematica and I'm learning it. and thanks again for your help. – Baboda May 14 '15 at 16:46
• See the Addendum to my Answer for the first part of your last Comment. You can plot a second expression for ρ superimposed on any of the plots in my Answer in much the same way as I added the ρ = 0 plot. For further discussion on this last item, you may wish to search Mathematica.StackExchange or ask another Question – bbgodfrey May 14 '15 at 17:20