MaplePrimes Questions

InputMatrix3aa := Matrix(3, 3, {(1, 1) = xx, (1, 2) = 283.6, (1, 3) = 285.4, (2, 1) = 283.6, (2, 2) = 285.4, (2, 3) = 0, (3, 1) = 285.4, (3, 2) = 0, (3, 3) = 0});
InputMatrix3 := Matrix(3, 3, {(1, 1) = 283.6, (1, 2) = 285.4, (1, 3) = 283.0, (2, 1) = 285.4, (2, 2) = 283.0, (2, 3) = 0, (3, 1) = 283.0, (3, 2) = 0, (3, 3) = 0});
InputMatrix3b := Matrix(3, 3, {(1, 1) = 285.4, (1, 2) = 283.0, (1, 3) = 287.6, (2, 1) = 283.0, (2, 2) = 287.6, (2, 3) = 0, (3, 1) = 287.6, (3, 2) = 0, (3, 3) = 0});
InputMatrix3c := Matrix(3, 3, {(1, 1) = 283.0, (1, 2) = 287.6, (1, 3) = 296.6, (2, 1) = 287.6, (2, 2) = 296.6, (2, 3) = 0, (3, 1) = 296.6, (3, 2) = 0, (3, 3) = 0});
InputMatrix3d := Matrix(3, 3, {(1, 1) = 287.6, (1, 2) = 296.6, (1, 3) = 286.2, (2, 1) = 296.6, (2, 2) = 286.2, (2, 3) = 0, (3, 1) = 286.2, (3, 2) = 0, (3, 3) = 0});

Old_Asso_eigenvector0 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa)):
Old_Asso_eigenvector1 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3), InputMatrix3)):
Old_Asso_eigenvector2 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3b), InputMatrix3b)):
Old_Asso_eigenvector3 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3c), InputMatrix3c)):
Old_Asso_eigenvector4 := Eigenvectors(MatrixMatrixMultiply(Transpose(InputMatrix3d), InputMatrix3d)):

#AA2 := MatrixMatrixMultiply(Old_Asso_eigenvector3[2], MatrixInverse(Old_Asso_eigenvector2[2]));
#AA3 := MatrixMatrixMultiply(Old_Asso_eigenvector4[2], MatrixInverse(Old_Asso_eigenvector3[2]));

AA2 := MatrixMatrixMultiply(Old_Asso_eigenvector2[2], MatrixInverse(Old_Asso_eigenvector1[2]));
AA3 := MatrixMatrixMultiply(Old_Asso_eigenvector3[2], MatrixInverse(Old_Asso_eigenvector2[2]));

sol11 := solve([Re(AA2[1][1]) = sin(m*2+phi), Re(AA3[1][1]) = sin(m*3+phi)], [m,phi]);
if nops(sol11) > 1 then
sol11 := sol11[1];
end if:
sin(rhs(sol11[1])+rhs(sol11[2]));

sol12 := solve([Re(AA2[1][2]) = sin(m*2+phi), Re(AA3[1][2]) = sin(m*3+phi)], [m,phi]);
if nops(sol12) > 1 then
sol12 := sol12[1];
end if:
sin(rhs(sol12[1])+rhs(sol12[2]));

sol13 := solve([Re(AA2[1][3]) = sin(m*2+phi), Re(AA3[1][3]) = sin(m*3+phi)], [m,phi]);
if nops(sol13) > 1 then
sol13 := sol13[1];
end if:
sin(rhs(sol13[1])+rhs(sol13[2]));

#*************************************
sol21 := solve([Re(AA2[2][1]) = sin(m*2+phi), Re(AA3[2][1]) = sin(m*3+phi)], [m,phi]);
if nops(sol21) > 1 then
sol21 := sol21[1];
end if:
sin(rhs(sol21[1])+rhs(sol21[2]));

