output of a function (A bug?)...

Hello there!

I am facing a strange problem. I am defining a function as a finite series which involves the constants c[k] and the variable x. when I try to calculate the value of the function at zero it should give me c[1] but its giving me 0. it seems a bug in maple. i have tried it on two different versions.i.e. 2016 and 17

Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/bug.mw .

dsolve gives an odd (but not incorrect) output ...

The problem, find the general solution of y '' + 4y = t cos (2t).

Maple input:

de:=diff(y(t),t,t)+4*y(t)=t*cos(2*t);
sol:=dsolve(de,y(t));

Maple output:

sin(2*t)*_C2+cos(2*t)*_C1+(1/8)*t^2*sin(2*t)-(1/64)*sin(2*t)+(1/16)*t*cos(2*t)

The odd thing is the inclusion of the term -(1/64)*sin(2*t). It is not incorrect since you can collect this term with sin(2*t)*_C2. Is there a reason why it's there, and how can i remove it without inspecting it? Note that Wolfram doesn't have this extra term.

https://www.wolframalpha.com/input/?i=solve+y%27%27+%2B+4y+%3D+t*cos(2*t)

I attached the worksheet and added a more detailed calculation.

diffeq.mw

Cayley Omega Process...

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.

how to remove duplicates from a set or list?...

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

 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >
 (5)
 >
 (6)
 >
 (7)
 >
 (8)
 >
 (9)
 >
 (10)
 >
 (11)
 >
 (12)
 >

how can i get this ?...

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 !!

How do I get a meaningful error message?...

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?

Code for Solving following second order matrix dif...

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

Histogram of normally distributed random integers...

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

How to 3D print a vector field showing field stren...

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( ------- ------- ------- ------- ------- ------- -------);

Difference between results of Maple And Matlab...

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:

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...

how to find infinity norm for function of fraction exponenctial

Phase Portraits in Maple...

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?

Do the divergences vanish or not?...

with(Physics):
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].