MaplePrimes Questions

Dear maple user  any one suggest me how to solve  second order coupled differential equation using galerkin finite element method for 8 elements and 10 elements using maple codes

 

I thought I remembed how to do this once in Maple, or asking something like this here, but may be it was something similar. But I am not able to figure it now or remember.

Given an expression, I want to find all occuranes of a pattern in it.  Not just one.  So this is like using patmatch but over and over again untill all patterns found. I'll give an example to make it easy to explain.

Given

expr := y^2*sin(1/y) + y^(3/2) + y + x*y^7;

I want to find all patterns of form y^n  so the result should be 

{y^(3/2), y^7, y^2, 1/y, y}

This below is how it is done in Mathematica, but having hard time translating this code to Maple.

The last line below does the actual repeated pattern matching. That line was not written by me. It is something from Mathematica forum at stackexchange and I use it all the time and it works well.

ClearAll[x,y,n]
expr = y^2*Sin[1/y] + y^(3/2) + y + x*y^7;
pat = y^n_.;
Last@Reap[expr /. a : pat :> Sow[a], _, Sequence @@ #2 &]

I looked at hastype also. But hastype will only tell me if the pattern is there or not. May be I did not use it right.

restart;
expr := y^2*sin(1/y) + y^(3/2) + y + x*y^7;
hastype(expr,symbol^(anything));

Gives true

I tried patmatch, but again, it only find one:

restart;
expr := y^2*sin(1/y) + y^(3/2) + y + x*y^7;
if patmatch(expr,a::anything+y^(n::anything)+b::anything,'la') then
   assign(la);
   n;
fi;

And the above is not even robust for finding one. Since I have to change the pattern again to account for multiplication/addition cases between terms. 

Is it possible to do in Maple the same thing I show in Mathematica? I am sure it is possible, but can't now find the right function in Maple.

Maple 2019.1

Should I adjust numcpus while running thread command

I want to extract lists that are term by term smaller than a fix one.

To be clearer, I want to create something like

if a[i] <= b[i] for all i=1..min(nops(a),nops(b)) then ...

I tried with the forall call, but it doesn't work:

if forall( i=1..min(nops(a),nops(b)),a[i] <= b[i]) then ...
 

I also tried the assuming call with the is call. It works, but doesnt't give me the result I want:

 

if is(a[i] <= b[i]) assuming(1 <= i, i <= min(nops(a),nops(b))) then...

Is there a way to have a chain of conditions in a if statement like I am trying to do?

 

Hello,

How to show the y-axis numbers in the second plot ?   y is in [0,3]. 

I try the following but it shows a negative axis. 

display(P, L, axis = [tickmarks = [5, subticks = 3], thickness = 2]);  this is not correct

The file is attached.

Thanks


 

Download Curves.mw

 

I do not understand why the following is not working. I have a package which has a module inside it. The module is exported by the package.

Inside that module, there is a proc, which is also exported by the module.

So why can't one call the proc from outside the package? What Am I doing wrong? and how to correct it? I'd like to be able to call the proc directly. 

A:=module()
  option package;
  export B;
  B := module()
      export foo;

      foo:=proc()
           print("in foo");
      end proc;

  end module;
end module;   

Now when typing (A::B):-foo() Maple is not happy and says Error, module does not export `foo`

I tried different syntax from the above, but can't get it to work. For example A::B:-foo() gives Error, `B` does not evaluate to a module

 

Maple 2019.1

P; Q; lma; [3 -42] [-, ---] [2 25 ] [22649 -2304] [-----, -----] [5523 1841 ] 1.627112258 with(geometry); point(Pp, P[1], P[2]); point(Qp, Q[1], Q[2]); ellipse(p, ['foci' = [Pp, Qp], 'MajorAxis' = lma]); Error, (in geometry:-ellipse) the given polynomial/equation is not an algebraic representation of a ellipse; I can't understand this error

Hi I’m a student, running Maple on a student license, and I have an issue with the way the Maple 2019 setup is.

I'm sorry if my answer is a bit hard to understand, I don't really know how to explain it.
 

My Maple 2018 expired and I was forced to upgrade to Maple 2019, however for me there is a huge difference in how the setup is in therms of “math” and “text” mode. 

 

Before, I was able to easily switch between “text” and “math” mode in a paragraph (the red “>”) in my worksheet, by using “cmd+R” and “cmd+T”. So I would have paragraphs for text, where i could switch between “math” and “text” for writing, and then I would have paragraphs only for math for when I would calculate things. (I’ve tried to screenshot how it would typically look)

 

Mt problem with Maple 2019, is that when I switch a paragraph into text and start writing and want to switch to “math” by using “cmd+R”, Maple executes the formula whenever I press “enter”, and give me an output I don’t want.

 

How do I change the settings to get back to the way they were on Maple 2018 and the years before this?

Thanks in advance.

(I know I can put a ":" after the "math" part in my text, but i don't wan't to do it every time)


 

 

 

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

Can anybody tell me any lecture series on parallel processing in maple

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.

First 6 7 8 9 10 11 12 Last Page 8 of 1777