MaplePrimes Questions

Hi,

I was wondering if anyone has a clever way to code the Cayley Omega process?
For those who are wondering, the Omega process is a differential operator. Given an n-dimensional space (x[1],x[2],x[3],...,x[n]), and n forms Q[1](x[1][1],x[1][2],x[1][3],etc) Q[2](x[2][1],x[2][2],x[2][3],etc) ... Q[n](x[n][1],x[n][1],x[n][1],etc), the operator is the determinant of the matrix who entries are the partial differential operators del/delx[i][j].

Thoughts? Suggestions?

 

Thanks.

The set and list produced by map (see below) contain duplicates.  How to remove duplicates?
 

p := (1+5^(1/2))*(1/2)

1/2+(1/2)*5^(1/2)

(1)

with(Bits)

[And, FirstNonzeroBit, GetBits, Iff, Implies, Join, Nand, Nor, Not, Or, Settings, Split, String, Xor]

(2)

with(LinearAlgebra)

[`&x`, Add, Adjoint, BackwardSubstitute, BandMatrix, Basis, BezoutMatrix, BidiagonalForm, BilinearForm, CARE, CharacteristicMatrix, CharacteristicPolynomial, Column, ColumnDimension, ColumnOperation, ColumnSpace, CompanionMatrix, CompressedSparseForm, ConditionNumber, ConstantMatrix, ConstantVector, Copy, CreatePermutation, CrossProduct, DARE, DeleteColumn, DeleteRow, Determinant, Diagonal, DiagonalMatrix, Dimension, Dimensions, DotProduct, EigenConditionNumbers, Eigenvalues, Eigenvectors, Equal, ForwardSubstitute, FrobeniusForm, FromCompressedSparseForm, FromSplitForm, GaussianElimination, GenerateEquations, GenerateMatrix, Generic, GetResultDataType, GetResultShape, GivensRotationMatrix, GramSchmidt, HankelMatrix, HermiteForm, HermitianTranspose, HessenbergForm, HilbertMatrix, HouseholderMatrix, IdentityMatrix, IntersectionBasis, IsDefinite, IsOrthogonal, IsSimilar, IsUnitary, JordanBlockMatrix, JordanForm, KroneckerProduct, LA_Main, LUDecomposition, LeastSquares, LinearSolve, LyapunovSolve, Map, Map2, MatrixAdd, MatrixExponential, MatrixFunction, MatrixInverse, MatrixMatrixMultiply, MatrixNorm, MatrixPower, MatrixScalarMultiply, MatrixVectorMultiply, MinimalPolynomial, Minor, Modular, Multiply, NoUserValue, Norm, Normalize, NullSpace, OuterProductMatrix, Permanent, Pivot, PopovForm, ProjectionMatrix, QRDecomposition, RandomMatrix, RandomVector, Rank, RationalCanonicalForm, ReducedRowEchelonForm, Row, RowDimension, RowOperation, RowSpace, ScalarMatrix, ScalarMultiply, ScalarVector, SchurForm, SingularValues, SmithForm, SplitForm, StronglyConnectedBlocks, SubMatrix, SubVector, SumBasis, SylvesterMatrix, SylvesterSolve, ToeplitzMatrix, Trace, Transpose, TridiagonalForm, UnitVector, VandermondeMatrix, VectorAdd, VectorAngle, VectorMatrixMultiply, VectorNorm, VectorScalarMultiply, ZeroMatrix, ZeroVector, Zip]

(3)

with(VectorCalculus)

[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, About, AddCoordinates, ArcLength, BasisFormat, Binormal, Compatibility, ConvertVector, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProduct, Flux, GetCoordinateParameters, GetCoordinates, GetNames, GetPVDescription, GetRootPoint, GetSpace, Gradient, Hessian, IsPositionVector, IsRootedVector, IsVectorField, Jacobian, Laplacian, LineInt, MapToBasis, Nabla, Norm, Normalize, PathInt, PlotPositionVector, PlotVector, PositionVector, PrincipalNormal, RadiusOfCurvature, RootedVector, ScalarPotential, SetCoordinateParameters, SetCoordinates, SpaceCurve, SurfaceInt, TNBFrame, Tangent, TangentLine, TangentPlane, TangentVector, Torsion, Vector, VectorField, VectorPotential, VectorSpace, Wronskian, diff, eval, evalVF, int, limit, series]

(4)

b := proc (x, w) options operator, arrow; (-1)^GetBits(x, w, output = number) end proc

proc (x, w) options operator, arrow; (-1)^Bits:-GetBits(x, w, output = number) end proc

(5)

