Group Abstract Group Abstract

Message Boards Message Boards

Graph a dual variable function?

Posted 10 years ago

I am trying to ListPlot the results of solving a quadratic in one variable as a function of a second variable. The equation is shown below:

((1-b)^2)*(R-r)^2=2*r*(1+b)^2,

where I am solving for r as a function of b. I can form the table, but it contains a mix of both branches of the solution to the quadratic equation in r. It is easy to solve but ListPlot will not plot the results. I am willing to live with the solution points mixed together, since the two branches will form two distinct curves and I can ignore the one that I cannot use.

Or, alternatively, how can I produce a graphic representation in some other way?

POSTED BY: Luther Nayhm
6 Replies

I would use

Manipulate[ContourPlot[(1 - b)^2*(R - r)^2 == 2*(1 + b)^2*r, {b, -1, 1}, {r, -5,5}], {R, 0.5, 2.0, 0.001}]

Then you can use the options in ContourPlot (ImageSize, PlotPoints, etc.) to make the display fit your needs. ContourPlot could be a bit slow (think of what it is doing), so each time you play with the value of R in the Manipulate scale you may need to wait a bit.

Best,

OL.

POSTED BY: Otto Linsuain
Posted 10 years ago

I see. Very nice. I have also played with the syntax and gotten a feel for the function I am plotting.

I appreciate the help. Thanks. I have a lot to learn about the minutia in using Mathematica.

POSTED BY: Luther Nayhm

[deleted double post]

POSTED BY: Jason Biggs
POSTED BY: Jason Biggs
Posted 10 years ago
POSTED BY: Luther Nayhm

Here's how I would go about it,

solns = 
 Solve[((1 - b)^2) (R - r)^2 == 2 r*(1 + b)^2, r][[All, 1, 2]]
(* {(
 1 + 2 b + b^2 + R - 2 b R + b^2 R - Sqrt[
  1 + 4 b + 6 b^2 + 4 b^3 + b^4 + 2 R - 4 b^2 R + 2 b^4 R])/(
 1 - 2 b + b^2), (
 1 + 2 b + b^2 + R - 2 b R + b^2 R + Sqrt[
  1 + 4 b + 6 b^2 + 4 b^3 + b^4 + 2 R - 4 b^2 R + 2 b^4 R])/(
 1 - 2 b + b^2)} *)

You have to be careful as there is a singularity in the second solution when b=1:

Limit[#, b -> 1] & /@ solns
(* {0, ?} *)

So you can plot the first solution over any range,

Plot3D[solns[[1]], {b, 0, 10}, {R, 0, 10}, PlotRange -> All, 
 ColorFunction -> "ThermometerColors"]

enter image description here

But the second solution you are limited in the range

Plot3D[solns[[2]], {b, 0, 5}, {R, 0, 10}, PlotPoints -> 100, 
 PlotRange -> {0, 50}, ColorFunction -> "ThermometerColors"]

enter image description here

POSTED BY: Jason Biggs
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard