Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hello,

I am trying to discretize high order derivatives (typicaly of order 3-4) and I would like to use maple to avoid errors. Using this thread of discussion I got the following minimum example that illustrates the problem I am facing:

NULL

# central discretisation u_xx, i=1,..,n-1
dxc:=add([1,-2,1] *~ [u[i+k,j] $k=-1..1])/(h^2);

(u[i-1, j]-2*u[i, j]+u[i+1, j])/h^2

(1)

NULL

# we need to compute gradient(laplacian) on faces i+1/2,j and i-1/2,j.

#First diff(u_xx,x)|i+1/2,j
d1:=add([1,-1] *~ [dxc[i+p,j] $p=0..1])/(h);
#which should give
d1:=add([1,3,-3,1] *~ [u[i+k,j] $k=-1..2])/(h^3);

(((u[i-1, j]-2*u[i, j]+u[i+1, j])/h^2)[i, j]-((u[i-1, j]-2*u[i, j]+u[i+1, j])/h^2)[i+1, j])/h

 

(u[i-1, j]+3*u[i, j]-3*u[i+1, j]+u[i+2, j])/h^3

(3)

NULL

I would like maple to evaluate the first expression for d1 and give the second expression that I wrote manually.

Is there a way to do this ? (using simplify() does't produce anything)

Cheers,

Download high_order_derivatives.mw

Kind help to implement the attached flowchart

 

Finding_Detour_using_alorigthm.pdf

Just experienced a strange response from Maple when I changed the Font anti-aliasing to enabled.

With Font anti-aliasing disabled I ran evalf(Pi,100) and Maple returned 100 digits - no problem.  I then did some other errands in other programs leaving Maple idle, when I came back I thought I would change anti-aliasing to enabled and see if maybe that's the reason why some users are experiencing icons disappearing etc..

Well I re entered and evalueated evalf(Pi,100) and Maple only output 10 digits.  Huh??? What!? Why?  changed font anti-aliasing back but no joy.  So I closed Maple and I got a pop up

Maybe it was hiding behind Maple I don't know but I don't think it was there until I closed Maple.  It seems this OpenJDK platform I believe is causing a lot of Maple issues.

Whoa!  That's really odd.  My restart was with Maple Font anti-aliasing enabled I performed a evalf(Pi,100) and no problem.  I changed to Font anti-aliasing disabled and evalf(Pi,100) presented me with 10 digits!

What the heck is going on.  This font anti-aliasing enabled caused my Maple to slow down as the screen filled up (as I recorded in a earlier post months ago) and now toggling anti-aliasing causes the outputs to not work as expected.  It's gotta be an open JDK issue. (FYI closing Maple did not produce the same pop-up as earlier - I expect idling maple for a while might)

In the following example, the information in which range fsolve should search for a solution and the range in which a function is defined is somehow redundant. (This example has been adopted from here where fsolve without assumptions does not throw an error but evaluates forever.)

Why can’t fsolve not always assume that the range equals the domain of interest? This would make life easier and provide more solutions to inexperienced users who have not yet learned the need for assumptions.

If there are good reasons (and there probably are) that such an implicit assumption (i.e. range equals domain) would be too restrictive: can’t fsolve give a hint or provide an new option to use ranges as assumptions?

Example with incomplete elliptic integral of the first kind

f := proc (x__0) options operator, arrow; int(1/(sqrt(x__0-x)*sqrt(-x^2+1)), x = 0 .. x__0) end proc

proc (x__0) options operator, arrow; int(1/(sqrt(x__0-x)*sqrt(-x^2+1)), x = 0 .. x__0) end proc

(1)

Range := 0 .. 1; plot(f(x__0), x__0 = Range, labels = [x__0, 'f(x__0)'])

 

f(.5) = 1.524886838NULL

Defining the inverse of f

g := proc (y) options operator, arrow; fsolve(`assuming`([f(x__0) = y, x__0 = Range], [lhs(Range) <= x__0 and x__0 <= rhs(Range)])) end proc

proc (y) options operator, arrow; fsolve(`assuming`([f(x__0) = y, x__0 = Range], [lhs(Range) <= x__0 and x__0 <= rhs(Range)])) end proc

(2)

x__0 = g(f(.5)) → x__0 = .5000000000NULL

Now without assumptions

h := proc (y) options operator, arrow; fsolve(f(x__0) = y, x__0 = Range) end proc

proc (y) options operator, arrow; fsolve(f(x__0) = y, x__0 = Range) end proc

(3)

h(f(.5))

Error, (in fsolve) cannot determine if this expression is true or false: abs(Re(x))+abs(Im(x)) <= 0.

 

``

Download ranges_as_assumptions.mw

I am trying to obtain the solution of the differential equation f'''+ff''-f'^2-Mf'=0, with f(0)=0, f'(0)=1, and f'(5)=0 with M=0.5 using finite element method

But got this error. I attached the file also.

restart

with(LinearAlgebra):

with(plots):

M := .5;

.5

(1)

a := 0;

0

(2)

b := 5;

5

(3)

N := 50;

50

(4)

h := (b-a)/N;

1/10

(5)

nodes := [seq(h*i+a, i = 0 .. N)];

[0, 1/10, 1/5, 3/10, 2/5, 1/2, 3/5, 7/10, 4/5, 9/10, 1, 11/10, 6/5, 13/10, 7/5, 3/2, 8/5, 17/10, 9/5, 19/10, 2, 21/10, 11/5, 23/10, 12/5, 5/2, 13/5, 27/10, 14/5, 29/10, 3, 31/10, 16/5, 33/10, 17/5, 7/2, 18/5, 37/10, 19/5, 39/10, 4, 41/10, 21/5, 43/10, 22/5, 9/2, 23/5, 47/10, 24/5, 49/10, 5]

(6)

elements := [seq([i, i+1], i = 0 .. N-1)];

[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50]]

(7)

bilinear := proc (u, v, w) options operator, arrow; int(diff(u(x), `$`(x, 3))+u(x)*(diff(u(x), `$`(x, 2)))-(diff(u(x), x))^2-M*u(x)*(diff(u(x), x)), x = w[1] .. w[2])+int((diff(u(x), x))*(diff(v(x), x)), x = w[1] .. w[2]) end proc;

proc (u, v, w) options operator, arrow; int(diff(u(x), `$`(x, 3))+u(x)*(diff(u(x), `$`(x, 2)))-(diff(u(x), x))^2-M*u(x)*(diff(u(x), x)), x = w[1] .. w[2])+int((diff(u(x), x))*(diff(v(x), x)), x = w[1] .. w[2]) end proc

(8)

Llinear := proc (v, w) options operator, arrow; v(a)*(diff(w(x), x)) end proc, x = a;

proc (v, w) options operator, arrow; v(a)*(diff(w(x), x)) end proc, x = 0

(9)

K := CreateMatrix(N+1, N+1, 0);

CreateMatrix(51, 51, 0)

(10)

F := CreateVector(N+1, 0);

CreateVector(51, 0)

(11)

for e in elements do x1 := nodes[e[1]]; x2 := nodes[e[2]]; h := x2-x1; Ke := bilinear(proc (x) options operator, arrow; piecewise(x < x1+(1/2)*h, 1-(x-x1)/h, (x2-x)/h) end proc, proc (x) options operator, arrow; piecewise(x < x1+(1/2)*h, (x-x1)/h, (x2-x)/h) end proc, [x1, x2]); Fe := Llinear(proc (v) options operator, arrow; v(x)*piecewise(x = x1, 1, x <> x1) end proc, [x1, x2]); for i in [e[1], e[2]] do for j in [e[1], e[2]] do K[i, j] := K[i, j]+Ke[i-e[1]+1, j-e[1]+1] end do; F[i] := F[i]+Fe[i-e[1]+1] end do end do

Error, invalid subscript selector

 

K[1, 1] := 1;

1

 

0

 

0

(12)

K[N+1, N+1] := 1;

1

 

0

(13)

u := LinearSolve(K, F)

Error, (in LinearAlgebra:-LinearSolve) invalid input: LinearAlgebra:-LinearSolve expects its 1st argument, A, to be of type {Matrix, list({Matrix, Vector})} but received K

 

f := unapply(u(x), x);

proc (x) options operator, arrow; u(x) end proc

 

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

 

 

``

``

Download FEM.mw

Given a graph G and a vertex v find the shortest self returning walk from that visits all vertices starts at v and comes back to v.

In the below graph the shortest self returning walk which visits all vertices and comes back to first to started vertex

A function which takes a graph G  and  vertex v as input and returns the length of the  shortest self returning walk of that vertex in the below example 10

 

I am sorry for the error i just saw the change after reading more in deep

 

For the vertex 7 the shortest self returning walk from that visits all vertices starts at 7 and comes back to 7 It is a walk so edges can repeat

 

The closed walk which passes through all vertices minimum from vertex 7 is so length 10. is what it means

so it returns 10.

A function which takes a matrix as input and k the number of places to round to Given a matrix

 

Matrix(17, 17, [[0, 1.67136411, 3.04642520, 3.03792037, 4.46305818, 4.48953189, 11.44947182, 11.44363094, 5.99694026, 10.05030814, 10.04436470, 12.86806872, 12.86675621, 8.65792026, 11.48220112, 11.47942388, 10.13243670], [1.67136411, 0, 1.37506109, 1.36655626, 2.79169407, 2.81816777, 9.77810770, 9.77226682, 4.32557615, 8.37894403, 8.37300059, 11.19670460, 11.19539209, 6.98655615, 9.81083701, 9.80805976, 8.46107258], [3.04642520, 1.37506109, 0, 2.74161735, 1.41663298, 4.19322886, 8.40304661, 8.39720573, 5.70063724, 7.00388294, 6.99793950, 12.57176570, 12.57045318, 5.61149506, 11.18589810, 11.18312085, 9.83613367], [3.03792037, 1.36655626, 2.74161735, 0, 4.15825033, 1.45161152, 11.14466396, 11.13882308, 2.95901989, 9.74550028, 9.73955684, 9.83014835, 9.82883584, 8.35311240, 8.44428075, 8.44150350, 7.09451633], [4.46305818, 2.79169407, 1.41663298, 4.15825033, 0, 5.60986184, 6.98641363, 6.98057275, 7.11727022, 5.58724996, 5.58130652, 13.98839867, 13.98708616, 4.19486208, 12.60253107, 12.59975383, 11.25276665], [4.48953189, 2.81816777, 4.19322886, 1.45161152, 5.60986184, 0, 12.59627548, 12.59043460, 1.50740837, 11.19711180, 11.19116836, 8.37853683, 8.37722432, 9.80472392, 6.99266923, 6.98989199, 5.64290481], [11.44947182, 9.77810770, 8.40304661, 11.14466396, 6.98641363, 12.59627548, 0, 5.58361857, 14.10368385, 6.98420414, 4.19901549, 20.97481231, 20.97349980, 5.59181627, 19.58894471, 19.58616747, 18.23918029], [11.44363094, 9.77226682, 8.39720573, 11.13882308, 6.98057275, 12.59043460, 5.58361857, 0, 14.09784297, 4.19891293, 6.98410159, 20.96897143, 20.96765892, 5.59130081, 19.58310383, 19.58032659, 18.23333941], [5.99694026, 4.32557615, 5.70063724, 2.95901989, 7.11727022, 1.50740837, 14.10368385, 14.09784298, 0, 12.70452017, 12.69857674, 6.87112846, 6.86981595, 11.31213229, 5.48526086, 5.48248361, 4.13549644], [10.05030814, 8.37894403, 7.00388294, 9.74550028, 5.58724996, 11.19711180, 6.98420414, 4.19891293, 12.70452017, 0, 5.59817917, 19.57564863, 19.57433612, 6.99097994, 18.18978103, 18.18700379, 16.84001661], [10.04436470, 8.37300059, 6.99793950, 9.73955684, 5.58130652, 11.19116836, 4.19901549, 6.98410159, 12.69857673, 5.59817917, 0, 19.56970519, 19.56839268, 6.99056705, 18.18383759, 18.18106035, 16.83407317], [12.86806871, 11.19670460, 12.57176569, 9.83014835, 13.98839867, 8.37853683, 20.97481232, 20.96897144, 6.87112846, 19.57564864, 19.56970520, 0, 5.47162962, 18.18326076, 6.88344719, 4.18501750, 5.53368276], [12.86675620, 11.19539209, 12.57045318, 9.82883584, 13.98708616, 8.37722432, 20.97349980, 20.96765892, 6.86981595, 19.57433612, 19.56839268, 5.47162962, 0, 18.18194824, 4.18355276, 6.88198245, 5.53331719], [8.65792026, 6.98655615, 5.61149506, 8.35311240, 4.19486208, 9.80472392, 5.59181627, 5.59130081, 11.31213229, 6.99097994, 6.99056705, 18.18326075, 18.18194824, 0, 16.79739315, 16.79461591, 15.44762873], [11.48220112, 9.81083701, 11.18589810, 8.44428075, 12.60253108, 6.99266923, 19.58894472, 19.58310384, 5.48526086, 18.18978104, 18.18383760, 6.88344719, 4.18355276, 16.79739316, 0, 5.57088509, 6.91955036], [11.47942387, 9.80805976, 11.18312085, 8.44150350, 12.59975383, 6.98989199, 19.58616748, 19.58032660, 5.48248361, 18.18700380, 18.18106036, 4.18501750, 6.88198245, 16.79461592, 5.57088509, 0, 6.92064952], [10.13243670, 8.46107258, 9.83613367, 7.09451633, 11.25276665, 5.64290481, 18.23918030, 18.23333942, 4.13549644, 16.84001662, 16.83407318, 5.53368276, 5.53331719, 15.44762874, 6.91955036, 6.92064952, 0]])

 

Convert all the digits in the matrix to k decimal places where k I can specify After converting to decimal places it should not show zero's at the end of the decimal places. Kind help

[sqrt(-3)^1, sqrt(-3)^7];
map(indets, %, radnumext),
map(indets, %, radext),
map(indets, %, radical);


Is this going to be fixed/removed?

Please check the following examples, first without using Units, and the second using it:

No Units:

 

With Units:

 

Why does the with(Units) doesn't compute the value? How can I make it work?

Thanks

Can I force the output of maple to follow a specific width?

For example, I want the output to go to a new line after 10 characters of output

So instead of

seq(i,i=1..20)
                           

I want the output as
1,2,3,4,5,/
6,7,8,9,10/
,11,12,13,/
14,15,16,1/
7,18,19,20

 

I am trying make atomic variables stand out in the document, I thought they used to automatically change to a purple type colour.

So under Format, styles , I set the style to size 14, Bold, dark green.  The font changed on the existing ones but not the colour.

On new ones no setting occours just default text. I then restored to default settings under styles and they all turned purple including the new ones.

Then I made another one but no adoption of the default style (purple) occured. 

This fiddlyness needs to be improved  

Has anyone any suggestions to make the atomic variables adope their default colour etc?

in phase portrait 3d , i use 4 initial condition, How  can I draw each initial condition in diferent colour. it very helpfull so i can see the moving of each IC. Thank you

Hello! I've been trying to solve system of non-linear differential equations. The equations are quite messy, so I've attached the file itself dsolve.mw. I have read about the similar problems, but they all are related to some expressions having multiple branches. I'm not quite sure where this problem occurs (if it does) here and how to solve it.

For example if we have : a*b+c*(d+e)+f+g+h*(k*p+l):
is there a way to write a loop or script so it could give me: [a*b,c*(d+e),f,g,h*(k*p+l)]:

hi Maplers
I want to solve the following differential equation numerically. but i get error

restart;
eqn := (diff(H(K),K))^3+4*K^4*H(K)^4*diff(H(K),K)+8*K^4*H(K)^5=0;
ics := H(0)=1/2;
sol := dsolve({eqn,ics},numeric);
Error, (in DEtools/convertsys) unable to convert to an explicit first-order system
First 99 100 101 102 103 104 105 Last Page 101 of 2097