Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

e1 := (1-u__1)*lambda__M*S__H-alpha__M*E__M-mu*E__M;
e2 := alpha__M*E__M-eta*lambda__T*I__M-I*(a*u__2+kappa__1)-(delta__M+mu)*I__M;
e3 := eta*lambda__T*I__M-varphi__T*`I__MET `-(delta__M+mu)*I__MET;
e4 := -E__T*mu-E__T*alpha__T+S__H*lambda__T;
e5 := alpha__T*E__T+(a__2*u__2+c__3*u__4)*I__TM-varphi*lambda__M*I__T-(c*u__4+kappa__2)*I__T-(delta__T+mu)*I__T;
e6 := varphi*lambda__M*I__T-epsilon__M*I__TEM-(delta__T+mu)*I__TEM;
e7 := varphi__T*I__MET-epsilon__T*L__MT-(delta__T+mu)*L__MT;
e8 := epsilon__T*L__MT+epsilon__T*I__TEM-(a__2*u__2+c__3*u__4+kappa__3)*I__TM-(delta__TM+mu)*I__TM;
e9 := lambda__V*S__V-alpha__V*E__V-(b__1*u__1+d*u__3+mu__V)*E__V;
e10 := alpha__V*E__V-(b__1*u__1+d*u__3+mu*v)*E__V;
 

    /  /                                                    0.5
    |  |/         2                                        \   
 int\x \\D(c[2]) x  + 2 c[2] D(x) x + D(c[1]) x + c[1] D(x)/   

                                              \            \
            2             2                1.5|            |
    + c[2] x  + c[1] x - x  - 1.504505556 x   /, x = 0 .. 1/
   /   /                                                    0.5
   | 2 |/         2                                        \   
int\x  \\D(c[2]) x  + 2 c[2] D(x) x + D(c[1]) x + c[1] D(x)/   

                                             \            \
           2             2                1.5|            |
   + c[2] x  + c[1] x - x  - 1.504505556 x   /, x = 0 .. 1/
 

Пример02.mws

for example,i have already got the odeplot of function m(t),n(t).  And now i want to use the value of m(t) to calculate function x(t),y(t).

eq1:=diff(x(t),t)=m(t)*cos(y(t))-n(t)*sin(y(t));  #The function of x(t):

eq2:=diff(y(t),t)=m(t)*sin(y(t))+n(t)*cos(y(t));  #The function y(t):

inc:=x(0)=1;y(0)=2;

dsolve({eq1,eq2,inc},[x(t),y(t)],numeric);

but i got an Error

Error, (in dsolve/numeric/process_input) unknown m present in ODE system is not a specified dependent variable or evaluatable procedure.

But before this i have already got the odeplot of function m(t) and n(t),how can i solve this problem?

Hi,

I naively thought that
f := t -> Some expression containing t
and
f := unapply(Some expression containing t, t)
where two different ways to define the same function f.

 

Recently I defined f and g this way
X := RandomVariable(Normal(m, s)):
U := Sample(X, 30000) ;  
f := t -> PDF(X, t);
g := unapply(PDF(X, t), t);

Could you explain me why f~(U) exectues in about 10 seconds and g~(U) in less than 0.1 s ?

Thanks in advance

 

 

In Mathematica, one can define a function 2 ways. Using delayed evaluation of its RHS (which is same as proc() in Maple) but also as immediate evaulation of its RHS.

In the immediate evaluation, what happens is that the RHS is evaulated first using normal evaluations, then the result of this evaluation becomes the new body of the function.

This can be very useful sometimes. For examle, if the RHS was a complicated integral, which can be evaluated immediatly and gives a result, which still depends on a parameter to fully evaluate, then this method saves having it to evaluate the full integral each time as with the case of delayed evaluation.

I do not know how to emulate immediate evaluation, but using a proc() in Maple. Here is a simple example to explain.

restart;
foo:=proc(n::integer)
     local r;
     r:=int(x*sin(n*x),x=0..Pi);
     r;
end proc;

(ps. I added the extra `r` there just for debuging. They are not needed)

Now when doing foo(3), then the integral will have to be computed each time for each `n`.

But If the integral was evaluated at time of the function definition, it will have the result of -(-1)^n*Pi/n and now when the function is called, then it will be much faster, since in effect the calling the function would be as if one typed

restart;
foo:=proc(n::integer)
     local r;
     r:=-(-1)^n*Pi/n;
     r;
end proc;

In Mathematica, I can do the above by defining a function using `=` instead of the delayed `:=`

