MaplePrimes Questions

I just noticed something funny. If I use the left side tool of Maple to define a matrix with zero entries and then change some entries and take determinant, then Maple treats zeros as symbold!!!! If I have to define my matrix completely myself, then what is the use of this tool?

Basic question on Maple scoping, having hard time finding it doing search.

I noticed when I do this

get_plot:= proc()     
    plot(sin(x),x=-Pi..Pi);
end proc:

Maple did not complain that `x` inside the proc() was implicitly declared. So this tells me that `x` is set local in scope to the body of the plot() itself and this is done automatically. right?  This is same as in Mathematica actually.

But when I did this

get_plot := proc()  
    local x; 
    x:=10;     
    plot(sin(x),x=-Pi..Pi);
end proc:
get_plot();

I got an error that Error, (in plot) unexpected option: 10 = -Pi .. Pi. So my theory was wrong.

While in Mathematica, one can do the above and it will work

getPlot[]:=Module[{x},
  x=10;
  Plot[Sin[x],{x,0,10}]
];
getPlot[]

It works, becuase the x inside plot have local scope for the Plot command only and it is not the same as the x outside the plot.

But in Maple, it seems once I declared x to be local, then the plot will use that local x. 

So the question is, why did Maple not complain in the first example above that x is implicilty declared as normally happen when one does something like

foo := proc()     
    x:=10;     
end proc:

The 'x' is either local or not. which is it? Why above gives warning but not

foo:= proc() 
  plot(sin(x),x=-Pi..Pi); 
end proc:

Basically, I wanted to know if I should write like this

foo:= proc() 
  local x;
  plot(sin(x),x=-Pi..Pi); 
end proc:

or without the local x if not needed.

Ok so i have entered the code as follows for my input dialog, but I do not want to vary the size of the window, rather the size of the text window inside the dialog window that the student is prompted to enter a paragraph that is related to an algebraic expression in the adjacent container. I cannot see this option available in the help page for the maplet, so i was just wondering if there is a more appropriate choice of maplet i can use that will enable me to do this. 

> with(Maplets[Elements]); OpenCommentaryDialog := Maplet(InputDialog['ID1']("Enter comments relevant to the expression assigned for this IIRF", 'onapprove' = Shutdown(['ID1']), 'oncancel' = Shutdown(), resizable = true, width = 1000, height = 1000));
> Maplets[Display](OpenCommentaryDialog);
 

I also want the text content the student enters to be able to be passed to a data structure that stores all comments made for all expressions in the worksheet, again I was unable to find how to do this on the help page

Dear Friends, 

I would appreciate your help in resolving some issues. Let me describe my dummy code and the issues I am having. 

I want to know the proper value of two parameters beta and `ΔA` in a tripe integral function  by the NonlinearFit command.The triple integral function is complex.

The code of function is below:

int(tan(beta)^2*exp(-Pi*tan(beta)^2*((x-varepsilon)^2+(0-varsigma)^2)/eta^2)/eta^2, [eta = 22.83-sqrt((5.83+`ΔA`)^2-varepsilon^2) .. 22.83+sqrt((5.83+`ΔA`)^2-varepsilon^2), varepsilon = -5.83-`ΔA` .. 5.83+`ΔA`, varsigma = -1 .. 1])-(int(tan(beta)^2*exp(-Pi*tan(beta)^2*((x-varepsilon)^2+(0-varsigma)^2)/eta^2)/eta^2, [eta = 22.83-sqrt(5.83^2-varepsilon^2) .. 22.83+sqrt(5.83^2-varepsilon^2), varepsilon = -5.83 .. 5.83, varsigma = -1 .. 1])) 

And this is the complete code:

datax := [-8, -4.5, -.5, 4.5, 8, 11.5, 14.5];

datay := [0.287e-2, 0.266e-2, 0.259e-2, 0.199e-2, 0.164e-2, 0.113e-2, 0.78e-3];

f := NonlinearFit(int(tan(beta)^2*exp(-Pi*tan(beta)^2*((x-varepsilon)^2+(0-varsigma)^2)/eta^2)/eta^2, [eta = 22.83-sqrt((5.83+`ΔA`)^2-varepsilon^2) .. 22.83+sqrt((5.83+`ΔA`)^2-varepsilon^2), varepsilon = -5.83-`ΔA` .. 5.83+`ΔA`, varsigma = -1 .. 1])-(int(tan(beta)^2*exp(-Pi*tan(beta)^2*((x-varepsilon)^2+(0-varsigma)^2)/eta^2)/eta^2, [eta = 22.83-sqrt(5.83^2-varepsilon^2) .. 22.83+sqrt(5.83^2-varepsilon^2), varepsilon = -5.83 .. 5.83, varsigma = -1 .. 1])), datax, datay, x)

I try to run it and get the value of parameters beta and `ΔA` ,but I keep getting this error,

Error, (in Statistics:-NonlinearFit) integration range or variable must be specified in the second argument, got HFloat(1.0) = HFloat(16.073603031200726) .. HFloat(29.58639696879927)
Does someone how to deal with this problem?

I would sincerely appreciate any inputs in this regard. 

 

Ok so as title says that is what i need, or the process of changing the document property listing that is generated when i start a new worksheet. 

 

The reason being is that of course the obvious solution is for me to have a personalized template for a worksheet with the desired attribute listing, which i have, but the trouble is i have already generated a large number of archive entries in a database or "library" of worksheets that i am building that have the standard attribute listing, and for the new functionality that i have chosen i rely on having the specific custom attribute listing for the new template, and i want to implement this functionality into use for the existing database entries as well as the future ones created, without having to copy and paste things for each of the existing entries for the obvious reason that this is boring and annoying

