Maple 2018 Questions and Posts

These are Posts and Questions associated with the product, Maple 2018

Hello!

Is there any chance to bring the expression x2+xy+y2 to the form like x2+y2+xy (i.e. to set/define exact order of monomials) with Maple? What syntax (i.e. commands, packages, etc.) should I use? Many thaks in advance for any useful advice

 

When dsolve throws an error, is it always due to invalid user input, such as parsing error of some sort related to the input given to it, or could it throw an error not related to the parsing part? And if so, how would one know, in code, the difference between an error thrown due to parsing error, vs. something else?

For example, this will throw an error due to parsing

 

ode:=diff(y(x),x)+y;
try
   dsolve(ode,y(x));
catch:    
    print(StringTools:-FormatMessage( lastexception[2..-1] )); 
end try;

   "y(x) and y cannot both appear in the given ODE."

I want to check programmatically, if and when an error thrown by dsolve, if it is due to input itself being invalid, such as parsing error, or invalid initial conditions, and such bad input from the user, vs. other possible error that could be generated internally for other reasons when the input is valid.

I looked at help and there is no mention of what type of exceptions dsolve can throw, or how would would determine the type of exception, as Maple exceptions seem to be just strings and there is no actual identifier or type associated with them to use to check on.

I also looked at https://www.maplesoft.com/support/help/Maple/view.aspx?path=ErrorMessageGuideOverview  and seen nothing there that helps. It just says
 

There are three circumstances that would generate an error in Maple:

1. 	User Errors - the user has supplied incorrect input
2. 	No Solution - in some cases, a Maple routine will issue an error, indicating that the given problem has no solution
3. 	Maple Errors - Maple generates an error during internal computation in response to a problem with its own code

Great., But it does not say how a would a user know which is which when an error is thrown? (using code, not by looking at the screen and then using google).

In Mathematica for example, error messages have actual names, and one could check for the actual message tag itself in the code, to find what the error actually is, instead of using just a plain string of the error message. 

Does Maple have such a thing to use to help find what class of error was thrown out the above three classes shown in the above web page?

 

In this procedure I roll x dies and request a sum of the dies, n.
I then specify the third argument, o, to be exactly, minimum or maximum, so that it generates random rolls until the sum matches the conditions of my third argument.
It then returns the roll in a list and the number of rolls needed to match the conditions.

 

sim:=proc(x,n,o) uses RandomTools:

sim(3, 12, exactly)

[5, 2, 5], 1

(1)

````

optional_argument.mw
Can I somehow make the third argument optional, with exactly being the default, so that I can enter only sim(3,12) to get a roll that is exactly 12?
I've written through this maplesoft document, but don't quite seem to understand how to make an optional argument in  this regard: https://fr.maplesoft.com/support/help/maple/view.aspx?path=parameter_classes

Any help in understanding this is appreciatet :)

Hello,

1 .

If A and B are non-commuting operators and I want to calculate

(A+B)^n for some integer n, how can I tell maple to not commute them?

 

2.

And if I have this operator construct A^3. How can I replace it with some defined function f, so A^3 becomes (f@@3)(...)

A := (a^6)^(1/3)*(-b^3)^(1/3)/a^3

I Can't get this to simplify to -b/a. 

I am developing an algorythm which returns some differential equation, which I want to simplify. Here is an example:

eqq:= k[t]*(`ℓ`^2)*(diff(q[3](tau), tau, tau)+(5*alpha-sigma+2*theta+1)*q[3](tau)+(-4*alpha+sigma-theta)*q[2](tau)+q[1](tau)*alpha) = -(sqrt(m*(1/k[t]))*`ℓ`*k[t]*`Δθ`*(q[3](tau)-q[2](tau))*sin(sqrt(Lambda*k[t]*(1/m))*sqrt(m*(1/k[t]))*tau)+2*xi*sqrt(lambda*k[t]*m)*(diff(q[3](tau), tau)))*`ℓ`*(1/sqrt(m*(1/k[t])))

I want the parameters to be associated to the the variables, q[1](tau)q[2](tau)q[3](tau) and their derivattives. So, I have used "collect" command, as below:

vars:= {q[1](tau),q[2](tau),q[3](tau),diff(q[1](tau),tau),diff(q[2](tau),tau),diff(q[3](tau),tau),diff(q[1](tau),tau$2),diff(q[2](tau),tau$2),diff(q[3](tau),tau$2)}:
collect(eqq,vars);

The problem is that the equations remain with non-simplified terms, such as the terms inside the "sine" functions and the term "k[t]*ell^2". The command "simplify" does not have any effect. Ideally, I would like to have something like this:

(diff(q[3](tau), tau, tau))+alpha*q[1](tau)+(-4*alpha+sigma-theta)*q[2](tau)+(5*alpha-sigma+2*theta+1)*q[3](tau)+2*xi*sqrt(lambda)/`ℓ`*(diff(q[3](tau), tau))-`Δθ`*sin(sqrt(Lambda)*tau)*q[2](tau)+`Δθ`*q[3](tau)*sin(sqrt(Lambda)*tau) = 0;

Does anyone know how to solve that?
 