foo[n] = Assuming[Element[n, Integers], Integrate[x Sin[n*x], {x, 0, Pi}]]

Now when I do f[3], it will actually use -(-1)^n*Pi/n as the body of the function since the RHS side of the function was evaluated immediatly at time the function was defined. This saves having to do the integral each time.

To make it work like in Maple, the one must make it delayed, like this

foo[n] := Assuming[Element[n, Integers], Integrate[x Sin[n*x], {x, 0, Pi}]]

How can one emulate the immediate evaluation of a proc() in Maple? If not the whole body, but may be a statment? as if one can do

restart; foo:=proc(n::integer) 
      local r; 
      r:=eval_now(int(x*sin(n*x),x=0..Pi)); #result of int is used in definition
      r; 
end proc;

so that the body of the proc will be evaluated as much as possible at time of definition? This can be much more efficient in some cases.

I know ofocurse I could write

foo:=int(x*sin(n*x),x=0..Pi) assuming n::integer;

and then use subs() to evaluate for different `n`. But I wanted to use proc().

 

To make animations, one must generate many plots. The following are two methods I know about. Which would be better? And is there a more efficient way than any of these?

This one pre-allocates an Array of the correct size needed, then fills it in in the loop. But then one has to convert the whole Array back to a list in order to animate it

restart;
nFrames := 10:
frames  := Array([seq(0,i=1..nFrames)]):
w       := 0:
for i from 1 to nFrames do
      frames[i] := plot(sin(w*t),t=-2*Pi..2*Pi);
      w         := w+1;
od:
plots:-display(convert(frames,list),insequence=true);

 

This method does not need to convert an Array to a list. But it does not pre-allocate memory needed before and has to dynamically grow the list each time, which might not be efficient

restart;
nFrames :=10:
frames  := NULL:
w       := 0:
for i from 1 to nFrames do
      frames := frames , plot(sin(w*t),t=-2*Pi..2*Pi);
      w      := w+1;
od:
plots:-display(frames,insequence=true);

For very large number of frames, I am not sure which is better. It is always best to pre-allocate memory to avoid dynamic growing list, which can be costly. But on the other hand, the first method requires converting the whole Array to a list, and I was not sure if that is done in-place or if Maple will have to copy the whole thing again to make a list.

Are there better and more efficient ways to do the above?

0<X<1<Y<100<Z

and satisfy 

                 log2x+log2y+log2z=103  and

                 (1/log2x)+(1/log2​​​​​​​y)+(1/log2​​​​​​​z)=1/103

find:           xyz(x+y+z)-xy-yz-zx = ?

I am learning how to do animations in Maple, and I need to export an animation I made to animated gif file.

nTerms := 20:
lam    := evalf([BesselJZeros(0,1..nTerms)]):
c      := seq(1/lam[n]^2*BesselJ(1,lam[n]/2)/BesselJ(1,lam[n])^2,n=1..nTerms):
mySol  := proc(r,t)
   local n;
   4/Pi*sum(c[n]*BesselJ(0,lam[n]*r)*sin(lam[n]*t),n=1..nTerms);
end proc:

maxTime := 5: (*seconds*)
delay   := 0.03:
nFrames := round(maxTime/delay):
frames  := Array([seq(0,i=1..nFrames)]):

frames  := [seq( plot3d([ r, theta, mySol(r,(i*delay)) ],
                   r      = 0..1,
                   theta  = 0..2*Pi,
                   coords = cylindrical,
                   axes   = none,                    
                   title  = sprintf("%s %3.2f %s","time ",(i*delay),"seconds")
                ),
             i=0..nFrames-1)
           ]:
plots:-display(convert(frames,list),insequence=true);

And the above makes

 

I have few questions which I could not find an answer for.

How to save the above sequence of images frames (in the list frames) to an animated gif file programmatically? Currently, I use plots:-display(frames,insequence=true); and then right-click on the screen out, select export->GIF  and this does save the file as animated file.

The problem with the above method, is that I have no control on telling Maple some options. For example, I want to control the amount of delay between each frame when it is played in the web page. I also want to tell Maple for example to play this once in the gif file.

These options are suppored in Mathematica. But I do not see how to do them in Maple. In Mathematica, given a list of frames (generted from a Plot command), which is the variable "frames" in the above Maple code, then one can do this

Export["anim.gif",frames,"DisplayDurations"->Table[.2,{Length@frames}]]

Now when loading anim.gif in a browser, the delay between each frame is 0.2 seconds. The "DisplayDurations" set the delay between each frame when played in the browser  automatically.

One can also add the option

"AnimationRepetitions" -> 1