l := proc (x, t, u, v) options operator, arrow; frac(x)*Vector([b(floor(x), 0)*t, b(floor(x), 1)*u, b(floor(x), 2)*v])+(1-frac(x))*Vector([b(floor(x), 0)*v, b(floor(x), 1)*t, b(floor(x), 2)*u]) end proc

proc (x, t, u, v) options operator, arrow; VectorCalculus:-`+`(VectorCalculus:-`*`(frac(x), VectorCalculus:-Vector([VectorCalculus:-`*`(b(floor(x), 0), t), VectorCalculus:-`*`(b(floor(x), 1), u), VectorCalculus:-`*`(b(floor(x), 2), v)])), VectorCalculus:-`*`(VectorCalculus:-`+`(1, VectorCalculus:-`-`(frac(x))), VectorCalculus:-Vector([VectorCalculus:-`*`(b(floor(x), 0), v), VectorCalculus:-`*`(b(floor(x), 1), t), VectorCalculus:-`*`(b(floor(x), 2), u)]))) end proc

(6)

map(l, {0, 1, 2, 3, 4, 5, 6, 7, 8}, 0, 1, p)

{Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian])}

(7)

map(l, [0, 1, 2, 3, 4, 5, 6, 7, 8], 0, 1, p)

[Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian])]

(8)

q := ListTools:-MakeUnique(%)

q := [Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian])]

(9)

Equal(q[1], q[9])

true

(10)

qq := [op({q[]})]

qq := [Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = -1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = -1/2-(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian]), Vector(3, {(1) = 1/2+(1/2)*5^(1/2), (2) = 0, (3) = 1}, attributes = [coords = cartesian])]

(11)

LinearAlgebra:-Equal(qq[1], qq[5])

true

(12)

NULL


 

Download cp.mw

 we know that  maple evaluate an expression as a tree, for example if i have the expression:

f:=x^2*exp(3/2)*sin(Pi/3-1/x);

i want to get all the tree, is there a command to obtain this !!

I get the following message:

"Error, (in Bits:-GetBits) argument 1, the number, must be a nonnegative integer"

Presumably "argument 1" does not mean that the offending argument is 1 (the problem is that the offending argument "must be a nonnegative integer", but 1 is a nonnegative integer).  So how do I get maple to report what the offending argument is? 

Could you help me to write maple code for solving following matrix differential equations?

where

In here, the matrices M,C,K,P are as follows ( M,C,K are nxn matrices and  V,P are nx1 matrices) 

In here, l,P,A,rho, alpha,v,N,E,I are constants.

Thank you very much.

I writed the matrices in maple. You can find it in the below.

 The Code.mw

I am looking to develop a histogram from a random data set that contains integers that are approximately normally distributed.  The intent is to develop a histogram from the dataset that looks like a fairly decent-approximation of a normalized curve (but not necessarily perfect)....  the next stage to this is a second histogram that shows a bimodal distribution (but not necessarily perfect)

 

To this point I have...

restart;

with(Statistics);

randomize();

N := RandomVariable(Normal(300, 10));

A := [seq(MapleTA:-Builtin:-decimal(0, Sample(N, 500)[i]), i = 1 .. 500)];

Histogram(A, frequencyscale = absolute, bincount = 25, binwidth = 1, tickmarks = [default, default]);

 

I am certain you will find what I have thus far is far from ideal, as such any help is appreciated.

 

Thanks,

Mark

 

To restrict the domain of a vector field, I have multiplied a coordinate with a non-real complex number (namely a sqrt(of negative expression)). This does work, as shown in this Maple 2017 worksheet program (below). My question is whether this is the best technique of accomplishing this result, or else how to do it better? Would be interested in suggestions for improvements. Here is my program so far:

