tomleslie

13876 Reputation

20 Badges

15 years, 170 days

MaplePrimes Activity


These are answers submitted by tomleslie

The example ODE you have chosen is not the smartest choice since it can be solve trivially with the dsolve() command. This solution is shown in the attached.

Since the actual solution is simple to obtain, the obvious question is - why bother with the method of multiple scales???

Maybe you want to do this for some pedagogic purpose? (NB the general solution obtained from dsolve() is linear in the variable 'tau' and there would seem to be no reason to look at different "scales" for the variable 'tau')

Assuming some kind of pedagogic purpose, as Rouben and Carl have noted, there are various problems with your implementation of the dsolve() command and the validity of your boundary conditions. The attached shows how far I got trying to fix these, without ever actually arriving at something functional - because the last error message makes no sense to me:-(


 

Method of Multiple Scales


Initial commands:

restart:
with(PDEtools):


Differential equation:

de:= (5.5693*v[0]*q(tau)-0.7175*q(tau)^2-10.801*v[0]^2+0.9997)*diff(q(tau),tau$2);

(5.5693*v[0]*q(tau)-.7175*q(tau)^2-10.801*v[0]^2+.9997)*(diff(diff(q(tau), tau), tau))

(1)

#
# The above can be solved directly. There are two particular
# solutions - essentially roots of the term
#
#   5.5693*v[0]*q(tau) - 0.7175*q(tau)^2 - 10.801*v[0]^2 + 0.9997=0
#
# and one general solution, essentially obtained by solving the term
#
#   diff(q(tau), tau, tau)=0
#
# Since q(tau) is linear in tau, this seems like a very odd example
# to choose for demonstrating the "multiple scales" method, even if
# the latter has been correctly interpreted/coded
#
  dsolve(de);

q(tau) = (55693/14350)*v[0]-(1/14350)*(1823249*v[0]^2+286913900)^(1/2), q(tau) = (55693/14350)*v[0]+(1/14350)*(1823249*v[0]^2+286913900)^(1/2), q(tau) = _C1*tau+_C2

(2)


Multiple-scale expansion:

q(tau) = e*Q[1](T[0],T[1])+e^2*Q[2](T[0],T[1]);

q(tau) = e*Q[1](T[0], T[1])+e^2*Q[2](T[0], T[1])

(3)


 

subs(T[0] = tau, T[1] = e*tau, (3)):
diff(%, tau):
subs(e*tau = T[1], tau = T[0], %):
collect(%, e, factor);

diff(q(T[0]), T[0]) = (D[2](Q[2]))(T[0], T[1])*e^3+((D[2](Q[1]))(T[0], T[1])+(D[1](Q[2]))(T[0], T[1]))*e^2+(D[1](Q[1]))(T[0], T[1])*e

(4)


 

subs(T[0] = tau, T[1] = e*tau, (3)):
subs(%, de):
expand(%):
subs(e*tau = T[1], tau = T[0], %):
collect(%, e, factor):
result:= %;

-.7175*e^8*Q[2](T[0], T[1])^2*(D[2, 2](Q[2]))(T[0], T[1])+(-1.4350*Q[1](T[0], T[1])*Q[2](T[0], T[1])*(D[2, 2](Q[2]))(T[0], T[1])-1.4350*Q[2](T[0], T[1])^2*(D[1, 2](Q[2]))(T[0], T[1])-.7175*Q[2](T[0], T[1])^2*(D[2, 2](Q[1]))(T[0], T[1]))*e^7+(5.5693*v[0]*Q[2](T[0], T[1])*(D[2, 2](Q[2]))(T[0], T[1])-1.4350*Q[1](T[0], T[1])*Q[2](T[0], T[1])*(D[2, 2](Q[1]))(T[0], T[1])-2.8700*Q[1](T[0], T[1])*Q[2](T[0], T[1])*(D[1, 2](Q[2]))(T[0], T[1])-.7175*Q[2](T[0], T[1])^2*(D[1, 1](Q[2]))(T[0], T[1])-1.4350*Q[2](T[0], T[1])^2*(D[1, 2](Q[1]))(T[0], T[1])-.7175*Q[1](T[0], T[1])^2*(D[2, 2](Q[2]))(T[0], T[1]))*e^6+(5.5693*v[0]*Q[2](T[0], T[1])*(D[2, 2](Q[1]))(T[0], T[1])+11.1386*v[0]*Q[2](T[0], T[1])*(D[1, 2](Q[2]))(T[0], T[1])-2.8700*Q[1](T[0], T[1])*Q[2](T[0], T[1])*(D[1, 2](Q[1]))(T[0], T[1])-1.4350*Q[1](T[0], T[1])*Q[2](T[0], T[1])*(D[1, 1](Q[2]))(T[0], T[1])+5.5693*v[0]*Q[1](T[0], T[1])*(D[2, 2](Q[2]))(T[0], T[1])-1.4350*Q[1](T[0], T[1])^2*(D[1, 2](Q[2]))(T[0], T[1])-.7175*Q[1](T[0], T[1])^2*(D[2, 2](Q[1]))(T[0], T[1])-.7175*Q[2](T[0], T[1])^2*(D[1, 1](Q[1]))(T[0], T[1]))*e^5+(5.5693*v[0]*Q[2](T[0], T[1])*(D[1, 1](Q[2]))(T[0], T[1])-1.4350*Q[1](T[0], T[1])*Q[2](T[0], T[1])*(D[1, 1](Q[1]))(T[0], T[1])+5.5693*v[0]*Q[1](T[0], T[1])*(D[2, 2](Q[1]))(T[0], T[1])+11.1386*v[0]*Q[1](T[0], T[1])*(D[1, 2](Q[2]))(T[0], T[1])+11.1386*v[0]*Q[2](T[0], T[1])*(D[1, 2](Q[1]))(T[0], T[1])+.9997*(D[2, 2](Q[2]))(T[0], T[1])-1.4350*Q[1](T[0], T[1])^2*(D[1, 2](Q[1]))(T[0], T[1])-10.801*v[0]^2*(D[2, 2](Q[2]))(T[0], T[1])-.7175*Q[1](T[0], T[1])^2*(D[1, 1](Q[2]))(T[0], T[1]))*e^4+(11.1386*v[0]*Q[1](T[0], T[1])*(D[1, 2](Q[1]))(T[0], T[1])+5.5693*v[0]*Q[1](T[0], T[1])*(D[1, 1](Q[2]))(T[0], T[1])+5.5693*v[0]*Q[2](T[0], T[1])*(D[1, 1](Q[1]))(T[0], T[1])+.9997*(D[2, 2](Q[1]))(T[0], T[1])+1.9994*(D[1, 2](Q[2]))(T[0], T[1])-10.801*v[0]^2*(D[2, 2](Q[1]))(T[0], T[1])-21.602*v[0]^2*(D[1, 2](Q[2]))(T[0], T[1])-.7175*Q[1](T[0], T[1])^2*(D[1, 1](Q[1]))(T[0], T[1]))*e^3+(5.5693*v[0]*Q[1](T[0], T[1])*(D[1, 1](Q[1]))(T[0], T[1])+1.9994*(D[1, 2](Q[1]))(T[0], T[1])+.9997*(D[1, 1](Q[2]))(T[0], T[1])-21.602*v[0]^2*(D[1, 2](Q[1]))(T[0], T[1])-10.801*v[0]^2*(D[1, 1](Q[2]))(T[0], T[1]))*e^2+(.9997*(D[1, 1](Q[1]))(T[0], T[1])-10.801*v[0]^2*(D[1, 1](Q[1]))(T[0], T[1]))*e

(5)


 

coeff(result, e, 0);

0

(6)

 

coeff(result, e, 1):
de1:= convert(%, diff);

.9997*(diff(diff(Q[1](T[0], T[1]), T[0]), T[0]))-10.801*v[0]^2*(diff(diff(Q[1](T[0], T[1]), T[0]), T[0]))

(7)

 

coeff(result, e, 2):
de2 := convert(%, diff);

5.5693*v[0]*Q[1](T[0], T[1])*(diff(diff(Q[1](T[0], T[1]), T[0]), T[0]))+1.9994*(diff(diff(Q[1](T[0], T[1]), T[0]), T[1]))+.9997*(diff(diff(Q[2](T[0], T[1]), T[0]), T[0]))-21.602*v[0]^2*(diff(diff(Q[1](T[0], T[1]), T[0]), T[1]))-10.801*v[0]^2*(diff(diff(Q[2](T[0], T[1]), T[0]), T[0]))

(8)

 

v[0]:= 0:

dsys:= {de1,de2};
ics:= {Q[1](0,0) = 0, Q[2](0,0) = 0, D[1](Q[1])(T[0],0) = 0, D[2](Q[2])(0,T[1]) = 0};
#
# When seeking an analytic solution, the pdsolve()
# syntax is
#
# pdsolve({dsys, ics})
#
# but when seeking a numeric solution, the PDEs and
# ics have to be separated into two sets/lists, so
# one actually needs
#
# pdsolve( dsys, ics, type = numeric);
#
# rather than
#
# pdsolve({dsys, ics}, type = numeric);
#
# Making this simple syntax change alters the error
# message. Maple now complains about the precise
# nature of the boundary/initial conditions
#
  pdsolve( dsys, ics, type = numeric);
 

{.9997*(diff(diff(Q[1](T[0], T[1]), T[0]), T[0])), 1.9994*(diff(diff(Q[1](T[0], T[1]), T[0]), T[1]))+.9997*(diff(diff(Q[2](T[0], T[1]), T[0]), T[0]))}

 

{Q[1](0, 0) = 0, Q[2](0, 0) = 0, (D[1](Q[1]))(T[0], 0) = 0, (D[2](Q[2]))(0, T[1]) = 0}

 

Error, (in pdsolve/numeric/process_IBCs) initial/boundary conditions must depend upon exactly one of the independent variables: Q[1](0, 0) = 0

 

#
# The first problem with the boundary conditions is
# with
#
#      Q[1](0,0) = 0, Q[2](0,0) = 0
#
# since these are conditions at a point, not along a
# boundary. Arbitrarily changing these two conditions
# to something "valid" on a boundary would be something
# like, that below. NB these may (now) not express the
# intended boundary requirements.
#
# This results in a further (but different) error message
#
  ics:= {Q[1](T[0],0) = 0, Q[2](T[0],0) = 0, D[1](Q[1])(T[0],0) = 0, D[2](Q[2])(0,T[1]) = 0};
  pdsolve( dsys, ics, type = numeric);

{Q[1](T[0], 0) = 0, Q[2](T[0], 0) = 0, (D[1](Q[1]))(T[0], 0) = 0, (D[2](Q[2]))(0, T[1]) = 0}

 

Error, (in pdsolve/numeric/process_IBCs) initial/boundary conditions can only contain derivatives which are normal to the boundary, got (D[1](Q[1]))(T[0], 0)

 

#
# The second problem with is that any boundary
# conditions involving derivatives are only valid if
# the derivatives are normal to the boundary. Again make
# an arbitrary change which will ensure that derivative
# bcs are a valid form (although these may not express
# the OP's intent)
#
# This results in a further (but different) error message
#
  ics:= {Q[1](T[0],0) = 0, Q[2](T[0],0) = 0, D[1](Q[1])(0,T[1]) = 0, D[1](Q[2])(0,T[1]) = 0};
  pdsolve( dsys, ics, type = numeric);

{Q[1](T[0], 0) = 0, Q[2](T[0], 0) = 0, (D[1](Q[1]))(0, T[1]) = 0, (D[1](Q[2]))(0, T[1]) = 0}

 

Error, (in pdsolve/numeric/par_hyp) must specify time variable using 'time=varname'

 

#
# Manipulating the boundary conditions again to make these
# normal to the boundaries (probably even further form the
# OP's requirement, changes the error message again - and
# frankly this one I do not understand. 'ics' has four distinct
# entries -ie four boundary/initial conditions, but Maple
# thinks there is only one - I give up
#
 ics:= {Q[1](T[0],0) = 0, Q[2](T[0],0) = 0, D[1](Q[1])(0,T[1]) = 0, D[2](Q[2])(T[0],0) = 0};
  pdsolve( dsys, ics, type = numeric, time=T[1], range=0..1);

{Q[1](T[0], 0) = 0, Q[2](T[0], 0) = 0, (D[1](Q[1]))(0, T[1]) = 0, (D[2](Q[2]))(T[0], 0) = 0}

 

Error, (in pdsolve/numeric/par_hyp) Incorrect number of boundary conditions, expected 4, got 1

 

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL


 

Download mscale.mw

It seems like some plotting commands can handle a plot whose range is zero, and some plotting commands can't!

In the attached animating a plot() command with zero range - no problem, but animating an odeplot() command with zero range - big problem

  restart;
  with(plots):
#
# This animation will work even although, for x=0,
# the embedded plot command has zero range, when x=0
#
  animate(plot, [sin(t), t=0..x], x=0..3 );
#
# However the following will fail with an error if the
# lower limit of the x-range is set to zero. Looks like
# the odeplot() command can't handle a range of zero,
# unlike the plot command above
#
# So this will work
#
  dsol := dsolve({diff(y(t),t) = -y(t), y(0)=1}, numeric):
  animate(odeplot, [dsol, [t,y(t)], t=0..x], x=1e-06..3 );
#
# But this won't :-(
#
  animate(odeplot, [dsol, [t,y(t)], t=0..x], x=0..3 );

 

 

Error, (in plots/animate) invalid range

 

 

 

Download animPlot.mw

although I have no idea how to prove it!

Long, long time ago (and in a completely different piece of software) a "polygon" was define not only by its vertices, but also by a (hidden) "direction attribute" on each edge. This "direction attribute"of a specific edge was assigned simply on the basis of the order in which vertices were entered.

It is relatively simply to see that for a non-intersecting polygon, all of the "direction attributes" would be either clockwise or anticlockwise. The "interior" of the polygon is then any region bounded by edges with consistent "direction attributes", either clockwise or anticlockwise

In the attached, the first, non-intersecting, polygon has a consistent set of clockwise "direction attributes".

The second, self-intersecting polygon has three shaded regions: the upper and lower have consistent clockwise "direction attributes", whilst the region on the left has consistent anticlockwise "direction attributes"

I'm think(?) this used to be known as a "winding" rule

with(plots):
with(plottools):
p1:=polygon( [ [ 0, 0], [0,1], [1,1], [1,0.75],[0.25, 0.75], [0.25, 0.25],[1.0, 0.25], [1.0,0] ]):
display(p1);
p2:=polygon( [ [ 0, 0], [0,1], [1,1], [1,0.75],[-0.25, 0.75], [-0.25, 0.25],[1.0, 0.25], [1.0,0] ]):
display(p2);

 

 

 


 

Download fillpoly.mw

I suggest that you consider the attached, which represents the first few lines of your code. There are some surprisingly illogical definitions/evaluations. Please rad the comments in this code carefully.

The code you posted goes downhill from this point, so I haven't even considered it
 

  restart:
  declare (f(x),g(x),t(x),prime=x):
  L:=5:R:=0.5:M:=5:K:=5:
#
# Notice that in each of the following defnitions
# simplification means that all terms involving 'p'
# disappear before values for f(x), t(x), g(x) are
# substituted - so why are these terms here in the
# first place???
#
  H01:= simplify
        ( (1-p)*(1+K)*diff(f(x),x,x)+p*(1+K)*diff(f(x),x,x)+K*diff(g(x),x)+t(x)-M*f(x)
        );
  H02:= simplify
        ( (1-p)*(1+(K/2))*diff(g(x),x,x)+p*(1+(K/2))*diff(g(x),x,x)-K*diff(f(x),x)-K*2*g(x)
        );
  H03:= simplify
        ( (1-p)*diff(t(x),x,x)+p*diff(t(x),x,x)
        );

  f(x):=sum((p^i)*f[i](x),i=0..L):
  g(x):=sum((p^i)*g[i](x),i=0..L):
  t(x):=sum((p^i)*t[i](x),i=0..L):
#
# Since terms involving 'p' disappeared earlier,
# H01, H02, H03, will only contain powers of 'p'
# arising from the definitions of f(x), g(x), t(x)
# above, so the maximum power of 'p' will be p^L,
# as the following demonstrates
#
  H01:=collect( expand(H01), p);
  H02:=collect( expand(H02), p);
  H03:=collect( expand(H03), p);
#
# Since the maximum power of 'p' is p^L, why does
# this loop run to L+1? All this will do for i=L+1
# is generate the equation 0=0
#
# Notice also, that apart from a trivial renaming of
# functions, the *form* of every "coefficient" in
# say equa[1] is the same  - is this intentional
#
  for i from 0 to L+1 do
      equa[1][i]:=coeff(H01,p,i)=0:
      equa[2][i]:=coeff(H02,p,i)=0:
      equa[3][i]:=coeff(H03,p,i)=0
  end do:

 

6*(diff(diff(f(x), x), x))+5*(diff(g(x), x))+t(x)-5*f(x)

 

(7/2)*(diff(diff(g(x), x), x))-5*(diff(f(x), x))-10*g(x)

 

diff(diff(t(x), x), x)

 

(6*(diff(diff(f[5](x), x), x))+5*(diff(g[5](x), x))+t[5](x)-5*f[5](x))*p^5+(6*(diff(diff(f[4](x), x), x))+5*(diff(g[4](x), x))+t[4](x)-5*f[4](x))*p^4+(6*(diff(diff(f[3](x), x), x))+5*(diff(g[3](x), x))+t[3](x)-5*f[3](x))*p^3+(6*(diff(diff(f[2](x), x), x))+5*(diff(g[2](x), x))+t[2](x)-5*f[2](x))*p^2+(6*(diff(diff(f[1](x), x), x))+5*(diff(g[1](x), x))+t[1](x)-5*f[1](x))*p+6*(diff(diff(f[0](x), x), x))+5*(diff(g[0](x), x))+t[0](x)-5*f[0](x)

 

((7/2)*(diff(diff(g[5](x), x), x))-5*(diff(f[5](x), x))-10*g[5](x))*p^5+((7/2)*(diff(diff(g[4](x), x), x))-5*(diff(f[4](x), x))-10*g[4](x))*p^4+((7/2)*(diff(diff(g[3](x), x), x))-5*(diff(f[3](x), x))-10*g[3](x))*p^3+((7/2)*(diff(diff(g[2](x), x), x))-5*(diff(f[2](x), x))-10*g[2](x))*p^2+((7/2)*(diff(diff(g[1](x), x), x))-5*(diff(f[1](x), x))-10*g[1](x))*p+(7/2)*(diff(diff(g[0](x), x), x))-5*(diff(f[0](x), x))-10*g[0](x)

 

diff(diff(t[0](x), x), x)+p*(diff(diff(t[1](x), x), x))+p^2*(diff(diff(t[2](x), x), x))+p^3*(diff(diff(t[3](x), x), x))+p^4*(diff(diff(t[4](x), x), x))+p^5*(diff(diff(t[5](x), x), x))

(1)

 

Download hpm2.mw

use the FileTools:-Rename() command

is shown in the attached.

restart;
expr:=sin(4*Pi*w)/sin(2*Pi*w) ;
subs(z=2*w, expand(algsubs( 2*w=z, expr)));

sin(4*Pi*w)/sin(2*Pi*w)

 

2*cos(2*Pi*w)

(1)

 

Download trigsimp.mw

You want something like that shown in the attached

  restart;
  RootOf(_Z^2*beta*h[1]-alpha*l[1]*l[2], label = _L2);
#
# All values of the above expresssion in easily(?)
# accessible form
#
  ans:=[allvalues(%)];
  ans[1];
  ans[2];

RootOf(_Z^2*beta*h[1]-alpha*l[1]*l[2], label = _L2)

 

[(alpha*l[1]*l[2]/(beta*h[1]))^(1/2), -(alpha*l[1]*l[2]/(beta*h[1]))^(1/2)]

 

(alpha*l[1]*l[2]/(beta*h[1]))^(1/2)

 

-(alpha*l[1]*l[2]/(beta*h[1]))^(1/2)

(1)

 

Download getRoots.mw

from the relevant help page

Called without arguments, the Date() command returns the current date (and time of day) as reported by the system clock.

although I don't think this handles any kind of "Daylight Saving", for which you might need

Date( 'timezone' = Calendar:-HostTimeZone() );

 

as in the attached (which renders better in a Maple worksheet than it does on ths site)

  with(plots):
  p1:= implicitplot3d( [x^2+y^2+z^2=1, x+y+z=0],x=-1..1, y=-1..1, z=-1..1, color=[red,blue], style=surface, transparency=0.5):
  p2:= intersectplot(x^2+y^2+z^2=1, x+y+z=0, x=-1..1, y=-1..1, z=-1..1, color=green, thickness=4):
  display([p1,p2]);

 

 

 


 

Download iPlot.mw

by using the ScientificConstants() package in Maple, which has all the atomic weights you woukd ever want to know,

Examine the attache

  with(ScientificConstants):
#
# function to return the atomic weight of an element.
# The returned value is in units of 'amu'
#
  gtWeight:= x-> [ x,
                   rhs
                   ( rhs
                     ( GetElement
                       ( x, atomicweight )[2]
                     )[1]
                   )
                 ]:
#
# Return the atomic weight of (say) carbon
#
  gtWeight('C');
#
# Return the atomic weights of the first 12 elements
#
  elems:=[H, He, Li, Be, B, C, N, O, F, Ne, Na, Mg]:
  gtWeight~(elems);

[C, 12.0107]

 

[[H, 1.00794], [He, 4.002602], [Li, 6.941], [Be, 9.012182], [B, 10.811], [C, 12.0107], [N, 14.0067], [O, 15.9994], [F, 18.9984032], [Ne, 20.1797], [Na, 22.989770], [Mg, 24.3050]]

(1)

 

Download atwt.mw

 

is actually the inability to compute the point [0,0] exactly using floating-point arithmetic. For the 7x7 grid, Maple actually calculates the centre point as [1e-10, 1e-10], (rather than [0,0]). Obviously, at the point [1e-10, 1e-10], the field is defined - and is huge, which explains the resulting plot.

Interestingly, for all other "odd" grid settings 3x3, 5x5,9x9, etc etc the origin appears to be calculated as exactly [0,0], whereas one might(??) expect that computing 0 using floating-point arithmetic, would always be a little "doubtful.

More details in the attached

I have converted this from a "post" to a "question"

  restart;
  with(plots):
#
# Illustrate OP's problem - the third plot is "wrong"
#
  expr:=[-x/(x^2+y^2)^1.5,-y/(x^2+y^2)^1.5]:
  fieldplot( expr,
             x = -1..1,
             y = -1..1,
             arrows=thick
           );
  fieldplot( expr,
             x = -1..1,
             y = -1..1,
             grid=[8,8],
             arrows=thick
           );
  fieldplot( expr,
             x = -1..1,
             y = -1..1,
             grid=[7,7],
             arrows=thick
           );

 

 

 

#
# So what is happening??
#
# If one calculates the grid points and the field components
# explicitly for various grid sizes (all with n odd) and then
# selects the "one in the middle", which *ought* to correspond
# to x=0,y=0, where the vector field is undefined, one gets
# the following
#
  seq
  ( [ n,[ seq
          ( seq
            ( [x, y, expr],
              y=-1..1, evalf(2/(n-1))
            ),
            x=-1..1, evalf(2/(n-1))
          )
        ][floor(n^2/2+1)][]
    ],
    n=3..13, 2
  );

[3, 0., 0., [Float(undefined), Float(undefined)]], [5, 0., 0., [Float(undefined), Float(undefined)]], [7, -0.1e-9, -0.1e-9, [0.3535533906e20, 0.3535533906e20]], [9, 0., 0., [Float(undefined), Float(undefined)]], [11, 0., 0., [Float(undefined), Float(undefined)]], [13, 0., 0., [Float(undefined), Float(undefined)]]

(1)

#
# In the above command, the floating-point calculation does
# produce [0,0] as a grid point for all grid sizes, other than
# n=7. When the grid point is *exactly* [0, 0], then the value
# of the vector field is [Float(undefined), Float(undefined)].
#
# However when n=7, rather than using the grid point [0, 0], the
# calculated grid point is at [-1.*10^(-10), -1.*10^(-10)], where
# the field is defined (but huge)
#
# The default for fieldplot() is to illustrate field strength
# with the *relative* drawn length of the arrows. The computed
# field strength at [-1.*10^(-10), -1.*10^(-10)] is so huge
# that the "relative" length of the arrows at all other grid
# points is essentially zero, and cannot be seen in the plot
#

#################################################################
#
# Workaround, define a "tolerance" around [0,0], within which
# the field strength is delared as undefined
#
  tol:= 1e-06:
  func1:= (p, q)->`if`( `and`( abs(p) < tol,
                               abs(q) < tol
                             ),
                        Float(undefined),
                        eval( expr[1], [x=p, y=q] )
                     ):
  func2:= (p, q)->`if`( `and`( abs(p) < tol,
                               abs(q) < tol
                             ),
                        Float(undefined),
                        eval( expr[2], [x=p, y=q] )
                      ):
#
# Now fieldplots work "correctly"
#
  fieldplot( [ func1,func2 ],
             x = -1..1,
             y = -1..1,
             arrows = thick
           );
  fieldplot( [ func1, func2 ],
             x = -1..1,
             y = -1..1,
             grid = [8,8],
             arrows = thick
           );
  fieldplot( [ func1, func2 ],
             x = -1..1,
             y = -1..1,
             grid = [7,7],
             arrows = thick
           );
                    

 

 

 

 

Download fplotProblem.mw

There are some weird non-printing, non-ASCII characters in the file name - I don't know why., These have to be removed in order for everything to work as you expect, See the attached

  restart;
  interface(version);
  with(StringTools):
#
# NB the string in the following is cut+paste from
# OP's worksheet in order to "preserve" any weird
# (eg non-printing?) characters
#
  a:="Microsoft_Edge_‎08_‎29_‎2019.html";
#
# and yes, Reverse() goes nuts!
#
  Reverse(a);
#
# Filter out non-ASCII characters
#
  b:=Implode(select( IsASCII, Explode(a)));;
#
# Now Reverse() works
#
  Reverse(b);

`Standard Worksheet Interface, Maple 2019.1, Windows 7, May 21 2019 Build ID 1399874`

 

"Microsoft_Edge_‎08_‎29_‎2019.html"

 

"lmth.9102���_92���_80���_egdE_tfosorciM"

 

"Microsoft_Edge_08_29_2019.html"

 

"lmth.9102_92_80_egdE_tfosorciM"

(1)

 

 


 

Download strProb.mw

is that the statement 1C=1K is perfectly valid if one is thinking of temperature increments.

However the statement 1C=274.15K is equally valid if one is thinking of "absolute" values - and believe me I hesitated before using the term "absolute", because of the possibility of confusing the word "absolute" with the kelvin temperatue scale.

So faced with the problem that 1C=1K and 1C=274.15K are equally valid, how does one combine temperatures from different scales. By default, Maple uses the former (which you may think is incorrect - but frankly I think is a 50:50 call). If you want to add temperatures from different "scales" in some kind of "absolute" sense, then you should (probably) use convert commands, as in the attached.

One think you should be careful about is the occurence of "zero" on any temperature scale. Whislst it is true that "0 inches" is equal to "0 metrres", it is obviously not true that 0C=0F=0K. However (probably as a result of Maple's simplification rules), a "0" with any temperature unit, returns a "unitless" zero. This has pretty mindblowing consequences, because (as shown in the attached)

is( 0*Unit(Celsius)=0*Unit(Fahrenheit));

will return true!!! Now I'd call that a BUG.

combine(20*Unit(Celsius)+30*Unit(K),units);

50*Units:-Unit(K)

(1)

convert(20*Unit(Celsius,preserve),temperature, kelvin)+ 30*Unit(K);
evalf(%);
20*Unit(Celsius)+convert(30*Unit(kelvin, preserve), temperature,Celsius);
evalf(%);

(6463/20)*Units:-Unit(K)

 

323.1500000*Units:-Unit(K)

 

-(4463/20)*Units:-Unit(`&deg;C`)

 

-223.1500000*Units:-Unit(`&deg;C`)

(2)

is( -1*Unit(Celsius)=-1*Unit(Fahrenheit));
is( 0*Unit(Celsius)=0*Unit(Fahrenheit));
is( 1*Unit(Celsius)=1*Unit(Fahrenheit));

false

 

true

 

false

(3)

 


 

Download tempTrouble.mw

 

Only workaround I can come up with is

  1. Select the lprint() output
  2. Right-click to pull up the context menu, then use Convert To -> Plain Text.
  3. Then the usual CTRL-C/CTRL-V

This works for me in the attached


 

restart:
kernelopts(version);
interface(prettyprint);
lprint(<1,2;3,4>);

`Maple 2019.1, X86 64 WINDOWS, May 21 2019, Build ID 1399874`

 

3

 

Matrix(2,2,{(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4},datatype = anything
,storage = rectangular,order = Fortran_order,shape = [])

 

Matrix(2,2,{(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4},datatype = anything
,storage = rectangular,order = Fortran_order,shape = []);

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4})

(1)

 


 

Download lpr.mw

From the help for AllPairsDistance

This procedure is an implementation of the Floyd-Warshall all-pairs shortest path algorithm

However this i only a partial step on the way to computing the "betweenness centrality", because

  1. The basic algorithm outputs only the distance - not the path itself (ie the intermediate vertexes)
  2. To compute the betweenness centrality, one needs to find all the paths with the same shortest distance between each two vertexes.
First 94 95 96 97 98 99 100 Last Page 96 of 207