Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

ExpODE4 := Y(1)*(sum(lambda^k*t^(k*d)/factorial(k*d), k = 0 .. infinity))

Statistics[NonlinearFit](ExpODE4, X, Y, t)

Hi again all

You can enjoy this simple Maple code to find the proper divisors of a given positive integer (whole number).

 

Download proper_divisor.mw

here  some_proper_divisor_examples_3.pdf   file

Hope this helps

Matt Anderson

 

I was setting up a worksheet for my vactor calculus class and tried to show how the DifferentialDiff command from the VectorCalculus package was limited.  I was expecting to have it give undefined or something similar for all directions with the function I am using.  Unfortunately, I got 0 when the directional derivative is truly undefined and I got undefined when the directional derivative is 0.

This is the code I am using.  Unfortunately, this site will not take the worksheet or plot the function for me.
 

with(VectorCalculus):
s := min(abs(x),abs(y));
plot3d(s,x=-1..1,y=-1..1);
DirectionalDiff(min(abs(x),abs(y)),<-1,1>,[x,y],point=<0,0>);

 

 

I solved this ode with IC, and obtained a solution.  Maple odetest says my solution satisfies the ODE but not the initial conditions. But I do not see why. When I plugin manually the initial conditions into the solution, I get true.

So I am not sure what is going on.

restart;
ode:=x*diff(y(x),x)*y(x) = (x+1)*(y(x)+1);
ic:=y(1)=1;
mysol:=y(x)-ln(y(x)+1)=-ln(2)+x+ln(x);
my_sol_at_IC:=subs([y(x)=1,x=1],mysol);

#now check manually
evalb(my_sol_at_IC);
is(my_sol_at_IC);

Using odetest gives

odetest(mysol,ode);
odetest(mysol,[ode,ic]);

What Am I doing wrong? 

Maple 2021.1

 

Edit June 12, 2021

This is another example where odetest gives different result depending on how the solution is written !

restart;
ode:=diff(y(x),x)=2/3*(y(x)-1)^(1/2):
mysol_1:=y(x) = 1/9*x^2 - 2/9*x + 10/9:
mysol_2:=y(x) - (1/9*x^2 - 2/9*x + 10/9) = 0 :
odetest(mysol_1,ode);
odetest(mysol_2,ode);

 

Hi,

I have created some vectors v[1] and v[2] and a vector field..I am new at Maple and learning so I can plot each vector on a 3D plot but cannot

figure out how to plot both vectors and the vector field on the SAME graph...

Any suggestions?

Thanks

Frank

Suppose that we have something like

plots:-animate(F,[theta],theta=0..2*Pi,background=plot([cos(t)-2,sin(t),t=0..2*Pi]),
scaling=constrained,axes=none);

I want to change the range of the parameter theta to something like theta=L[i],i=1..20.
Here, L is a list of numbers. Can I?
Thank you.

mapleatha

 

I can't figure what is going on here. I have an expression, where when I run the program, I see inside the debugger that the result of evalb(simplify(tmp_1)) where tmp_1 is the expression, gives false

When I copy the same tmp_1 expression to new worksheet and do evalb(simplify(tmp_1)) it gives true.

I added print statements in the code to print tmp_1 and print result of simplify(tmp_1) and for some reason, it gives false when I run the program, but it gives true when I do the same thing in a work sheet, by copying tmp_1 and trying it there.

Never seen anything like this, as expression is all numbers. Here is the print out when I run the program

Here is the same thing in worksheet

restart;
tmp_1 :=-(2*ln(-2))/7 - ln(-1)/7 = ln(1) - (2*ln(-2))/7 - ln(-1)/7;
simplify(tmp_1);
evalb(simplify(tmp_1));

                      true

and if you think I made mistake somewhere, here is also screen shot from the debugger window itself

 

again, same thing gives true in separate worksheet, copying same exact expression from above

There seem to be something loaded when I run my program that causes this difference, but I have no idea now what it is.  This has nothing to do with the debugger loaded btw, I am just using the debugger to show the details. When I run the program, without the debugger, I get false for the above, and I was trying to find why.

