vv

13790 Reputation

20 Badges

9 years, 304 days

MaplePrimes Activity


These are Posts that have been published by vv

In this post I want to present an easy method to obtain a discrete parametrization of a surface S defined implicitly (f(x,y,z)=0).
This problem was discussed here several times, the most recent post is
http://www.mapleprimes.com/posts/207661-Isolation-Of-Sides-Of-The-Surface-On-The-Graph

S is supposed to be the boundary of a convex body having (x0,y0,z0) an interior point and contained in a ball of radius R centered at (x0,y0,z0).
Actually, the procedure also works if the body is only star-shaped with respect to the interior point, and it is also possible to plot only a part of the surface
inside a solid angle centered at (x0,y0,z0).

Usage:
Par3d(f, x=x0, y=y0, z=z0, R, m, n,  theta1 .. theta2,  phi1 .. phi2)

f           is an expression depending on the variables x, y, z
x0, y0, z0  are the coordinates of the interior point
R           is the radius of the ball which contains the surface,
m, n        are the numbers of the grid lines which will be generated
The last two parameters are optional and are used when only a part of S will be parametrized.

The procedure Par3d returns a MESH structure M, which can be plotted with PLOT3D(M).

Par3d :=proc(f,x::`=`,y::`=`,z::`=`,R,m,n,th:=0..2*Pi,ph:=0..Pi)
    local A,i,j, rij,fij,Cth,Sth,Cph,Sph, theta,phi, r;
    A:=Array(1..m+1,1..n+1,1..3,datatype=float[8]);
    for i from 0 to m do for j from 0 to n do
      theta:=op(1,th)+i/m*(op(2,th)-op(1,th));
      phi:=op(1,ph)+j/n*(op(2,ph)-op(1,ph));
      Cth:=evalf(cos(theta)); Sth:=evalf(sin(theta));
      Cph:=evalf(cos(phi));   Sph:=evalf(sin(phi));
      fij:= eval(f, [lhs(x)=rhs(x)+r*Sph*Cth, lhs(y)=rhs(y)+r*Sph*Sth, lhs(z)=rhs(z)+r*Cph]);
      rij:=fsolve(fij,r=0..R);  if [rij]::list(numeric) then rij:=min(rij) fi; 
      if [rij]=[] or not(type(rij,numeric)) then print(['i'=i,'j'=j], fij); rij:=undefined fi; 
      A[i+1,j+1,1]:=evalf(rhs(x)+rij*Sph*Cth);
      A[i+1,j+1,2]:=evalf(rhs(y)+rij*Sph*Sth);
      A[i+1,j+1,3]:=evalf(rhs(z)+rij*Cph);
    od;od:
    MESH(A);
end:

The procedure is not optimized, e.g.
- Cth, etc could be Vectors computed outside the loops
- Some small changes to use evalhf.

###### EXAMPLES ######

f1 := x^2+3*y^2+4*z^2 - x*y - 2*y*z - 10:
plots:-implicitplot3d(f1, x=-5..5, y=-5..5, z=-2..2);

M:=Par3d(f1, x=0,y=0,z=0,5,40,40):
PLOT3D(M);

f2 := x^4+y^4+z^4-1:
M:=Par3d(f2, x=0,y=0,z=0,5,40,40):
PLOT3D(M);

M:=Par3d(f2, x=0,y=0,z=0, 5,40,40, 0..Pi, 0 .. Pi/3): #Plot half of the top only
plots:-display(PLOT3D(M), scaling=constrained);

M:=Par3d(f2,      x=0,y=0,z=0, 5,30,30, 0..Pi, 0 .. Pi):
N:=Par3d(f2+0.01, x=0,y=0,z=0, 5,30,30, 0..Pi, 0 .. Pi):
plots:-display(PLOT3D(M), color=red):
plots:-display(PLOT3D(N), color=green):
plots:-display(%,%%, orientation=[-40,65,10]);

 

f3 := (x^2+y^2-1)^2+(z+sin(x*y+z))^4-120:
plots:-implicitplot3d(f3, x=-4..4,y=-4..4,z=-5..5, numpoints=10000);

Par3d(f3, x=0,y=0,z=0,5, 30,30):
PLOT3D(%);

Note.
The procedure could be used to plot locally around a point (x0,y0,z0)
One may use the spherical coordinates (theta0,phi0) and then call the procedure taking theta0-a .. theta0+a,  phi0-b, .. phi0+b  for the trailing parameters
The spherical coordonates can be computed using:

ThetaPhi :=proc(x,y,z, X,Y,Z)
    local r:=sqrt((X-x)^2+(Y-y)^2+(Z-z)^2);
    ['theta'=arctan(Y-y,X-x), 'phi'=arccos((Z-z)/r)]