restart;
#
with(plots):
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(` Vector Field inside Torus`);
print(` ------- ------- ------- ------- ------- ------- -------`);
print(` Assignment:  `);
print(` In a circular pipe of radius (my2r), water is flowing in the direction `);
print(` of the pipe, with speed (my2r)^2-(mya)^2, where (mya) is the distance  `);
print(` to the axis of the pipe.  `);
print(` Depict the vector field describing the flow if the pipe goes around in `);
print(` the shape of a torus with major radius (my1r).  `);
print(`   `);
print(`   `);
print(`   `);
print(` ------- ------- ------- ------- ------- ------- -------`);
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 1) major radius of torus:`);
#
my1r  := 5;     
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 2) minor radius of torus (pipe radius):`);
#
my2r := 4; 
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 3) definition of torus (polar coordinates):`);
#
c00 := [(my1r+my2r*cos(s))*cos(t),(my1r+my2r*cos(s))*sin(t),my2r*sin(s)];
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 4) 3D plot of solid torus (polar coordinates):`);
#
plot3d({c00},scaling=constrained,color=red);
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 5) 3D plot of wireframe torus (polar coordinates):`);
#
P1 := plot3d({c00},scaling=constrained,style=wireframe);
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 6) implicit definition of torus (cartesian coordinates):`);
#
c01 := (sqrt(x^2+y^2)-my1r)^2+z^2-my2r^2;
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 7) implicit 3D plot of solid torus (cartesian coordinates):`);
#
gx := my1r+my2r; # min and max of each coordinate
#
implicitplot3d(c01,x=-gx..gx,y=-gx..gx,z=-gx..gx,numpoints=9000);
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 8) vector field definition (cartesian coordinates):`);
#
my1vfx := -y;
my1vfy := x;
my1vfz := 0;
#
my1fld := [my1vfx,my1vfy,my1vfz];
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 9) 3D plot of vector field (cartesian coordinates):`);

#
fieldplot3d(my1fld,x=-gx..gx,y=-gx..gx,z=-gx..gx);
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 10) definition of vector field with unit length vectors (cartesian coordinates):`);
#
my1vl := sqrt(my1vfx^2+my1vfy^2+my1vfz^2); # vector length
#
my2fld := [my1vfx/my1vl,my1vfy/my1vl,my1vfz/my1vl];
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 11) 3D plot of vector field with unit length vectors (cartesian coordinates):`);
#
fieldplot3d(my2fld,x=-gx..gx,y=-gx..gx,z=-gx..gx);
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 12) definition of vector field with asked for length vectors (cartesian coordinates):`);
#
mya := sqrt((sqrt(x^2+y^2)-my1r)^2+z^2);
c01r := sqrt(my2r^2-mya^2); # also used for domain restricting vector field below
#
my1tsz := solve([c01],[z]);
#
assign(my1tsz[1][1]);
my1tz := z;
unassign('z');
#
assign(my1tsz[2][1]);
my2tz := z;
unassign('z');
#
my1vp := c01r/my2r; # vector length (maximum one unit)
#
my3fld := [my1vp*my1vfx/my1vl,my1vp*my1vfy/my1vl,my1vp*my1vfz/my1vl];
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 13) 3D plot of vector field with asked for length vectors (cartesian coordinates):`);
#
fieldplot3d(my3fld,x=-gx..gx,y=-gx..gx,z=-gx..gx);
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n(Section 14) same asked for vector field with 3-D arrow vectors:`);
print(`   `);
print(` (to get this to display properly it was necessary to do:  `);
print(` -> Maple 2017 -> Preferences... -> Precision ->   `);
print(`   [unselect] Limit expression length to   `);
print(`   Apply to Session`);
print(`   `);
#
gr := 15;
#
P3 := fieldplot3d(my3fld,x=-gx..gx,y=-gx..gx,z=-gx..gx,arrows=`3-D`,grid=[gr,gr,gr]);
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);
print(`\n display asked for vector field within wireframe torus:`);
#
display([P1,P3]);
#
#
print(` ------- ------- ------- ------- ------- ------- -------`);

Hi

However I run similar codes in Maple and Matlab, but the different results are observed.

By increasing number of basis (i.e. m) The convergence is observed, but results are different from each other.

The convergence for Maple: (m,P) =(10,10.8154),(20,10.8081),(30,10.8067),(50,10.8061)

The convergence for Matlab: (m,P) =(10,10.0474),(20,10.0194),(30,10.0143),(40,10.0125)

I have two questions:

1-which answer is correct?

2-why the different results for the same  number of basis  are obtained?

 

Maple code (Maple 2016)

restart;

tm := time():

with(LinearAlgebra):

Digits := 500:

beta := 1:

nu := 0.3:

lambda := 2:

G := 5:

ko := .5*0.1e7:

Ec := 0.380e12:

Em := 0.70e11:

ri := 0:

ro := 0.5:

ti := 0.1e-1:

K := 0.4e-1*0.1e10:

n := 1:

m := 20:

alpha := 0.1:

t := ti*(1+alpha*r/ro)^beta:

Er := (Ec-Em)*(r/ro)^n+Em:

W := simplify(add(a[n]*ChebyshevT(n, r), n = 0 .. m)):

sys := {eval(W, r = ro), eval(diff(W, r), r = ri)}:

W := subs(solve(sys, {a[0], a[1]}), W):

d1 := diff(W, r):

d2 := diff(d1, r):

W := subs(solve({eval(ko*d1-Ec*ti^3*(1+alpha)^(3*beta)*(d1*nu+d2*r)/(12*r*(-nu^2+1)), r = ro) = 0}, {a[2]}), W):

d1 := diff(W, r):

d2 := diff(d1, r):

Uf := int(K*(1+lambda*r/ro+G*(r/ro)^2)*W^2*r, r = ri .. ro):