Any suggestions what to try and what to check for and what could cause this? Should it not give true when I run the program also? Could it be some Digits setting changed when the program run? I do not change any system defaults of any sort when running the program. 

Maple 2020.1

edit june 12, 2021

Here is another manifestation of the same problem I just found. There is something seriously wrong for it to behave this way.

This is an expression called tmp_1 in a local variable in a proc inside a module. There are not even any local symbols in it. When I run the program, all the attempts to show it is true fail. Some give FAIL and some give false when the result should be true

When I simply copy the expression from the debugger window to an open worksheet, I get true

Here is the screen shot

 

Only when I did is(expand(tmp_1)) did it give true

But when I copy the expression to the worksheet, it gives true using all the other attempts:

restart;
tmp_1:=1 = 5/4*exp(0)+1/4*piecewise(0 <= 1,-1,1 < 0,exp(-2)):
is(tmp_1);
is(simplify(tmp_1));
is((rhs-lhs)(tmp_1)=0);
is(simplify((rhs-lhs)(tmp_1)=0));
evalb(simplify((rhs-lhs)(tmp_1)=0));
is(expand(tmp_1))

I can't make a MWE so far, since these problems only show up with I run my large program. I think Maple internal memory get messed up or something else is loaded that causes these stranges problems.

For now, I added expand() to the things I should try. My current code now looks like

if is(tmp_1) or is(simplify(tmp_1)) or is((rhs-lhs)(tmp_1)=0)
               or is(simplify((rhs-lhs)(tmp_1)=0)) or evalb(simplify((rhs-lhs)(tmp_1)=0))
               or is(expand(tmp_1)) then    
   ....

Maple 2021.1

 

 

... and two suggestions to the development team

POINT 1
In ?DiscreteValueMap (package Statistics) it's given an example concerning rhe Geometric distribution along with this comment:
"The Geometric distribution is discrete but it necessarily assumes integer values, so (bold font is mine) it also does not have a DiscreteValueMap"

This sentence seems to indicate that "because a distribution is discrete over the set of integers, it cannot have a DiscreteValueMap", some sort of logical implication...

But my feeling is that the Geometric distribution (or any other discrete distribution) does not have a DiscreteValueMap because this attribute has just not been specified when defining the distribution.

restart:
with(Statistics):

GeomRV := RandomVariable(Geometric(1/2)):
f := unapply(ProbabilityFunction(GeomRV, n), n):

AnotherGeomRV := Distribution(
      'ProbabilityFunction'=f,
      'Support'=0..infinity,
      'DiscreteValueMap'=(n->n),
      'Type'=discrete
):
DiscreteValueMap(AnotherGeomRV , n);

Thus having the set of natural numbers as support doesn't imply that DiscreteValueMap cannot exist.

Suggestion 1: modify the ?DiscreteValueMap help page so that it no longer suggests that some discrete distributions cannot have a .DiscreteValueMap 

______________________________________________________________________________________

POINT 2
I think there exists a true problem with the definition of discrete distributions in Maple: the ProbabilityFunction of a (discrete) random variable) takes non zero values outside their definition set.
For instance

ProbabilityFunction(GeomRV, Pi);  # something non null


I tried to do this  for the Geometric distribution (not entirely correct):

restart:
with(Statistics):

GeomRV := RandomVariable(Geometric(1/2)):
f := unapply(ProbabilityFunction(GeomRV, n), n):
g := n -> (1-ceil(n-floor(n)))*f(n)    # (1-ceil(n-floor(n))) = 1 if n in Z, 0 otherwise

AnotherGeomRV := Distribution(
      'ProbabilityFunction'=g,
      'Support'=0..infinity,
      'DiscreteValueMap'=(n->n),  # is wanted
      'Type'=discrete
):
ProbabilityFunction(AnotherGeomRV, 2);
                 1/8
ProbabilityFunction(AnotherGeomRV, Pi);
                  0

PS: None of the statistics based upon the  ProbabilityFunction (Mean, Variance, ... ) is correctly computed with the previous construction. This could be easily overcome by completing this definition, just as its done in Maple, for all the requires statistics, for instance 

AnotherGeomRV := Distribution(
      ....
      'Mean'=1   # or more generally (1-p)/p form Geometric(p)
):


