       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, 1/Sqrt}, {2 + Sqrt*Cos[t],
3 + Sqrt*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*Cos[t], Sqrt*Sin[t]},
coniccurvedomain -> {-Pi, Pi},
coniccenter -> {0, 0},
conicfocus -> {{Sqrt, 0}, {-Sqrt, 0}},
conicdirectrix -> {x == -2*Sqrt, x == 2*Sqrt},
conicvertex -> {{Sqrt, 0}, {-Sqrt, 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*Cos[t], 3 + Sqrt*Sin[t]},
coniccurvedomain -> {-Pi, Pi},
coniccenter -> {2, 3},
conicfocus -> {{2 + Sqrt, 3}, {2 - Sqrt, 3}},
conicdirectrix -> {2*Sqrt + x == 2, x == 2*(1 + Sqrt)},
conicvertex -> {{2 + Sqrt, 3}, {2 - Sqrt, 3}}}

David Park

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?

```

• Prev by Date: Re: trouble with pattern matching & manipulating
• Next by Date: Re: trouble with pattern matching & manipulating
• Previous by thread: Re: Plotting ellipses and other functions
• Next by thread: Plotting ellipses and other functions