MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How can I plot the region satisfying an inequality?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18916] Re: How can I plot the region satisfying an inequality?
  • From: Adam Strzebonski <adams at wolfram.com>
  • Date: Mon, 26 Jul 1999 14:27:52 -0400
  • Organization: Wolfram Research, Inc.
  • References: <7mp3dn$l99@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Function InequalityPlot[ineqs, {x, x0, x1}, {y, y0, y1}]
defined below will plot the 2D part of the region satisfying
polynomial inequalities ineqs. It uses
Experimental`GenericCylindricalAlgebraicDecomposition
so it works only in Mathematica 4.

ineqs needs to be a system of polynomial inequalities 
in x and y with rational number coefficients. The code
could be extended to handle algebraic inequalities with
algebraic number coefficients, and to plot lower 
dimensional parts of the solution set, by using
Experimental`CylindricalAlgebraicDecomposition instead of
Experimental`GenericCylindricalAlgebraicDecomposition,
and extending cylinderplot code to handle lower dimensional
cylinders.

---------------

<< Experimental`;
<< Developer`;
Needs["Utilities`FilterOptions`"];
Needs["Graphics`FilledPlot`" ];

cylinderplot[cyl_, x_, opts___?OptionQ] := 
  Module[{x0 = cyl[[1, 1]], x1 = cyl[[1, 5]], ys}, 
    ys = If[Head[cyl[[2]]] === Or, List @@ (cyl[[2]]), {cyl[[2]]}];
    FilledPlot[{#[[1]], #[[5]]}, {x, x0, x1}, 
       DisplayFunction -> Identity, opts]& /@ ys]

InequalityPlot[ineq_, {x_, x0_, x1_}, {y_, y0_, y1_}, opts___?OptionQ]
:= 
  Module[{cyls, plots, ii}, 
    ii = If[Head[ineq] === List, And@@ineq, ineq];
    cyls = GenericCylindricalAlgebraicDecomposition[
          ii && x0 < x < x1 && y0 < y < y1, {x, y}];
    If[Head[cyls] === GenericCylindricalAlgebraicDecomposition,
       Return[$Failed],
       cyls=cyls[[1]]];
    plots = 
      If[cyls === False, 
         Plot[y1 + 1, {x, x0, x1}, PlotRange -> {{x0, x1}, {y0, y1}}, 
            DisplayFunction -> Identity, 
            Evaluate[FilterOptions[Plot, opts]]], 
         If[Head[cyls] === Or, cyls = List @@ cyls, cyls = {cyls}];
         cylinderplot[#, x, FilterOptions[FilledPlot, opts]]& /@ cyls];
    Show[plots, FilterOptions[Graphics, opts], Axes -> True, 
       AxesLabel -> {x, y}, DisplayFunction -> $DisplayFunction, 
       AspectRatio -> Automatic, PlotRange -> {{x0, x1}, {y0, y1}}]]


Best Regards,

Adam Strzebonski
Wolfram Research


ELodger wrote:
> 
> Hi There,
> 
> Is there a way to plot the region satisfying a set of inequalities,
> such as:
> 
> x - y > 0 and
> x + y < 0
> 
> on [-10, 10]
> 
> ?
> 
> Thanks!
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


  • Prev by Date: Re: Re: Slow Version 4 Front End
  • Next by Date: Re: ReadList
  • Previous by thread: Re: How can I plot the region satisfying an inequality?
  • Next by thread: TableAlignments