RE: Plotting ellipses and other functions
- To: mathgroup at smc.vnet.net
- Subject: [mg37046] RE: [mg37026] Plotting ellipses and other functions
- From: "David Park" <djmp at earthlink.net>
- Date: Mon, 7 Oct 2002 05:24:57 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
David,
To plot equations like that, simply use ImplicitPlot.
Needs["Graphics`ImplicitPlot`"]
ImplicitPlot[(x - 2)^2 + 2(y - 3)^2 == 6, {x, -1, 5}, {y, 1, 5}];
ImplicitPlot[x^3*y + y^3 == 9, {x, -10, 10},
{y, -10, 10}];
You may have to fish a little to obtain the appropriate x and y ranges.
Start by making them larger and then narrow down to the region that you
want.
I have put a new package at my web site for solving conic section problems
in the plane. You can solve for complete information on any conic section
and obtain a parametric representation for plotting it. The package also
comes with complete Help documentation and examples.
Using your first example (the second is not a conic).
Needs["ConicSections`ConicSections`"]
eqn = (x - 2)^2 + 2(y - 3)^2 == 6;
The routine ParseConic will take any quadratic equation and return the scale
a, eccentricity e, a parametrization, and rotation matrix P, translation T
and reflection matrix R that transforms the conic from standard position to
its actual position. (In standard position the conic has its foci and
verticies on the x-axis with the center at zero.)
{{a, e}, curve[t_], {P, T, R}} = ParseConic[eqn]
{{Sqrt[6], 1/Sqrt[2]}, {2 + Sqrt[6]*Cos[t],
3 + Sqrt[3]*Sin[t]}, {{{1, 0}, {0, 1}}, {2, 3},
{{1, 0}, {0, 1}}}}
We could then plot the curve using ParametricPlot, which is more efficient
and controllable.
ParametricPlot[Evaluate[curve[t]], {t, -Pi, Pi},
AspectRatio -> Automatic,
Frame -> True,
Axes -> None,
PlotLabel -> eqn];
Knowing a and e we can use the StandardConic routine to obtain all the
information about the conic in standard position as a set of rules.
standarddata = StandardConic[{a, e}]
{conictype -> "Ellipse",
conicequation -> x^2/6 + y^2/3 == 1,
coniccurve -> {Sqrt[6]*Cos[t], Sqrt[3]*Sin[t]},
coniccurvedomain -> {-Pi, Pi},
coniccenter -> {0, 0},
conicfocus -> {{Sqrt[3], 0}, {-Sqrt[3], 0}},
conicdirectrix -> {x == -2*Sqrt[3], x == 2*Sqrt[3]},
conicvertex -> {{Sqrt[6], 0}, {-Sqrt[6], 0}}}
routine to obtain the same information for the conic in its actual position.
standarddata // TransformEllipseRules[P, T, R]
{conictype -> "Ellipse",
conicequation -> (1/6)*((-2 + x)^2 + 2*(-3 + y)^2) == 1,
coniccurve -> {2 + Sqrt[6]*Cos[t], 3 + Sqrt[3]*Sin[t]},
coniccurvedomain -> {-Pi, Pi},
coniccenter -> {2, 3},
conicfocus -> {{2 + Sqrt[3], 3}, {2 - Sqrt[3], 3}},
conicdirectrix -> {2*Sqrt[3] + x == 2, x == 2*(1 + Sqrt[3])},
conicvertex -> {{2 + Sqrt[6], 3}, {2 - Sqrt[6], 3}}}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: David [mailto:davidol at hushmail.com]
To: mathgroup at smc.vnet.net
How can I plot functions like:
(x-2)^2 + 2(y-3)^2 = 6
and
x^3y + y^3 = 9
using Mathematica?