herclau

Mr. Hermes Rozsa Iglesias

1038 Reputation

13 Badges

20 years, 169 days

MaplePrimes Activity


These are replies submitted by herclau

taken from solution in use in  Dsolve2

eval(%,applyop~(apply,1,dat[2],t));

@Preben Alsholm 

 

eval(%,dat[2]) is not entirely satisfactory, as shown in the highlighted characters in bold

 deq := diff(y(t), t$2) = y(t)-x(t), diff(x(t), t) = x(t);         
init := y(0) = 1, D(y)(0) = 2, x(0) = 3:

dat:=DEtools[convertsys]({deq}, {}, {x(t), y(t)}, t,Y,YP);
 
dat := [[YP[1] = Y[1], YP[2] = Y[3], YP[3] = Y[2]-Y[1]], [Y[1] = x(t), Y[2] = y(t), Y[3] = diff(y(t), t)], undefined, []]

eq:=Dsolve(dat);
                                
dsolve(eq);   
eval(%,dat[2]);
 
{diff((y(t))(t), t) = -exp(-t)*_C2+exp(t)*_C1-(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t), (x(t))(t) = _C3*exp(t), (y(t))(t) = exp(-t)*_C2+exp(t)*_C1+(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t)}

remove(has,%,diff);    
{(x(t))(t) = _C3*exp(t), (y(t))(t) = exp(-t)*_C2+exp(t)*_C1+(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t)}

#Comparison:
dsolve({deq});  
{x(t) = _C3*exp(t), y(t) = exp(-t)*_C2+exp(t)*_C1+(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t)}

@Preben Alsholm 

 

eval(%,dat[2]) is not entirely satisfactory, as shown in the highlighted characters in bold

 deq := diff(y(t), t$2) = y(t)-x(t), diff(x(t), t) = x(t);         
init := y(0) = 1, D(y)(0) = 2, x(0) = 3:

dat:=DEtools[convertsys]({deq}, {}, {x(t), y(t)}, t,Y,YP);
 
dat := [[YP[1] = Y[1], YP[2] = Y[3], YP[3] = Y[2]-Y[1]], [Y[1] = x(t), Y[2] = y(t), Y[3] = diff(y(t), t)], undefined, []]

eq:=Dsolve(dat);
                                
dsolve(eq);   
eval(%,dat[2]);
 
{diff((y(t))(t), t) = -exp(-t)*_C2+exp(t)*_C1-(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t), (x(t))(t) = _C3*exp(t), (y(t))(t) = exp(-t)*_C2+exp(t)*_C1+(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t)}

remove(has,%,diff);    
{(x(t))(t) = _C3*exp(t), (y(t))(t) = exp(-t)*_C2+exp(t)*_C1+(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t)}

#Comparison:
dsolve({deq});  
{x(t) = _C3*exp(t), y(t) = exp(-t)*_C2+exp(t)*_C1+(1/4)*_C3*exp(t)-(1/2)*_C3*t*exp(t)}

 

Dsolve2:=proc (eqs::{list,set}(equation),ics::{list,set}(equation),vars::{set,list}(function(name)))
local t,dat,A,b,v,vi,ic,Xt,X,x,sys;
uses LinearAlgebra;
t:=op(op~(vars));
dat:=DEtools[convertsys](eqs,ics,vars,t,x);
A,b:=GenerateMatrix(rhs~(dat[1]),lhs~(dat[2]));
Xt:=applyop~(apply,1,dat[2],t);
X:=<lhs~(Xt)>;
v:=diff~(X,t)=A.X-b;
vi:=eval(X,t=dat[3])=<dat[4]>;
sys:=convert(Equate(lhs(v),rhs(v)),set) union convert(Equate(lhs(vi),rhs(vi)),set);
userinfo(2,'procname',print(v,vi));
eval(dsolve(sys,_rest),Xt);
end proc:

 

Dsolve2:=proc (eqs::{list,set}(equation),ics::{list,set}(equation),vars::{set,list}(function(name)))
local t,dat,A,b,v,vi,ic,Xt,X,x,sys;
uses LinearAlgebra;
t:=op(op~(vars));
dat:=DEtools[convertsys](eqs,ics,vars,t,x);
A,b:=GenerateMatrix(rhs~(dat[1]),lhs~(dat[2]));
Xt:=applyop~(apply,1,dat[2],t);
X:=<lhs~(Xt)>;
v:=diff~(X,t)=A.X-b;
vi:=eval(X,t=dat[3])=<dat[4]>;
sys:=convert(Equate(lhs(v),rhs(v)),set) union convert(Equate(lhs(vi),rhs(vi)),set);
userinfo(2,'procname',print(v,vi));
eval(dsolve(sys,_rest),Xt);
end proc:

 

Thanks to your instructions I developed this little Procedure. I would like to make it more independent, without the need to load "with (DEtools): with (linearalgebra)." Pending comments.
I hag problem with use LinearAlgebra[GenerateMatrix] in ...
...
Error, LinearAlgebra:-GenerateMatrix is not a module

restart;

with(DEtools): with(LinearAlgebra):
deq:=diff(u(t),t,t)+0.25*diff(u(t),t)+2*u(t)=3*sin(t):
dat:=convertsys(deq,{u(0)=2,D(u)(0)=-1},u(t), t, x, x_p):

