Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am in a mode with a red arrow on the left.

How do I define f to be an algebraic function of x over C, the complex numbers, such as

f(x)=x+7+I

I want to be able to plug in complex numbers for x and have a complex number

returned, say

f(9-5*I)=16-4*I

In the blog  Plots of twisted ribbons, the author gave an interesting description of plotting twisted ribbons. In this blog , we give a similar description of twisted ribbons and give the geometrical interpretations of this definition.

 

Let r(phi)=[a*cos(phi), a*sin(phi), 0] (phi=0..2*Pi) be a circle in the xy-plane, and P be a point on the circle. Let QR be a line segment (with length of 2) passing through the point P and let P be the middle point of QR. Also, QR is coplanar with the z-axis.

Now let P rotate about the z-axis at the angular velocity of phi, where phi is the angle between OP and the x-axis. At the same time, the line segment QR is rotating about its middle point, P, at the angular velocity of theta (where theta is the angle between PQ and the z-axis and theta is dependent on phi, eg, theta=k*phi). In the whole process, QR will remain coplanar with the z-axis.

 

Apparently, the locus of the line segment QR is a twisted ribbon. When theta=phi/2, we have the Mobius strip.


2. The equation of the twisted ribbon

 

Now we try to find the equation of the surface. Clearly,

vector(OP)= [a*cos(phi), a*sin(phi), 0].

And with some geometrical manipulations, we have

vector(PQ)=[sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta)].

So the vector equation of the twisted ribbon is

V(phi, t)=vector(OP)+t*vector(PQ)

And the parametric equation is
x=a*cos(phi)+t*sin(theta)*cos(phi),
y=a*sin(phi)+t*sin(theta)*sin(phi)

z=t*cos(theta)

(where theta=k*phi (k a constant), phi=0..2*Pi and t=-b..b (b determines the width of the ribbon.))

Or
x=(a+t*sin(k*phi))*cos(phi),
y=(a+t*sin(k*phi))*sin(phi)

z=t*cos(k*phi)

(where k a constant, phi=0..2*Pi and t= -b..b)

When we take k=1/2, 1, 3/2, 2,…, we have different twisted ribbons.

When k=1/2, we have the equation of the Mobius strip:
x=(a+t*sin(phi/2))*cos(phi),
y=(a+t*sin(phi/2))*sin(phi)

z=t*cos(ph)/2

(phi=0..2*Pi and t= -b..b) .

 

k=1

 

k=2

Is there a way to change the background color of a plot viewing area different from the white?

 

 

Thanks!

John Fredsted suggested using the following procedure (slightly modified) to determine whether an expression was deeply algebraic.

isDeeplyAlgebraic := proc(x)
	if not type(x,'algebraic') then false
	elif type(x,'atomic') then true
	else andmap(procname,x)
	end if
end proc:
TypeTools:-AddType('DeeplyAlgebraic1'
                   , proc(x)
                         if not x :: 'algebraic' then false;
                         elif x :: 'atomic' then true;
                         else andmap(type,x,'DeeplyAlgebraic1');
                         end if;
                     end proc);

The first is a completely flat expression, the second is deeply nested.  The following graphs plot the time required to determine whether each expression is "deeply algebraic" as n increases, with each approach. The graph on the left is the time required to evaluate expr1, the graph on right is for expr2.  The red plot corresponds to the procedure, the green plot corresponds to the type. As you can see, for both flat and nested expressions, the procedure is significantly faster than the type.

 

I then did some testing to see whether the type matching could be improved.  A more efficient use of the type mechanism is to use a structured type rather than a procedure.  Alas, I don't believe that it is possible to create a purely structured type, with no use of 'satisfies', that is equivalent to what we want.  Here is the best I could come up

TypeTools:-AddType('DeeplyAlgebraic3'
                   , 'And'('algebraic'
                           , 'Or'('atomic'
                                  , 'satisfies'(x->andmap(type,x,'DeeplyAlgebraic3'))
                                 )));

Adding that to each graph gives the following two plots

 

The yellow line (p3) corresponds to this new type.  For expr1, the flat expression, it is significantly faster than the previous type, and approaches the speed of the standalone procedure.  Alas, for expr2, the nested expression, it is even slower than the previous type.  However, the reason it is slower is that with a nested expression the 'satisfies' part of the type has to be evaluated, which generates a call to a user-level procedure.

This observation suggests that if the type could be expressed as a structured type, with no use of 'satisfies', it might be significantly more efficient.  While I can see no way to do that with the desired predicate, it is possible to construct a type specific to these two examples:

TypeTools:-AddType('nestedF', 'And(algebraic,Or(atomic,function(Or(atomic,nestedF))))');