How do i change keyboard shortcuts, E.g one of my keyboard keys are broken or have stopped working. How do i redirect my shortcut to another keyboard combination or another hotkey simply.

Hello, is it possible to have a document synchronized in the same way as Onenote? We're a group of engieneer students wanting to share documents, however the only way we can figure out a way to do it. Is uploading to maplecloud groups, sharing a "base" document, and everytime someone "updates" the document you save a new one. So it kind of defeats the purpose of making it a smart idea of collaborating on one document, am i missing something or is this really how oldschool it works?

Hello,

     I'm trying to simplify an expression involving signum and sqrt using assumptions:

assumptions := { A>0,psi::real,1+A*cos(psi)<sqrt(1+sin(psi)),1+sin(psi)>0 }:
signum(1+A*cos(psi)-sqrt(1+sin(psi))):
simplify(%) assuming op(assumptions);

It seems to me that, given these assumptions, we can safely conclude that the result should be -1. However, I can't get Maple to show this. Interestingly, setting A=1 does allow maple to simplify the result to -1. Is there something I'm missing?


Thanks!

I was wondering how Maple cope with piecewise functions during forward integration and if it's preferable to use dsolve events option in place of defining a piecewise discontinuos function.

As far as I understood dsolve/events halts the integration each time an event is triggered and subsequently restarts the integration using the pre-trigger outputs as new initial conditions. I suppose that by using a piecewise, if a discontinuity is detected, dsolve proceeds exactly in the same way halting and restarting the integration.

Here a toy example of a 2D rolling dice (idea of a rolling dice from the rolling cube by @one man :P ) in which the reaction forces of the floor can be seen as function of the compenetration dice/ground

Both the appraches (events and piecewise) give the same results

falling_dice.mw

Hi, I'm quite a beginner in Maple.

Currently, I'm solving several complex ODE using maple. When I run the code, it gives me some results. However, when I re-run the code using exactly the same equations and parameter, I somehow got completely different results. Using the same input sometimes it gives float(undefined), complex number, or real number.

Could anyone explain what's happening here? Does it mean that my set of ODE is not independent of each other?

Any helps would be greatly appreciated.

Thanks!

We know that Grid:-Map(x->f(x),[x1..xn]) is for parallel computing f(xi)'s but when some xi's are equal I think Maple copies one result for the others. But maybe my function f has some random sampling inside and so will have different output for same inputs. So I need to do parallel computations for same inputs without cheating of copying the result of one for the rest. For a very simple case that Maple copies while it is wrong to copy, see the following.

I will be happy if someone tells me how to solve this issue. Thanks.

More surprising to me is that if I try to use different xi's and then typing same xi's, I will see some new patterns of copying. 

For example in output (3) and (4), first random point of one parallel computation is the second random point of another computation. Or in output (6) only the two last computations are copy of each other!

 

I may need to add that I did this computations on a computer with 4 core processor. Is Maple producing random numbers using something like processor's time? Or something like this?
I can't report Maple computations if they don't really produce random points independently in seperate parallel computations.

If I type pi, Maple just show what I typed, but if I insert the Greek letter pi, then it works. Are there other things that I should take care of them when I'm using "floor" command in my programming?

help me for remove this error.

Error, `;` unexpected
 

thanks_Prab.mw

 

Hello,

      I've noticed a strange phenomenon involving simplify: given the exact same input, its output varies between two different results depending on memory usage patterns.

      I've attached a sample code. There, I have an equation which should simplify to 0=0. If I run the code with garbage collection gc uncommented, it will correctly give 0=0. However, with gc commented out, it gives the unsimplified result result ~80% of the time (with 0=0 the remaining 20%):

1/2*A1*k*epsilon*p*(-I*exp(I*psi__p)*(2-2*cos(2*psi__p))^(1/2)+exp(2*I*psi__p)-1)*exp(-I*psi__p-1/2*2^(1/2)*k^(1/2)*(-k*p*cos(psi__p)+(k^2*p^2+2*k*p*
cos(psi__p)+1)^(1/2)-1)^(1/2)*t)*(-exp(-I*k*x-1/2*I*2^(1/2)*k^(1/2)*(k*p*cos(psi__p)+(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+1)^(1/2)*t)+exp(I*k*x+1/2*I*
2^(1/2)*k^(1/2)*(k*p*cos(psi__p)+(k^2*p^2+2*k*p*cos(psi__p)+1)^(1/2)+1)^(1/2)*t)) = 0

For my particular machine, it seems that when the memory usage is <98.4MB, it gives 0=0, and the unsimplied case otherwise.

      Any idea why this is? It seems odd that simplify would return different results depending on garbage collection, especially since use of gc is now discouraged.

example.txt

A few notes:

  • It seems replacing gc with a simple call to kernelopts(memusage) also produces the correct output
  • This is a snippet of a larger body of code I wrote: there, even without gc, it will sporadically (with the exact same input) produce the correct answer ~50% of the time
  • Only the last 4 lines are relevant; the beginning of the attached code is simply to generate appropriate memory usage and doesn't affect the relevant, final 4 lines
First 44 45 46 47 48 49 50 Last Page 46 of 61