Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 27 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

If A and B are vectors, matrices, arrays, etc., of the same size and shape, then A *~ B performs the elementwise multiplication.

How would you recommend that this feature be indexed in the help pages, since you seem to have tried to find it? It is listed under ?elementwise

In Maple, e^x is exp(x). There is no caret (^) in it.

See ?Student,Calculus1,VolumeOfRevolution and ?Student,Calculus1,VolumeOfRevolutionTutor

A surface integral is a method of computing the flux (or flow) of a vector field (such as a force field or a moving fluid) through a surface. It is not ordinarily used to compute volume.

If you parametrize a surface, then in any integral that uses that parametrization, you need to multiply the integrand by the determinant of the Jacobian (the matrix of partial derivatives) of the transformation. This is completely analogous to changing dx to du when doing a u-substitution in a single integral. This determinant is where the extra factor of r comes from for polar and cylindrical coordinates and the extra factor of rho^2*sin(theta) for spherical coordinates. You haven't done this in your integral. I'm not saying that you should go do it! Because the easiest way to do this volume integral is in cylindrical coordinates.

Your plot is pretty good. It definitely shows the correct two surfaces.

In the worksheet below, I compute the volume five different ways, all using integrals. The Answer by Tom Leslie is incorrect.
 

restart:

plots:-display(
   plot3d( #upper hemisphere
      [r, theta, sqrt(4-r^2)], r= 1..2, theta= 0..2*Pi,
      coords= cylindrical, style= wireframe, color= brown, thickness= 3
   ),
   plot3d( #lower hemisphere
      [r, theta, -sqrt(4-r^2)], r= 1..2, theta= 0..2*Pi,
      coords= cylindrical, transparency= .4
   ),
   plot3d( #inner cylinder
      [1, theta, z], theta= 0..2*Pi, z= -sqrt(3)..sqrt(3),
      coords= cylindrical, color= pink, style= patchnogrid
   ),
   scaling= constrained
);

I compute the volume five ways. In each of the triple integrals, I compute the volume in the first octant and multiply by 8.

1. As a triple integral in cylindrical coordinates:

8*Int(r, [z,r,theta]=~ [0..sqrt(4-r^2), 1..2, 0..Pi/2]);

8*(Int(r, [z = 0 .. (-r^2+4)^(1/2), r = 1 .. 2, theta = 0 .. (1/2)*Pi]))

value(%);

4*3^(1/2)*Pi

2. As a triple integral in Cartesian coordinates:

8*(Int(1, [z,y,x]=~ [0..sqrt(4-(x^2+y^2)), sqrt(1-x^2)..sqrt(4-x^2), 0..1]) +
   Int(1, [z,y,x]=~ [0..sqrt(4-(x^2+y^2)), 0..sqrt(4-x^2), 1..2])
   );

8*(Int(1, [z = 0 .. (-x^2-y^2+4)^(1/2), y = (-x^2+1)^(1/2) .. (-x^2+4)^(1/2), x = 0 .. 1]))+8*(Int(1, [z = 0 .. (-x^2-y^2+4)^(1/2), y = 0 .. (-x^2+4)^(1/2), x = 1 .. 2]))

value(%);

4*3^(1/2)*Pi

3. As a triple integral in spherical coordinates (using phi as azimuth/longitude and theta as zenith/latitude):

8*Int(rho^2*sin(theta), [rho, theta, phi]=~ [csc(theta)..2, Pi/6..Pi/2, 0..Pi/2]);

8*(Int(rho^2*sin(theta), [rho = csc(theta) .. 2, theta = (1/6)*Pi .. (1/2)*Pi, phi = 0 .. (1/2)*Pi]))

value(%);

4*3^(1/2)*Pi

4. As the volume of a solid of revolution about the y-axis by the method of cylidrical shells. (The portion in the first quadrant is rotated.)

2*Int(2*Pi*x*sqrt(4-x^2), x= 1..2);

2*(Int(2*Pi*x*(-x^2+4)^(1/2), x = 1 .. 2))

value(%);

4*3^(1/2)*Pi

5. As the volume of a solid of revolution about the x-axis by the method of washers. (The portion in the first quadrant is rotated.)

2*Int(Pi*((4-x^2)-1), x= 0..sqrt(3));

2*(Int(Pi*(-x^2+3), x = 0 .. 3^(1/2)))

