MaplePrimes Questions

Generate 8 random 3 by 3 matrices using the RandomMatrix command from the  LinearAlgebra package. As each matrix is generated use Eigenvalues to compute its eigenvalues. Then take the product of the eigenvalues, and check that for each matrix, this product is equal to the determinant of the matrix.  

[Hint: The product will be complicated algebraically and you will need to apply first expand, then simplify to reduce the product of the eigenvalues to an integer. First try to do for a single matrix , then make a loop to do it 8 times.] 

There is a one-to-one correspondence between subsets of {1, 2, . . . , n} and binary lists of length n, that is, lists L = [x1, x2 , . . . , xn] where x1, x2, . . . , xn are elements of the set {0,1}.  The correspondence is given by associating to the set S the list L where xi = 1 if i is in S and 0 if not. For example, the set {1,3,5} corresponds to the list [1,0,1,0,1,0,0] if n = 7.

(a) Write a procedure list_to_set whose input is a binary list and whose output is the corresponding set. E. g., list_to_set([1,0,1,0,1]) will return the set {1,3,5}. Note that nops(L) is the length of a list.

(b) Write a procedure set_to_list whose input is a pair S,n where S is a subset of {1, 2, . . . , n} and n is a positive integer and whose output is the binary list of length n corresponding to the set S. E. g., if n = 5 then set_to_list({1,3,5},5) will return [1,0,1,0,1].

(c) Show by a few tests that each procedure works. Then apply set_to_list to each set in the powerset of {1, 2, 3, 4} to form all binary lists of length 4. Make a program to print out a table of the following form. (But the order need not be the same as that started below.)

   [0,0,0,0] <-->  {  }
   [1,0,0 0] <--> { 1 }
   [0,1,0,0] <--> { 2 } 
    ........
    etc

Some extra commas in the output is okay. You may obtain the power set of the set {1,2,...,n} by the command powerset(n); but you must first load the package combinat.

For each natural number n, the n-th square matrix  An is defined by 
                              An( i, j) =0 if  i = j,   An( i, j) =1 if i ≠ j
Carry out the following computations for n=3,4 and 5.

(a) Compute the determinant of  An

(b) Compute the characteristic polynomial of  An

(c) Determine all eigenvalues of  An and determine for each eigenvalue a basis of the corresponding eigenspace.

The expression X^n, for an interger power n and any X, can be computed using the following formulae, which represent a negative power in terms of a positive power (-n), and a positive power in terms of a smaller non-negative power (either n/2 or n-1), and use only multiplication and division: 
                                    
                          X^n = 1/X^(-n)                      if n < 0 
                          X ^n = I*d                             if n = 0
                          X ^n  = X^(n/2) * X^(n/2)      if n is even
                          X^n  = X*X^(n-1)                  if n is odd.
These formulae lead to an efficient recursive algorithm for computing integer powers using the minimal number of multiplications. 

(a) Write a procedure MatPow(X,n::integer) to implement this algorithm for computing powers of matrices. Test MatPow(<<1|2>,<3|4>>,12) and MatPow(<<1|2>,<3|4>>,-12).

(b) Write a procedure PolyPow(X,n::integer) to implement this algorithm for computing powers of numbers and polynomials. Your procedure needs to exapnd each product of polynomials in order to be effective. Test PolyPow(123,12), PolyPow(123,-12), PolyPow(x^2+1,12) and PolyPow(x^2+1,-12). 

Write a procedure using the variable args that will take an unspecified finite number of numbers, delete the smallest and the largest, and return the average of the rest as a floating point number. If there are fewer than 3 arguments have an error message say: "There are not enough arguments. There should be at least three." 

You should have no input parameters in the definition of the procedure. You may write it directly or you may use the Maple command sort as a part of your program. Do ?sort to see how sort works. Test your procedure with each of the following argument sequences:  

   50,40,40, 40, 40, 10

   1,2

   seq(100 - i, i = 1..100)

   seq(modp(n,111), n=1..1000).


If n people (numbered 1 to n) stand in a circle and someone starts going around the circle and eliminating every other person till only one person is left, the number J(n) of the person left at the end is given by 

    J(n) = 1                           if n = 1
    J(n) = 2*J(n/2) - 1          if n > 1 and n is even
    J(n) = 2*J((n-1)/2) + 1   if  n > 1 and n is odd

