Professional Documents
Culture Documents
Making A "Volcanic Landscape"
Making A "Volcanic Landscape"
Polynomial functions of two variables may be neat for algebra-- but they do not occur
frequently in applications, and they are useless for interesting plots. BOUNDED rational
functions like f(x,y)=(-x/(1+x^2+y^2)), and functions defined in terms of trig functions
like f(x,y)=sin(x)*cos(y) are much btter suited for explorations.
A really neat alternative for fun pictures (that we use later when differentiating etc, and that
actually becomes more important in applications, including "neural networks") is illustrated
here.
Start with a simple "bump":
> with(plots);
# plotsetup(plotdevice=window);
setoptions3d(shading=ZHUE,style=patchcontour);
> volcano:=exp(-x^2-y^2);
plot3d((volcano),x=-3..3,y=-3..3);
> arizona:=volcano+miningpit;
plot3d((arizona),x=-3..3,y=-3..3);
To somewhat automate the creation of more fun landscapes one may proceed as follows:
> f:=(a,b,c)->c*exp(-(x-a)^2-(y-b)^2);
> moon:=f(0,0,-3)+f(2,2,2)+f(-2,-2,2)+f(-1,2,3)+f(1,-2,2)+f(2,0,
2);
> ?plot3d,options
For fun, we conclude with an animation of successive cross-sections parallel to the x-axis.
Here "moon" is an expression in x and y, and thus we use "subs" to fix y at specific values for b.
> display([seq(plot(subs(y=b/2,moon),x=-3..3),b=-6..6)],
thickness=2,insequence=true);