Suggestion 2: modify the way discrete distributions are defined in Maple in order to avoid that ProbabilityFunction returns wrong values.

Given finite points on a plane, how to calculate the Newton polygon, i.e. the lower bound of its convex hull?

The convex hull can be obtained by ConvexHull command from ComputationalGeometry package, but I don't know how to get its lower bound easily. Besides that, theoretically the Newton polygon does not depend on the full structure of convex hull, so maybe there is a more effective way to do that?

 

P.S. There is a method DEplot_polygon in DETools that can "generate the plot of the Newton polygon of a linear differential operator at a point“, but I not sure how it can be used to calculate the Newton polygon for general cases.

I came across this example from Maple's Online Help:

F := proc(t)
plottools[line]([-2,0], [cos(t)-2, sin(t)], color=blue),
plottools[line]([cos(t)-2, sin(t)], [t, sin(t)], color=blue),
plot(sin(x), x=0..t, view=[-3..7, -5..5]);
end proc:

animate(F,[theta],theta=0..2*Pi,background=plot([cos(t)-2,sin(t),t=0..2*Pi]),
scaling=constrained,axes=none);


Why is it not working?

Thank you!

mapleatha

Hi, I have a problem with tensor calculus. Please guide me.

I have two Tensors B[mu, nu] and A[~mu, ~nu].

Furthermore, I have two mixed tensors as U[~1, mu, nu] and U[~2,mu,nu]

rho, mu, and nu can run from 1 to 2. Hence, A, B, and both Us are 2*2 matrices.

Note that there was only one U, but since it is a mixed tensor, hence I have separated it into two tensors for making it easy.

Now I want to compute the following summation:

U[~rho,mu,nu] U[~alpha,beta,gamma] B[rho,alpha] A[~mu,~beta] A[~nu,~gamma].

Maple must give a number for rho, mu, nu, alpha, beta, and gamma (which can take 1 and 2) and compute "all" possible summations. Since the result will be just "a number", hence I could not use TensorArray.

How can I do it and get a result?

The forms of all tensors are in the attached maple file:
question.mw

Download question.mw

I need to change any occurance of   anything*sqrt(anything)  to say Z in any large expression.  (later, I can add the correct replacement once I know how to do it for Z).

I can change   sqrt(anything) with the help of the answers in Substitution-Of-Sub-Expressions-Is  but not  anything*sqrt(anything)

Here is an example to make it clear. Given

expr:=(-x + sqrt(9*x^2*exp(2*c) + 8)*exp(-c)+99)/(4*x)+ (a*sqrt(z)-99+sin(c*sqrt(r+4)+20))/3+10+1/(c+exp(-x)*sqrt(exp(x)))+sqrt(h)

Need to all some transformation on  those subexpressions circled above. For now, lets say I wanted to replace them with so it should becomes this

I can do this

subsindets(expr,anything^({1/2,-1/2}),ee->Z)

But I need to have the term (if any) that multiplies the sqrt as well included.

And that is the problem. Can't figure how to do it. When I try

subsindets(expr,anything*anything^({1/2,-1/2}),ee->Z)

Maple says Error, testing against an invalid type Ok. So anything*anything^({1/2,-1/2}) is not a type. What to do then?  Tried also subsindets(expr,t::anything*anything^({1/2,-1/2}),ee->Z) same error

And 

applyrule(t1::anything*sqrt(t0::anything)=Z, expr);

gives  which is wrong.

How to make this work in Maple using subsindets? Can one use pattern with subsindets? How to make a type for

               anything*sqrt(anything) 

Maple 2021.1

 

I 'd like to extract all items that contain "a" in an expression except "ab". What I can think of is to use the two functions select and remove to do it, but I feel a little less automated. Is there a better way?

f := a*b+a*c+a+b+c
s:=remove(has,select(has,[op(f)],a),a*b)                    

 s := [a c, a]

Hi,

 

I'm a student learning calculus I

 

Would someone explain what the synax in the steps means? I don't understand what is going on with the section that has _X0 in it.

 

 

 

1 2 3 4 5 6 7 Last Page 3 of 1828