(i) Write a recursive procedure to compute J. [As a check the first 16 values (starting with 1) of J(n) are 1,1,3,1,3,5,7,1,3,5,7,9,11,13,15,1]. 
(ii)Compute the value of J(10000). 
(iii) Can you explain why this is so much faster than our recursive procedure to compute the n-th Fibonacci number?

I have a worksheet using sai.m (consists of Xi_hat values as a table) and TKtm.m (consists of equation). When I run the ws the values of Psi_hats dont evaluated in TKtm eq, but when I copy the TKtm and paste it in new row they are evaluated. Why?


 

``

``

restart

read "sai.m"``

``

read "TKtm.m"

TKtm

-HFloat(8.471127434835482e-8)*(-HFloat(3.2871687813435684e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 0]-HFloat(8.41455103438575e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 0]-HFloat(1.1842546165173334e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 0]+HFloat(3.538379030573464e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 0]+HFloat(1.4352419825010453e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 1]+HFloat(4.8104977164910354e-5)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 1]+HFloat(5.05930283832792e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 1]-HFloat(4.1386253796027285e-5)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 1]-HFloat(0.0011373448609075419)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 2]-HFloat(4.732392115584591e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 2]+HFloat(2.089803495158474e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 2]+HFloat(1.989801635177615e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 2]+HFloat(8.603626184898737e-6)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 2]-HFloat(6.14439676933793e-5)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 3]+HFloat(5.151239824352348e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 3]-HFloat(2.0604843790262536e-5)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 3]-HFloat(2.165887607592778e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 3]+HFloat(1.7717825274845376e-5)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 3]+HFloat(6.673501129170035e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 4]+HFloat(3.5580629365501574e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 4]-HFloat(1.0277832120686807e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 4]-HFloat(1.4960967814699452e-4)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 4]-HFloat(1.5776267653365094e-5)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 4]-HFloat(2756.100581746564)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 4]^2-HFloat(31892.02101692787)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 0]^2-HFloat(74414.71570120404)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 1]^2-HFloat(6378.404203385573)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 3]^2-HFloat(4556.003002418266)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 3]^2-HFloat(223244.14710361214)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 0]^2-HFloat(74414.71570120404)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 0]^2-HFloat(44648.829420722424)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 0]^2-HFloat(14882.94314024081)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 1]^2-HFloat(10630.67367478978)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 1]^2-HFloat(8268.301743751397)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 1]^2-HFloat(44648.829420722424)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 2]^2-HFloat(14882.94314024081)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 2]^2-HFloat(8929.765884144486)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 2]^2-HFloat(6378.404203385573)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 2]^2-HFloat(4960.9810462508385)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 2]^2-HFloat(31892.02101692787)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 3]^2-HFloat(10630.67367478978)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 3]^2-HFloat(3543.5578891161026)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 3]^2-HFloat(24804.90522381272)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[0, 4]^2-HFloat(8268.301743751397)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 4]^2-HFloat(4960.981047739132)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[2, 4]^2-HFloat(3543.557890604397)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[3, 4]^2+HFloat(9.924710058946695e-5)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 0]-HFloat(24804.90522381272)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[4, 0]^2-HFloat(0.0012032458385423347)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 1]-HFloat(24804.90522381272)*`#mover(mi("&Xi;",fontstyle = "normal"),mo("&uminus0;"))`[1, 1]^2-HFloat(0.4030903729505378))*(diff(tau[1](t), t))^2

(1)

