1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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 . $\endgroup$ – Alexei Boulbitch May 13 '15 at 18:52
  • $\begingroup$ @Alexei Boulbitch Yes b is real. So how can i solve/plot it then? $\endgroup$ – Baboda May 13 '15 at 18:54
  • $\begingroup$ 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. $\endgroup$ – Alexei Boulbitch May 13 '15 at 18:57
  • $\begingroup$ @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? $\endgroup$ – Baboda May 13 '15 at 19:23
2
$\begingroup$

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"})]

enter image description here

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", "ρ"})]

enter image description here

Addendum

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}]]

enter image description here

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Baboda May 14 '15 at 9:12
  • $\begingroup$ 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. $\endgroup$ – bbgodfrey May 14 '15 at 13:29
  • $\begingroup$ 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. $\endgroup$ – Baboda May 14 '15 at 16:46
  • $\begingroup$ 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 $\endgroup$ – bbgodfrey May 14 '15 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.