NUM := int(((d2+d1/r)^2-(2*(1-nu))*d2*d1/r)*Er*t^3*r/(12*(-nu^2+1)), r = ri .. ro)+ko*ro*(eval(d1, r = ro))^2+Uf:

DEN := int(d1^2*r, r = ri .. ro):

PT := NUM-Em*ti^3*P*DEN/ro^2:

for c from 3 to m do

eq[c] := diff(PT, a[c]) end do:

MT := GenerateMatrix([seq(eq[j], j = 3 .. m)], [a[j]$j = 3 .. m])[1]:

solve(Determinant(MT)):

evalf[10](%[1]);

____________________________________________________________________________

Matlab Code (R2014a)

clear all;
digits(10);
tic
m = 20;
n = 1;
alpha = 0.1;
beta = 1;
nu = 0.3;
lambda = 2;
G = 5;
ko = 0.5*1e6;
Ec = 0.380e12;
Em = 0.70e11;
ro = 0.5;
ti = 0.1e-1;
K = 0.04*0.1e10;
ri=0;
syms r P;
c=sym('c%d',[1,m+1]);
c(1)=1;
c(2)=r;
for j=3:m+1
    c(j)=simplify(2*r*c(j-1)-c(j-2));
end
Er = (Ec-Em)*(r/ro)^n+Em;
a=sym('a%d',[1,m+1]);
t = ti*(1+alpha*r/ro)^beta;
W = simplify(a*transpose(c));
[a(1),a(2)] = solve(subs(W,r,ro)==0,subs(diff(W,r),r,ri)==0,a(1),a(2));
W = simplify(a*transpose(c));
d1 = diff(W, r);
d2 = diff(d1, r);
a(3)=solve(subs(ko*d1-Ec*ti^3*(1+alpha)^(3*beta)*(d1*nu+d2*r)/(12*r*(-nu^2+1)),r,ro)==0,a(3));
W = simplify(a*transpose(c));
d1 = diff(W, r);
d2 = diff(d1, r);
Uf = int(K*(1+lambda*r/ro+G*(r/ro)^2)*W^2*r,r,ri,ro);
NUM = int(((d2+d1/r)^2-(2*(1-nu))*d2*d1/r)*Er*t^3*r/(12*(-nu^2+1)),r,ri,ro)+ko*ro*(subs(d1,r,ro))^2+Uf;
DEN = int(d1^2*r, r , ri , ro);
PT = NUM-Em*ti^3*P*DEN/ro^2;
for q=1:m-2
    eq(q)= diff(PT, a(q+3));
end;
for q = 1:m-2
    for u = 1:m-2
        T = coeffs(eq(q),a(u+3));
        tt(q,u) = T(2);
    end;
end;
F=sort(vpa(solve(det(tt))));
F(1)
toc

___________________________________________________________

how to find infinity norm for function of fraction exponenctial

I am wanting to plot a phase portrait of du/dt against u.

 

I have attempted to draw this on maple however am having great difficulty. Can anyone recommend what I may be doing wrong or how I should go about doing this?

Load the Tetrads package, and choose Schwarzshild spacetime:

with(Physics):
with(Tetrads):
Setup(metric = schwarzschild,quiet):

Consider then the following code/output:

expr := D_[~mu](e_[mu,a]);
seq(simplify(SumOverRepeatedIndices(expr             )),a = 1..4);
seq(simplify(SumOverRepeatedIndices(D_[~mu](e_[mu,a]))),a = 1..4);

In my mind, the last two code lines are entirely identical, but their corresponding outputs are certainly not. I don't get it. The above can be compared with the following code/output in which the vierbein indices mu and a have been interchanged:

expr := D_[~mu](e_[a,mu]);
seq(simplify(SumOverRepeatedIndices(expr             )),a = 1..4);
seq(simplify(SumOverRepeatedIndices(D_[~mu](e_[a,mu]))),a = 1..4);

Here, the outputs are identical. The mystery becomes total when realizing that according to Maple, e_[a,mu] and e_[mu,a] are considered completely identical [a notational choice I do not find reassuring].

 

I've been doing some soul searching and started to think that the maple interface and i are kindred spirts, conjoined spirit twins if you will, and i can confirm this if this is the manner in which the totient function is calculated:

 

For example how to input the mixed fraction 3 1/7? What are keys for super- and subscript?

I've keep checking in every 18 months or so for the last 10 years... since Maple got a sort-of-notebook interface. I keep hopeing for a MathCad-like true notebook, where I can organize my document the way I want, instead of the clunky console I/O based interface. But every time I check, its not quite there.

 

Are we there yet?

First 857 858 859 860 861 862 863 Last Page 859 of 2427