Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I noticed some problems with pdsolve in 2020. Using Maple 2020 on windows 10 with latest Physics 626.

This PDE now hangs when the timeout is increased. This does not happen in Maple 2019.2.1/
 

restart; 
pde := diff(w(x,y),x)+(a*sin(lambda*x + mu)^k * (y-b*x^n -c)^2 + y - b*x^n + b*n*x^(n-1) - c)*diff(w(x,y),y) = 0; 
cpu_time := timelimit(60*5,CodeTools[Usage](assign('sol',pdsolve(pde,w(x,y))),output='realtime'));

In Maple 2019.2 it gives

    Error, (in trig/reduce/reduce) time expired

Which is good. Since I can now go on to the next PDE.

The hang goes away in Maple 2020 when small timeout is used.  For example I just tried 30 seconds timeout instead of 300 or more seconds and it did expire ok.

This tells me that it depends where it was in the kernel at the time. But as a user, I have no way to control this and so I use the same timeout for all the problems.

Do others using Maple 2020 see the same issue? I know that the timeout does not happen at exactly the same amout given, but for this one, I waited for almost 40 minutes and it still did not time out.

Is this a new bug and is there a better way to handle this other than using timelimit()?

Thank you

Hi 

I'm trying to plot Bar in maple 

yr=[0.1,0.2,0.3];

sle=[8,12,200]

Statistics:-ColumnGraph(yr,sle)

But not work

I'm trying to accent variables with both hats and checks (^ , v). I was able to get this to work using `#mover(mi("π"),mi("^"))`; but `#mover(mi("π"),mi("✓"))`; doesn't look very good. Is there a better alternative? 

With this application our students of science and engineering in the areas of physics will check the first condition of balance using Maple technology. Only with entering mass and angles we obtain graphs and data for a better interpretation.

First_equilibrium_condition.zip

Lenin AC

Ambassador of Maple

This behavior by Maple is completely wrong if you ask me.

But given this is how Maple works, the question I have is how to explictly close a file opened by call to readline()?

I have a proc(), where inside it, it wants to read say first 3 lines by calling readline("input.txt") on a file. Then the proc() returns back to caller.

The first call reads the first 3 lines from the file OK.

I expected all resources to be removed after the call returns, including any files opened to be automatically closed. So next time proc() is called, I expected the first 3 lines to be read again.

It turns out the next time  proc() is called, now lines 4,5,6 are read. This is becuase the file remained open between calls!  Only way to close the file is to call restart() on the whole session. But I do not want to do this. 

Looking at help, I see no method to explicity close the file other than reading all the lines.

How does one explicitly close a file opened by readline() without reading the whole file?

Here is example

restart;

foo := proc()
local n,current_line;

   for n from 1 to 3 do
       current_line:= readline("input.txt");
       print("line read is ",current_line);
   od;
end proc;

And now the above is called as follows

currentdir("C:\\test"); #change as needed
foo()
                   "line read is ", "line 1"
                   "line read is ", "line 2"
                   "line read is ", "line 3"

Next call

foo()
                   "line read is ", "line 4"
                   "line read is ", "line 5"
                   "line read is ", "line 6"

Where input.txt is 

line 1
line 2
line 3
line 4
line 5
line 6

I know how to do all this using fopen() and fscanf() and explicit fclose(). I also know I can use FileTools package.

But wanted to check first if readline() will do what I wanted more easily if I can figure how to close the file explicitly.

Hello

I would like to fillup the area between multiple function in my plot.

The plot consist out of multiple functions. Each function connects to one another.

In total there are 10 functions that define the border. The grey horizontal lines (PL4 and PL7) and all red lines PL8 - PL15.

I tried to find codes, but i cant get them to work.

 

 

Thanks a lot for any help!

 

I was working through an old text book, trying to understand a different problem.  I came across this problem in an exercise set and thought it was simple.  Until I tried it.

The difficlty I had was in using subs to substitute all values.  I had to use subs 2 or 3 times to get all substitutions.  How can I avoid this?