-8.47112743483548*10^(-8)*(-2.23244147103612*10^5*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 0]^2-.403090372950538-24804.9052238127*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 1]^2-24804.9052238127*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 0]^2-0.120324583854233e-2*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 1]-3543.55789060440*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 4]^2+0.992471005894670e-4*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 0]-8268.30174375140*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 4]^2-4960.98104773913*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 4]^2-3543.55788911610*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 3]^2-24804.9052238127*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 4]^2-31892.0210169279*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 3]^2-10630.6736747898*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 3]^2-8929.76588414449*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 2]^2-6378.40420338557*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 2]^2-4960.98104625084*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 2]^2-44648.8294207224*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 2]^2-14882.9431402408*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 2]^2-10630.6736747898*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 1]^2-8268.30174375140*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 1]^2-44648.8294207224*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 0]^2-14882.9431402408*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 1]^2-74414.7157012040*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 0]^2-6378.40420338557*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 3]^2-4556.00300241827*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 3]^2-31892.0210169279*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 0]^2-74414.7157012040*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 1]^2-0.157762676533651e-4*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 4]-2756.10058174656*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 4]^2-0.102778321206868e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 4]-0.149609678146995e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 4]+0.355806293655016e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 4]+0.177178252748454e-4*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 3]+0.667350112917003e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 4]-0.206048437902625e-4*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 3]-0.216588760759278e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 3]-0.614439676933793e-4*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 3]+0.515123982435235e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 3]+0.860362618489874e-5*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 2]+0.208980349515847e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 2]+0.198980163517762e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 2]-0.113734486090754e-2*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 2]-0.473239211558459e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 2]+0.505930283832792e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 1]-0.413862537960273e-4*`#mover(mi("&Xi;"),mo("&uminus0;"))`[4, 1]+0.481049771649104e-4*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 1]+0.353837903057346e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[3, 0]+0.143524198250105e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 1]-0.841455103438575e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[1, 0]-0.118425461651733e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[2, 0]-0.328716878134357e-3*`#mover(mi("&Xi;"),mo("&uminus0;"))`[0, 0])*(diff(tau[1](t), t))^2

HFloat(1.0692333981133118e-7)*(diff(tau[1](t), t))^2

(2)

``


 

Download soal970429.mw

TKtm.pdf

sai.pdf

change .pdf extentions to .m.

How to fix it?

I've made a worksheet (updated)in which I'm timing a program (GTS2) because it sometimes takes a long time to run, and I am not interested in timing the cases where it takes an exceptionally long time to run I've created a timer function that runs GTS2 through timelimit.

timelimit(20, GTS2(H, F, Na, Nd))

this should run the function for 20 seconds, and then stop it if it overruns, before returning that the whole function ( GTS2timer2  ) has taken 20 seconds.

On line 3.3 GTStimer2 is run with two sets of inputs which give a runtime >40s. My guess is that the 20+ extra seconds that the operation takes are spent running solve which is called in GTS, and I expect i can solve the problem by putting solve in the timelimit function directly (if i'm wrong about this please tell my why).

My question is why timelimit isn't able to stop GTS after 20 seconds.

EDIT:

Playing around with the worksheet the morning after I made it the case that was running for 40+s is now giving the error

Error, (in factor/diophant) time expired

My guess is that as it is stopping the solve in GTS2  needs a try/catch of its own. Any idea how to make that work? 

In Physics package there is this compact notation X=(t,x,y,z)

Is there something similar in the VectorCalculus packge?

For example

restart;

with(VectorCalculus);

SetCoordinates(cartesian[x, y, z]);

v := VectorField([vx, vy, vz]);

Jacobian(v);

 

I don't explicitly want to write the arguments (x,y,z) of the functions vx,vy,vz everytime.

In following loop why Maple returns m=2, where I expect 1?

restart;
X := Vector[row](2, [1, 1]):
M := 1:
for m from 1 to M do

S := X[m] :

end do:
                              
m;
                               2
 

Has anyone installed and run maple under ubuntu installed the Windows Subsystem for Linux?   We are having trouble doing this: specifically running programs with text input files, etc.

 

 

How do I plot just 10 points of the equation?

I got ..

with(plots):
a := x+2*y = 3;
implicitplot(a, x = -5 .. 5, y = -5 .. 5, style = point);
 

but I only need 10 points. How do I do that? Thank you

 

Dear Friends!
I want to generate a system of the equation from the matrices! please help me in this regard! Thanks!

I was making a maple worksheet (out of functions from another), when i noticed that  execution groups and new execution groups that i was making were not showing an output.  I'm wondering why this happens, and how it can be fixed.

in more detail there are 4  [> groups of commands, the first two give the correct output when i hit enter, however, if enter is pressed on any group of commands after the second the command wont return the any output.

I believe this is a formatting issue that comes from the way i cut/paste and edited the previous worksheet down to this, but i'd like to understand so i can avoid it happening again.

3d_plot_of_Lie_derivatives_against_Dimensions_of_solutions_timer.mw

Ahh, this is a teathing problem, I had been using writeto so i could store measurements of RAM; this changes the nature of the question.

How do you implement writeto so only some things are sent there? (in the case of this worksheet the output of GTS2usage
 

Dear users!

Hope everyone fine here. I want to compare the coefficients of like power of exponential function in attachemed file. Please see and fix my problem.

Help.mw

First 794 795 796 797 798 799 800 Last Page 796 of 2427