Kitonum

21460 Reputation

26 Badges

17 years, 47 days

MaplePrimes Activity


These are answers submitted by Kitonum

restart;
Z:=Vector[row](5, {(1) = z, (2) = z-2, (3) = z-4, (4) = z-6, (5) = z-8}):
k:=4:
Test := proc()
local i, j; 
global CC, Testna, Z, k:
for i from 1 to 3 do 
for j from 1 to 3 do
CC[i,j] := add(Testna[i,j+(n-1)*3]*(Z[n]-Z[n+1]), n=1..k);
end do;
end do;
Matrix(3, (i,j)->CC[i,j]);
end proc:


Example of use:

interface(rtablesize=infinity):
Testna := LinearAlgebra:-RandomMatrix(3, 12);
Test();

You can easily do this with a simple procedure with two formal parameters: one of them is a numerical constant, and the other is a certain range:

P:=proc(a::{numeric,range}, b::{numeric,range})
uses plots;
if a::numeric then
animate( plot, [a*sin(B*x), x=0..10, scaling=constrained], B=b, size=[1000,400]) else
animate( plot, [A*sin(b*x), x=0..10, scaling=constrained], A=a, size=[1000,400]) fi;
end proc:


Examples of use:

P(0.5, 1..2);
P(1..2, 0.5);

 

For a single use you can use single quotes around the external  diff  to get a delayed calculation:

restart;
eq:=1/r*'diff'(r*diff(f(r), r), r);
                                 


On a subsequent call,  eq  will be calculated.

Use  Explore  command for this.

Example:

Explore(plot(a*sin(b*x+c),x=0..2*Pi, scaling=constrained, view=[0..2*Pi,-2..2]), parameters=[a=0.5..2, b=0.5..2, c=0..Pi/2]); 

 

I replaced  pi  with  Pi  in your code and added the option  explicit in the last line.

Cond_Poincare_new.mw

 

I ran your code, but I could not wait for any result. It seems that Maple simply hangs on this example.
Perhaps you are not interested in the general symbolic solution, but about the existence of solutions or finding a finite set of solutions. It is easy to do this by a routine search in nested loops. The code below finds about 80,000 solutions in 1 minute:

restart;
k:=0:
for Q from 0.1 to 2 by 0.1 do
for delta from 0.1 to 2 by 0.1 do
for t from 0.1 to 2 by 0.1 do
for E[0] from 0.1 to 2 by 0.1 do
for lambda[1] from 0.1 to 2 by 0.1 do
if 0 < (lambda[1]^2*(Q+2*t+4*delta-4*E[0])+lambda[1]*(Q+2*t+3*delta-7*E[0])-3*E[0])/((lambda[1]^2-6*lambda[1]-6)*t) and Q < -(3*delta*lambda[1]+2*t*lambda[1]-4*E[0]*lambda[1]+6*delta-3*E[0])/lambda[1] and delta < E[0]*(4*lambda[1]+3)/(3*(lambda[1]+2)) and t < -(3*delta*lambda[1]-4*E[0]*lambda[1]+6*delta-3*E[0])/(2*lambda[1]) and lambda[1] < 1 and (lambda[1]^2*(Q+2*t+4*delta-4*E[0])+lambda[1]*(Q+2*t+3*delta-7*E[0])-3*E[0])/((lambda[1]^2-6*lambda[1]-6)*t) < (lambda[1]*(-2*Q-4*t-2*delta+3*E[0])-lambda[1]^2*delta+lambda[1]^2*E[0]+2*E[0]-2*Q-4*t)/((lambda[1]^2-6*lambda[1]-6)*t) and (lambda[1]*(-2*Q-4*t-2*delta+3*E[0])-lambda[1]^2*delta+lambda[1]^2*E[0]+2*E[0]-2*Q-4*t)/((lambda[1]^2-6*lambda[1]-6)*t) < 1 then 
k:=k+1; L[k]:=[Q, delta, t, E[0], lambda[1]] fi;
od: od: od: od: od:
L:=convert(L,list):
nops(L);
seq(L[i],i=1..70001,7000), L[-1];

restart;
Kx:=tau->(10+2*cos(5*tau)*cos(3*tau))*exp(-tau^2);
temp:=unapply(-(D@@2)(Kx)(tau), tau);
Dx:= temp(0);

restart;
expr:=y(x)^2+x+y(x)+2*1/y(z)+sin(x)+sin(y(x))+y+f(z)/Int(sin(y(x)),x)+y(x,y,z);
candidates:=convert(select(has,expr,y),list);
map(t->`if`(has(t,y(x)),"OK","not ok"), candidates);

 

If we use single quotes, we get a delayed calculation. Maybe it will be useful for you:

An example:

restart;
'int'(x^2, x=0..1);
Result=%;
                                          

 

Getting a list of solutions:


 

restart

k := 28; alpha := 12.5*10^(-6); T0 := 0; g := 5*10^6

Tinf := 200; h := 45; `&Delta;t` := 15; t_total := 150; Sol[0] := {T1[0] = Tinf, T2[0] = Tinf}; L := 0.4e-1; M := 3; `&Delta;x` := L/(M-1); tau := alpha*`&Delta;t`/`&Delta;x`^2; for i from 0 to t_total/`&Delta;t` do Sol[i+1] := solve(eval({T1[i+1] = tau*(T0+T2[i])+(1-2*tau)*T1[i]+tau*g*`&Delta;x`^2/k, 2*h*`&Delta;x`*(Tinf-T2[i])/k+2*(T1[i]-T2[i])+g*`&Delta;x`^2/k = (T2[i+1]-T2[i])/tau}, Sol[i])) end do; [seq(Sol[i], i = 1 .. 11)]