value(%);

4*3^(1/2)*Pi

 


 

Download SphereCylinder.mw

You should state your Maple version in your Question header.

It works for me in Maple 2016:

restart:
gg:=A* exp( - ( (t - t0) / (tau) )**2 ):
val1:=int(gg, t=-x0..x1) assuming t0::real, tau::real, x0<x1;

val1 := (1/2)*erf((x0+t0)/tau)*A*sqrt(Pi)*tau-(1/2)*erf((-x1+t0)/tau)*A*sqrt(Pi)*tau

You should put your Maple version in your Question header.

It works for me in Maple 2016:

restart:
gg:=A* exp( - ( (t - t0) / (tau) )**2 ):
val1:=int(gg, t=-x0..x1) assuming t0::real, tau::real, x0<x1;

@John Fredsted If you get that message ("The resource that you're looking for..."), it almost certainly means that a Question has been changed to a Post (or vice versa) or the author has removed their own material and the Active Conversations index hasn't yet been updated (it takes about 15 minutes). Why it takes 15 minutes to update such a trivial index is beyond me.

People's fear of censorship on Internet fora is vastly exaggerated. I'm only aware of two cases of censorship here at MaplePrimes in my years here. One was for some explicitly racist content, and the other was for posting some copyrighted code without permission. In both cases, the offending message was replaced with a message explaining the reason for removal.

Moderators have the ability to change Posts to Questions (or vice versa) or to edit content in any other way. I often change Posts to Questions or re-attach a Reply to a new parent. Indeed, I'm tempted to change this thread to a Post.

I wrote a Maple solution for this using the simplest code I could, and using only simple formulas from high-school algebra and geometry---no piecewise, integrals, etc. Let me know if you can understand this better.
 

 

t1 := Matrix(14, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 4170, (3, 1) = 1, (3, 2) = 3966, (4, 1) = 1, (4, 2) = 3466, (5, 1) = 3, (5, 2) = 3058, (6, 1) = 3, (6, 2) = 3058, (7, 1) = 4, (7, 2) = 1854, (8, 1) = 4, (8, 2) = 1354, (9, 1) = 7, (9, 2) = -2258, (10, 1) = 7, (10, 2) = -2758, (11, 1) = 8, (11, 2) = -3962, (12, 1) = 8, (12, 2) = -3962, (13, 1) = 10, (13, 2) = -4370, (14, 1) = 10, (14, 2) = 0})plot(t1);  

 

The intersection of this plot with the x-axis should be ≈ 5.125 and the area from 0 to 5.125 (or from 5.125 to 10) should be ≈ 13810``       

X:= t1[..,1]:  Y:= t1[..,2]: #Separate data by columns.

n:= numelems(X):

for k from 2 to n-1 do
   if Y[k]*Y[k+1] <= 0 then #Crossed the x-axis.
      #Formula for x-intercept of a line given in two-point form:
      x0:= (X[k+1]*Y[k] - X[k]*Y[k+1])/(Y[k]-Y[k+1]);
      break #i.e., exit the loop
   end if
end do:
      

'x0' = (x0 = evalf(x0));

x0 = (3085/602 = 5.12458471760797)

k;

8

Area:= 0:

for j from 2 to k-1 do
   Area:= Area + (X[j+1]-X[j])*(Y[j]+Y[j+1])/2 #Trapezoid area formula
end do:
Area:= Area + (x0-X[k])*Y[k]/2: #Triangle area formula     

'Area' = (Area = evalf(Area));

Area = (8313225/602 = 13809.3438538206)

#Bonus: Derivation of x-intercept formula:

solve((0-y0)=(y1-y0)/(x1-x0)*(x-x0), x);

-(x0*y1-x1*y0)/(-y1+y0)

``


 

Download Trapezoids.mw

It's done like this:

addcoords(
   EEspherical,
   [rho, theta, phi],
   [rho*cos(phi)*sin(theta), rho*sin(phi)*sin(theta), rho*cos(theta)]
);

Or, you can simply replace the existing spherical coordinates by using spherical instead of EEspherical.

You can add this command to an initialization file.

Assuming that you don't want to explicitly set the vertex positions and that you'll accept any reasonanly spread-out planar representation of the graph, it can be done like this:
 

``

NULL

I want to create the above network, given the following distance matrix