This isn't equivalent to the original predicate because it only works with functions, not operators (+, *, etc).

Here are the results with that type

Now we are making progress.  The blue plot (p4) is the time for this restricted type.  It is significantly faster than even the standalone procedure.

Note that if there were a structured type, say allops, that returned true if all of the operands of an expression match the given type, then we would be able to construct a purely structured type that matches our original predicate, that is,

TypeTools:-AddType('DeeplyAlgebraic4'
                   , 'And(algebraic
                          , Or(atomic
                               , allops(DeeplyAlgebraic4)))');

Hey,

I am trying to animate this code, I have a loop that makes a matrix of random numbers
 

with(RandomTools):for i from 1 to 20 do
>   for j from 1 to 2 do
>   p[i, j] := i+Generate(float, 0..1);
>   od;
> od;   
 

and if I try to plot the following this works such as

points:= {seq([p[T,1], p[T, 2], T],T=1..20)};
pointplot3d(points, symbol=box);

This gives me all 20 points on the plot

Hello,

I am trying to do some basic plots with maple, but when I plot them they look strange and do not look like they should, what am I doing wrong?

The plot I tried to do is:

plot(cos(20*Pi*t), t = -5 .. 5)

I am having this problem with most of the plots I try to do, they do not come out symmetrical and have strange anomalies in them.

 

Thanks,

 

Hi all,

I have the following function:

phiS := (C,q) -> w*(int(a*f*g(x), x=0..a*f) + int(x*g(x), x=a*f..((w+pi2)*q-pi2*C)/w) + int(q*g(x), x=((w+pi2)*q-pi2*C)/w..infinity)) - s*q - pi1*(f-C) - pi2*int((C-q)*g(x), x=((w+pi2)*q-pi2*C)/w..infinity);

when I type the command:

simplify(diff(phiS(C,q),C));

I get the correct output (I've differentiated phiS on paper): pi1- pi2*int(g(x), x=((w+pi2)*q-pi2*C)/w..infinity);

***************

eqn1:= 1.x+1.y+1.z=0

eqn2:= a.x + b.y + c.z=0

eqn3:= b.c.x+c.a.y+a.b.z=1

When I try to solve this system of equations as:

solve( {eq1,eqn2,eqn3},{x,y,z} )

I get the message "Warning, solutions may have been lost"

Can you please help me to solve these equations and express my solutions in "factored form" ?

Dear all,

I would like to solve the following equation (linearized Poisson-Boltzmann in 2D) in Maple:

diff(u(x,y),x,x)+diff(u(x,y),y,y)-k^2*u(x,y)=0;

subject to the boundary condition:

u(x,a*cos(bx))=0 and  u(x,y)|y->infinity=0

(a,b and k are parameters)

I succeed to get the solution with pdsolve, my problem is how to solve the boundary condition problem.

Thanks!





 

Gurus...

Any idea why I get the "Parts of the expression are ambiguous. Please select one of the suggested meanings." alert on some of this code, but not other parts? I want them all to be "table assignments" not "function definitions" (per my options in the window). I would really like to not have it keep asking me the question on each run, so is there a way for me to be more specific? Thanks in advance!

Fred

deq(i,XMethanol):=M*diff(X[i](t),t)=(L*(X[i-1](t)-X[i](t))+V*(Y[i+1](t)-Y[i](t)));

deq(i,XWater):=XW[i](t)=1-X[i](t);

I have these 3 equations i am trying to rearrange into real and imaginarry parts. This is pretty easy execpt I am unable to rearrange C(k) into real and imaginary parts.

C(k)= H1(k)/ (H1(k) + iH0(k))

Is it possible to solve piecewise equations in maple? All I get is 'warning, solutions may have been lost'.

solve((piecewise(x<0,x,x>=0,x^2)=0));

Thanks.

 

I want to plot the normal vector of the Mobius strip represented by the parametric equations:
x=(2+u*cos(v/2))*cos(v):

What could be done with a module whose ModuleLoad routine redefined itself?

Could such a routine do some action, and then cover its tracks effectively by overwriting itself?

Would there be any way to use march() to examine the .mla archive member, in which that ModuleLoad routine is stored, without accessing the name of the module? Presumably any invocation of the actual module name would result in its being accessed from the library and hence trigger its ModuleLoad routine.

I am trying to evaluate the hypergeometric function : hypergeom([1],[1.5],-z) where z is in the order of 1e-6. Its taking very long time where as if I use maple through matlab, then its quite fast !!. Evaluation of Gauss-hypergeometric functions for the similar arguments in maple is quite fast.  Is there any trick I can use for the fast computation of the confluent hypergeom in the case above?.

Thanks for any help

First 1870 1871 1872 1873 1874 1875 1876 Last Page 1872 of 2025