# Ngô Quốc Anh

## September 10, 2010

### MuPAD: Drawing a surface with a line on

Filed under: Uncategorized — Tags: — Ngô Quốc Anh @ 14:21

I took me years to figure out how did we plot such a picture in this entry. Thanks to MuPAD, we can do it quite easily. What I got is the following Firstly, we need to choose a function which has a mountain-pass shape. Thank to a special solution to the Toda system considered in this entry, we can choose $\displaystyle u(z) = \log \frac{{4\left( {1 + 4{{\left| z \right|}^2} + {{\left| {{z^2} + 2z} \right|}^2}} \right)}}{{{{\left( {1 + {{\left| {z + 1} \right|}^2} + {{\left| {{z^2}} \right|}^2}} \right)}^2}}}, \quad z \in \mathbb R^2$.

To plot such a function, we use

f1 := plot::Function3d( ln(4*(1+4*abs(x+y*I)^2+abs(((x+y*I)^2+2*(x+y*I))^2))/((1+abs((x+1)+(y+1)*I)+abs((x+y*I)^4))^2)), x = -1.3..1.3, y = -1.3..1.3, Submesh = [2,1], CameraDirection = [3,4,2]);

Next we try to plot a curve on the surface. To this purpose, we use

f2 := plot::Curve3d([x, 1/4-x^4, ln(4*(1+4*abs(x+(1/4-x^4)*I)^2+abs(((x+(1/4-x^4)*I)^2+2*(x+(1/4-x^4)*I))^2))/((1+abs((x+1)+((1/4-x^4)+1)*I)+abs((x+(1/4-x^4)*I)^4))^2))], x = -1/8..1, LineWidth = 0.5, AdaptiveMesh = 2, LineStyle = Solid);

Note that, the way to do it is to parametrize the surface. Since each point lying within the surface, its coordinates is nothing but $(x,y,f(x,y))$

then what we need to do is to replace $y$ by a function of $x$, for e.g. $y=\frac{1}{4}-x^4$ from above. Therefore, $x$ can be regarded as a parameter. The range of the curve is determined by the range of parameter $x$, from above, it is from $-\frac{1}{8}$ to $1$.

Finally, we need to put two end points. These points are determined by the range of $x$. We use the following

p1 := plot::Point3d([1, 1/4-1^4, ln(5681/64/(1/4*65^(1/2) + 881/256)^2)], Color = RGB::Blue, PointSize = 2*unit::mm);

p2 := plot::Point3d([-1/8, 1/4-1/8^4, ln(447856773689345/70368744177664/(1/4096*39049217^(1/2) + 283187601731585/281474976710656)^2)], Color = RGB::Blue, PointSize = 2*unit::mm);

Putting on everything by using

plot(f1, f2, p1, p2, Axes = None);

Here is the result ## 2 Comments »

1. thank you very much for this useful entry

Comment by Dan — March 25, 2011 @ 20:33

2. Dear sir,

the problem I would like to solve is related to representation of constrained optimization problems in MUPAD, but in broader terms, this could apply to a variety of cases.

I actually comes pretty close to what you posted in “MuPAD: Drawing a surface with a line on”, but a straightforward extension of its indications to the case I am strudying seems not possible.

To exemplify, my problem is to trace on the surface of a target function like, for instance, z = x^2+y^2 its intersection with, say, a plane (the constraint) that according to its inclination would result on the surface of the target function in an ellipse, a circle or a parabola.

Of course, in a more general setting, the constraint itself needs not be linear.

The natural choice would seem plot::curve3d, but I have no clue on how to parametrize the constraint function when it is a quadratic function such as an ellipse or a circle.

Also, all my initial equations are expressed in Cartesian coordinates.

Thank you very moch for any suggestion you could offer on the subject.

Regards

Comment by Dan — April 18, 2011 @ 19:01

This site uses Akismet to reduce spam. Learn how your comment data is processed.