Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hello.

I have this problem when executing the entire worksheet or selected groups.
Also Maple can crash by itself, to its heart's content)
What I can do to solve this problem?
OS: W7 x64, Java is up to date

Thx.

Hi Guys i need some Help. 

I created a work sheet where i am calculatin the polynominial coefficient of an equation. The Problem is that if i take these coefficient and then calculate the root with Matlab and compare it with the symbolic toolbox  i get wrong roots. My question now is did i something wrong by creating the coefficient ? 

Polynom_Calculation.mw 

These are the values for the parameters : 

b1=0
b2=0
v1=0
v2=0
s1=0
s2=0.175
j2=0.28
tau =20
th1 = 0
th3 = 0
 

i added  my Maple skript. i hope that sb can help me.

In the first one I used hypergeometric function where the number is converged. Now using the series expansion of hypergeometric function I rewrite the equation as in the 2nd and 3rd case. But here it is not converging. I expect the same answer as in the first case i.e 0.14042. Thank you

 

problem2.mw

I have an 8*5 matrix, and i'd like to replace elements of it that are >20 with 20. For those interestedm, the matrix comes from this question.

M := Matrix(8, 5, {(1, 1) = 1.266, (1, 2) = .734, (1, 3) = .656, (1, 4) = .735, (1, 5) = 1.843, (2, 1) = 2.859, (2, 2) = 5.625, (2, 3) = 5.188, (2, 4) = 5.453, (2, 5) = 10.765, (3, 1) = 3.281, (3, 2) = 9.000, (3, 3) = 5.516, (3, 4) = 5.828, (3, 5) = 6.156, (4, 1) = 7.718, (4, 2) = 34.125, (4, 3) = 5.453, (4, 4) = 5.344, (4, 5) = 5.453, (5, 1) = 8.703, (5, 2) = 6.515, (5, 3) = 6.125, (5, 4) = 6.641, (5, 5) = 6.734, (6, 1) = 17.766, (6, 2) = 8.578, (6, 3) = 8.765, (6, 4) = 9.875, (6, 5) = 32.610, (7, 1) = 22.156, (7, 2) = 15.640, (7, 3) = 15.610, (7, 4) = 15.187, (7, 5) = 23.735, (8, 1) = 20.140, (8, 2) = 20.156, (8, 3) = 20.266, (8, 4) = 19.344, (8, 5) = 21.078})

I tried to create a logical matrix that i could input into M (this is how it works in maple) to select the elements so i could replace  them, but this didn't work 

Hello,  how can i  to adapt the  commands  below  to write  in fprintf a vector with  N components.

 

 fd≔fopen("temp_file",WRITE);

fprintf(fd,"x = %d, y = %g",x,y)

fclose(fd)  

For exemple: Given a vector (or list)  v:=[1,2,3,4,....N], i would like to get  a file with  N column and 1 line, where N is a integer number, which i will give.

Thanks for any help.

 

 

Hello MaplePrime users,

Yesterday, I posted my MagicPuzzles package to the MapleCloud. It is a collection of tools I have written for manipulating, solving, and visualizing puzzles like Magic Squares and Magic Stars. Here's a sample solution for each:



For the Magic Square, the numbers on each horizontal and vertical line, along with the numbers on each of the two diagonals, add up to 65.

The inaugural version has separate sub-packages for:

  • Magic Annulai (my own name)
  • Magic Hexagons
  • Magic Squares
  • Magic Stars

Moreover, each sub-package contains these commands:

  • Equations(), to return the linear equations for the variables based on the Magic Sum;
  • Constraints(), to return the conditions that prevent redundant solutions found by reflections and rotations;
  • VerifySolution(), to confirm if a list of numbers is a solution;
  • EquivalentSolutions(), to determine solutions equivalent to a given solution;
  • PrimarySolution(), which takes a solution and returns the associated primary solution;
  • Reflection() and Rotation(), to reflect and rotate a solution; and
  • Draw(), to provide a visualization (like the ones above).

There is also a command, MagicSolve(), which is used to find solutions, which take the form of permutations of [1,...n] for some positive integer n, to the equations. Essentially, it solves the linear equations, and cycles through all permutations for the free variables, and selects those that give "magic" solutions.

In future versions, I intend to add:

  • Other specific classes of problems;
  • More sample solutions; and
  • Known algorithms for finding particular solutions.


To install the package, you can do so from here, or just execute the following within Maple 2017+:

PackageTools:-Install( 5755630338965504, 'overwrite' );

There are many examples in the help pages.

I think others will find this package interesting and useful, and I encourage you to check it out.

(a) Plot the graph of  
                       sin(x)*exp( -x^2)
 for x in the interval [-2,2]. 
(b) Find to 10 decimal digits the maximum and minimum values of 
                         sin(x)*exp( -x^2)
 for x in [-2,2] AND find the corresponding values of x. [So if the maximum occurs at x=a, you should also compute sin(x)*exp( -x^2)   both to 10 digits. Similarly for the minimum. Using unapply to make the expression into a function will be useful here.]  

So far I have this for a

> j := exp(-x^2)*sin(x);

> plot(j, x = -2 .. 2);

 

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? 

First 780 781 782 783 784 785 786 Last Page 782 of 2217