tomleslie

13876 Reputation

20 Badges

15 years, 182 days

MaplePrimes Activity


These are replies submitted by tomleslie

you got 'mugged' by using 2-D math input - but I'm not sure exactly how!

In 2-D math input, most quantities (ie commands names etc) are rendered in an italic font, but simple numbers are rendered in a non-italic font.

In the DiscretePlot() commands, the +~ construct, is followed by an integer which is rendered in an italic font. Not sure how you managed to "achieve" this (or how it is being interpreted!!)

In the following, all I did was to delete the 'italic' numerals 1,2,3, and retype 1,2,3, which all appeared in an 'upright' font

Check out the attached:

``

restart; with(LinearAlgebra); with(DynamicSystems); pts := 20; T := Vector([`$`(1, pts)]); A := RandomMatrix(pts, pts, generator = 0. .. 1.0); p1 := DiscretePlot(A[1, () .. ()], T, style = stem, colour = red); plots:-display([p1]); p2 := DiscretePlot(A[2, () .. ()], `~`[`+`](T, 1), style = stem, baseline = 1, color = blue); p3 := DiscretePlot(A[3, () .. ()], `~`[`+`](T, 2), style = stem, baseline = 2, color = green); p4 := DiscretePlot(A[4, () .. ()], `~`[`+`](T, 3), style = stem, baseline = 3, color = black); plots:-display([p1, p2, p3, p4])

 

 

 

NULL


 

Download stemplot4.mw

 

 

  1. Specify which version of Maple you are using
  2. Upload the problem worksheet here using the big green up-arrow in the Mapleprimes toolbar

 

@Bosco Emmanuel 

Do you mean something more like the attached? (Again rendering is better in worksheet)

  restart;
  with(LinearAlgebra):
  with(DynamicSystems):
#
# Geberate some more or less random data for illustrative
# purposes
#
  pts:=20:
  T:=Vector([1$pts]):
  A:=RandomMatrix(pts, pts, generator=0.0..1.0):
#
# Produce a single 'stem' plot: each stem is fixed
# height, x-position determined by value in the
# first row of the above matrix.
#
  p1:=DiscretePlot(A[1,..],T, style=stem, colour=red);

#
# Produce further plots, from successive matrix rows,
# (offsetting these in the y-direction,
#
  p2:=DiscretePlot(A[2,..], T+~1, style=stem, baseline=1, color=blue):
  p3:=DiscretePlot(A[3,..], T+~2, style=stem, baseline=2, color=green):
  p4:=DiscretePlot(A[4,..], T+~3, style=stem, baseline=3, color=black):
  plots:-display([p1,p2,p3,p4]);

 

 

 

Download stemPlot2.mw

@Adam Ledger 

the atttached?

restart;
expr:=product( n/k^2-1/(k*n), k=1..n-3) assuming n::posint;
limit(expr, n=infinity);

GAMMA(n^2)*n*n^(-n+2)/(GAMMA(n^2-n+3)*GAMMA(n-2)^2)

 

0

(1)

 

Download getlim.mw

This code is either doing something very clever, or.........

The Duffing equation is not difficult to solve (numerically) in Maple. The attached uses the definition of the Duffing equation from https://en.wikipedia.org/wiki/Duffing_equation, and produces the solution for one of the examples given in the same page.

You say "Actually, I just follow the example, but it doesn't work". What example? From where?

  restart;
#
# Set up the Duffing equation using notation from
# Wikipedia article at https://en.wikipedia.org/wiki/Duffing_equation
#
  ode := diff(x(t),t,t)+delta*diff(x(t),t)+alpha*x(t)+beta*x(t)^3-gamma*cos(omega*t) = 0:
