MaplePrimes Questions

 

Sum of -(2*((-1)^n-1))*sin(n*Pi*x)*exp(-Pi^2*n^2*t)/(Pi*n) from n=20??? Thank you very much

I try to use command "for a in 1,2 do Tangent(f, x = a) end do" in my Maplet but it does not work. 

Here it is:

 [Button("Tangent line", Action( Evaluate(for a in 'solve(diff(func, x) = slp, x)' do 'MMLV1'='MathML[Export]('y'=Tangent(func,x=a))' end do)))],

 

And here is all code for my Maplet

> restart:with(Maplets[Elements]):with(Student[Calculus1]):  TL2:=Maplet([ ["Input function  f(x)=", TextField['func'](20)],[Button("Display function",Action(Evaluate('MMLV'='MathML[Export](func)')))],MathMLViewer['MMLV'](), ["Input slope", TextField['slp'](10)],  [Button("Tangent line", Action( Evaluate(for a in 'solve(diff(func, x) = slp, x)' do 'MMLV1'='MathML[Export]('y'=Tangent(func,x=a))' end do)))],   MathMLViewer['MMLV1']()   ]):  Maplets[Display](TL2):
print(`output redirected...`); # input placeholder

I am trying to create an array whose elements are from another matrix. Suppose I have a matrix of n cross m dimension my array will have a dimension of 1 cross n*m. When I create  array I am getting error. The array contains only last element of matrix. The expected answer is given in attachment.

sigma.mw

Suppose there is a list with edges (L1): [{3,5},{4,3},{4,6},{3,2},{2,6}] and a list with vertices (L2): [1,5,4].

I would like to get a true-statement when a number of L2 appears in one of the edges of L1.

I tried the following:

for i in L1 do

ME:=member(i,L2):
print(ME):

od: 

This only gives false-statements. Could anyone help me?

I found a case where pdetest fails when called after another call to pdetest. I am using Physics version 272 from the clould. Using Maple 2018.2.1 on windows 10

restart;
u:='u';x:='x';t:='t';
pde := diff(u(x, t), t) + diff(u(x, t),x) =0;
sol:=pdsolve(pde,u(x,t));
pdetest(sol,pde);
    #0  OK
   
#restart;
u:='u';x:='x';t:='t';
pde:=diff(u(x,t),t)+diff(u(x,t),x)=0;
bc:=u(0,t)=0;
ic:=u(x,0)=sin(x);
sol:=pdsolve([pde,ic,bc],u(x,t)) assuming x>0;
pdetest(sol,pde);
   
     #sol := u(x, t) = -sin(-x+t)*Heaviside(-t+x)   #OK
     
     #-Dirac(-t+x)*sin(x)*cos(t)+Dirac(-t+x)*cos(x)*sin(t)+
      Dirac(-x+t)*sin(x)*cos(t)-Dirac(-x+t)*cos(x)*sin(t)   #WRONG should be 0
 

 

If I run the above again, but with restart call in between active, so that all is cleared, then pdetest gives 0 as expected on the second pde, with the same solution

 

restart;
u:='u';x:='x';t:='t';
pde := diff(u(x, t), t) + diff(u(x, t),x) =0;
sol:=pdsolve(pde,u(x,t));
pdetest(sol,pde);
   #0   #OK
   
restart;
u:='u';x:='x';t:='t';
pde:=diff(u(x,t),t)+diff(u(x,t),x)=0;
bc:=u(0,t)=0;
ic:=u(x,0)=sin(x);
sol:=pdsolve([pde,ic,bc],u(x,t)) assuming x>0;
pdetest(sol,pde);
   
   #0   #OK !! 

can any one explain why this happens?  Is this a bug? It seems like pdetest caching problem. it remembers something from the last call and this affects the result it gives for the next call.

any work around?

Another GCD attempt. Why is there a parse problem? Thanks


 

``

``

restart

"proc GCD3:=proc(n1,n2)    local r, a,b;    a:=n1; b:= n2;    while (a mod b) >0  do       r:=a mod b;      a:=b;      b:=r;   end do;    return b;  end proc;  "

Error, unable to parse

"proc GCD3:=proc(n1,n2)   local r, a,b;  a:=n1; b:= n2;    while (a mod b) >0  do  r:=a mod b;  a:=b;  b:=r;   end do;  return b;  end proc;  "

 