Dsolve:=proc (Deq::list)
local dat,A,b,v,vi,ic,X:
A,b:=GenerateMatrix(rhs~(Deq[1]),lhs~(Deq[2]));
X:=<map2(apply,lhs~(Deq[2]),t)>;
v:=diff~(X,t)=A.X-b;
vi:=eval(X,t=Deq[3])=<Deq[4]>;
convert(Equate(lhs(v),rhs(v)),set) union convert(Equate(lhs(vi),rhs(vi)),set);
end proc:

cvrs:=Dsolve(dat):
f:=dsolve(cvrs,numeric,output=Array([0,0.25,0.5,0.75,1])):
g:=dsolve({deq,u(0)=2,D(u)(0)=-1},numeric,output=Array([0,0.25,0.5,0.75,1])):

Proc_ConvertSys.mw

Why am I not receiving email confirmations for subscriptions or answers?

Gracias

 

Thanks to your instructions I developed this little Procedure. I would like to make it more independent, without the need to load "with (DEtools): with (linearalgebra)." Pending comments.
I hag problem with use LinearAlgebra[GenerateMatrix] in ...
...
Error, LinearAlgebra:-GenerateMatrix is not a module

restart;

with(DEtools): with(LinearAlgebra):
deq:=diff(u(t),t,t)+0.25*diff(u(t),t)+2*u(t)=3*sin(t):
dat:=convertsys(deq,{u(0)=2,D(u)(0)=-1},u(t), t, x, x_p):

Dsolve:=proc (Deq::list)
local dat,A,b,v,vi,ic,X:
A,b:=GenerateMatrix(rhs~(Deq[1]),lhs~(Deq[2]));
X:=<map2(apply,lhs~(Deq[2]),t)>;
v:=diff~(X,t)=A.X-b;
vi:=eval(X,t=Deq[3])=<Deq[4]>;
convert(Equate(lhs(v),rhs(v)),set) union convert(Equate(lhs(vi),rhs(vi)),set);
end proc:

cvrs:=Dsolve(dat):
f:=dsolve(cvrs,numeric,output=Array([0,0.25,0.5,0.75,1])):
g:=dsolve({deq,u(0)=2,D(u)(0)=-1},numeric,output=Array([0,0.25,0.5,0.75,1])):

Proc_ConvertSys.mw

Why am I not receiving email confirmations for subscriptions or answers?

Gracias

Thank you very much, with little change ... get it searched!!

randomforce2.mw

 

GRACIAS

Thank you very much, with little change ... get it searched!!

randomforce2.mw

 

GRACIAS

A := Matrix([[10, 3, 2, 13], [5, 35, 11, 6], [8, 4, 7, 12], [24, 14, 18, 20]]);
A*~map(evalhf@isprime, A);

Another example

t:=<[$(1..7)]>:
t*~evalhf~(is~(t<~6));

How do it shorter with command Alias?

Gracias

 

A := Matrix([[10, 3, 2, 13], [5, 35, 11, 6], [8, 4, 7, 12], [24, 14, 18, 20]]);
A*~map(evalhf@isprime, A);

Another example

t:=<[$(1..7)]>:
t*~evalhf~(is~(t<~6));

How do it shorter with command Alias?

Gracias

 

Thanks for the ride.
How to color the inner surface of the graph?

plots[animate](plot3d, [[2*cos(2*Pi*r/(20.0)), 3*sin(2*Pi*r/(20.0)), cos(2*Pi*r/(10.0))*cos(2*Pi*((1/10)*t))], r = 0 .. 20, theta = 0 .. 10], t = 0 .. 20, background = Cameras, shading = zhue)

How I can I achieve the animation shown in the accompanying graph?  my attempt is far!

 

 

 

GRACIAS

Thanks for the ride.
How to color the inner surface of the graph?

plots[animate](plot3d, [[2*cos(2*Pi*r/(20.0)), 3*sin(2*Pi*r/(20.0)), cos(2*Pi*r/(10.0))*cos(2*Pi*((1/10)*t))], r = 0 .. 20, theta = 0 .. 10], t = 0 .. 20, background = Cameras, shading = zhue)

How I can I achieve the animation shown in the accompanying graph?  my attempt is far!

 

 

 

GRACIAS

Both commands return values ​​"true / false". And what is sought is to evaluate within the matrix to zero values ​​are not prime.

A := Matrix([[10, 3, 2, 13], [5, 35, 11, 6], [8, 4, 7, 12], [24, 14, 18, 20]])

map(isprime, A)

  [false, true, true, true,]
  [true, false, true, false]  
 [false, false, true, false]
 [false, false, false, false]

A(~isprime(A)) = 0

A =      0     3     2    13             
           5     0    11     0                
           0     0     7     0                
           0     0     0     0

Both commands return values ​​"true / false". And what is sought is to evaluate within the matrix to zero values ​​are not prime.

A := Matrix([[10, 3, 2, 13], [5, 35, 11, 6], [8, 4, 7, 12], [24, 14, 18, 20]])

map(isprime, A)

  [false, true, true, true,]
  [true, false, true, false]  
 [false, false, true, false]
 [false, false, false, false]

A(~isprime(A)) = 0

A =      0     3     2    13             
           5     0    11     0                
           0     0     7     0                
           0     0     0     0

2 3 4 5 6 7 8 Last Page 4 of 13