#
# As an illustrative solution, use the values for parameters
# and initial conditions from the examples section of the
# above Wikipedia article
#
  sol:=dsolve( { eval(ode, [ alpha=-1,
                             beta=1,
                             delta=0.3,
                             omega=1.2,
                             gamma=0.5
                           ]
                     ),
                 x(0)=1,
                 D(x)(0)=0
               },
               numeric,
               maxfun=0
             ):
#
# Set range for solution, NB avoid t=0 to let
# the start-up transient "die out"
#
  pRange:=400..600:
#
# Plot simple solution as a function of time
# ie x(t) versus t
#
  plots:-odeplot( sol,
                 [t, x(t)],
                 t=pRange,
                 numpoints=10000
               );
#
# Plot diff(x(t),t) versus x(t), showing
# 'chaos'
#
  plots:-odeplot( sol,
                  [x(t), diff(x(t),t)],
                  t=pRange,
                  numpoints=10000
                );

 

 

 


 

Download duffing.mw

 

@Carl Love 

but I think you need n>2 (rather than n>=2), cos evaluation with n=2 will fail.

Returned expression contains GAMMA(n-2) and GAMMA(0) is undefined.

  restart;
#
# Carl's suggestion
#
  expr1:=product(n/k^2-1/(k*n), k=1..n-3) assuming n::posint;
#
# Returned expression will still *barf* if n=1 or 2
#
  eval(expr1, n=1);
  eval(expr1, n=2);
#
# But since OP seems only interested in n>=3
# I guess this is OK?
#
  seq( eval(expr1, n=j), j=3..10);

GAMMA(n^2)*n*n^(-n+2)/(GAMMA(n^2-n+3)*GAMMA(n-2)^2)

 

Error, (in GAMMA) numeric exception: division by zero

 

Error, (in GAMMA) numeric exception: division by zero

 

1, 15/4, 138/25, 6545/1296, 16215/4802, 2342949/1310720, 7512505/9565938, 29537761/100000000

(1)

 

 


 

Download gammaProb.mw

@Carl Love 

  1. If m is a positive integer factorial(m) returns the product of the integers 1..m, ie mul(1..m).
  2. If m is 0, then factorial(m) returns 1
  3. If m is any other value (eg a float, complex whatever) then factorial(m) calls GAMMA(m+1), so, for example, factorial(-7.2+3.1*I) will return the same as GAMMA(-6.2+3.1*I)
  4. The GAMMA function is defined everywhere on the complex plane with the exception of the negative integers. Hence both GAMMA() and factorial() will 'Error' for negative integer arguments
  5. The OP's first expression contains GAMMA(1-n^2), so assuming n::posint  will not help, since 1-n^2 will be a negative integer (except for the trivial case n=+/-1)
  6. The OP's second expression contains GAMMA(-n^2+n-2), equivalently,  factorial(-n^2+n-3), both of which result in negative integer arguments, for any value of 'n' (positive or negative)

is a simple 'line contiuation', so extending your original code would just give

Y:= (delta,b,n) -> piecewise
                   ( n=0, 1/(1+b^2),
                     n=1, arctan(1/b),
                     n=2, 1+ln(b^2 + 1)/2-b*arctan(1/b),
                     n=3, 1/2*(2*delta-3*b-2*b*ln(b^2 + 1)/2+arctan(1/b)*(b^2-1)),
                     n=4, (1/36)*(18*delta^2-36*delta*b+33*b^2-11+6*ln(b^2 + 1)/2*(3*b^2-1)+6*b*arctan(1/b)*(3-b^2)),
                     n=5, (1/72)*(24*delta^3-36*delta^2*b+12*delta*(3*b^2-1)+25*b-25*b^3+12*b*log(b^2 + 1)/2*(1-b^2)+3*arctan(1/b)*(1-6*b^2+b^4)),
                     n=6, (1/7200)*(1800*delta^4-2400*delta^2*b+600*delta^2*(3*b^2-1)+1200*b*delta*(1-b^2)+685*b^4-1370*b^2+137+60*log(b^2 + 1)/2*(5*b^4-10*b^2+1)+60*b*arctan(1/b)*(-5+10*b^2-b^4)),
                     n=7, (1/21600)*(4320*delta^5-5400*delta^4*b+1200*delta^3*(3*b^2-1)+1800*delta^2*b*(1-b^2)+180*delta*(5*b^4-10*b^2+1)-441*b+1470*b^3-441*b^5+60*b*log(b^2 + 1)/2*(-3*b^4+10*b^2-3)+30*arctan(1/b)*(-1+15*b^2-15*b^4+b^6))
                   ):