restart:

dist:= Matrix(
   (7$2), shape= symmetric, scan= band[0,6],
   [[0$7], [7, 11, 7, 15, 14, 8], [4, 12, 16, 5, 6], [5, 5, 3, 9], [12, 14, 11], [7, 11], [14]]
);

dist := Matrix(7, 7, {(1, 1) = 0, (1, 2) = 7, (1, 3) = 4, (1, 4) = 5, (1, 5) = 12, (1, 6) = 7, (1, 7) = 14, (2, 2) = 0, (2, 3) = 11, (2, 4) = 12, (2, 5) = 5, (2, 6) = 14, (2, 7) = 11, (3, 3) = 0, (3, 4) = 7, (3, 5) = 16, (3, 6) = 3, (3, 7) = 11, (4, 4) = 0, (4, 5) = 15, (4, 6) = 5, (4, 7) = 9, (5, 5) = 0, (5, 6) = 14, (5, 7) = 6, (6, 6) = 0, (6, 7) = 8, (7, 7) = 0}, storage = triangular[upper], shape = [symmetric])

demand:= <100, 200, 120, 45, 250, 80, 75>:

hubs:=[seq(parse(i), i = "A" .. "G")]:

seq(assign(Index(hubs[k])= k), k= 1..nops(hubs));

seq(assign(Vlabels(v)= sprintf("%a %d", v, round(demand[Index(v)]))), v= hubs);

edges:= {{A,C},{A,D},{C,D},{C,F},{D,F},{D,G},{G,E},{E,B},{B,A}}:

subsindets(edges, set(name), e-> [e, dist[Index~(e)[]]]);

{[{A, B}, 7.0], [{A, C}, 4.0], [{A, D}, 5.0], [{B, E}, 5.0], [{C, D}, 7.0], [{C, F}, 3.0], [{D, F}, 5.0], [{D, G}, 9.0], [{E, G}, 6.0]}

edgesL:= subsindets(%, name, Vlabels);

{[{"A 100", "B 200"}, 7.0], [{"A 100", "C 120"}, 4.0], [{"A 100", "D 45"}, 5.0], [{"B 200", "E 250"}, 5.0], [{"C 120", "D 45"}, 7.0], [{"C 120", "F 80"}, 3.0], [{"D 45", "F 80"}, 5.0], [{"D 45", "G 75"}, 9.0], [{"E 250", "G 75"}, 6.0]}

macro(GT= GraphTheory):

G:= GT:-Graph(edgesL);

GRAPHLN(undirected, weighted, ["A 100", "B 200", "C 120", "D 45", "E 250", "F 80", "G 75"], Array(%id = 18446744579123119758), `GRAPHLN/table/1`, Matrix(%id = 18446744579132820806))

GT:-SetVertexPositions(G, GT:-GetVertexPositions(G, style= spring));

GraphTheory:-DrawGraph(G, font= [HELVETICA,BOLD,10]);


 

Download DrawnGraph.mw

PolyhedralSets:-Plot(
   PolyhedralSets:-PolyhedralSet(
      {-x-y+3*z >= 0, -x+2*y >= 0, 3*x-2*y-z >= 0}
   )
);

Good Question; Vote Up.  You should do it like this:

Package:= module()
option package;
export 
   Output:= proc(Input)
      Record(
         'o1'= f1(Input)
         'o2'= f2(Input)
         'o3'= f3(Input)
      )
   end proc
;
end module:         

A Record is just a special simple type of module that only has exports, and there's no interaction amongst them. So, you would still access this as Output(Input):-o1.

Your stepsize is too large to get accurate results. Try this instead:

DEtools[DEplot](
   sys, {x(t), xdot(t)}, t= 0..200, {[x(0)=3, xdot(0)=4]}, 
   stepsize= 0.01, linecolour= blue, thickness= 0, 
   view= [-4..4, -3..3]
);

convert(F, set);
convert(G, list);

I prefer these more-efficient variants:

{F[ ]};
[G[ ]];

Note that it is impossible to control the order that items appear in a set. Maple uses an order that makes lookup efficient and is consistent across sessions.

The area of any non-self-intersecting polygon in the coordinate plane can be found very easily with the shoelace formula (Wikipedia link).

I don't understand your second question.

First 200 201 202 203 204 205 206 Last Page 202 of 395