Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

How I can convert my maple code to matlab?.

dsolv.mw
 

 

restart;

``

 

fdsolve := proc({alpha:=NULL, t0:=NULL,
                 t1:=NULL, x0:=NULL, y0:=NULL,
                 N:=NULL}, params)
    local t, h, h1, h2, c, b, x, y, L, n, l, X, Y, f, g;
    eval(F(t,x,y), params);
    f := unapply(%, [t,x,y]);
    eval(G(t,x,y), params);
    g := unapply(%, [t,x,y]);
    L := floor(1/alpha);
    h := (t1 - t0)/N;
    h1 := h^alpha/GAMMA(alpha+1);
    h2 := h^alpha/GAMMA(alpha+2);
    c := (i,n) ->
        `if`(i=0,
            (n-1)^(alpha+1) - (n-1-alpha)*n^alpha,
            (n-i+1)^(alpha+1) + (n-i-1)^(alpha+1) - 2*(n-i)^(alpha+1));
    b := (i,n) -> (n-i)^alpha - (n-1-i)^alpha;
    t := Array(0..N, i-> (1-i/N)*t0 + i/N*t1, datatype=float[8]);
    x[0], y[0] := x0, y0;
    for n from 0 to N-1 do
        X[0], Y[0] :=
            x[0] + h1*add(b(i,n+1)*f(t[i],x[i],y[i]), i=0..n),
            y[0] + h1*add(b(i,n+1)*g(t[i],x[i],y[i]), i=0..n);
        for l from 1 to L do
            X[l], Y[l] :=
                x[0] + h2*add(c(i,n+1)*f(t[i],x[i],y[i]), i=0..n)
                     + h2*f(t[n+1], X[l-1], Y[l-1]),
                y[0] + h2*add(c(i,n+1)*g(t[i],x[i],y[i]), i=0..n)
                     + h2*g(t[n+1], X[l-1], Y[l-1]);
        end do;
        x[n+1], y[n+1] := X[L], Y[L];
        #printf("y[%d]=%a\n", n+1, y[n+1]);
    end do;
    return Array(0..N, i -> [t[i], x[i], y[i]]);
end proc:

 

F := (t,x,y) -> r*x*(1-x/k) - beta*x*y/(a+x^2);
G := (t,x,y) -> mu*beta*x*y/(a+x^2) - d*y - eta*x*y;

proc (t, x, y) options operator, arrow; r*x*(1-x/k)-beta*x*y/(a+x^2) end proc

 

proc (t, x, y) options operator, arrow; mu*beta*x*y/(a+x^2)-d*y-eta*x*y end proc

(1)

params := { r=0.05, a=0.8, mu=0.8, d=0.24,
            eta=0.01, beta=0.6, k=1.6 };

{a = .8, beta = .6, d = .24, eta = 0.1e-1, k = 1.6, mu = .8, r = 0.5e-1}

(2)

T := 300.0;  # time interval: 0 < t < T
q := 100;    # divide the time interval into q subintervals

300.0

 

100

(3)

We produce several solutions starting from various initial data x__0, y__0.

This reproduces the phase diagran in the cited article's Figure 2  (alpha=0.98):

sol := fdsolve(alpha=0.98, t0=0.0, t1=T, x0=2.5, y0=0.14, N=q, params):
p1 := plot([seq([sol[i][2], sol[i][3]], i=0..q)])

 

 

 


 

Download dsolv.mw

 

I want to check that all entries in a list are of some value. Say 0. (or in general, if all entries satisfy some condition).

So, If any entry is not zero, then it returns false. It returns true only if all elements meet this conditions.

What would be the right way to do this in Maple? I know I could write a loop. But I am asking if there is a build-in function in Maple. Here is an example

ode:=y(x)*diff(y(x),x)=x*(y(x)^2+2):
sol:= dsolve(ode,y(x)):
check:=map(z->odetest(z,ode1),[sol]);

                       check := [0, 0]

I want to check that all entries in check are zero. This tells me all my solution are correct.

I can't use member(check,0) since this only check if at least one entry is zero. I want to chek that all entries are zero.

In Mathematica, it has AllTrue function. Like this