``


 

Download GCD3.mw

Any sugggestions gratefully received

I do know that Maple has a gcd command but I am just experimenting

GCD2.mw
 

``

``

restart

"GED2:=proc(n1 ,n2)     local a,b;     option remember;     a:=n1:b:=n2:     if b = 0 then do         return a ;    else       return GED2(b, a mod b);    end if;  end proc;"

Error, unterminated procedure

"GED2:=proc(n1 ,n2)    local a,b;     option remember;  a:=n1:b:=n2:     if b = 0 then do return a ;    else  return GED2(b, a mod b);    end if;  end proc;"

 

``


 

Download GCD2.mw

 

In an expression I have several terms with different coefficients and permutations of them say

aS+bc + bS+cS- + cb + others etc

I want to order them the way I want, like, say

abcS+ + bcS+cS- +bc  etc

How can I do this?

Happy New Year!

 

I solve ode for simply DC motor system:

J:= 0.01;b:=0.1;K:= 0.01;R:=1;L:=1;
eq1:=J*diff(theta(t),t,t)+b*diff(theta(t),t)=K*i(t):
eq2:=L*diff(i(t),t)+R*i(t)=V-K*diff(theta(t),t):

ICs:= theta(0)=0, D(theta)(0) = 0, D(theta)(0) = 0, i(0) = 0:
sol:=dsolve({eq1,eq2,ICs},numeric,parameters=[V],output=listprocedure):
sol(parameters=[10]):
ode_x1:=sol[2];
ode_x1:=rhs(ode_x1);
ode_x2:=sol[3];
ode_x2:=rhs(ode_x2);

p1:=plot([ode_x1(t),ode_x2(t)],t=0..50,gridlines=true):
plots[display](array([p1]));

I have time wektor and input wektor V in csv file. How to change this code to simulate 

ode solution ode_x1 and ode_x2 with data from file? Now I set V as 

sol(parameters=[10])

and t in 

plot([ode_x1(t),ode_x2(t)],t=0..50,gridlines=true)

Best

Hello everybody.

This is my question. I tried to evaluate a list of polynomial over a list of values. Something like this:

eval([a*x, b*x], x = [p, q, t])

to get something like this:

[[a*p, a*q, a*t], [b*p, b*q, b*t]]

I know this method: eval~(a*x,x=~[p,q,t])  though this works for one polynomial over a list of values. Not precisely, what I am looking for.

I figured out a method that worked defining functions and with ‘apply’ and ‘map’. Here an example:

m:=t->3*2^t:

n:=t->(t+4)^2:

map(apply~,[m,n],[1,2,3]);

[[6, 12, 24], [25, 72, 147]]

However, how can I get this result using the ‘eval’ function.

Thank you all in advanced for any contribution.

restart; _local(gamma); _local(GAMMA); _local(Pi); _local(pi); _local(I); _local(D);
                               I
Warning, The imaginary unit, I, has been renamed _I
b := .45; mu[t] := 1.112; delta := .181; rho := 0.2e-1; beta[k] := .123; sigma := 0.9e-1; alpha := 0.312e-1; gamma := 0.14e-2; phi := .24; xi := .134; A[h] := .576; k[1] := 0.1e-2; beta[c] := 0.1e-1; mu[c] := 0.19e-2; eta := .557; z := .636; phi[c] := 0.57e-1;
                              0.45
                             1.112
                             0.181
                              0.02
                             0.123
                              0.09
                             0.0312
                             0.0014
                              0.24
                             0.134
                             0.576
                             0.001
                              0.01
                             0.0019
                             0.557
                             0.636
                             0.057
ODE1 := diff(B(T), T) = rho*b-mu[t]*B(T)-delta*B(T);
                  d                            
                 --- B(T) = 0.0090 - 1.293 B(T)
                  dT                           
ODE2 := diff(C(T), T) = delta*B(T)-mu[t]*C(T)+1-rho*b-beta[k]*C(T)*H(T)+sigma*C(T);
  d                                                           
 --- C(T) = 0.181 B(T) - 1.022 C(T) + 0.9910 - 0.123 C(T) H(T)
  dT                                                          
