Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 357 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

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.

The derivative of a curve is the tangent of the angle that the tangent line makes with the positive x-axis. You need to find the points where the curves intersect, and find the difference of the arctans of the derivatives at those points. It is not clear whether your g should be cos(x^2) or cos(x)^2. I'll use the latter; the solution process is identical for either.

f:= x-> sqrt(x^4+5)/(sin(x)+5):
g:= x-> cos(x)^2:
plot(f-g);

r:= map2(fsolve, f-g, [-2..0, 0..2]): #Ranges determined from plot.
`-`(arctan@~(D(f),D(g)))~(r);

[-.958033052751182, .830203838366253]

That gives you the two angles in radians.

Those last two lines of code in expanded and perhaps more-readable form are:

r1:= fsolve(f-g, -2..0);
r2:= fsolve(f-g, 0..2);
arctan(D(f)(r1)) - arctan(D(g)(r1));
arctan(D(f)(r2)) - arctan(D(g)(r2));

But I write the way that I do because I disdain repetitive code.

Edit: Corrected "arctan of difference" to "difference of arctans".

Edit: Added code expansion, following VV's suggestion.

I believe that the interrupt button may only work when executing Maple-level code. That means that it doesn't work while kernel code is executing or while results are displaying after the computation is finished.

You shouldn't kill the Java process in Task Manager---that is a huge waste of time---plus you'll need to recover your unsaved worksheets (and those recoveries are not always complete). Instead, using the "More details" view of Task Manager, find the mserver.exe process that is running. It'll be the one with a larger number in the CPU column. You can click on the column header to sort by CPU. Kill that mserver.exe. Your worksheet will now have a "Kernel connection has been lost" pop-up. Ignore what the pop-up says---it is incorrect (and BS). Dismiss the pop-up. Save your worksheet. Close your worksheet. Reopen your worksheet (using the Recent Documents menu item). You're done.

That may sound like a lot of steps, but once you learn them, they'll save you much time over killing the Java process, especially if you have multiple worksheets open. It is just generally a good idea, not just with respect to Maple, to have Task Manager running at all times, in the "More details" view, sorted by the CPU column.

In the definition of Gr you use square brackets [ ]. In Maple, you can't use square brackets for algebraic grouping; you must use parentheses ( ). Square brackets have many uses in Maple, mostly dealing with indexable structures.

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