sol22 := solve([Re(AA2[2][2]) = sin(m*2+phi), Re(AA3[2][2]) = sin(m*3+phi)], [m,phi]);
if nops(sol22) > 1 then
sol22 := sol22[1];
end if:
sin(rhs(sol22[1])+rhs(sol22[2]));

sol23 := solve([Re(AA2[2][3]) = sin(m*2+phi), Re(AA3[2][3]) = sin(m*3+phi)], [m,phi]);
if nops(sol23) > 1 then
sol23 := sol23[1];
end if:
sin(rhs(sol23[1])+rhs(sol23[2]));

#**************************************
sol31 := solve([Re(AA2[3][1]) = sin(m*2+phi), Re(AA3[3][1]) = sin(m*3+phi)], [m,phi]);
if nops(sol31) > 1 then
sol31 := sol31[1];
end if:
sin(rhs(sol31[1])+rhs(sol31[2]));

sol32 := solve([Re(AA2[3][2]) = sin(m*2+phi), Re(AA3[3][2]) = sin(m*3+phi)], [m,phi]);
if nops(sol32) > 1 then
sol32 := sol32[1];
end if:
sin(rhs(sol32[1])+rhs(sol32[2]));

sol33 := solve([Re(AA2[3][3]) = sin(m*2+phi), Re(AA3[3][3]) = sin(m*3+phi)], [m,phi]);
if nops(sol33) > 1 then
sol33 := sol33[1];
end if:
sin(rhs(sol33[1])+rhs(sol33[2]));

#****************************************************

AAA1 := Matrix([[sin(rhs(sol11[1])+rhs(sol11[2])),sin(rhs(sol12[1])+rhs(sol12[2])),sin(rhs(sol13[1])+rhs(sol13[2]))],[sin(rhs(sol21[1])+rhs(sol21[2])),sin(rhs(sol22[1])+rhs(sol22[2])),sin(rhs(sol23[1])+rhs(sol23[2]))],[sin(rhs(sol31[1])+rhs(sol31[2])),sin(rhs(sol32[1])+rhs(sol32[2])),sin(rhs(sol33[1])+rhs(sol33[2]))]]);

MA := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - lambda*IdentityMatrix(3):
eignvalues1 := evalf(solve(Determinant(MA), lambda)):
MA1 := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - eignvalues1[1]*IdentityMatrix(3):
MA2 := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - eignvalues1[2]*IdentityMatrix(3):
MA3 := MatrixMatrixMultiply(Transpose(InputMatrix3aa), InputMatrix3aa) - eignvalues1[3]*IdentityMatrix(3):
eigenvector1 := LinearSolve(MA1,<x,y,z>):
eigenvector2 := LinearSolve(MA2,<x,y,z>):
eigenvector3 := LinearSolve(MA3,<x,y,z>):

MR := MatrixMatrixMultiply(AAA1, Matrix([[Re(eigenvector1[1]),Re(eigenvector2[1]),Re(eigenvector3[1])],[Re(eigenvector1[2]),Re(eigenvector2[2]),Re(eigenvector3[2])],[Re(eigenvector1[3]),Re(eigenvector2[3]),Re(eigenvector3[3])]]));
ML := Re(Old_Asso_eigenvector1[2]);

solve(ML[1][1] = MR[1][1], xx);
with(Optimization):
Minimize(ML[1][1] - MR[1][1], {0 <= xx}, assume = nonnegative);

Error, (in Optimization:-NLPSolve) abs is not differentiable at non-real arguments;

when one of element in matrix s variable below code is very slow

 