## Prove if F is the fibonacci sequence,
restart;
with(combinat, fibonacci):
F := n -> fibonacci(n);  ## F(n+1) = F(n)+F(n-1); F(1) = 1;
## the problem
P := n-> F(n+1)*F(n+2) - F(n)*F(n+3);
##
check_low := proc(n)
    local idx;
    for idx to n do
        print(P(idx),(-1)^idx);
    end do;
end proc;
check_low(1);
check_low(2);
check_low(3);
check_low(4);

## Assume true for n=k
A := P(k) = (-1)^k;

notation := { F(k)   = a,
              F(k+1) = b,
              F(k+2) = c,
              F(k+3) = d,
              F(k+4) = e };

## some fibonacci definitions
fibs := [ e = c + d,  d = b + c, c = a + b ];

eq1 := subs(notation,A);
eq1 := subs(fibs,eq1);
eq1 := subs(fibs,eq1);  ## have to repeat to get only a and b in the expression

eq2 := subs(notation,P(k+1));
eq2 := subs(fibs, eq2);
eq2 := subs(fibs, eq2);
eq2 := subs(fibs, eq2);  ## have to repeat to get only a and b in the expression
## Reduce eq2 to (-1)^(k+1)
simplify(eq2 = -lhs(eq1));
verify(eq2, -lhs(eq1), equal);
evalb(eq2); simplify(%);  ## Ah, this is why I need equal in verify.
evalb(-lhs(eq1)); simplify(%);

testeq(eq2, -lhs(eq1));

 

Hi, 

Suppose you have to do some sequence of operations on a random variable (RV), and that you need to repeat this for several RV of the same family (e.g. exponential RV), differing only in the values of their parameters.

Here are two examples do code this.
1/ probably the most natural way to proceed (?)
restart:
with(Statistics):
X := a -> RandomVariable(Exponential(a)):
for n from 1 to 100 do
  S := X(n);
  # here are some operations to do
end do:
anames(alluser);

The last instruction indicates that 103 user variables have been created (X, n, S and 100 random variables).
Note that adding one of the commands S := 'S'; or unassign('S') before the end of the loop just unassigns S but not remove the variables named _ProbabilityDistribution, ..., _ProbabilityDistribution98.


2/ To prevent this inflation of random variables I thought to use the procedure Specialize:
restart:
with(Statistics):
X := RandomVariable(Exponential(a)):
for n from 1 to 100 do
  S := Specialize(X, [a=n]):

  # here are some operations to do
end do:
anames(alluser);

This doesn't change the situation.

So my (multiple) question: 

  • How can I prevent the creation of the objects _ProbabilityDistribution, ..., _ProbabilityDistribution98 given only one of them is used for a given value of the loop counter (once the operations have been done I pass to another random variable) ?
  • How can I unassign a random variable ?
    Maybe it is not possible as suggested by the help page about "_": "Any symbol beginning with an underscore (_) is effectively reserved for use only by library code. It is not available to users." ?

Thanks in advance

Hello everyone,

I have the following problem:

I have an array of data dataarray[i,j,k] whose elements are either 1 or -1. I also have three vectors x[i], y[j] and z[k] (the axis).  I want to represent the data of dataarray so I have two different volumes: A green volume such as dataarray(x,y,z)=1 and a red one with dataarray(x,y,z)=-1. Is that possible? In case that it is, how can I do that?

Thank you very much in advance

Hi!

I am trying to determine the weights of a Gauß quadrature rule, the code I currently have is this:

 

for i from 1 to n do
  RekursivesZwischenergebnis:=1;
  for j from 1 to n do
    if i <> j then
      RekursivesZwischenergebnis:= RekursivesZwischenergebnis*((x-GaußKnoten[j])/(GaußKnoten[i]-GaußKnoten[j]))
    end if;
  end do;
  GaußGewichteAlt[i]:=int(RekursivesZwischenergebnis,x=-1..1);
end do;
 

The code works, is inefficient however. I want to use the product or mul function, however I dont know how to tell Maple not to multiply

((x-GaußKnoten[j])/(GaußKnoten[i]-GaußKnoten[j]))

