Maple 12 Questions and Posts

These are Posts and Questions associated with the product, Maple 12

How to calculate determinant of a cube matrix ?

is there function to calculate 3x 3x 3 cube determinant?

How to proof classical and quantum both p summation equal to one in maple?

I can calculate real number eigenvector with QR algorithm from rotation matrix

but this real number is just magnitude of complex number

what is the rotation matrix for calculating complex number?

what algorithm do maple use to calculate fraction eigenvector?

are complex decimal and complex fraction eigenvectors are two different algorithm?

I was recently cleaning up a worksheet to make things more succinct.  In that process I modified how I expressed the series coefficients, Ck.  What seemed to be an innocous change apparently upset MAPLE to the point it cannot process my results.  In the abbreviated worksheet link below I process the results in the previous manner, Ck1, as opposed to my current modification, Ck2.

In the previous manner the results are generated under 3 minutes.  After modifying the expression for Ck, MAPLE cannot seem to process the results at all.  As far as I can tell the Ck1 & Ck2 concur.  So I am perplexed.  Can anyone see what is wrong?  The only thing I can think of is that sin(2*pi*k/T*x) in the denominator might cause the problem.  However, the sin term is cancelled out by the same sin term in S4.

Ck_modification.mw

1.

with(Groebner):
K := {r-x^4,u-(x^3)*y,v-x*y^3,w-y^4};
G := Basis(K, 'tord', degrevlex(r,u,v,w));
R1 := eliminate(G, {r,u,v,w}); # eliminate is the reverse of Basis
Ga := Basis({a*G[1],a*G[2],a*G[3],a*G[4],a*G[5],a*G[6],a*G[7],a*G[8],a*G[9],a*G[10],a*G[11],a*G[12],a*G[13],a*G[14], (1-a)*K[1], (1-a)*K[2], (1-a)*K[3], (1-a)*K[4]}, 'tord', deglex(a,r,u,v,w));
Ga := remove(has, Ga, [x,y,a]);
eliminate(Ga, [r,u,v,w]);

how to eliminate Ga to find back K ?

2.

A1A2 and A3A4 parallel
A(0,0), B(u1,0), D(u2,u3), C(x1,x2), E(x3,x4)
#BC = A1A2
xx1 := u1:
xx2 := x1:
yy1 := 0:
yy2 := x2:
#AD = A3A4
xx3 := 0:
xx4 := u2:
yy3 := 0:
yy4 := u3:
eq1 := (xx2 - xx1)*(yy4 - yy3) - (yy2 - yy1)*(xx4 - xx3);
(x1-u1)*u3-x2*u2;
#CD = A1A2
xx1 := x1:
xx2 := u2:
yy1 := x2:
yy2 := u3:
#AB = A3A4
xx3 := 0:
xx4 := u1:
yy3 := 0:
yy4 := 0:
eq2 := (xx2 - xx1)*(yy4 - yy3) - (yy2 - yy1)*(xx4 - xx3);
-(u3-x2)*u1;
with(LinearAlgebra):
#E is on the same line of AC
xx1 := x3:
yy1 := x4:
xx2 := 0:
yy2 := 0:
xx3 := x1:
yy3 := x2:
eq3 := Determinant(Matrix([[xx1,yy1,1],[xx2,yy2,1],[xx3,yy3,1]]));
-x3*x2+x1*x4;
#E is on the same line of BD
xx1 := x3:
yy1 := x4:
xx2 := u1:
yy2 := 0:
xx3 := u2:
yy3 := u3:
eq4 := Determinant(Matrix([[xx1,yy1,1],[xx2,yy2,1],[xx3,yy3,1]]));
-x3*u3+u1*u3-u1*x4+u2*x4;
 

sol := eliminate({eq1,eq2,eq3,eq4},[x1,x2,x3,x4]);

with(Groebner):
K := {(rhs(sol[1][1])-lhs(sol[1][1])),(rhs(sol[1][2])-lhs(sol[1][2])),(rhs(sol[1][3])-lhs(sol[1][3])),(rhs(sol[1][4])-lhs(sol[1][4]))};
G := Basis(K, 'tord', degrevlex(x1,x2,x3,x4));
R1 := eliminate(G, {x1,x2,x3,x4}); # eliminate is the reverse of Basis
Ga := Basis({a*G[1],a*G[2],a*G[3],a*G[4], (1-a)*K[1], (1-a)*K[2], (1-a)*K[3], (1-a)*K[4]}, 'tord', deglex(a,x1,x2,x3,x4));
Ga := remove(has, Ga, [u1,u2,u3,u4,a]);

From Question1, is it possible to find from sol to eq1, eq2, eq3 and eq4 ?

I have resolved the roots of a series both numerically & analytically.  Let me qualify numerical  versus analytical.  Analytically I evaluate the series without substituting values for the various parameters of the series.  I then differentiate the series, then substitute in the appropriate parametric values, & then solve.  By this method I obtained 5 complex roots.

The numerical approach has values already assigned to the parameters of the series.  I then differentiate & solve.  I obtain only REAL roots in this instance.  I then restricted these results to obtain the solution I believe to be correct given by result (7).