and this will make the animation play one time in the browser when first loaded. Now Maple generated animation gif file plays continuously which I do not want to, this is even though inside the notebook, Maple says it will play "single" time. But this option does not seem to be exported to the animation gif file

 

 

Is there a way to configure these options? When I right-click, and export the animation to GIF file, I see no export options to change.

I could not use the export("anim.gif",frames)  command in Maple, the generated GIF file is not animated.

thank you

I was under the impression that if you had some a>b

then evalf[i](a) would be bigger or equal to evalf[i](b) for any i, but today I stumbled upon an example where this is not the case.

a := (sqrt(5)-1)*(1/2)``

evalf(a)

.6180339890

(1)

evalf[1](a)

.5

(2)

b := .6

evalf[1](b)

.6``

(3)

``

I've either overlooked something here or I simply don't understand how the evalf command is supposed to work.
Can anybody help me out?
Also, for some reason it seems like evalf[i](a) always ends with 0, for any i larger than 1, which also seems weird to me.
 

Download Afrunding.mw

Hi,
Can somebody explain me these strange results ?

 

restart:
with(Statistics):
X := RandomVariable(Normal(1.0, 1.0)):
S := Sample(X, 10):

# naively... but it's not what I was expecting for
#                maybe a misuse of the 'normalize=truefalse' option ????
Likelihood(Normal(1.0, 1.0), S);
       # a strange answer

# 2nd way
A := Likelihood(Normal(m, 1.0), S):
evalf(subs(m=1.0, A));
   # this is the good answer
   0.004387

# third way
Likelihood(Normal(1.0, 1.0), S, 'normalize=false');
   4.48e-7    # a wrong answer

 

Thanks for your enlightenment

Please how can i obtain analytical siolution of the system of pde with maple

pde1 := diff(u(x, t), t) = (1/50)*(diff(u(x, t), x, x))+1-4*u(x, t)+u(x, t)^2*v(x, t);
pde2 := diff(v(x, t), t) = (1/50)*(diff(v(x, t), x, x))+3*u(x, t)-u(x, t)^2*v(x, t);
u(x, 0) = 1+sin(2*Pi*x), v(x, 0) = 3, u(0, t) = u(1, t) and u(1, t) = 1, v(0, t) = v(1, t) and v(1, t) = 3;

 

I am looking at the help pages, and I see Maple code using symbols never seen in Maple language before.

I tried to do ?&under to get help on this new Maple language command/symbol, but help does not show it. I read help Neutral Operators but do not understand it.

What does the following mean in plain Maple code?

And what does the following mean using Plain Maple code:

 

Could the above be written without using these `&` things?  I am having hard time understanding what the code is doing because of these. Never used them before.

These are from help on "Definition of a Structured Type in Maple"

I want to compute the following supremum of the function.

I'll write in Latex code.

I have the following term which I want to estimate:

\delta_1(\epsilon):= \sup_{|x|<100}\sup_{ 0<= t<1/\epsilon} \epsilon \cdot |\int_0^t [ f(x,\cos s , \sin s , p_0(t)+q_0(s))-g(x,t)]ds|

where p_0(t) is an unknown function that depends on t alone.

f(x,y_1,y_2,z):=x+(y_1^2)*z

g(x,t):= \lim_{T\to \infty} 1/T \int_0^T f(x,\cos s , \sin s , p_0(t)+q_0(s))ds

q_0(s):= \exp(-s)(q_0(0)+\int_0^s (h(x_0(0),\cos(r), \sin(r))-p_0(0))dr)

where h(x,y_1,y_2):=y_1^2.

Can someone lend me a hand?

Thanks!

 

Please help me to remove error from the plotting. Here I have attached a mapple file

.u_nonlinerafit.mw

I figured out what the interpolation is, but can someone please give me a reference for the publication of the person that discovered that this works thankyou. 

 


 

PolyI1 := proc (N, n) options operator, arrow; (-1)^N*(sum(n*factorial(n-1)*(-1)^k*a[k]/(factorial(n-N-1)*(n-k)*factorial(k)*factorial(N-k)), k = 0 .. N)) end proc

proc (N, n) options operator, arrow; (-1)^N*(sum(n*factorial(n-1)*(-1)^k*a[k]/(factorial(n-N-1)*(n-k)*factorial(k)*factorial(N-k)), k = 0 .. N)) end proc

(1)

PolyI2 := proc (N, n) options operator, arrow; CurveFitting[PolynomialInterpolation]([seq([k, a[k]], k = 0 .. N)], n) end proc

