MaplePrimes Questions

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

WC51 III
Maple 2015

With straight line selected in following plot, I right-click on plot and select Line → Line Width...  In Set line width dialog I toggle line width to 1 and click OK.

I have the changes I want, but if I choose Restart → Execute Worksheet all my changes are lost.  It is often easier to use the Plot Options Toolbar instead of hunting for Maple syntax to make changes in a plot graphic.  I'm wondering if there is a way to "lock" my plot edits so that they won't disappear as I continue working on a Maple worksheet?

restart;
with(plots);
eq1 := -y^3+x^2+x*y-7; eq2 := y = (8/9)*x-2/3;
implicitplot({eq1, eq2}, x = 0 .. 4, y = 0 .. 3, axis = [gridlines = [6, color = "MidnightBlue"]], size = [1/2, 1], axesfont = ["Roman", bold, 10], thickness = 3);





 

e1 := tau-gamma*S__1-beta*S__1*S__3/(S__3*alpha__1+1)-beta*xi*S__1*S__4/(S__4*alpha__1+1)+phi*S__5 = 0;
e2 := beta*S__1*S__3/(S__3*alpha__1+1)+beta*xi*S__1*S__4/(S__4*alpha__1+1)-(gamma+eta__1+eta__2)*S__2;
e3 := eta__1*S__2-(gamma+gamma__1+delta__1+omega)*S__3;
e4 := eta__2*S__2+omega*S__3-(gamma+gamma__2+delta__2)*S__4;
e5 := delta__1*S__3+delta__2*S__4-(gamma+phi)*S__5;
solve({e1, e2, e3, e4, e5}, {S__1, S__2, S__3, S__4, S__5});
 

Hello,

      I've found that, occasionally, solve won't work if the solving variables are specified---but it will work if the variables aren't specified. For instance:

eqns:=
[x=1, -1/(exp(h)+1/exp(h))^(1/2)/(exp(h)-1/exp(h))^(1/2)*(exp(h)^2-2+1/exp(h)^2)^(1/2)*x = tanh(h)^(1/2)]:

# Works
solve(eqns);

# Doesn't work
solve(eqns, x);

I was wondering why this is, and if there is a workaround?

(I want to specify the solving variables so that solve doesn't attempt to solve for parameters---like h in this case. Also, I'm using solve as opposed to a consistency checker because, in general, I'm applying the same code to larger systems with additional variables to solve for).

Thanks!

First 795 796 797 798 799 800 801 Last Page 797 of 2428