plot(Y(2,b,7), b=0..10);

with(Student:-MultivariateCalculus):
P5 := <-11/12,-7/36,-47/36>:
P1 := <-17/12,11/36,-65/36>:
P6 := <-2/3,-1/9,-8/9>:
P8 := <-5/4,-1/12,-17/12>:
TripleScalarProduct(P1-P5,P6-P5, P8-P5);

and the answer is 1/18, as Kitonum's solution has already demonstrated

For example on my machine (Win7 64-bit), if I run Maple "normally" (ie with User privileges) and try saving to my default Windows directory ie C::\Windows, then I get a message "Maple is unable to write, blah, blah)"

On the other hand, if I run Maple as an "administrator", then I can write to my default Windows directory

This difference in behaviour is to be expected- it is designed to protect the inexperienced/careless user from trashing their own OS (or other applications)

of 'implied multiplication', and worksheet now executes . See attached


 

with(DifferentialGeometry)with(Tensor)with(LieAlgebras)

DGsetup([z, r, theta, phi], M)

`frame name: M`

(1)
M > 

g1 := evalDG(r*`&t`(dz, dz)/(4*m+r)+4*mr*(1-cos(theta))*`&t`(dphi, dz)/(4*m+r)+4*mr*(1-cos(theta))*`&t`(dz, dphi)/(4*m+r)+(4*m+r)*`&t`(dr, dr)/r+r*(4*m+r)^2*(16*m^2*(1-cos(theta))^2/(4*m+r)^2+sin(theta)^2)*`&t`(dphi, dphi)*(1/r)+r*(4*m+r)^2*`&t`(dtheta, dtheta)*(1/r))

_DG([["tensor", M, [["cov_bas", "cov_bas"], []]], [[[1, 1], r/(4*m+r)], [[1, 4], -4*mr*(-1+cos(theta))/(4*m+r)], [[2, 2], (4*m+r)/r], [[3, 3], (4*m+r)^2], [[4, 1], -4*mr*(-1+cos(theta))/(4*m+r)], [[4, 4], -8*cos(theta)^2*m*r-cos(theta)^2*r^2-32*cos(theta)*m^2+32*m^2+8*m*r+r^2]]])

(2)
M > 

C1 := Christoffel(g1, "FirstKind")

_DG([["tensor", M, [["cov_bas", "cov_bas", "cov_bas"], []]], [[[1, 1, 2], 2*m/(4*m+r)^2], [[1, 2, 1], 2*m/(4*m+r)^2], [[1, 2, 4], 2*mr*(-1+cos(theta))/(4*m+r)^2], [[1, 3, 4], 2*mr*sin(theta)/(4*m+r)], [[1, 4, 2], 2*mr*(-1+cos(theta))/(4*m+r)^2], [[1, 4, 3], 2*mr*sin(theta)/(4*m+r)], [[2, 1, 1], -2*m/(4*m+r)^2], [[2, 1, 4], -2*mr*(-1+cos(theta))/(4*m+r)^2], [[2, 2, 2], -2*m/r^2], [[2, 3, 3], -4*m-r], [[2, 4, 1], -2*mr*(-1+cos(theta))/(4*m+r)^2], [[2, 4, 4], -sin(theta)^2*(4*m+r)], [[3, 1, 4], -2*mr*sin(theta)/(4*m+r)], [[3, 2, 3], 4*m+r], [[3, 3, 2], 4*m+r], [[3, 4, 1], -2*mr*sin(theta)/(4*m+r)], [[3, 4, 4], -sin(theta)*(8*cos(theta)*m*r+cos(theta)*r^2+16*m^2)], [[4, 1, 2], 2*mr*(-1+cos(theta))/(4*m+r)^2], [[4, 1, 3], 2*mr*sin(theta)/(4*m+r)], [[4, 2, 1], 2*mr*(-1+cos(theta))/(4*m+r)^2], [[4, 2, 4], sin(theta)^2*(4*m+r)], [[4, 3, 1], 2*mr*sin(theta)/(4*m+r)], [[4, 3, 4], sin(theta)*(8*cos(theta)*m*r+cos(theta)*r^2+16*m^2)], [[4, 4, 2], sin(theta)^2*(4*m+r)], [[4, 4, 3], sin(theta)*(8*cos(theta)*m*r+cos(theta)*r^2+16*m^2)]]])