check = {0, 0, 0};
AllTrue[check, # == 0 &]

     True

The "#==0&"  is the test to do. It uses this test on each element automatically. If all satisfy this test, then it returns true.

Again, I can easily write a small function in Maple to do this,

alltrue :=proc(arr,value)
    local z;
    for z in arr do
        if z<>value then
           return(false);
        fi;
    od;
    return(true);
end proc:

alltrue(check,0) return true.

But I am asking if there is a build-in such function similar to the above one in Mathematica, which accepts a more general test function to use.

I am interested in obtaining a Maple program (symbolic language) that can evaluate exponentials of non-commuting operators. 

eA+B=eAeBeC1eC2eC3...

See R. M. Wilcox, J. Math. Phys. 8, (1967), 962

This is the Baker-Campbell-Hausdorff expansion, or equivalently the Zassenhaus expansion.

 

 

ANIMATED image of cascade of opening matryoshkas

E.R. Ibragimova

 

 

ИбрагимоваЭ.Р_03_Казань_Матрёшки.mws

Murtazin Shamil, 6th grade

Simulation of the animated image "Flask with bubbles"

 

FLASC_Murtazin_S.A..mw

Hello everyone,

I have a given parametric surface (u,v) -> F(u,v) where F(u,v) is a vector in R^3 and a parametrized vector field (u,v) -> G(u,v) where G(u,v) in R^3. Is it possible to plot the surface together with the vector field so that for some subset {(u_1,v_1),....,(u_n,v_n)} of the parameter set the vector G(u_i,v_i) is plotted at the surface point F(u_i,v_i) for i=1,...,n ?

If it is not directly possible to do this, is there any workaround?

1) I do not understand,

Ei(1, -ln(a-2)) for real numbers > +2

how to I convert it into this series format are there are 2 parameters ? (from https://en.wikipedia.org/wiki/Exponential_integral)

I'm aware of https://www.maplesoft.com/support/help/Maple/view.aspx?path=Ei&term=Ei

but as you can deduce I'm still having difficulties. 

2) Also In mary boas's book she only deals with Ei(x) no where can I figure out how 0.2193839344 is calculated from Ei(1,1.)?

Ei(1,1.)

0.2193839344

 

I'm trying to evaluate function like this , but  D(x) always returns 0, is  there any way to evaluate the function ? 

 

f := proc (x) options operator, arrow, function_assign; piecewise(x < 0, 3^(-(1/3)*x^2), .5*2^(5^(-x))) end proc;
R(x) := int(f(t), t = x .. x+l):
L(x) := int(f(t), t = x-l .. x):
D(x) := (R(x)-L(x))/(R(x)+L(x)):

 

why

expr:=1-3*y;
patmatch(expr, b::integer - a::integer*y,'la');

gives false but

expr:=1-3*y;
patmatch(expr, b::integer + a::integer*y,'la');

gives true?

Should one then use `+` for matching with `+` and `-`? This result was a little confusing to me. 

It is actually good that it behaves this way. Makes it easier to write the pattern (less cases to cover). But I would have expected both to return true, that is all.

I found I can start Maple itself 2 times on my windows PC. (I think my license allows max of 2, but I could be wrong).

I want to run a program which takes long time. But I want to use Maple at same time.

Which is the recommended approach:

1) Start 2 separate Maple applications. Use one to run the long program, and then I can use the second Maple for other things while the first is running)

2) Start one Maple, but set the "How should Maple handle the create of new Math engine" to "Ask me each time"

for me, choice 1 seems more safe. But thought to ask if there is something else I should consider when making which choice to pick.

Update

Found out that actually when clicking on Maple icon, I was not starting a new Maple at all. It was just starting a new worksheet using the currently running Maple ! This is confusing. With Mathematica, clicking on its icon actually starts a new complete separate Mathematica application. Not a new notebook using the currently running Mathematica.

So the question I have now is: Can one start 2 separate Maple applications on windows?  And if so, how?

How to calculate the following at point p=(xo,yo):

       n . del(u), u=u(x,y)

from the known function u, where n is the unit outward normal at p and the dot represents the dot product.

The objective is to create example PDE problems with Neumann BCs on irregular 2D domains.

Why does

MultiSeries:-series(LegendreQ(-1/2,x),x=-1))

not work?

series(LegendreQ(-1/2,x),x=-1))

seems to work, but does it give the correct result?

I actually thought there was a pole at -1.

Thx

PS: or is the cut between -1 and 1 with both logarithmic singularities?

I'm still wondering about the behaviour of MultiSeries

As an example question, I am trying to learn a method for assertaining whether a Set with a given predicate is finite or infinite.

 

For example, is $S$ infinite or finite, if it is defined as:

 

$$S={\biggl\{k \in \mathbb N:\biggl\lfloor {\frac {{k-1}}{{2}
}} \biggr\rfloor-\biggl\lfloor {\frac {{\ln(\pi^{k})}}{{\ln(10)}
}} \biggr\rfloor=0}\biggr\}$$
 

hey gauys,

I have a problem with solving an equation. How can i obtain an analytical solution for that ?rootof.mw

Thanks

 

 

is there a way  for a proc() in a parent module to call an exported proc in a child module, without having to use long form of the call    child:-child_proc() and just do child_proc()?  Here is an example

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

  B:=module()     
     export boo;
     boo:=proc()
        print("in B:-boo()");
     end proc;
  end module;
  
  foo:=proc()
     B:-boo();  #how can one just type  boo() here?
  end proc;
end module;

B:-foo(); now works ok. But I'd like to just use  boo() and not B:-boo() since the name of the child module is too long. 

I can't figure how to do it. I can't use with(B) in the parent, Maple complains. 

 

First 798 799 800 801 802 803 804 Last Page 800 of 2217