Asymptote vs Sage
I am submitting an example created in Asymptote which is and isn't working (a bug?), let me hope it won't offend someone. I had an opportunity to compare Asymptote and Sage (neither TikZ nor PSTricks this time, I'm sorry), I would like to share my modest experience anyway.
A story
But before that, if you are begging so nicely, I will tell you a story behind the scene of creating these pictures. There is always a story behind our work.
I met a girl once. Virtually, of course, how else? And I wanted to make an impression on this mathematician. So I was given an assignment (her school homework) to solve three out of her three tasks before I would get a chance of meeting her face-to-face. Tasks from mathematics, something with integrals to compute... I decided to go for an interactive mathematics, I was so thrilled about all this that I parallely solved the same tasks in two programs. In Sage (Python with support of Jmol) and in Asymptote (PDF).
I did my best and you will see the results in a minute. But there was a catch! My results weren't virtually perfect. The Sage notebook wasn't publicly available at that time and I couldn't persuade Jmol to export me the 3D model to PDF.
And how about Asymptote? Even Asymptote didn't save the day. If you try my example and uncomment if
condition (lines 25 and 32) you will get an error no matching variable 'f'
(even Linux and Microsoft Windows agreed on this one). If you try to save a day by uncommenting line 20 in addition to that, you are getting a plane!
Once she saw that, she had left me at once, and, virtually, how else?
Looking back, I think she was no mathematician, but she was a TeXist! Poor me!
Back to reality
Sage provided me a very fine interface. It was interactive, the equations were typeset in TeX, it computed areas, volumes and the models were in 3D (Jmol is Java-based). Asymptote provided me a perfect solution to have those 3D models interactive and in the PDF file.
(Encapsulated) postscript
Please see a comment section to get this mal-asymptote.asy
file working as it really should be!
import settings;outformat="eps";// settings.render=16;// interactiveView=false;// batchView=false;// User's preference...// pick up a function: none, 1st, 2nd or 3rd// write(whichcurve==3); // inform me in the terminalreal whichcurve=1; // 0, 1, 2 or 3 // The core of the program...import graph3;import solids;size(300);currentlight=Viewport; // no light;pen colora=green;pen colorb=blue;//real f(real x) {return 0;} // :-) // line 20real mallower;real malupper;string maldesc;//if (whichcurve == 1) { // line 25 currentprojection=perspective(2,2,4,up=Y); write("Creating first function..."); real f(real x) {return sqrt(3+x);} // line 28 maldesc="$\sqrt{3+x}$"; mallower=-1; malupper=3;// } // == 1 // line 32if (whichcurve == 2) { currentprojection=perspective(0,2,2,up=Y); write("Creating second function..."); real f(real x) {return sqrt((x-2)/(2x+1));} // line 37 maldesc="$\sqrt{\frac{x-2}{2x+1}}$"; mallower=2; malupper=3; } // == 2if (whichcurve == 3) { currentprojection=perspective(0,-0.5,2,up=Y); write("Creating third function..."); real f(real x) {return sqrt((2-x)/(3+2x));} // line 46 maldesc="$\sqrt{\frac{2-x}{3+2x}}$"; mallower=1; malupper=2; } // == 3pair F(real x) {return (x,f(x));}triple F3(real x) {return (x,f(x),0);}path p=graph(F,mallower,malupper,n=10,operator ..);path3 p3=path3(p);//triple pO=(0,0,0);render render=render(merge=true);revolution a=revolution(p3,X,140,360);draw(surface(a),colora,render);revolution b=revolution(p3,Y,0,220);draw(surface(b),colorb,render);real xmax=malupper+0.4;real ymax=max(abs(f(mallower)),abs(f(malupper)))+0.2;draw(Label("$x$",xmax,E),(0,0,0)--(xmax,0,0),Arrow3);draw((0,0,0)--(-xmax,0,0),dashed);draw(Label("$y(x)=$"+maldesc,ymax,N),(0,0,0)--(0,ymax,0),Arrow3);draw((0,0,0)--(0,-ymax,0),dashed);//draw(Label(maldesc,ymax),(0,ymax,0)--(xmax,ymax,0));//draw((0,0,0)--(0,0,f(malupper)),Arrow3);