Kitonum

21550 Reputation

26 Badges

17 years, 125 days

MaplePrimes Activity


These are answers submitted by Kitonum

restart;

Sys:=[x1*a+x2*b+x3*c+x4*d=0,

y1*a+y2*b+y3*c+y4*d=0,

z1*a+z2*b+z3*c+z4*d=0,

t1*a+t2*b+t3*c+t4*d=0];

Var:=[a,b,c,d];

(A, v) := LinearAlgebra[GenerateMatrix]( Sys, Var );

A . Vector(Var) = v;  # Your system in matrix form

 

Addition: If you want to prevent the immediate calculation of the left (for example, for presentation) you can write as follows. On subsequent calls the calculation will be done:

subs(X=A, X.Vector(Var) = v);

%;

                

 

 

1) Your task is equivalent to the problem of extraction coefficients of a multivariate polynomial. First, you generate the list of all key variables (the list [C] as Rouben wrote).  But no need to write  u^k, just write  u  in the Rouben's code for  C.

2) If you need to get the coefficient of the specific monomial (monomial is the product of the key variables in some degrees), the following simple procedure can help you. Procedure  coefff returns the coefficient of the monomial  t  in the multivariate polynomial  P  (parameter  T  is the list of the key variables):

coefff:=proc(P,T,t)

local L,H,i,k:

L:=[coeffs(P,T,'h')]: H:=[h]: k:=0:

for i from 1 to nops(H) do

if H[i]=t then k:=L[i] fi:

od:

k;

end proc:

 

Example of use:

coefff(a*u[x]^2+b*u[x]*u[y]+c*u*u[y]^2, [u,u[x],u[y]], u[x]*u[y]);
                                                     b

Two methods of the example :

A:=<x,x^2; x^3,x^4>; B:=<cos(x),-sin(x); sin(x),cos(x)>;

C:=(A^+).B;

C1:=map(diff,C,x);  # Direct elementwise differentiation

C2:=map(diff,A^+,x).B + (A^+).map(diff,B,x);  # Differentiation by OP's formula

 

 

A^+  is a transposed matrix to  .

 

Addition:  In recent versions Maple, you can use a more compact syntax:

C1:=diff~(C,x);

1) Probably for input of indexed variables you used the second of the two options in the palette "Expression" of Maple 2015. Under this Maple considers 1 as a symbol, and not as an integer. Therefore, use the left variant or type  x[1] .

In example the left x[1] was typed as yours (see output (18)):

 

2) In your formula (7) there is a premature calculation. As a workaround use quotes:

        

 

 Correction: If you properly inputted indexed  variables, you can not use quotation marks, because when setting a function by an arrow the calculation  occurs at call:

          

 Here is the file:

Question1.mw

 

What are you going to calculate, called the directional derivative. The direction vector must be specified as a list whose number of elements must equal the number of variables, that is 3, and the elements of this vector should be numbers or symbols that are not dependent on x, y, z .

Example:

restart;

with(Student[MultivariateCalculus]):

f:= x*y*z + 3*x^2*y*z;

v:= [a, b, c];

DirectionalDerivative(f, [x,y,z], v );

          

 

 

See help on  DirectionalDerivative  command

nops  command  returns the number of members of the sequence (the number of operands of the first level) after the command op   .

See

op(10*x^2);  # operands of the first level

                     10,  x^2

 

See the help on  op  and  nops  commands.

 

restart;
f:=exp(-I*Im(s)*(t));  # I is iota, s is a complex number and t is time.

evalc(f) assuming s::complex, t::realcons;

                           cos(Im(s)*t)-I*sin(Im(s)*t)

 

In Maple  I  is the imaginary unit.

Perhaps this example will help you:

 

eliminate({x^3+3*y^2=7, x^4-y^5=1}, y);

[{y = -(9*x^4-9)/(-x^6+14*x^3-49)}, {x^15-35*x^12+490*x^9+243*x^8-3430*x^6-486*x^4+12005*x^3-16564}]

 

sol := solve([x-y = 10, x+y < 100], [x,y]);

[convert(convert(op(sol)[1],RealRange),relation), op(sol)[2]];  # All solutions

                                              sol := [[x < 55, y = x-10]]

                                      [And(-infinity <= x,x < 55), y = x-10]

 

The variable x  in   [And(-infinity <= x,x < 55), y = x-10]  serves as a parameter.

 

 Addition:  Geometrically the set of all the solutions of your system  is a ray (half-line):

plot([x,x-10, x=-10..55], color=red, thickness=3, view=[-10..65, -20..55]);

                       

 

 

B:=proc(m,n)

if n=1 then B(m,n):=omega(m) else 

B(m,n):=add(omega(j)*B(m-j,n-1),j=1..m-1)

end if;

end proc:

 

Examples of use:

B(1,1),  B(2,1),  B(3,2),  B(2,3);

               omega(1), omega(2), 2*omega(1)*omega(2), 0

 

Edit.  sum  command has been replaced by  add  command.

Or use exact arithmetic:

restart;

t0 := 2000:  P0 := 100:  m := 9/50:

dsolve({P(t0) = P0, diff(P(t), t) = b*P(t)+m*t});

P := unapply(rhs(%), t);

fsolve(P(2001) = 2*P0);

plot(eval(P(t), b = convert(%, fraction)), t = 2000 .. 2001);

           

 

 

 

Add to your equation additional equation  diff(x(t),t,t)=y(t)  and another initial condition that is easy to find from the original equation.

An example:

sol:=dsolve({diff(x(t),t,t)-diff(x(t),t)=1+t^2+x(t)^(3/2), diff(x(t),t,t)=y(t), x(0)=0, y(0)=1, D(x)(0)=0}, numeric):

 

Use of  sol :

sol(0.5);

x:=t->rhs(sol(t)[2]):

D(x):=t->rhs(sol(t)[3]):

(D@@2)(x):=t->rhs(sol(t)[4]):

x(0.5),  D(x)(0.5),  (D@@2)(x)(0.5);

 

 

 

Maple 2015.1 automatically sorts as you want:

f[1]:=[1,3,2]:

f[2]:=[2,1,3]:

f[3]:=[1,2,3]:

f[4]:=[2,3,1]:

f[5]:=[3,2,1]:

f[6]:=[3,1,2]:

sort([seq(f[i], i=1..6)]);

                     [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]

If you need many times  use the components of your inequalities, you can define the new functions:

h:=(s,t)->f(s,g(s,t))+f(g(s,t),t):  

p:=(s,t)->f(g(s,t),g(s,t)):  

q:=(s,t)->f(s, g(s,t)):  

u:=(s,t)->f(g(s,t),t):  

w:=(s,t)->g(f(s,t), t):

 

Then the inequalities can be written more compactly:

h(x,y)>=p(x,y);

2*q(x,y)>=u(x,y);

2*q(x,y)>= w(x,y);

q(x,y)^2>=u(x,y);

       

 

 

 

 

 

You operate with matrices whose elements are also matrices. When you multiply these objects, Maple does not understand that the individual elements of these objects should also be multiplied as matrices. Workaroud is that probably you should write this multiplication explicitly

See an example and a workaround:

A:=Matrix(2,{(1,1)=Matrix([[1,2],[3,0]]),(1,2)=Matrix([[-1,0],[1,3]]),(2,1)=Matrix([[1,2],[4,0]]),(2,2)=Matrix([[-1,0],[1,5]])});

B:=A^2;  # Maple does not know what to do next

B1:=Matrix(2, (i,j)->add(A[i,p].A[p,j],p=1..2));  # A workaround

 

 

 

First 207 208 209 210 211 212 213 Last Page 209 of 290