if j=i.  mul(function(j), j=1..n,j<>i) doesnt work. Any efficient suggestions?

Hello,

I'm compiling a maple procedure to a C code with the Compiler command. I was wondering if it is possible to change the optimization flag, for example -03  for gcc? Is there a way to maybe change a file in the Maple directory that specifies the compiler options?

with(IterativeMaps): with(ImageTools):

 

BP := proc(f, S, I, m, M, xm, xM)
    local L;
    L := Bifurcation([x], f, S, m, M, xmin=xm, xmax=xM, height=800, width=1300, iterations=I+500):
    ArrayTools:-Dimensions(L):
    ColouringProcedures:-HueToRGB(L):
    Embed(L);
    L:    
end proc:

 

F := []:
f := [sign(r)*ln(abs(r))*cot(x)*(log[2+abs(r)](abs(x)) - x*sin(x))]:

F := [op(F), BP(f, [0.1], 10000, -10, 10, -15, 15)]:
F := [op(F), BP(f, [0.2], 10000, -10, 10, -15, 15)]:

F := [op(F), BP(f, [0.3], 10000, -10, 10, -15, 15)]:

F := [op(F), BP(f, [0.4], 10000, -10, 10, -15, 15)]:

 

I was trying to create some images of some bifurcations. I can't seem to create an animation from the images.

 

Also, Embed works great but each call to BP overwrites the previous image(rather than creating a new image)... Preview works but doesn't scale the images up properly.

How can type limit proc() and use print to export expression as mathtype?

 


 

limit((x^2-4)/(x+2), x = -2)

-4

(1)

"hs:=proc()  pd:=(``lim)((x^(2)-4)/(x-2));  end:"

Error, invalid underscript

"hs:=proc()  pd:=(``lim)((x^2-4)/(x-2));  end:"

 

``


 

Download help_limit.mw

 

So here's something silly but cool you can do with Maple while you're "working" from home.

  • Record a few seconds of your voice on a microphone that's close to your mouth (probably using a headset). This is your dry audio.
  • On your phone, record a single clap of your hands in an enclosed space, like your shower cubicle or a closet. Trim this audio to the clap, and the reverb created by your enclosed space. This is your impulse response.
  • Send both sound files to whatever computer you have Maple on.
  • Using AudioTools:-Convolution, convolve the dry audio with the impulse response . This your wet audio and should sound a little bit like your voice was recorded in your enclosed space.

Here's some code. I've also attached my dry audio, an impulse response recorded in my shower (yes, I stood inside my shower, closed the door, and recorded a single clap of my hands on my phone), and the resulting wet audio.

with( AudioTools ):
dry_audio := Read( "MaryHadALittleLamb_sc.wav" ):
impulse_response := Read( "clap_sc.wav" ):
wet_audio := Normalize( Convolution( dry_audio, impulse_response ) ):
Write("wet_audio.wav", wet_audio );

A full Maple worksheet is here.

AudioSamplesForReverb.zip

I was reviewing the StringTools features and I'm curious about some parts of it.

(1)     Here is a section from the StringTools[Length] help topic:

Notice that, like length, the Length command counts the number of bytes in the string, not the number of characters.
Length("d303251cembre");
                               9
 
When I execute the command in Maple 2020, it actually returns 13 instead of 9.  The length command also returns 13.  I do not understand the information from StringTools[Length] help.  I looked back to Maple 18 and it did not include these lines in the help topic.
 
(2)   I am confused about the rng argument in StringTools commands of LowerCase, UpperCase and OtherCase.  It seems that these commands consider -2 as the last character in the string.  The help topic shows this:
 
UpperCase("abcdefghij", 3 .. -2);
                          "abCDEFGHIJ"
 
I'm expected to use -1 as the last character such as:
 
S:="This is a test";
S[-4..-1];
                       "test"
 
(3)  Next, I looked at StingTools[SubString].  The help topic gives the following example:
 
SubString("abcdef", -5 .. -3);
                             "bcd"
That works like I expected.  So, -1 is the last character for SubString.
 
Thanks,
Lee
 
First 451 452 453 454 455 456 457 Last Page 453 of 2097