MA := MatrixMatrixMultiply(InputMatrix3aa - lambda*IdentityMatrix(3);
eignvalues1 := evalf(solve(Determinant(MA), lambda));
MA1 := MatrixMatrixMultiply(InputMatrix3aa - eignvalues1[1]*IdentityMatrix(3);
MA2 := MatrixMatrixMultiply(InputMatrix3aa - eignvalues1[2]*IdentityMatrix(3);
MA3 := MatrixMatrixMultiply(InputMatrix3aa - eignvalues1[3]*IdentityMatrix(3);
eignvector1 := LinearSolve(MA1,<x,y,z>);

eignvector2 := LinearSolve(MA2,<x,y,z>);

eignvector3 := LinearSolve(MA3,<x,y,z>);

Need to create a fibonacci defintiion using this form..Any help appreciated..thanks in advance

The Fibonacci numbers Fn are defined for all positive integers n as follows:

Fn = ( 1,                 n =1, 2 , )    

      (Fn−1 + Fn−2 , otherwise.)

 Complete the definition of fib so that fib(n) returns Fn for all positive integers n. You must compute Fn using the below definition! A recursive proc is most natural.

fib:=
proc(n::posint)
description "Calculate fib(n), the n'th Fibonacci number.";
option remember; # important for efficiency!
---MORE STUFF HERE---
end proc; # fib

I need to complete the definition of P km using a for loop so that km(n,m) returns n k=1 k m whenever n, m ∈ Z, n > 0, and m ≥ 0.( You must use a for loop in the variable k, with k ranging from 1 to n, to do this question in the manner requested.)

km is defined as 

km:=
proc(n::TYPE1,m::TYPE2)
description "km(n,m) returns the sum of k^m as k ranges from 1 to n.";
---MORE STUFF HERE---
end proc; # km

Not sure where tostart..Any help appreciated...thank you

Tried different ways to apply unapply but failed:

a := .1994;

modfit3 := a*x^1.5;
 
f := unapply(rhs(modfit3), x);
%;
Error, invalid input: rhs received .1994*x^1.5, which is not valid for its 1st argument, expr

What's wrong here?

S

 

Exercise: Find all the elements of order 2 in D30 .

I set the D30 group , but I do not know how to calculate and list elements of order 2 . I thought of calculating the order of all the elements ( With PermOrder () command , perhaps) , and then use the select command to select those with order of 2. But the big problem is to calculate the order of elements.

I know only calculate the order of the group. Could anyone help me ?

I'm trying to create a routine to perform the test of rational roots , but I'm having some problems. Below is the routine I created :

But the program is only printing " aux = -24 " . I don't know what it can be .

I need to modify my code , but I don't know where. Can someone help me? Thank you!

Hi Everyone,

I want to draw a 3D cylindrical object with follwoing constraint:

(1) For z=0 to 5, it should be a cylinder with radius 2 units

(2) For z = 10 to 20, it should be a cylinder with radius 8 units

(3) Connecting piece between z=5 to 10 is a type of cylinder such that its radius increses from 2 to 8 as z moves from 5 to 10.

 

I know how to draw (1) and (2) individually, but can't make a connecting object.

Can anyone help me drawing that object?

Thanks in advance.

How can I integrate the value of different k values in the plot function, instead of assigning values to k before giving the plot comman? Can't see anything about this in the help file.

staffan

 

hw2_unfinished.mw

There is something wroung with the t0.

How to correct it?

hello all!

Pascal := proc (n::posint)

local x, y, i;

 for i from 0 to n do print(coeffs(expand((x+y)^i)))

end do end proc;
Pascal(4);

   

1
1, 1
1, 2, 1
1, 3, 3, 1
1, 4, 6, 4, 1

 How to create 

         

1
1  1
1  2  1
1  3  3  1
1  4  6  4  1

 

hello everybody!

I want to create a random symmetric matrix which have det=2. I just made it like this, no better than those ones. Thanks!

Doixung := proc (n)

local A, i, j; A := Matrix(n);

n := LinearAlgebra[Dimension](A);

for i to n do A[i, i] := RandomTools[Generate](integer(range = 1 .. 20))

   end do;

for i to n do

     for j to n do

           while j < i do A[i, j] := RandomTools[Generate](integer(range = 1 .. 20)) end do;

           while i < j do A[i, j] := A[j, i] end do

     end do

end do;

print(A) end proc

Hello everbody.

Newton:=proc(p[0],TOL,N)  

 local i,p,f;   i:=1;

 while i<= N do      

     p:=p[0]-(f(p[0]))/(diff(f(p[0]),x));    

     if abs(p-p[0])<TOL then             return p;     else i:=i+1;            p[0]:=p; end if;  

end do;

printf("The method failed after N iterations,N=%d",N);  end proc:

hi all

i have this code and want to plot(NphiB1,y). but it is not plotted.

help me plz

restart:
nB0:=1:
hb:=6.63*10^(-34):
aB:=1/(3*(3*nB0*Pi^2)^(1/3)):
gB:=4*Pi*aB/mB:
xiphase:=1/sqrt(4*mB*gB*nB0):
qcB:=8.26*10^(-3)/xiphase:
qB:=y*qcB:
v1:=-gB*nB0:
v0:=4*gB*nB0:

L:=1.5*xiphase:
k2:=sqrt(qB^2+2*mB*v1):
k3:=sqrt(qB^2-2*mB*v0):
beta:=k3*L:
W:=2*cos(beta)*(qB/k2-k2/qB):
Q:=sin(beta)*(qB/k3-k3/qB+qB*k3/k2^2-k2^2/k3/qB):
P:=sin(beta)*(qB/k3-k3/qB-qB*k3/k2^2+k2^2/k3/qB):
theta1 := -arctan((Q*(-P*Q+sqrt(Q^2*W^2+W^4-W^2*P^2))/(Q^2+W^2)+P)/W):
b1:=(theta1+k2*L)/(2*k2):
Stheta1 := -(Q*(-P*Q+sqrt(Q^2*W^2+W^4-W^2*P^2))/(Q^2+W^2)+P)/(W*sqrt(1+(Q*(-P*Q+sqrt(Q^2*W^2+W^4-W^2*P^2))/(Q^2+W^2)+P)^2/W^2)):
Ctheta1 := 1/sqrt(1+(Q*(-P*Q+sqrt(Q^2*W^2+W^4-W^2*P^2))/(Q^2+W^2)+P)^2/W^2):
phiB1=evalf(-arctan((1/4)*(cos(2*qB*b1)*(sin(beta)*(-qB/k3-k3/qB+qB*k3/k2^2+k2^2/qB/k3)+cos(theta1)*sin(beta)*(-qB/k3-k3/qB-qB*k3/k2^2-k2^2/qB/k3)+2*sin(theta1)*cos(beta)*(-qB/k2-k2/qB))+sin(2*qB*b1)*(4*cos(theta1)*cos(beta)-2*sin(theta1)*sin(beta)*(k2/k3+k3/k2)))/(-sin(2*qB*b1)*(sin(beta)*(-qB/k3-k3/qB+qB*k3/k2^2+k2^2/qB/k3)+cos(theta1)*sin(beta)*(-qB/k3-k3/qB-qB*k3/k2^2-k2^2/qB/k3)+2*sin(theta1)*cos(beta)*(-qB/k2-k2/qB))+cos(2*qB*b1)*(4*cos(theta1)*cos(beta)-2*sin(theta1)*sin(beta)*(k2/k3+k3/k2))))):
NphiB1:=evalf(phiB1/Pi);
#SNphiB1:=simplify(NphiB1);
plot(NphiB1,y);

Hello everbody!

Jacobi:=proc(A::Matrix,b::Vector,x,epsilon,m)  

uses LA=LinearAlgebra;  

local      i,k,n:= LA:-RowDimension(A),    

        x:= Vector(LA:-RowDimensions(A)),    

        p:= Vector(LA:-RowDimensions(A));  

k:=1;

 while  k<=n do      

       for i to n while i<>j do          

          x[i]:=1/(A[i,i])*(-add(A[i,j]*p[j],j=1..n)+b[i]);       end do;      

        if abs(x-p)<epsilon do return x; end if;    

       k:=k+1;    

       p:=x;

 end do;  

x;  

end proc:

First 1196 1197 1198 1199 1200 1201 1202 Last Page 1198 of 2428