MaplePrimes Questions

When making a proc that accepts positional and keyword based arguments, Maple allows the caller to put the keyword arguments before or after the positional arguments, or in between.

Is there a way to force the keyword arguments (if they are used) to only be placed after the (required) positional arguments during the call? 

An example will make it more clear. Given this proc

foo := proc(a::integer, b::integer, {c::integer:= 1, d::integer:= 1},$)
    print("a=",a," b=",b," c=",c," d=",d);
end proc:

It can be called as any one of these cases

foo(1,2);                                #case 1                                             
foo(1, 2,'c' = 1, 'd' = 2);              #case 2
foo('c' = 1, 1, 'd' = 2, 2);             #case 3
foo('c' = 1, 1, 2);                      #case 4
foo(1, 'c'=1, 2);                        #case 5
#more combinations possible

Is it possible to change how proc is defined, so that Maple will accept case1, and case 2 only in the above when the call is made and give an error otherwise?

i.e. only allow keyword arguments after all positional arguments.  I read https://www.maplesoft.com/support/help/Maple/view.aspx?path=argument_processing  and it says

After all arguments matching keyword parameters have been processed, matching of required positional and optional or expected ordered parameters is carried out

So from above, it looks like what I am asking for is not really possible. But I thought to ask, in case there is some way.

I find ability to put keyword arguments in the call anywhere and in-between required positional arguments confusing that is all.

Maple 2019.1

I am trying to expand a multivariable (more specifically 4 variables) function in powers of one of its variables when it goes to infinity.

However, the result I get is always zero, even if I input (or not) values for some of the other variables.

Can anybody help?

series_expansion.mw

P.s.: I want to do the same for the other two functions I defined in the worksheet as well.

Is there a command or method in Maple to list all initially protected names?

This page https://www.maplesoft.com/support/help/Maple/view.aspx?path=UndocumentedNames list undocumented protected names, and this page https://www.maplesoft.com/support/help/Maple/view.aspx?path=initialconstants  lists initially known names, which I assume are all protected.

But what about a list of all protected names? sin,cos, eval, uneval, etc.. any name that can't be assigned to. In my search so far, I could not find how to find these names. There are 100's of such names. Can one get them all in a list to look at?

Using Maple 2019.1

I want to solve the following system using PDE Solve command but finding an error. Please help me in this regard. Thanks!
 

 

restart; d1 := 1; d2 := 1; AA := 0.2e-2; BB := 0.79e-1; L := 1;
with(PDEtools, casesplit, declare);
PDE1 := diff(u(x, t), t) = d1*(diff(u(x, t), x, x))-u(x, t)*v(x, t)^2+AA*(1-u(x, t)); PDE2 := diff(v(x, t), t) = d1*(diff(v(x, t), x, x))+u(x, t)*v(x, t)^2-BB*v(x, t);
                      /  2         \                           
         d            | d          |                  2        
PDE1 := --- u(x, t) = |---- u(x, t)| - u(x, t) v(x, t)  + 0.002
         dt           |   2        |                           
                      \ dx         /                           

   - 0.002 u(x, t)
                          /  2         \                   
             d            | d          |                  2
    PDE2 := --- v(x, t) = |---- v(x, t)| + u(x, t) v(x, t) 
             dt           |   2        |                   
                          \ dx         /                   

       - 0.079 v(x, t)
IBC1 := {u(0, t) = 1, u(1, t) = 1, u(x, 0) = 1-(1/2)*sin(Pi*(x-L)/(2*L))^100}; IBC2 := {v(0, t) = 0, v(1, t) = 0, v(x, 0) = (1/4)*sin(Pi*(x-L)/(2*L))^100}; dys1 := {IBC1, IBC2, PDE1, PDE2};
         /              /  2         \                           
         | d            | d          |                  2        