(3)
M > 

C2 := Christoffel(g1, "SecondKind")

_DG([["connection", M, [["con_bas", "cov_bas", "cov_bas"], []]], [[[1, 1, 2], 2*(32*cos(theta)*m^3*r+12*cos(theta)*m^2*r^2+cos(theta)*m*r^3+128*m^4+64*m^3*r+12*m^2*r^2+m*r^3-4*cos(theta)*mr^2+4*mr^2)/((4*m+r)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))], [[1, 1, 3], -8*mr^2*sin(theta)/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[1, 2, 1], 2*(32*cos(theta)*m^3*r+12*cos(theta)*m^2*r^2+cos(theta)*m*r^3+128*m^4+64*m^3*r+12*m^2*r^2+m*r^3-4*cos(theta)*mr^2+4*mr^2)/((4*m+r)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))], [[1, 2, 4], 2*(-1+cos(theta))*(32*cos(theta)*m^2+24*cos(theta)*m*r+3*cos(theta)*r^2+64*m^2+24*m*r+3*r^2)*mr/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[1, 3, 1], -8*mr^2*sin(theta)/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[1, 3, 4], -2*r*mr*(4*m+r)*(8*m+r)*(-1+cos(theta))*sin(theta)/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[1, 4, 2], 2*(-1+cos(theta))*(32*cos(theta)*m^2+24*cos(theta)*m*r+3*cos(theta)*r^2+64*m^2+24*m*r+3*r^2)*mr/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[1, 4, 3], -2*r*mr*(4*m+r)*(8*m+r)*(-1+cos(theta))*sin(theta)/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[2, 1, 1], -2*r*m/(4*m+r)^3], [[2, 1, 4], -2*r*mr*(-1+cos(theta))/(4*m+r)^3], [[2, 2, 2], -2*m/((4*m+r)*r)], [[2, 3, 3], -r], [[2, 4, 1], -2*r*mr*(-1+cos(theta))/(4*m+r)^3], [[2, 4, 4], -r*sin(theta)^2], [[3, 1, 4], -2*mr*sin(theta)/(4*m+r)^3], [[3, 2, 3], 1/(4*m+r)], [[3, 3, 2], 1/(4*m+r)], [[3, 4, 1], -2*mr*sin(theta)/(4*m+r)^3], [[3, 4, 4], -sin(theta)*(8*cos(theta)*m*r+cos(theta)*r^2+16*m^2)/(4*m+r)^2], [[4, 1, 2], -2*mr/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[4, 1, 3], 2*r*mr*(cos(theta)+1)/(sin(theta)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))], [[4, 2, 1], -2*mr/(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2)], [[4, 2, 4], (64*cos(theta)*m^3*r+48*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+64*m^3*r+48*m^2*r^2+12*m*r^3+r^4-8*cos(theta)*mr^2+8*mr^2)/((4*m+r)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))], [[4, 3, 1], 2*r*mr*(cos(theta)+1)/(sin(theta)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))], [[4, 3, 4], (cos(theta)+1)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+64*m^3*r+16*m^2*r^2+8*cos(theta)*mr^2-8*mr^2)/(sin(theta)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))], [[4, 4, 2], (64*cos(theta)*m^3*r+48*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+64*m^3*r+48*m^2*r^2+12*m*r^3+r^4-8*cos(theta)*mr^2+8*mr^2)/((4*m+r)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))], [[4, 4, 3], (cos(theta)+1)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+64*m^3*r+16*m^2*r^2+8*cos(theta)*mr^2-8*mr^2)/(sin(theta)*(32*cos(theta)*m^2*r^2+12*cos(theta)*m*r^3+r^4*cos(theta)+128*m^3*r+64*m^2*r^2+12*m*r^3+r^4+16*cos(theta)*mr^2-16*mr^2))]]])