end:

ThetaPhi(10,20,30, 11,21,28);evalf(%);

 

 


 

I found a strange bug in int.
For some functions f(x), Maple is able to compute the antiderivative (correctly) but refuses to compute the definite integral.
Or, computes the integral over 0..1  and  0..2  but refuses to compute over 1..2.

int(exp(x^3), x);  #ok

-(1/3)*(-1)^(2/3)*((2/3)*x*(-1)^(1/3)*Pi*3^(1/2)/(GAMMA(2/3)*(-x^3)^(1/3))-x*(-1)^(1/3)*GAMMA(1/3, -x^3)/(-x^3)^(1/3))

(1)

int(exp(x^3), x=1..2); #?

int(exp(x^3), x = 1 .. 2)

(2)

int(exp(x^3), x=1..2, method=FTOC); #??

int(exp(x^3), x = 1 .. 2, method = FTOC)

(3)

int(exp(x^3), x=0..2); #?

int(exp(x^3), x = 0 .. 2)

(4)

int(exp(-x^3), x);  #ok

(3/4)*x*exp(-(1/2)*x^3)*WhittakerM(1/6, 2/3, x^3)/(x^3)^(1/6)+exp(-(1/2)*x^3)*WhittakerM(7/6, 2/3, x^3)/(x^2*(x^3)^(1/6))

(5)

int(exp(-x^3), x=0..2);  #ok

(3/4)*2^(1/2)*exp(-4)*WhittakerM(1/6, 2/3, 8)+(1/8)*2^(1/2)*exp(-4)*WhittakerM(7/6, 2/3, 8)

(6)

int(exp(-x^3), x=0..1);  #ok

(3/4)*exp(-1/2)*WhittakerM(1/6, 2/3, 1)+exp(-1/2)*WhittakerM(7/6, 2/3, 1)

(7)

int(exp(-x^3), x=1 .. 2);  #???

int(exp(-x^3), x = 1 .. 2)

(8)


 

Download !strange-bug-int.mw

Correct computatiton for

for reasonable expressions f(x,y), g(x,y) would be very useful in double integrals.

For the moment this is not possible. Too many bugs:

int(Heaviside(1-x^2-y^2), x=-infinity..infinity, y=-infinity..infinity); #should be Pi
                           undefined
int(Heaviside(1-x^2-y^2), x=-1..1, y=-1..1); #should be Pi
                               0
int(Heaviside(y-x^2), x=-1..1, y=-1..1); #should be 4/3
                               -2

int(Heaviside(y-x^2), y=-1..1, x=-1..1); #This one is OK!
                              4/3

 

 

 

 

A string is wound symmetrically around a circular rod. The string goes exactly
4 times around the rod. The circumference of the rod is 4 cm and its length is 12 cm.
Find the length of the string.
Show all your work.

(It was presented at a meeting of the European Mathematical Society in 2001,
"Reference levels in mathematics in Europe at age16").

Can you solve it? You may want to try before seing the solution.
[I sometimes train olympiad students at my university, so I like such problems].

restart;
eq:= 2/Pi*cos(t), 2/Pi*sin(t), 3/2/Pi*t; # The equations of the helix, t in 0 .. 8*Pi:
               
p:=plots[spacecurve]([eq, t=0..8*Pi],scaling=constrained,color=red, thickness=5, axes=none):
plots:-display(plottools:-cylinder([0,0,0], 2/Pi, 12, style=surface, color=yellow),
                         p, scaling=constrained,axes=none);
 

VectorCalculus:-ArcLength(<eq>, t=0..8*Pi);

                           20

 

Let's look at the first loop around the rod.
If we develop the corresponding 1/4 of the cylinder, it results a rectangle  whose sides are 4 and 12/4 = 3.
The diagonal is 5 (ask Pythagora why), so the length of the string is 4*5 = 20.

 

In a recent post, the following inequality was proved with Maple:



(a,b,c,d >= 0).

Here is another direct proof attempt.

f:=(a+b+c+d)^2*(a*b+a*c+a*d+b*c+b*d+c*d)^2-144*(a^2+b^2+c^2+d^2)*a*b*c*d:
g:=expand(eval(f,d=1)):
s:=minimize(g, [a=0..infinity,b=0..infinity,c=0..infinity]):
length(s);   # huge
        304856
map(evalf@evalf[500],s);

map(evalf@evalf[1000],s);


So, Maple returns the expression

min(0,r1,r2,r3)


where r1,r2,r3 are huge expressions containing RootOfs. In order to evaluate them, several hundreds of digits are needed.
The solution seems to be correct, but the question is: may we (mathematically) accept it? What do you think?

 

4 5 6 7 Page 6 of 7