[{T1[1] = 139.7321429, T2[1] = 233.4821429}, {T1[2] = 151.6601563, T2[2] = 178.0647123}, {T1[3] = 126.4287365, T2[3] = 187.4535803}, {T1[4] = 129.2528047, T2[4] = 164.1030050}, {T1[5] = 118.4837267, T2[5] = 165.9948026}, {T1[6] = 118.6974395, T2[6] = 155.9600220}, {T1[7] = 114.0069931, T2[7] = 155.8355913}, {T1[8] = 113.6555134, T2[8] = 151.4342705}, {T1[9] = 111.5704268, T2[9] = 150.9623048}, {T1[10] = 111.2188749, T2[10] = 148.9922605}, {T1[11] = 110.2734446, T2[11] = 148.5989180}]

(1)

NULL


 

Download Advheat-ex55_new.mw

I advise you to use  plots:-animate  command to create animations rather than  plots:-display  command with the option  insequence=true . In the first case, Maple automatically generates the necessary animation frames. In most cases, this is technically easier. You specify in the code only the start and final values of the animation parameter and the number of frames (default is 25). Here is your animation by this method:

plots:-animate(plot,[sin(w*t),t=-2*Pi..2*Pi], w=0..9, frames=10);


Here is a more complex example using the same technique. The problem: create an animation that shows the trajectory of the point on the rim of the wheel if the wheel rolls evenly over the horizontal surface (this is a cycloid). First, we write a procedure that, for a parameter value (wheel rotation angle  phi ), creates one frame of the animation corresponding to turning the wheel to this angle. Then just apply  plots:-animate  command:

restart;
P:=proc(phi)
local Disk, Point, Curve, Wheel;
uses plottools, plots;
Disk:=disk([0,1], color=yellow);
Point:=disk(0.07, color=red);
Curve:=plot([s-sin(s),1-cos(s), s=0..phi], color=red, thickness=2); 
Wheel:=display(Point, Disk);
display(Curve, translate(rotate(Wheel, -phi, [0,1]), phi, 0));
end proc:

plots:-animate(P, [phi], phi=0..4*Pi, scaling=constrained, size=[1000,200], frames=60); 

Output:

We need to help Maple a little. First we make replacements: u=log[2](x), v=log[2](y), w=log[2](z) , so x=2^u, y=2^v, z=2^w . Now we can reformulate the problem: find   2^u*2^v*2^w*(2^u+2^v+2^w)-2^u*2^v-2^v*2^w-2^u*2^w  if  {u+v+w=103, 1/u+1/v+1/w=1/103} . In the second equality we add 3 fractions and obtain  (u*v+v*w+u*w)/(u*v*w)=1/103 . Thus, the numerator and the denominator can be found to within a constant factor:  u*v+v*w+u*w=ku*v*w=103*k . Next, we ask Maple to solve the resulting system for  u , v , . Further obvious:

Sol:=solve({u+v+w=103, u*v+v*w+u*w=k, u*v*w=103*k}, {u,v,w}, explicit);
{seq(expand(eval(2^u*2^v*2^w*(2^u+2^v+2^w)-2^u*2^v-2^v*2^w-2^u*2^w, t)), t={Sol})}[]; 
# The final result
         

Addition.   Already after sending my answer I noticed that everything can be done much easier by direct calculation in Maple:

Sol:=solve({log[2](x)+log[2](y)+log[2](z)=103, 1/log[2](x)+1/log[2](y)+1/log[2](z)=1/103});
{seq(eval(x*y*z*(x+y+z)-x*y-y*z-z*x, t), t=Sol)}[];
    


Your conditions correspond to the second solution of the system, if you take for example  y = 2 .


Edit.
 

Unfortunately Maple does not solve this system analytically, but it easily solves numerically.


 

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);
bcs:=u(x, 0) = 1+sin(2*Pi*x), v(x, 0) = 3, u(0, t) = 1, u(1, t) = 1, v(0, t) = 3, v(1, t) = 3;
pds:=pdsolve({pde1,pde2},{bcs}, {u(x,t),v(x,t)}, numeric);

diff(u(x, t), t) = (1/50)*(diff(diff(u(x, t), x), x))+1-4*u(x, t)+u(x, t)^2*v(x, t)

 

diff(v(x, t), t) = (1/50)*(diff(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) = 1, u(1, t) = 1, v(0, t) = 3, v(1, t) = 3

(1)

pds:-plot3d(u(x,t), x = 0 .. 1, t = 0 .. 1, axes = box);  # Example of use

 

 


 

Download pde_sys.mw

See the corrected file.

u_nonlinerafit1.mw

The first one:
ProcInserer:=(x,pos,L)->[L[1..pos-1][], x, L[pos..-1][]]:

The second one:
Inverse:=L->[seq(L[i], i=nops(L)..1, -1)]: 


Examples of use:

ProcInserer(x, 3, [1,2,3,4]);
Inverse([1,2,3,4]);

 

Addition. I did not notice at first that it was necessary to use  for  loops. Here is the same with  for  loops:

ProcInserer1:=proc(x,pos,L)
local n, i, L1;
n:=nops(L);
for i from 1 to n+1 do
if i<pos then L1[i]:=L[i] else
if i=pos then L1[i]:=x else
L1[i]:=L[i-1] fi; fi;
od;
convert(L1, list);
end proc:

Inverse1:=proc(L)
local n, i, L1;
n:=nops(L);
for i from 1 to n do
L1[i]:=L[n-i+1];
od;
convert(L1, list);
end proc:

 

 

First 117 118 119 120 121 122 123 Last Page 119 of 290