dys1 := < --- u(x, t) = |---- u(x, t)| - u(x, t) v(x, t)  + 0.002
         | dt           |   2        |                           
         \              \ dx         /                           

   - 0.002 u(x, t), 

                /  2         \                                     
   d            | d          |                  2                  
  --- v(x, t) = |---- v(x, t)| + u(x, t) v(x, t)  - 0.079 v(x, t), 
   dt           |   2        |                                     
                \ dx         /                                     

   /                                                           100
   |                                        1    /1           \   
  < u(0, t) = 1, u(1, t) = 1, u(x, 0) = 1 - - sin|- Pi (x - 1)|   
   |                                        2    \2           /   
   \                                                              

  \   
  |   
   >, 
  |   
  /   

   /                                                       100\ 
   |                                    1    /1           \   | 
  < v(0, t) = 0, v(1, t) = 0, v(x, 0) = - sin|- Pi (x - 1)|    >
   |                                    4    \2           /   | 
   \                                                          / 

  \ 
  | 
   >
  | 
  / 
pds := pdsolve(dys1, numeric, time = t, range = 0 .. 1);
Error, (in pdsolve) invalid input: `pdsolve/numeric` expects its 2nd argument, IBCs, to be of type {list, set}, but received time = t
p1 := pds:-plot(t = 0, numpoints = 50);

p2 := pds:-plot(t = 1/8, numpoints = 50, color = blue);

p3 := pds:-plot(t = 1/4, numpoints = 50, color = green);

plots[display]({p1, p2, p3});
Error, `pds` does not evaluate to a module
Error, `pds` does not evaluate to a module
Error, `pds` does not evaluate to a module
Error, (in plots:-display) expecting plot structures but received: {p1, p2, p3}

Hi, Is there a way in which i can solve the following optimal control problem numerically with Maple ??

where P(t)=N(t)+S(t)+A(t) and N(0)=0.4897, S(0)=0.4018, A(0)=0.1085.

μ=0.000833, d=0.000666, ε1=0.0020, ε2=0.000634, β1=0.002453, β2=0.25*0.02, γ1=0.0048, γ2=0.25*0.02+0.00013, k1=1, k2=0.001, k3=0.99.

 where 

p1,p2,p3 are transversality conditions 

p1(60)=0 
p2(60)=0 
p3(60)=0

Answers and advice are very appreciated. 

Thank you all for reading.

Benz.

Hi MaplePrimes team,

 

If I assume a plot-based function or procedure C(s,t) and P1(t) are hidden in a package somewhere I don’t care about the type of geometry (spacecurve or plot3d). Now, I just want to animate P1(t) following the variable t. How do I do?

Example 1: Curve Animation in variable t

1. Equation

C := (s,t)-> Vector([cos(s), sin(s), t*s/2]):     #Helix shape as example

 

2. Plot

P1 := t-> display(spacecurve(C(s,t), s = 0..3*2*Pi, linestyle = solid)):

 

 

Example 2: Surface Animation in variable t

1. Equation

S := (x,y,t)-> Vector([x, y, t/(1 + x^2 + y^2)]):

2. Plot

P2 := t-> display(plot3d(S(x,y,t), x = -2..2, y = -2..2)):

 

If I assume the function or procedure S(x,y,t) and P2(t) are hidden in a package somewhere I don’t care. Now, I just want to animate P2(t) following the variable t. How do I do?

 

 

Example 3: Mixing Curve and Surface Animation in variable t

The ideal/”dream” basic syntax would be:

animate(display, [P1(t), P2(t)], t = t1..t2)

But it does not work.

 

Best.

Guy.

What is the problem in the following code to solve given PDE?

pde_question.mw

Thanks.

 

hi everybody:

I have two Maple files that file 1.mw file is a package and 2.mw file is based on the 1.mw file when running the 2.mw file I see the error and don't know how to solve it, I attach these files, thank you for helping me.

1.mw

2.mw

No doubt that someone will provide a smarter solution: 

 

# the main idea

f := exp(a-b);
subs(B=-b, expand(subs(b=-B, f)));

