2

I would like to plot the area in the plane where two inequalities hold, both involving two variables. I would like to do it the way Wolfram Alpha does it, but within a LaTeX document. I have looked into the documentation of pgfplots, but I cannot figure out if and how this is possible. Maybe I need a different package, but I have had little success with google.

Peter Grill
  • 223,288
  • Possible Duplicate: http://tex.stackexchange.com/questions/37766/plotting-the-solution-of-inequalities-with-wolframalpha-or-maple/37769#37769 – Peter Grill Dec 24 '11 at 15:22
  • It is worth visiting http://tex.stackexchange.com/a/8930/9467 because the solution used fewer keystrokes in PSTricks. – kiss my armpit Dec 24 '11 at 15:46
  • Since there has been some suggestions pointing to possible duplicates, let us know whether they solve your problem and we'll probably close this question (to keep things tidy). If none of the linked questions solve your problem, edit your question and state why this is the case, and perhaps provide some more information regarding your intended output. – Werner Dec 24 '11 at 15:56
  • Hey! No, I had already seen those posts, but they all have the advantage over me that their inequalities are of the kind y < f(x) (i.e. they can isolate the variables). In fact, these inequalities are all linear. The below answer by DJP seems very promising, I will give that a closer look. – Jesko Hüttenhain Dec 24 '11 at 20:12
  • You need to install Sage (which is big) on your system in order to use. – DJP Dec 24 '11 at 22:55

1 Answers1

4

There is a package for LaTeX called sagetex which gives you the power of a CAS in your latex documents. I didn't see it mentioned, and since the example you gave involved something more complicated than linear inequalities you might be interested. It's great for problems involving complicated mathematics like what you see on Wolfram Alpha. Look into Sage; this page was especially helpful to me. Include the sagetex package in the preamble:

\documentclass{article}
\usepackage{sagetex}
\begin{document}
\pagestyle{empty}
\begin{sagesilent}
G=Graphics()
H=Graphics()
I=Graphics()
J=Graphics()
var('x,y')
G+=implicit_plot(2*y^2*x-5*y^2+8*y-4*x*y+3*x-2, (x,-2,4), (y,-2,7),color='red')
H+= implicit_plot(3*y^2*x-8*y^2+12*y-6*x*y+4*x-3,(x,-2,4),(y,-2,7),color='black')
I += region_plot([2*y^2*x-5*y^2+8*y-4*x*y+3*x-2>=0, 3*y^2*x-8*y^2+12*y-6*x*y+4*x-3<=0], (x,0,6), (y,-2,7),plot_points=400,frame=True,axes=False)
J += text("$\chi$", (4, 1), fontsize=16, color='black')
\end{sagesilent}
\[ \sageplot{I+H+G}\] 
\[ \sageplot{I+J}\] 
\end{document}

This gave me output:

Two plots

The first plot has the implicit plots drawn in, the second just has the region. I added a latex character, \chi, to the diagram to show you that you can add LaTeX text onto your figure. Changing \sageplot{I+J} to just \sageplot{I} would remove it. By modifying the code you ought to be able to get the output you want and have it look even better than Wolfram Alpha.

Werner
  • 603,163
DJP
  • 12,451