proc (N, n) options operator, arrow; CurveFitting[PolynomialInterpolation]([seq([k, a[k]], k = 0 .. N)], n) end proc

(2)

collect(expand(PolyI1(2, n)), n); PolyI2(2, n)

((1/2)*a[2]-a[1]+(1/2)*a[0])*n^2+(-(1/2)*a[2]+2*a[1]-(3/2)*a[0])*n+a[0]

 

((1/2)*a[2]-a[1]+(1/2)*a[0])*n^2+(-(1/2)*a[2]+2*a[1]-(3/2)*a[0])*n+a[0]

(3)

collect(expand(PolyI1(3, n)), n); PolyI2(3, n)

((1/6)*a[3]-(1/2)*a[2]+(1/2)*a[1]-(1/6)*a[0])*n^3+(-(1/2)*a[3]+a[0]-(5/2)*a[1]+2*a[2])*n^2+(-(3/2)*a[2]+(1/3)*a[3]-(11/6)*a[0]+3*a[1])*n+a[0]

 

((1/6)*a[3]-(1/2)*a[2]+(1/2)*a[1]-(1/6)*a[0])*n^3+(-(1/2)*a[3]+a[0]-(5/2)*a[1]+2*a[2])*n^2+(-(3/2)*a[2]+(1/3)*a[3]-(11/6)*a[0]+3*a[1])*n+a[0]

(4)

collect(expand(PolyI1(4, n)), n); PolyI2(4, n)

(-(1/6)*a[1]+(1/4)*a[2]-(1/6)*a[3]+(1/24)*a[0]+(1/24)*a[4])*n^4+(-(5/12)*a[0]+(3/2)*a[1]-2*a[2]+(7/6)*a[3]-(1/4)*a[4])*n^3+((35/24)*a[0]-(13/3)*a[1]+(19/4)*a[2]-(7/3)*a[3]+(11/24)*a[4])*n^2+(-(25/12)*a[0]-(1/4)*a[4]+4*a[1]-3*a[2]+(4/3)*a[3])*n+a[0]

 

(-(1/6)*a[1]+(1/4)*a[2]-(1/6)*a[3]+(1/24)*a[0]+(1/24)*a[4])*n^4+(-(5/12)*a[0]+(3/2)*a[1]-2*a[2]+(7/6)*a[3]-(1/4)*a[4])*n^3+((35/24)*a[0]-(13/3)*a[1]+(19/4)*a[2]-(7/3)*a[3]+(11/24)*a[4])*n^2+(-(25/12)*a[0]-(1/4)*a[4]+4*a[1]-3*a[2]+(4/3)*a[3])*n+a[0]

(5)

collect(expand(PolyI1(5, n)), n); PolyI2(5, n)

((1/12)*a[3]-(1/120)*a[0]+(1/24)*a[1]-(1/12)*a[2]-(1/24)*a[4]+(1/120)*a[5])*n^5+(-a[3]+(11/24)*a[4]+(1/8)*a[0]-(7/12)*a[1]+(13/12)*a[2]-(1/12)*a[5])*n^4+((49/12)*a[3]-(41/24)*a[4]+(7/24)*a[5]-(17/24)*a[0]+(71/24)*a[1]-(59/12)*a[2])*n^3+((15/8)*a[0]-(13/2)*a[3]+(61/24)*a[4]-(5/12)*a[5]-(77/12)*a[1]+(107/12)*a[2])*n^2+(-(137/60)*a[0]+5*a[1]+(10/3)*a[3]-(5/4)*a[4]+(1/5)*a[5]-5*a[2])*n+a[0]

 

((1/12)*a[3]-(1/120)*a[0]+(1/24)*a[1]-(1/12)*a[2]-(1/24)*a[4]+(1/120)*a[5])*n^5+(-a[3]+(11/24)*a[4]+(1/8)*a[0]-(7/12)*a[1]+(13/12)*a[2]-(1/12)*a[5])*n^4+((49/12)*a[3]-(41/24)*a[4]+(7/24)*a[5]-(17/24)*a[0]+(71/24)*a[1]-(59/12)*a[2])*n^3+((15/8)*a[0]-(13/2)*a[3]+(61/24)*a[4]-(5/12)*a[5]-(77/12)*a[1]+(107/12)*a[2])*n^2+(-(137/60)*a[0]+5*a[1]+(10/3)*a[3]-(5/4)*a[4]+(1/5)*a[5]-5*a[2])*n+a[0]

(6)

NULL


 

Download 21052018002.mw

First 806 807 808 809 810 811 812 Last Page 808 of 2217