(4)
M > 

KillingVectors(g1, parameters = [m])

[_DG([["vector", M, []], [[[1], 1]]]), _DG([["vector", M, []], [[[4], (1/4)/mr]]])], [_DG([["vector", M, []], [[[1], 1], [[4], m/mr]]]), _DG([["vector", M, []], [[[4], (1/4)/mr]]])], [{m = 0}, {m = m}]

(5)

restart

NULL


 

Download impliedMult.mw

that you can use Filetools() to check whether a given file is "readable" or not. Extending my previous post

restart;
kernelopts(version);
with(DocumentTools):
src := FileTools:-JoinPath(["example/BesselsEquation.mw"],base=datadir);
FileTools:-IsReadable(src);
Retrieve( src, "L6");

`Maple 2018.0, X86 64 WINDOWS, Mar 9 2018, Build ID 1298750`

 

"C:\Program Files\Maple 2018\data\example/BesselsEquation.mw"

 

true

 

x^2*(diff(diff(y(x), x), x))+x*(diff(y(x), x))+(-nu^2+x^2)*y(x) = 0

(1)

 

Download retProb2.mw

If the IsReadable() command returns 'true' then I'd conclude that the target file does not contain the requested label

If you want to add restrictions on the parameteres used in my previous post, then you could use

assume(a::RealRange(0,infinity));

or

assume(b::integer(1,100));

although I am doubtful that such assumptions are necessary

what part of

  restart;
  with(VectorCalculus):
#
# define a vector field with arbitary basis coefficients
#
  v1 := VectorField( <a, b, c>, 'cartesian'[x,y,z] );
#
# generate a vector field with specific values for the
# basis coefficients
#
  v2:=eval(v1, [a=1, b=2, c=3]);

 

doesn't work for you

illustrating the problem, using the big green up-arrow in the Mapleprimes tool bar.

You can do a quick/dirty check on what is happening by setting infolevel, as in the toy example

restart;
infolevel[all]:=5;
evalf(Int( exp(-x^3)/(x^2+1), x = 0..1 ));


which will return

evalf/int/control: integrating on 0 .. 1 the integrand
                               /  3\
                            exp\-x /
                            --------
                              2     
                             x  + 1
evalf/int/control: tolerance = .5000000000e-9; method = _DEFAULT; method options = []
Control: Entering NAGInt
Control: trying d01ajc (nag_1d_quad_gen)
d01ajc: epsabs=.500000000000000e-12; epsrel=.5000000000e-9; max_num_subint=200
d01ajc: procedure for evaluation is:
proc (x) exp(-1.*x^3)/(x^2+1.) end proc
d01ajc: trying evalhf callbacks
d01ajc: result=.664936943073927478
d01ajc: abserr=.369114152062270785e-14; num_subint=1; fun_count=21
Control: result=.664936943073927478
                          0.6649369431

 

 

 

First 96 97 98 99 100 101 102 Last Page 98 of 207