Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Maple 2024.2 gives wrong inverse Laplace transform on -exp(s)/2*Ei(1, s + I) and other similar to this, but will only show this one as they seem all related. It gives -exp(-I*(t + 1))/(2*(t + 2))  but the correct inverse should be -exp(-I*(t + 1))/(2*(t + 1))
 

restart;

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1836 and is the same as the version installed in this computer, created 2024, December 2, 10:11 hours Pacific Time.`

restart;

Y:=-exp(s)/2*Ei(1, s + I);
y_wrong:=inttrans:-invlaplace(Y,s,t)

-(1/2)*exp(s)*Ei(1, s+I)

-(1/2)*exp(-I*(t+1))/(t+2)

#to show it is wrong, let ask for the laplace transform of it. We see it is not the same as Y

Y_back:=inttrans:-laplace(y_wrong,t,s): simplify(%);

-(1/2)*exp(I+2*s)*Ei(1, 2*s+2*I)

simplify(Y-Y_back);

-(1/2)*exp(s)*Ei(1, s+I)+(1/2)*exp(I+2*s)*Ei(1, 2*s+2*I)

#correct invlaplace should be -exp(-I*(t + 1))/(2*(t + 1)). Proof:
y_correct:=-exp(-I*(t + 1))/(2*(t + 1));

-exp(-I*(t+1))/(2*t+2)

Y_back:=inttrans:-laplace(y_correct,t,s);

-(1/2)*exp(s)*Ei(1, s+I)

simplify(Y-Y_back);

0

 


 

Download bug_in_inverse_laplace_transform.mw

 

Also Reported to Maple support.

Solved a "simple" dynamics problem involving the law of cosines... etc.  Part of the solution involves selecting the positive root from the resulting 2nd order equation in x(t)- below.  

eq1 := (r1 + r2)^2 = r1^2 + x(t)^2 - 2*r1*x(t)*cos(theta(t))  (law of cosines)

eq2:=diff(eq1,t)

eq3 := subs(diff(x(t), t) = v, diff(theta(t), t) = omega, eq2)  (remove xdot and theta dot)

assume(0 < x(t));
assume(0 < t);
assume(0 < theta(t) and theta(t) < 2*Pi);

xx := solve(eq3, v)  (creates an relationship between v, theta and x)

     xx := -r1*x(t~)*omega*sin(theta(t~))/(-cos(theta(t~))*r1 + x(t~))

Not clear what this t~ notation means?

when I solve eq1 above for x(t) there are two roots.  I select the positve root, but receive this warning...

eqx := solve(eq1, x(t))[1]

Warning, solve may be ignoring assumptions on the input variables.
        eqx := cos(theta(t))*r1 + sqrt(cos(theta(t))^2*r1^2 + 2*r1*r2 + r2^2)

How can I correct or address the warning message?

Finally,  to piece together the solution I perform this step

v := subs(x(t) = eqx, xx)

The result has a fairly obvious "simplification", but using "simplify" and "combine" only makes it worse...  Is there a combination of commands to accomplish a simplification.

Here is the entirety of the Maple...

restart;
with(Typesetting);
Settings(typesetdot = true);

eq1 := (r1 + r2)^2 = r1^2 + x(t)^2 - 2*r1*x(t)*cos(theta(t));
eq2 := diff(eq1, t);
eq3 := subs(diff(x(t), t) = v, diff(theta(t), t) = omega, eq2);
assume(0 < x(t));
assume(0 < t);
assume(0 < theta(t) and theta(t) < 2*Pi);
xx := solve(eq3, v);
eqx := solve(eq1, x(t))[1];
v := subs(x(t) = eqx, xx);

examine the result for v... easy to see the "simpificaion"... but not sure how to manipulate Maple to accomplish this...

JD

Hi!

I am working on a chemical engineering problem and trying to find a value (Ua) that does not result in a reactor temperature (T) exceeding 398.15 K.

I am employing a system of ode's, secondary functions, variables, starting conditions etc., and the dsolve function to determine these parameters.

Some values are given or calculated, UA is not. So for now I have just been guessing at the value (needed to preform the dsolve initially) and plotting to see relations to T and other parameters. My teacher has directed us to employ this trial and error apporach, which I find time consuming.

There is of course a smarter, more time efficient way of doing this and I was wondering how one could implement this? Moreover, how does one find the values of all the other variables at this Ua value? Is there a one-liner?

I tried implementing a loop to check for max UA values <= 398.15, but was not able to implement it..

Any help would be kindly appreciated.

FindingExtractingvaluesdsolvewithspecificconditions.mw

So my file got corrupted, i have no clue how to fix it. The file i was able to restore from OneDrive is 2 days old and is missing most of the information, i only have the backup files for the later version. Is there someone with expertice who can help me out? 

Can anyone explain me the reason of the last result?
Thanks in advance

restart

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

a/n^b;
den := denom(%);
print(cat(`_`$50));

3/n^2;
den := denom(%);
print(cat(`_`$50));

1.23/n^1.65;
den := denom(%);
num := numer(%%);

a/n^b

 

n^b

 

__________________________________________________

 

3/n^2

 

n^2

 

__________________________________________________

 

1.23/n^1.65

 

1

 

1.23/n^1.65

(2)
 

 

Download What-does-happen-here.mw

Lb1 represents a number of lengths, but I don't want to use a number to replace it now, but directly using eval, the variable in it becomes Lb1, unlike the following values show, how to write it like a number?

Every December since 2015, software engineer and puzzle enthusiast Eric Wastl has created an Advent Calender of code challenges called Advent of Code. These puzzles can be solved in any programming language, since you are only required to submit a string or integer solution, and tend to increase in difficulty over the course of the 25 days. Each puzzle has two parts each using the same input (which is different for each user), the second part being revealed only after the first part is solved.

I started participating in this puzzle challenge in 2021 and I like to solve them using Maple right when they are unlocked at 12am EST each day. I post my my solutions to my github as Maple worksheets, and (usually) later as cleaned up Maple text files: https://github.com/johnpmay/AdventOfCode2024

I typically work in a Maple worksheet since I find the worksheet interface ideal to quickly play with an evolving piece of code to solve a puzzle (it is kind of a race if you want it to be, Advent of Code tells you your place every day and gives you "points" if you are one of the first 100). Also I find the nature of the Maple language and its variety of libraries pretty ideal for approaching these problems.

Today, I am writing about this because 2025 Day 5 was a cool puzzle that really asked to be analyzed further in Maple. (Note, if you are participating in Advent of Code and haven't solved Day 5, there are heavy spoilers ahead).

Once you decypher the silly story about the elves, the problem comes down to a set of pairwise ordering rules, and a collection of lists (called updates) that need to be checked if they are sorted according to the rule. This seems straightforward, but as always you have a (big!) input file to handle.  In this case the input looks like this (the actual input not included here, but it's much much longer)

75|13
53|13
[...elided...]


75,47,61,53,29
97,61,53,29,13
[...elided...]

For this step, StringTools is your best friend (I typically read in the whole input as a string using FileTools:-Text:-ReadFile).  I first use StringSplit on the double line break "\n\n" to seperate the rules from the updates.  Then I map an ordinary Split over those to make everything into nested lists of integer.

(rules, updates) := StringSplit(Trim(input), "\n\n")[]:
rules := map(s->map(s2i,Split(s,"|")), Split(rules,"\n")): 

        rules := [[75, 13], [53, 13], ...]

updates := map(s->(map(s2i,Split(s,","))), Split(updates, "\n")):

        updates := [[75, 47, 61, 53, 29], [97, 61, 53, 29, 13], ...]

(the function s2i is a "string to integer" helper function since it's considered bad practice to just call parse on input handed to you by a stranger on the internet.  In older version of maple I used: s2i := s->sscanf(s,"%d")[1] in newever versions you can use the way less cryptic s2i := s->convert(s,'integer') )

Okay, now that we have two nice lists, it's easy to check which of the updates is sorted according to the rules with a simple nested loop.

goodups := DEQueue():

for u in updates do
    for r in rules do
        if member(r[1],u,'i') and member(r[2],u,'j') then
           if j < i then next 2; end if;
        end if;
     end do;
     push_back(goodups, u);
end do:

For each update, check that if a rule applies to it then that rule is obeyed. If the rule r is violated, advance the outer loop with the relatively new and useful next 2; syntax (it also works with break #) and if not check the next rule. If no rules were violated then push u into our stack of Good Updates.  This is a perfectly fine solution to part 1 of the puzzle, but if you thing about it a little why not just use sort with a custom comparision function built from the rules?

V := ListTools:-MakeUnique(map2(op,1,rules)): # all the numbers that can appear
N := [seq(map2(op,2,select(n->m=n[1], rules)), m in V)]: # all their neighbors in the graph induced by rules
T := table([seq(V[i]={N[i][]}, i=1..nops(V))]): # table of neighbors
comp := (x,y)->evalb(y in T[x]): # "less than" according the rules

Now with that comp function we can just do

goodups := select(u->sort(u, comp)=u, updates);

to find all the correctly sorted updates, this will seem like a better idea when you get the [SPOILER] part 2 of the problem which is to sort all the incorrectly sorted updates.

NOW WAIT A MINUTE.  If you look at the fine help page for ?sort you'll see it very clearly says about the comp function F (emphasis added):

custom boolean procedure

 When F does not match one of the symbols listed above, it must be a Boolean-
 valued function of two arguments.  Specifically, F(a,b) returns false if and  
 only if b must precede a in the sorted output.  That is F(a,b) is a non-
 strict less than comparison function.  In addition, F(a,b) must be defined  
 for all pairs a for a and b in the input structure and F(a,b) must be  
 transitive
, that is, if F(a,b) = true and F(b,c) = true then F(a,c) = true.

Dear reader, I guess we should check if our rules from the puzzle create a relation that is transitive.  The good news is that the sample input given in the problem description is indeed transitive. The easiest way I could think to check that was to use GraphTheory and see if there were any cycles in the directed graph given by the rules. So, let's make a graph with an edge for every comparison rule a<b, b<c, etc.  If there is a cycle in the graph, that will be a case where a < b < c < a in our rules and therefore non-transitivity in the comparison.  When we do that, we see it's cycle-free.

with(GraphTheory):
G := Graph({rules[]});
FindCycle(G); # returns []

That graph is really nice, it looks like this:

If you count the in-degree of each vertex, you can see it actually induced a total order on the numbers going linearly from smallest to largest numbers.

So, is that also true of the actual input you are given? Of course not. When you create the graph of your actual puzzle input you find there is a 3-cycle.

with(GraphTheory):
G := Graph({rules[]});
FindCycle(G); # returns a 3-cycle
seq(FindCycle(G,v),v in Vertices(V)); # returns a 3-cycle for every v!

In fact, there is a 3-cycle from every single vertex.  But at least the graph is pleasing to contemplate. Let it calm you:

So, does this mean sort with out comp function doesn't work? Is all lost? In fact, I solved both parts of the puzzle using a custom comparision for sort before stopping to consider that maybe the comparison wasn't transitive. And... it just works! So, WHY does it work? (the comparison is very very non-transitive). The answer is of course that the lists you need to sort don't contain all of the numbers covered by the rules.  In fact, your clever/cruel puzzlemaster has in fact constructed each of those (200 or so) lists so that it misses every one of the 3-cycles in the above graph. You can carefully check that by restricting the relation graph to the subset of numbers in each list and check for cycles:

G := Graph({rules[]});
H := InducedSubgraph(G, updates[i]); # try for i=1..nops(updates)
FindCycles(H); # returns [] for every element of update

In fact, each of those induced subgraphs looks like this

and you can maybe observe that this induced a total order on the numbers in the problem. Or if you are not careful, and you didn't bother to check, you would get the right answer anyway. Because it's only Day 5, and Eric Wastl hasn't decided to make thing really challenging yet.

I hope you've enjoyed my deep dive into this problem. And I hope it's inspired you to go try out Advent of Code. It's a fun challenge. Let me know in a comment if you're participating! Maybe we can start a leaderboard for MaplePrimes folks working on the puzzles.

Hi:

I want to copy some Maple output elsewhere in the form of Maple input.

Usually, if I highlight the output expression I can copy it with CTLR-C, and paste it elsewhere where it appears as Maple input.

Just like you'd expect and just like you'd want.

But if the expression is fairly long and complicated (it covers two lines on my screent this time), the highlight insists on including the > symbol on the next line and when I paste, all I get is the Maple output that I started with.

If I write the output expression name to a temporary file and read it in another worksheet, the same thing happens when I ask for the name of the output expression - it appears as Maple output. But I need the expression in the form of Maple input so I can modify it.

All this makes me think that there is a limit to the size of the copy buffer, but I can't find anywhere to change that.

Does anyone know how to do this very simple task which usually works reliably for small expressions?

Thank you.

Hi everyone!

I'm double checking a result from maple.  When I substitute maple's solution into the differential equation, left side does no equal right side.  Does anyone have some insight into this?

thanks

the maple file is below

is_this_correct.mw

Is it possible in maple to resume an asymptotic expansion from a specific order onwards.

To be more specific.

Let's assume that I have the asymptotic expansion to say Order 20 already calculated or can import it from file.

Is it possible for Maple to use the expansion I already have and immediately start calculating Order 21 onwards ?

This will save a lot of time for numerical  expansions that can take literally days to complete.

Hey guys, 

I am working with Maple 2024. I have to solve many systems of polynomial equations symbolically. I have 8 equations, 8 variables and 14 inequalities (which also implies that I only want real solutions). In my opinion the equations are not too difficult. However there is a maximum of up to 4 variables multiplied together which could be a problem. Since I have to solve thousand of those systems I need to reduce the amount of time needed. While many of the systmes only take a few seconds, there are a few systems (10%) that need way to much time (multiple houres, sometimes I stop the process before the computation is over). 

In my attached file you can see the kind of equations I have. While "equations_500 union inequalities" only needs a few seconds, "equations_1162 union inequalities" needs more than 2 houres (than I stopped). 
I also tryed a second approach. At first I just solved the 8 equations. Then I took every solution, combined it with the set of inequalities and solved it again. Not only does it not work for equations_1162 eather, but it also sometimes brings the warning "solutions may have been lost" which is not really convincing. For that process I also used "with(RealDomain) since I only want to find real solutions when solving the eight equations in the first step. 

I figured out, that for the normal and simpel solve command it cqn help to rename the variables so the lexigraphic order as the initial situation playes a role. But when I understood the pages explaining SolveTools or Groebner, this optimal order of the variables is completed automatically inside these environments. 

So my question is: Is there any way to accelerate the process (in this case for equations_1162)? Waiting some minutes isfine, but I cant wait houres for one solution. 

Thank you in advance. 

solve_system_of_polynomials_with_inequalities.mw

Suppose I want to run several systems of equations as below, however, the processing time exceeds 45 thousand seconds (reaching hours of calculations)

  • What is better, buying a new processor (new notebook) or buying a new stick of RAM?
  • Or does none of this affect Maple? Therefore, it is just a computational disadvantage (the delay time), characterizing the slowness of the program for very large systems as an imminent characteristic.
  • Another question: The newer Maples (new versions) seem to be heavier to run. Is it just me? What seems to me is that the previous versions of Maple, because they contain fewer resources, are lighter and run certain calculations faster. Would this be correct?
  • Last question: Is it possible to do parallel processing in Maple? So that calculations on huge systems can be run faster

Thank you so much! :)

Help me, I want to make this system be stable on graphs? How to make this system stable in plot?

This is my model:

dx/dt=\[Alpha]*
  x[t]*(1 - (x[t]/n)) - ((\[Beta]*x[t]*
     y[t])/(1 + (\[CapitalTau]*\[Beta]*x[t]))) - (x[
    t]*\[CapitalEpsilon]);
dy/dt=y'[t] == -\[Gamma]*y[t];

Prove: If a is an irrational number, then the function y = cos (ax) + cos x is not periodic.
Is it possible to graphically represent or calculate this fact using an example?

I try to get some Bilinear form for some PDE equation  and already i have algorithm by writing in lecture but i can't apply i don't what is mistake i did, and i didn't seen some of this lecture code in maple  like (myint(expr,var))
 i  do upload PIcture of algorithm and example which they get Bilinear form 

Bilinear.mw

thanks for any help

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