ODE3 := diff(D(T), T) = beta[k]*C(T)*H(T)-(mu[t]+alpha+gamma)*C(T)-phi*C(T);
       d                                                 
      --- D(T) = 0.123 C(T) H(T) - 1.1446 C(T) - phi C(T)
       dT                                                
ODE4 := diff(E(T), T) = alpha*D(T)-xi*E(T)-mu[t]*E(T);
               d                                 
              --- E(T) = 0.0312 D(T) - 1.246 E(T)
               dT                                
ODE5 := diff(F(T), T) = phi*D(T)+xi*E(T)-mu[t]*F(T)-sigma*C(T);
    d                                                       
   --- F(T) = phi D(T) + 0.134 E(T) - 1.112 F(T) - 0.09 C(T)
    dT                                                      
ODE6 := diff(G(T), T) = (1-k[1])*A[h]-beta[c]*G(T)*H(T)-mu[c]*H(T)-eta*J(T);
 d                                                             
--- G(T) = 0.575424 - 0.01 G(T) H(T) - 0.0019 H(T) - 0.557 J(T)
 dT                                                            
ODE7 := diff(H(T), T) = k[1]*A[h]+beta[c]*G(T)*H(T)-mu[c]*H(T)-z*H(T);
        d                                                
       --- H(T) = 0.000576 + 0.01 G(T) H(T) - 0.6379 H(T)
        dT                                               
ODE8 := diff(J(T), T) = z*H(T)-(phi[c]+eta)*J(T);
                d                                
               --- J(T) = 0.636 H(T) - 0.614 J(T)
                dT                               
ans := dsolve({ODE1, ODE2, ODE3, ODE4, ODE5, ODE6, ODE7, ODE8, B(0) = B0, C(0) = C0, D(0) = D0, E(0) = E0, F(0) = F0, G(0) = G0, H(0) = H0, J(0) = J0}, numeric, output = listprocedure);
Warning, The use of global variables in numerical ODE problems is deprecated, and will be removed in a future release. Use the 'parameters' argument instead (see ?dsolve,numeric,parameters)
    [T = proc(T)  ...  end;, B(T) = proc(T)  ...  end;,

      C(T) = proc(T)  ...  end;, D(T) = proc(T)  ...  end;,

      E(T) = proc(T)  ...  end;, F(T) = proc(T)  ...  end;,

      G(T) = proc(T)  ...  end;, H(T) = proc(T)  ...  end;,

      J(T) = proc(T)  ...  end;]
B0 := 100; C0 := 90; D0 := 45; E0 := 38; F0 := 100; G0 := 45; H0 := 50; J0 := 20;
                              100
                               90
                               45
                               38
                              100
                               45
                               50
                               20
ans := dsolve([ODE1, ODE2, ODE3, ODE4, ODE5, ODE6, ODE7, ODE8, B(0) = B0, C(0) = C0, D(0) = D0, E(0) = E0, F(0) = F0, G(0) = G0, H(0) = H0, J(0) = J0], numeric, output = listprocedure);
Error, (in f) unable to store 'HFloat(450.486)-HFloat(90.0)*phi' when datatype=float[8]

 

im trying to input this variable with value structure

> xxx := x[2, 0], x[2, 1], x[2, 2], x[1, 0], x[1, 1]

check the type

> whattype(xxx);
exprseq

but when i try to use Get tools from maplets package, its give me error

> xxx:=Get`('xxx1'::exprseq)
invalid argument(s): xxx1::exprseq

is it possible to passing exprseq from maplet input into procedure?
or is there another way to input it (xxx) ?

You are please to check maple file:    robust_rev1.mw



case close, many thanks @tomleslie and @vv

Might be a beginners trap...

How can I evaluate a constant expression or an expression/formula that contains several scientific constants without "Constantin'g' them out like in sample 2)??

1) Example:

Rb := (1/4)*alpha/(Pi*R[infinity])

'real' value of (Rb)??

1) This example works:

evalf(1-Constant(m[e])/Constant(m[p])) -- but it's awful with respect to the simple demand to just divide two known constants..

Can someone explain why it would be reported that degree(0,x)=-infinity, ldegree(0,x)=infinity;
How are these used in an argument?

Hi guys,

I have a formula such as f(x)=X^2

I want that the software ask value for x and then show the result of f(x)

thanks for any help.

First 615 616 617 618 619 620 621 Last Page 617 of 2308