exp(a-b)

 

exp(a)*exp(-b)

(1)

# ad hoc application
restart:

f := 2*gamma(t, r)-2*alpha(t, r)-2*beta(t, r);
c := op~(1, [op(f)]);
C := [seq(u[i], i=1..numelems(c))];

subs(C=~c, expand(subs(c=~C, exp(f))))
 

2*gamma(t, r)-2*alpha(t, r)-2*beta(t, r)

 

[2, -2, -2]

 

[u[1], u[2], u[3]]

 

exp(2*gamma(t, r))*exp(-2*alpha(t, r))*exp(-2*beta(t, r))

(2)

 


 

Download exp.mw

Could someone confirm if this is a problem in this sample application?

In 2019, in the folder 

    C:\Program Files\Maple 2019\samples\ProgrammingGuide\RandomnessTests

There is sample application. Opening the main module file RandomnessTests.mpl  and scrolling down a little bit to the include statements show

$include "WaldWolfowitz.mm"
$include "BitFrequency.mm"
$include "SequenceFrequency.mm"
$include "Compressibility.mm"
$include "BinaryRank.mm"
$include "Entropy.mm"

$include "Data.mm"
$include "Visualization.mm"

However, in the same folder, there is no Data.mm file. There is only Data.mpl file.

So how could this sample application work?  

This sample app have more problems. The file Visualization.mm  say

Data := module()
option package;
...

And the file Data.mpl has

Data := module()
....

This is all so confusing. Seems someone made some typos and not tested this app? Why put a sample application which makes learning packages in Maple more confusing?

ps. I did not yet try to figure how to locad it and run it myself, I was just browsing it.

 

 

I have the following expression

I would like to know if is it possible avoid negative exponent goes to denominator when I use expand().

Thank you!

 

 

 

 

 

 

Hi. I want to take Laplace transform from differential equation with the final condition(tf).   If the differential equations have initial conditions  it appears in Laplace (for example laplace transform of diff(u,t) is U-s*u(0) that u(0) is initial condition)but for final conditions or boundry conditions What to do ?my equation is
 

restart

with(inttrans)

[addtable, fourier, fouriercos, fouriersin, hankel, hilbert, invfourier, invhilbert, invlaplace, invmellin, laplace, mellin, savetable]

(1)

``

u is function of x,t and u(x(10),10)=0

u[1] := (1/2)*x^2*t; L1 := laplace(eq1, t, s)

(1/2)*x^2*t

 

eq1/s

(2)

u(x(10),10)=0; desired output u[1]=x^2(t-10)/2

s1 := u[1]; N[1] := (1/2)*(diff(s1, x))^2+x*(diff(s1, x)); ul[2] := laplace(N[1], t, s); u[2] := invlaplace(ul[2]/s, s, t)

(1/2)*x^2*t

 

(1/2)*x^2*t^2+x^2*t

 

x^2*(s+1)/s^3

 

(1/6)*x^2*t^2*(3+t)

(3)

I want to apply: u[2](x(10),10)=0

``


 

Download lap.mw

attached

Hi

I have an optimization problem subjects with a system of ordinary differential equations with initial conditions.

I would like to obtain u^star, x^star and y^star solution of my problem 

I prefer if possible we implement hamilton jacobi bellman if possible

 

Optimal_control_problem.mw

 

thanks

 

Hello. I am building a graph and specify the axis titles. The 'y' label is to the left of the axis. Is it possible to move it somehow? I want to put it above the axle (in this case it was over 100)

plot(ff(x), x = 0 .. 10, color = black, labelfont = [TIMES, 19], thickness = 1, size = [1200, 600], axes = boxed, linestyle = 5, labels = ['x', 'y'], axis = [gridlines = [20, color = black]])

Maple always starts a new document with a 2D input style and Times New Roman font. How to change the boot style? (default).
Oliveira

First 657 658 659 660 661 662 663 Last Page 659 of 2425