I've 2 equatoions that i wish to solve to get 2 values, which should be used as an input for the next step and so on,

I've managed to produce the equations, but i can't force the code to use the output of the first loop T1[1] and T2[1] into the 2nd loop and so on

It produces only equations, I'd appreciate it if anyone could tell me how to do that into an array or something similar

restart

k := 28:

Tinf := 200; -1; h := 45; -1; `Δt` := 15; -1; t_total := 150; -1; T1[0] := Tinf; -1; T2[0] := Tinf; -1; L := 0.4e-1; -1; M := 3; -1; `Δx` := L/(M-1); -1; tau := alpha*`Δt`/`Δx`^2; -1; for i from 0 to t_total/`Δt` do T1[i+1] = tau*(T0+T2[i])+(1-2*tau)*T1[i]+tau*g*`Δx`^2/k; 2*h*`Δx`*(Tinf-T2[i])/k+2*(T1[i]-T2[i])+g*`Δx`^2/k = (T2[i+1]-T2[i])/tau end do

T1[1] = 139.7321429

 

71.42857143 = 2.133333333*T2[1]-426.6666666

 

T1[2] = .4687500000*T2[1]+0.625000000e-1*T1[1]+33.48214286

 

84.28571429-2.064285714*T2[1]+2*T1[1] = 2.133333333*T2[2]-2.133333333*T2[1]

 

T1[3] = .4687500000*T2[2]+0.625000000e-1*T1[2]+33.48214286

 

84.28571429-2.064285714*T2[2]+2*T1[2] = 2.133333333*T2[3]-2.133333333*T2[2]

 

T1[4] = .4687500000*T2[3]+0.625000000e-1*T1[3]+33.48214286

 

84.28571429-2.064285714*T2[3]+2*T1[3] = 2.133333333*T2[4]-2.133333333*T2[3]

 

T1[5] = .4687500000*T2[4]+0.625000000e-1*T1[4]+33.48214286

 

84.28571429-2.064285714*T2[4]+2*T1[4] = 2.133333333*T2[5]-2.133333333*T2[4]

 

T1[6] = .4687500000*T2[5]+0.625000000e-1*T1[5]+33.48214286

 

84.28571429-2.064285714*T2[5]+2*T1[5] = 2.133333333*T2[6]-2.133333333*T2[5]

 

T1[7] = .4687500000*T2[6]+0.625000000e-1*T1[6]+33.48214286

 

84.28571429-2.064285714*T2[6]+2*T1[6] = 2.133333333*T2[7]-2.133333333*T2[6]

 

T1[8] = .4687500000*T2[7]+0.625000000e-1*T1[7]+33.48214286

 

84.28571429-2.064285714*T2[7]+2*T1[7] = 2.133333333*T2[8]-2.133333333*T2[7]

 

T1[9] = .4687500000*T2[8]+0.625000000e-1*T1[8]+33.48214286

 

84.28571429-2.064285714*T2[8]+2*T1[8] = 2.133333333*T2[9]-2.133333333*T2[8]

 

T1[10] = .4687500000*T2[9]+0.625000000e-1*T1[9]+33.48214286

 

84.28571429-2.064285714*T2[9]+2*T1[9] = 2.133333333*T2[10]-2.133333333*T2[9]

 

T1[11] = .4687500000*T2[10]+0.625000000e-1*T1[10]+33.48214286

 

84.28571429-2.064285714*T2[10]+2*T1[10] = 2.133333333*T2[11]-2.133333333*T2[10]

(1)

``


 

Download Advheat-ex55.mwAdvheat-ex55.mw

I using Maple 18 (not Maple 2018) and I'm trying to figure out how to grab earthquake data from earthquakescanada database from here http://www.earthquakescanada.nrcan.gc.ca//stndon/NEDB-BNDS/bull-en.php using the HTTP requests.

First I used the default search within the web browser, and get a new address which I enter as the URL

HTTP:-Get("http://www.earthquakescanada.nrcan.gc.ca//stndon/NEDB-BNDS/bull-en.php?time_start=2018%2F04%2F23+22%3A47%3A00&time_end=2018%2F05%2F23+22%3A47%3A00&depth_min=0&depth_max=100&mag_min=-3&mag_max=9.9&shape_type=region&radius_center_lat=50&radius_center_lon=-95&radius_radius=1000&region_north=90&region_south=41&region_east=-40&region_west=-150&eq_type_L=1&display_list=1&list_sort=date&list_order=a&tpl_output=html&submited=1"

It takes a long time to download the information and would require HTML surgery but changing the option for output to txt or csv, it's faster and in a much more readable form.  However it's not in a table or Array format, it has become a string.

Is there any way to use ImportMatrix, or ImportData to get a better format of the information?  - both give errors in Maple18.  Or am I stuck trying to use string surgery in Maple 18?  The Import command isn't available until Maple 2016 (I don't mean the Import command within ExcelTools) and I believe that works in Maple 2018 however I'm at a loss for trying to use it in Maple 18. 

I need some help. I'm trying to solve this system of equations, but maple says the solutions may have been lost.

I don't know why. Here are the equations:

I have four equations,very unknown variables in the equation.

I am trying to solve for any 4 unknowns ,not must had be Zoo1.Zoo2.th1.th2,it can be Za1.Za2.Zb1.Zb2.  

Any help  would be greatly appreciated.

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 = ?

First 821 822 823 824 825 826 827 Last Page 823 of 2429