I cannot seem to steer the solver in the analytic case to obtain the correct REAL result that I am expecting.  Can anyone help on this?

Before any website moderator thinks this is the same question as Error-in-Isinternal-Too-Many-Levels, it is not.  I have resolved that question.  This is a different question, but on the same problem!

reconcile_solns.mw

i have two functions , first naive function has error after used.
 
if run FromMatlab, does it mean that do not need to copy the result and run again because it had already run?
as i do not understand the output code after translated.
 
there is syntax error when translate second function
 
with(Matlab):
FromMatlab("function X = sylv_naive(A,B,Q)
% X=SYLV_NAIVE(A,B,Q) solves the Sylvester equation AX + XB = Q
%    A, B, Q: matrix coefficients
%    X : solution of AX + XB = Q
[m,n] = size(Q);
H = kron(eye(n), A) + kron(B.', eye(m));
Qvec = reshape(Q,m*n,1);
Xvec = H\Qvec;
X = reshape(Xvec,m,n);
");
sylv_naive(Jesus7,Jesus7,Matrix([[0,0],[0,0]]));
sylv_naive(Jesus7,Jesus7,Matrix([[0],[0]]));
Error, (in ArrayTools:-Reshape) the desired output contains a different number of elements than the input
 
 
 
with(Matlab):
FromMatlab("function X = sylvester(A,B,Q)
% X=SYLVESTER(A,B,Q) solves the Sylvester equation AX + XB = Q
% by using the Bartels and Stewart algorithm based on the complex
% Schur decomposition
%    A, B, Q: matrix coefficients
%    X : solution of AX + XB = Q
[m,n] = size(Q);
[U,A1] = schur(A,'complex');
[V,B1] = schur(B.','complex');
Q1 = U'*Q*conj(V);
X = zeros(m,n);
X(:,n) = (A1 + B1(n,n)*eye(m))\Q1(:,n);
for i = n-1:-1:1
    v = Q1(:,i) - X(:,i+1:n)*B1(i,i+1:n).';
    X(:,i) = (A1 + B1(i,i)*eye(m))\v;
end
X = U*X*V.';");

Error, (in Matlab:-FromMatlab) on line 15, syntax error
    X(:,i) = (A1 + B1(i,i)*eye(m))
 
 

Error, (in is/internal) too many levels of recursion

I get the error above when attempting to solve for the roots of partial derivative.  My results are below:


 

S3 := -(1/2*I)*(-(2*I)*exp(I*Pi*k*tau/T)*Pi*k-exp(I*Pi*k*tau/T)*T+I*exp(I*Pi*k*tau/T)*Pi*k*tau+(4*I)*Pi*k-(2*I)*exp(-I*Pi*k*tau/T)*Pi*k+exp(-I*Pi*k*tau/T)*T+I*exp(-I*Pi*k*tau/T)*Pi*k*tau)*sin(2*Pi*k*x/T)/(Pi^2*k^2)

S3 = ((-I)*(1/2))*((I*Pi*k*tau-(2*I)*Pi*k)*(exp(I*Pi*k*tau/T)+exp(-I*Pi*k*tau/T))-T*(exp(I*Pi*k*tau/T)-exp(-I*Pi*k*tau/T))+(4*I)*Pi*k)*sin(2*Pi*k*x/T)/(Pi^2*k^2)
"(->)"true"(->)"true

Despite the the simplifications MAPLE generated above MAPLE does not recognize the expressions as being equivalent.  So set the following for the Fourier coeffs:NULL

Ck := (-I*((2*(I*Pi*k*tau-(2*I)*Pi*k))*cos(Pi*k*tau/T)-(2*I)*T*sin(Pi*k*tau/T)+(4*I)*Pi*k))*(1/(2*Pi^2*k^2))

-((1/2)*I)*(2*(I*Pi*k*tau-(2*I)*Pi*k)*cos(Pi*k*tau/T)-(2*I)*T*sin(Pi*k*tau/T)+(4*I)*Pi*k)/(Pi^2*k^2)

(1)

The Fourier series can now be expressed as a 1 sided series employing both the Sum vs sum vs add commands for comparison:``

T0 := kernelopts(cputime), time(), time[real]();

204175839, 9435456, 8.998352053

(2)

S7 := a[0]+Sum(Ck*sin(2*Pi*k*x/T), k = 1 .. m):

1600991, 0, 0.

(3)

solve([diff(S5, x) = 0, 0 < x, x < 10*T/(2*Pi*m)], x)

Error, (in is/internal) too many levels of recursion

 

solve([diff(S5, x) = 0, 0 < x, x < 1/8], x)

Error, (in is/internal) too many levels of recursion

 

``


 

Download 2_many_levels_of_recursion.mw

Is it possible to use Regex to generate a complete list of patterns?

for search pattern in a list of characters

I posted this earlier on a question I asked more than a month ago due to the similarity of the problem.  However, I got no response.  So I will post this as a new question in an effort to get a response.

I get the following error when working with the "INERT" Sum?

Warning, solutions may have been lost

I do not get the message when working with the "ACTIVE" sum.  I tried the AllSolutions option, but still get the same message.  How can I get the proper output working with the "INERT" form?

lost_solutions.mw

I got decimal places problem,

not known correct or not

the value are different but difference is constant 

i do not know how many places needed to get exact result

i do not believe the difference is constant

because the matrix are different

but even if using 36 decimal places still constant, 

i notice increasing decimal places , the constant difference is changed

is it possible  to output fraction when calculate eigenvector?

I believe I am having memory issues which is causing the MAPLE kernal to terminate.  If I assign m a value then it seems to work, but I would like to leave m unassigned so that S1 can later be evaluated for any arbitrary m.  Is there a way around this?


 

T := M*tau;

`assuming`([simplify(expand(combine(S1)))], [m::integer])

``


 

Download MAPLE_crashing.mw

Below is a link to my worksheet that evaluates 6 expressions that are presumably equivalent.  However, there seems to be a region for 7<n<100 where the results diverge.  All other values of n yield identical results.  I am at a TOTAL loss as to what is happening.  I hope that someone here might shed some light on this quirk.

divergent_behavior.mw

Am I applying improper syntax for the is command?  Out of the 5 attempts to equate X with the time derivative of S11 only the combine command yields the expected result.  If only combine works then why do the others not work?
 

Ck1 := sin(Pi*k)/(Pi*k); 1; Ck2 := (1-cos(Pi*k))/(Pi*k); 1; S11 := a[0]+int(sum(2*Ck2*Pi*k*cos(2*Pi*k*x/T)/T, k = 1 .. m), x = 0 .. t); -1; Q1 := 2*sin(alpha)*(diff(S11, t)); -1; Q3 := sum(2*Ck2*Pi*k*(sin(alpha+2*Pi*k*t/T)+sin(alpha-2*Pi*k*t/T))/T, k = 1 .. m); -1; is(Q1 = Q3)

true

(1)

sum1 := sum(2*Ck2*Pi*k*cos(2*Pi*k*x/T)/T, k = 1 .. m):

true

(2)

subs(x = t, simplify(expand(combine(2*sin(alpha)*sum1)))) = simplify(expand(combine(Q3)))"(->)"true

NULL

m := 2*n;

-4*sin(Pi*t/T)*sin(Pi*t*n/T)*cos(Pi*t*n/T)*(2*cos(Pi*t*n/T)^2-1)/(T*cos(Pi*t/T)*(-1+cos(Pi*t/T)^2))

(3)

is(`assuming`([X = diff(S11, t)], [n::integer])), is(`assuming`([expand(X = diff(S11, t))], [n::integer])), is(`assuming`([combine(X = diff(S11, t))], [n::integer])), is(`assuming`([eval(X = diff(S11, t))], [n::integer])), is(`assuming`([value(X = diff(S11, t))], [n::integer])), simplify(`assuming`([combine(X-(diff(S11, t)))], [n::integer]))

false, false, true, false, false, 0

(4)

X

-4*sin(Pi*t/T)*sin(Pi*t*n/T)*cos(Pi*t*n/T)*(2*cos(Pi*t*n/T)^2-1)/(T*cos(Pi*t/T)*(-1+cos(Pi*t/T)^2))

(5)

`assuming`([combine(X-(diff(S11, t)))], [n::integer])

0

(6)

`assuming`([X-combine(diff(S11, t))], [n::integer])

-4*sin(Pi*t/T)*sin(Pi*t*n/T)*cos(Pi*t*n/T)*(2*cos(Pi*t*n/T)^2-1)/(T*cos(Pi*t/T)*(-1+cos(Pi*t/T)^2))-(2*cos((-Pi*t+4*Pi*t*n)/T)-2*cos((Pi*t+4*Pi*t*n)/T))/(T*cos(Pi*t/T)-T*cos(3*Pi*t/T))

(7)

"(=)"

0

(8)

``


 

Download syntax_for_is.mw

 

In the link below I attempt to solve 2 trig series which are essentially equivalent as indicated by the numerical output of eq (5).  The series  represented by S13 & S14 has arguments of the trig functions that realizes that only the odd terms for k yield non-zero results.  The case represented S11 & S12 by makes no such presumption; nonetheless, all cases agree within reason numerically.  Now to find min/max values taking the derivative is needed which is simply done by removing the integral as indicated by Q1 through Q6.

Now resolving the roots works OK for Q6 because beta = 2*pi *t/T conveniently collapsed the numerator into factorable expressions.  Resolving the roots for Q3 did not work so well because what I think is that the expression in red has multiple roots so it only spits out t as the solution?  I expressed the angle alpha in terms of beta & probably need to resolve kappa to somehow get the expression in red to collapse into a factored expression, but I am not sure how to execute this.  When I solve for kappa I get ZERO.

Does anyone have suggestions?  Remember I demonstrated that both series are practically idendical numerically; hence, there derivatives should be as well as long as both series are well behaved functions.  So the solutions must be the same as well.

trig_series_solns.mw

2 3 4 5 6 7 8 Last Page 4 of 32