tomleslie

13876 Reputation

20 Badges

15 years, 175 days

MaplePrimes Activity


These are answers submitted by tomleslie

becuase the following will provide the answer you want

X := [1,3,4, 50,10]:
[seq( 1+add(X[1..j]), j=1..numelems(X))];
                        2, 5, 9, 59, 69

You can wrap this in a procdure if you want, as in

doSum:= proc( Y );
                          return [seq( 1+add(Y[1..j]), j=1..numelems(Y))];
               end proc:
doSum(X);

[2, 5, 9, 59, 69]

 

Just because Carl beat me to it!

Kaprekar's sequnce either "converges" to one of a limited  number of fixed points, or eventually the cycle repeats. This one stops when the current number has occured before. (NB this only works in base 10, although it woudn't be difficult to change for other bases)

  restart:
  Kaprek:= proc( y::integer )
                 local x:=y,
                       n:=[ seq( irem( x, 10, 'x'),
                                 j = 1..length(x)
                               )
                          ];
                 return( parse(cat( sort( n, `>`)[]))
                          -
                         parse(cat( sort( n, `<`)[]))
                       )
                 end proc:

  A:=Array(1..1):
#
# Enter the start number and run the sequence
#
  A[1]:=12345:
  for k from 1 do
      A(k+1):= Kaprek(A[k]);
      if   member( A[k+1], A[1..k] )
      then break:
      end if:
  od:
#
# The sequence
#
  A();
#
# Final number in the sequence
#
  A[-1];

Vector[row](7, {(1) = 12345, (2) = 12345, (3) = 12345, (4) = 12345, (5) = 12345, (6) = 12345, (7) = 12345})

 

82962

(1)

 

Download Kaprekar.mw

The plottools:-getdata() command returns a lot of information about the data being plotted. Consider the output of the "toy" example

p1:=plot( sin(x), x=0..2*Pi):
plottools:-getdata(p1);

The first argument returned by getdata() tells you the type of structure being plotted

The second argument tells you the 'x' and 'y' ranges

The third argument gives an n x 2 matrix of the data which is to be plotted.

You can access this matrix and then programmatically examine/manipulate/convert the data it contains in the same way that you can with any other matrix. This means that you can "specify some constraints such that the points being extracted must satisfy".

Deleting the superfluous nonsense with which you like to clutter your worksheets, and using add(), rather than sum() or Sum() which you have been advised to do on numerous previous occasions, then I come up with the attached

restart;
S4 :=x-> (2*((2*k*Pi*tau*(-8*Pi^2*k^2*tau^3+4*Pi^2*k^2*tau^2*w+2*T^2*tau+T^2*w)*cos(w*Pi*k/T)+T*sin(w*Pi*k/T)*(-16*Pi^2*k^2*tau^3+4*Pi^2*k^2*tau^2*w+T^2*w))*exp(-(1/2)*w/tau)+16*Pi^3*k^3*tau^4-4*k*Pi*tau^2*T^2))*sin(2*k*Pi*x/T)/(4*Pi^2*k^2*tau^2+T^2)^2:

a[0] := 0: Kappa := 4: tau := 1: N := 2:
T := M*tau: w := N*tau: M := Kappa*N:

S5 :=(m, x)->evalf(a[0]+add(S4(x), k = 1 .. m));

proc (m, x) options operator, arrow; evalf(a[0]+add(S4(x), k = 1 .. m)) end proc

(1)

peak:= S5(10000, 0.3998201722e-3);
(peak-1)*(1/2);

1.178180182

 

0.890900910e-1

(2)

peak:= S5(50000, 0.7999280138e-4);
(peak-1)*(1/2);

1.178819787

 

0.894098935e-1

(3)

peak := S5(100000, 0.3998201722e-4);
(peak-1)*(1/2)

1.178899571

 

0.894497855e-1

(4)

peak := S5(500000, 0.7999280138e-5);
(peak-1)*(1/2)

1.178963627

 

0.894818135e-1

(5)

peak := evalf(S5(1000000, 0.3998201722e-5));
(peak-1)*(1/2)

1.178971646

 

0.894858230e-1

(6)

 

``

Download someSums.mw

  1. I reformultaed you problem (a bit) mainly so that I could understand what was going on
  2. I too had issues with using DirectSearch(). No matter what options I supplied it "worked" for some angles, and "failed" for others. I was unable to track down why
  3. I did manage to generate a solution for the underlying problem using only fsolve(). A simple application of fsolve() won't work because there are always two solutions - one on the positive y-axis and one on the negative y-axis. However one can test the solutions returned by fsolve() and if the intercept is negative, then re-run the fsolve() command using the 'avoid' option to produce the "desired" positive intercept
  4. The attached contains my DirectSearch() attempt  ( which fails for some angles), a basic approach using fsolve() which just outputs a 'blob' at the positive intercept, and a somewhat better plot whihch actually includes the 'cam-follower'. The last animation is probably of most interest

  restart;
  with(plots):
  with(plottools):
#
# Generate the cardioid, and set up a rotation
# just to check verything is working properly
#
  spX:=  piecewise
         ( theta < 0, undefined,
           theta <= Pi,   cos(theta+(1/4)*Pi)*exp((theta+(1/4)*Pi)*(1/2)),
           theta <= 2*Pi, sin(theta-3*Pi/4)*exp((theta-3*Pi/4)*(1/2)),
           theta > 2*Pi, undefined
         ):
  spY:=  piecewise
         ( theta < 0, undefined,
           theta <= Pi,   sin(theta+(1/4)*Pi)*exp((theta+(1/4)*Pi)*(1/2)),
           theta <  2*Pi, cos(theta-3*Pi/4)*exp((theta-3*Pi/4)*(1/2)),
           theta > 2*Pi, undefined
         ):
  p1:=plot( [ spX, spY, theta=0..2*Pi ],
            thickness=3,
            color=red,
            discont=true
          ):
  display( [ seq( rotate(p1,alpha),
                  alpha=0..8*evalf(Pi), evalf(Pi/8)
                )
           ],
           insequence=true
         );

 

#
# Define a rotation matrix which allows the above
# plot to be rotated by any specified angle beta,
# and produce the "rotated" x and y-coordinates
#
  mRot:=Matrix(2,2, [ [ cos(beta), -sin(beta)],
                      [ sin(beta),  cos(beta)]
                    ]
              ):
  rS:= mRot.< spX, spY >:

#
# Set the number of solutions to be used for all
# calculations.
#
  numSols:= 0..32:

#
# Given the rotation angle beta, need to find the
# value of theta for which the x-coordinate of rS
# above is 0: then evaluate the y-coordinate of rS
# for the "given" beta and the "obtained" value of
# theta
#
# Using DirectSearch this works "most" of the time,
# but for certain beta-values, it produces incorrect
# theta-values and I have no real idea why!!!
#
# I did try all sorts of minor variations, accuracy
# settings etc. The best I could do was to move around
# which values failed
#
  with(DirectSearch):
  ans:= [ seq
          ( rhs( SolveEquations
                 ( eval
                   ( rS[1],
                     beta=k*Pi/(op(2, numSols)/2)
                   ),
                   [ eval
                     ( rS[2],
                       beta=k*Pi/(op(2, numSols)/2)
                     ) >0,
                     theta>=0,
                     theta<=2*Pi
                   ],
                   usewarning=false
                 )[3][]),
            k=numSols
          )
        ]:
  plt:=seq( display
            ( [ pointplot
                ( [ 0,
                    evalf
                    ( eval
                      ( rS[2],
                        [beta=k*Pi/8, theta=ans[k+1] ]
                      )
                    )
                  ],
                  symbol=solidcircle,
                  symbolsize=40,
                  color=blue
                ),
                rotate( p1, k*Pi/(op(2, numSols)/2))
              ],
              scaling=constrained
            ),
            k=numSols
         ):
#
# NB The following animationa is OK for some values,
# but wrong for others
#
  display(plt, insequence=true);

 

#
# Attempt the same calculation using fsolve(). The problem
# with using fsolve() is that there are always two answers
# for where the cardioid crosses the y-axis, one positive
# and one negative. As far as I can tell there is no way
# to control which is returned:-(
#
# The only way I could come up with to produce only the
# the positive y-axis intercept, was a two stage process.
#
# For any give value of beta (the rotation angle)
#
#  1) Just run fsolve() to compute the angle theta for
#     which the x-coordinate is zero, without worrying
#     whether the resulting y-axis intercept is positive
#     or negative
#  2) Evaluate the y-axis intercept at the value of theta
#     obtained in (1). If the intercept is negative, then
#     re-un the fsolve() command with the 'avoid' option.
#     This results in the "other" value for theta, and
#     hence gives a positive y-intercept
##########################################################
#
# Get the first stage of solutions
#      
  ans:= seq
        ( fsolve
          ( eval
            ( rS[1],
              beta=k*Pi/(op(2, numSols)/2)
            ),
            theta=0..2*Pi
          ),
          k=numSols
        ):
#
# Check whether the resulting y-intercept is positive
# If it isn't rerun the fsolve() command with the 'avoid'
# option
#
  ans:= seq
        ( `if`
          ( evalf
            ( eval
              ( rS[2],
                [ beta=k*Pi/(op(2, numSols)/2),
                  theta=ans[k+1]
                ]
              )<0
            ),
            fsolve
            ( eval
              ( rS[1],
                beta=k*Pi/(op(2, numSols)/2)
              ),
              theta=0..2*Pi,
              avoid={ theta=ans[k+1] }
            ),
            ans[k+1]
         ),
         k=numSols
       ):
  plt:= seq
        ( display
          ( [ pointplot
              ( [ 0,
                  evalf
                  ( eval
                    ( rS[2],
                      [ beta=k*Pi/(op(2, numSols)/2),
                        theta=ans[k+1]
                      ]
                    )
                  )
                ],
                symbol=solidcircle,
                symbolsize=40,
                color=blue
              ),
              rotate( p1, k*Pi/(op(2, numSols)/2))
            ],
            scaling=constrained
          ),
          k=numSols
       ):
  display(plt, insequence=true);
 

 

#
# Instead of just putting a 'blob' at the positive
# y-intercept, draw a 'disk' which justs rests on
# the cardioid the way and a line, representing the
# 'cam-follower'
#
  cOff:= 0.25:
  plt:= seq
        ( display
          ( [ disk
              ( [ 0 ,
                  evalf
                  ( eval
                    ( rS[2],
                      [ beta=k*Pi/(op(2, numSols)/2),
                        theta=ans[k+1]
                      ]
                    )
                  )+cOff
                ],
                cOff,
                color = blue
              ),
              line
              ( [0, evalf
                    ( eval
                      ( rS[2],
                        [ beta=k*Pi/(op(2, numSols)/2),
                          theta=ans[k+1]
                        ]
                      )
                    )+2*cOff
                ],
                [0, evalf
                    ( eval
                      ( rS[2],
                        [ beta=k*Pi/(op(2, numSols)/2),
                          theta=ans[k+1]
                        ]
                      )
                    )+2*cOff+2.0
                ],
                color=blue,
                thickness=5
              ),
              rotate( p1, k*Pi/(op(2, numSols)/2))
            ],
            scaling=constrained
          ),
          k = numSols
       ):
  display(plt, insequence=true);

 

 

Download camFollower.mw

You have one PDE which contains three dependent variables q(x,t), QL(x,t) and T(x,t). As a general rule, solving for three dependent variables, will require three (partial differential, or other) equations

  1. The params definition contains [beta = .5, v = .5, v__l = 1.0, eta = 1.5, f__w = .5 alpha = 0], presumably this should be [beta = .5, v = .5, v__l = 1.0, eta = 1.5, f__w = .5, alpha = 0]. Note the comma between the definitions of 'f__w' and 'alpha'
  2. The PDE contains the 'unknown' parameters 'Omega' and 'epsilon' which are defined nowhere
  3. The PDE contains the undefined function f(x) - do you expect to be able to numerically solve a PDE containing such an arbitrary function?
  4. The PDE contains the undefined function w(s) - granted that s is a dummy variable of integration, but  is this meant to imply some variant of the dependent variable w(x,t), eg w(s,t), w(x,s), or a function completely unrelated to w(x,t)?

The above will have to be resolved before one can get anywhere

with output as an array of plots

arrPlot.mw

as in,

   restart;
   pceq := (2/3)*Pi*G*rho^2*R^2:
   pnonreleq := (1/5)*(3*Pi^2)^(2/3)*hbar^2*n^(5/3)/m:
   rhocomposition := rho = m/((4/3)*Pi*R^3), n = Z*rho/(A*m_p):
   obj := subs(rhocomposition, rhocomposition, pceq = pnonreleq):
#
# obj has three possible solutions for R. OP seems to "know"
# that (s)he wants the first - although since the order of
# solutions isn't guaranteed, seems a little risky. Better
# to sort() by length and pick the "shortest" ??? Why???
#
   req:= sort([solve(obj, R)], length)[1];
   req1:= simplify(req, symbolic);

 

Notes

  1. Maple can solve this ODE exactly, so I have used this as the "exact" solution
  2. I have also included the results of a Maple numeric solution
  3. The last execution group converts the final output table to latex format and stores ths in a file. You will need to change the fiename here to something appropriate for your installation


 

restart;
h1 := t-> piecewise(0 <= t and t < 1, 1):
###### We will be using t as the global time parameter throughout. #####
hi:=proc(j,k) local a,b,c,m;
  m:=2^(j);
  a := k/m;
  b := (k+1/2)/m;
  c := (k+1)/m;
  return piecewise(a <= t and t < b, 1, b <= t and t < c, -1)
end proc:
##
J:=3:
N :=2^J:
hd := Vector(N):
H := Matrix(N, N):
T := Vector(N):
hd[1] := h1(t):
for i from 1 to N do T[i] := (i-1/2)/N end do:
##
for j from 0 to J-1 do
  m := 2^j;
  for k from 0 to m-1 do
    i := m+k+1;
    hd[i] := hi(j, k)
  end do
end do:
#Now Compute H at the collocation points
for i from 1 to N do
  for j from 1 to N do
    H[i, j] := eval(hd[i], t = T[j])
  end do
end do:
##
pn:=proc(i,n)
  if n=1 then
    return int(hd[i],t) ## Notice the use of an indefinite integral!
  else
    return int(pn(i,n-1),t) ## Notice the use of an indefinite integral!
  end if
end proc:
##
##EXAMPLE 2 from the reference given:
f:=t->t^2;
alpha1:=t->-1:
alpha2:=t->t:
y0:=1:
y1:=-1:
##
RHS:= t->f(t)-alpha1(t)*y1-alpha2(t)*(t*y1+y0);
R:=Vector(N):
TMP:=Matrix(N,N):
A:=Matrix(N,N):
##
for i from 1 to N do
  R[i] := evalf(RHS(T[i]));
  tmp := alpha1(t)*pn(i,1)+alpha2(t)*pn(i,2);
  for j from 1 to N do
    TMP[i,j]:=eval(tmp, t = T[j])
  end do
end do:

##Compute the wavelet coefficients:
use LinearAlgebra in
  A := Transpose(LinearSolve(Transpose(H+TMP), R))
end use:
#Now compute the approximate solution
sol := y1*t+y0+add(A[m0]*pn(m0,2), m0 = 1 .. N):
#Convert to a function of t for easy comparison with exact solution
y:=unapply(sol,t):
y(31/32);
#############################################
## Compare with the solution found by dsolve/numeric:
## EXAMPLE 2 ode:
#
# lets call the MapleNumeric solution mNumer
#
  ode:=diff(Y(t),t,t)-diff(Y(t),t)+t*Y(t)=t^2:
  mNumer:=dsolve({ode,Y(0)=1,D(Y)(0)=-1},numeric,abserr=1e-10,relerr=1e-9):
#plots:-odeplot(res1,[t,Y(t)-y(t)],0..1,caption="The error on the interval 0..1");

proc (t) options operator, arrow; t^2 end proc

 

proc (t) options operator, arrow; f(t)-alpha1(t)*y1-alpha2(t)*(t*y1+y0) end proc

 

HFloat(-0.619928976817079)

(1)

#
# Maple can solve this ODE exactly so use this as
# the exact solution, mExact
#
  ode:=diff(Y(t),t,t)-diff(Y(t),t)+t*Y(t)=t^2:
  mExact:=unapply(rhs(dsolve({ode,Y(0)=1,D(Y)(0)=-1})),t):

#
# Print results to screen
#
  printf( "\n\n\n      Time    Maple Exact      Maple Numeric"
          "    OP Numeric     Exact-OP Numeric\n\n");
  seq( printf( " %8a %16.12f %16.12f %16.12f %16.12f\n",
                 k,
                 evalf[12](mExact(k)),
                 rhs( mNumer(k)[2]),
                 y(k),
                 evalf[12](mExact(k))-y(k)
             ),
       k=0..1, 1/32
     );




      Time    Maple Exact      Maple Numeric    OP Numeric     Exact-OP Numeric

        0   1.000000000010   1.000000000000   1.000000000000   0.000000000010
     1/32   0.968251626962   0.968251626829   0.968200755110   0.000050871852
     1/16   0.935466807180   0.935466807088   0.935303020440   0.000163786740
     3/32   0.901587561903   0.901587561871   0.901306795990   0.000280765913
      1/8   0.866558144078   0.866558144095   0.866212081760   0.000346062318
     5/32   0.830325217888   0.830325217842   0.829914993018   0.000410224870
     3/16   0.792838050440   0.792838050252   0.792311645030   0.000526405410
     7/32   0.754048715681   0.754048715524   0.753402037798   0.000646677883

      1/4   0.713912310550   0.713912310553   0.713186171320   0.000726139230
     9/32   0.672387183002   0.672387183024   0.671584590090   0.000802592912
     5/16   0.629435172203   0.629435171858   0.628517838599   0.000917333604
    11/32   0.585021860107   0.585021859972   0.583985916848   0.001035943259
      3/8   0.539116834762   0.539116834834   0.537988824838   0.001128009924
    13/32   0.491693964509   0.491693963987   0.490479428658   0.001214535851
     7/16   0.442731683134   0.442731683072   0.441410594402   0.001321088732
    15/32   0.392213285195   0.392213285283   0.390782322070   0.001430963125
      1/2   0.340127231184   0.340127231062   0.338594611661   0.001532619523
    17/32   0.286467461862   0.286467461726   0.284841944807   0.001625517055
     9/16   0.231233721102   0.231233721104   0.229518803143   0.001714917959

    19/32   0.174431886592   0.174431886659   0.172625186666   0.001806699926
      5/8   0.116074307262   0.116074307350   0.114161095379   0.001913211883
    21/32   0.056180146899   0.056180146982   0.054173064204   0.002007082695
    11/16  -0.005224267508  -0.005224267429  -0.007292371931   0.002068104423
    23/32  -0.068105093468  -0.068105093399  -0.070235213027   0.002130119558
      3/4  -0.132420618229  -0.132420618170  -0.134655459084   0.002234840855
    25/32  -0.198120902717  -0.198120902684  -0.200443363426   0.002322460709
    13/16  -0.265147425885  -0.265147425858  -0.267489179377   0.002341753492
    27/32  -0.333432730664  -0.333432730640  -0.335792906938   0.002360176274
      7/8  -0.402900073603  -0.402900073570  -0.405354546108   0.002454472505
    29/32  -0.473463079722  -0.473463079658  -0.475989879503   0.002526799781
    15/16  -0.545025404543  -0.545025404485  -0.547514689739   0.002489285196

    31/32  -0.617480405530  -0.617480405520  -0.619928976817   0.002448571287
        1  -0.690710824747  -0.690710824916  -0.693232740736   0.002521915989

 

#
# Store results as a matrix, ready for outputting somewhere
#
  resMat:=Matrix( [ [ "Time", "Maple Exact", "Maple Numeric",
                      "OP Numeric", "Exact-OP Numericseq"
                    ],
                    seq( [ k,
                           evalf[12](mExact(k)),
                           rhs( mNumer(k)[2]),
                           y(k),
                           evalf[12](mExact(k))-y(k)
                         ],
                         k=0..1, 1/32
                       )
                  ]
                );

resMat := Matrix(34, 5, {(1, 1) = "Time", (1, 2) = "Maple Exact", (1, 3) = "Maple Numeric", (1, 4) = "OP Numeric", (1, 5) = "Exact-OP Numericseq", (2, 1) = 0, (2, 2) = 1.00000000001, (2, 3) = HFloat(1.0), (2, 4) = HFloat(1.0), (2, 5) = HFloat(1.000000082740371e-11), (3, 1) = 1/32, (3, 2) = .968251626962, (3, 3) = HFloat(0.9682516268290818), (3, 4) = HFloat(0.9682007551100116), (3, 5) = HFloat(5.0871851988376626e-5), (4, 1) = 1/16, (4, 2) = .935466807180, (4, 3) = HFloat(0.9354668070883871), (4, 4) = HFloat(0.9353030204400468), (4, 5) = HFloat(1.6378673995320892e-4), (5, 1) = 3/32, (5, 2) = .901587561903, (5, 3) = HFloat(0.9015875618710141), (5, 4) = HFloat(0.9013067959901054), (5, 5) = HFloat(2.807659128946094e-4), (6, 1) = 1/8, (6, 2) = .866558144078, (6, 3) = HFloat(0.8665581440949476), (6, 4) = HFloat(0.8662120817601875), (6, 5) = HFloat(3.460623178125344e-4), (7, 1) = 5/32, (7, 2) = .830325217888, (7, 3) = HFloat(0.8303252178423797), (7, 4) = HFloat(0.8299149930177395), (7, 5) = HFloat(4.1022487026043386e-4), (8, 1) = 3/16, (8, 2) = .792838050440, (8, 3) = HFloat(0.7928380502515826), (8, 4) = HFloat(0.7923116450302079), (8, 5) = HFloat(5.264054097920967e-4), (9, 1) = 7/32, (9, 2) = .754048715681, (9, 3) = HFloat(0.7540487155236516), (9, 4) = HFloat(0.753402037797593), (9, 5) = HFloat(6.466778834069986e-4), (10, 1) = 1/4, (10, 2) = .713912310550, (10, 3) = HFloat(0.7139123105529388), (10, 4) = HFloat(0.7131861713198944), (10, 5) = HFloat(7.261392301056713e-4), (11, 1) = 9/32, (11, 2) = .672387183002, (11, 3) = HFloat(0.6723871830238821), (11, 4) = HFloat(0.6715845900895655), (11, 5) = HFloat(8.025929124344522e-4), (12, 1) = 5/16, (12, 2) = .629435172203, (12, 3) = HFloat(0.6294351718584141), (12, 4) = HFloat(0.62851783859906), (12, 5) = HFloat(9.173336039400848e-4), (13, 1) = 11/32, (13, 2) = .585021860107, (13, 3) = HFloat(0.5850218599715091), (13, 4) = HFloat(0.5839859168483772), (13, 5) = HFloat(0.0010359432586227735), (14, 1) = 3/8, (14, 2) = .539116834762, (14, 3) = HFloat(0.5391168348337606), (14, 4) = HFloat(0.5379888248375175), (14, 5) = HFloat(0.001128009924482476), (15, 1) = 13/32, (15, 2) = .491693964509, (15, 3) = HFloat(0.49169396398687837), (15, 4) = HFloat(0.4904794286582561), (15, 5) = HFloat(0.0012145358507438808), (16, 1) = 7/16, (16, 2) = .442731683134, (16, 3) = HFloat(0.44273168307151844), (16, 4) = HFloat(0.4414105944023683), (16, 5) = HFloat(0.0013210887316317255), (17, 1) = 15/32, (17, 2) = .392213285195, (17, 3) = HFloat(0.39221328528265414), (17, 4) = HFloat(0.3907823220698541), (17, 5) = HFloat(0.001430963125145901), (18, 1) = 1/2, (18, 2) = .340127231184, (18, 3) = HFloat(0.34012723106188897), (18, 4) = HFloat(0.3385946116607133), (18, 5) = HFloat(0.0015326195232867046), (19, 1) = 17/32, (19, 2) = .286467461862, (19, 3) = HFloat(0.2864674617258563), (19, 4) = HFloat(0.28484194480748526), (19, 5) = HFloat(0.0016255170545147468), (20, 1) = 9/16, (20, 2) = .231233721102, (20, 3) = HFloat(0.23123372110381696), (20, 4) = HFloat(0.22951880314270903), (20, 5) = HFloat(0.0017149179592909625), (21, 1) = 19/32, (21, 2) = .174431886592, (21, 3) = HFloat(0.1744318866591724), (21, 4) = HFloat(0.17262518666638452), (21, 5) = HFloat(0.0018066999256154959), (22, 1) = 5/8, (22, 2) = .116074307262, (22, 3) = HFloat(0.11607430735039213), (22, 4) = HFloat(0.1141610953785118), (22, 5) = HFloat(0.0019132118834882111), (23, 1) = 21/32, (23, 2) = 0.561801468990e-1, (23, 3) = HFloat(0.05618014698168101), (23, 4) = HFloat(0.05417306420439914), (23, 5) = HFloat(0.0020070826946008563), (24, 1) = 11/16, (24, 2) = -0.52242675081e-2, (24, 3) = HFloat(-0.0052242674291024), (24, 4) = HFloat(-0.007292371930645191), (24, 5) = HFloat(0.002068104422545191), (25, 1) = 23/32, (25, 2) = -0.681050934683e-1, (25, 3) = HFloat(-0.06810509339912937), (25, 4) = HFloat(-0.07023521302662113), (25, 5) = HFloat(0.002130119558321125), (26, 1) = 3/4, (26, 2) = -.132420618229, (26, 3) = HFloat(-0.1324206181698698), (26, 4) = HFloat(-0.1346554590835287), (26, 5) = HFloat(0.0022348408545286857), (27, 1) = 25/32, (27, 2) = -.198120902717, (27, 3) = HFloat(-0.1981209026836814), (27, 4) = HFloat(-0.2004433634255647), (27, 5) = HFloat(0.0023224607085647053), (28, 1) = 13/16, (28, 2) = -.265147425885, (28, 3) = HFloat(-0.2651474258580951), (28, 4) = HFloat(-0.267489179376926), (28, 5) = HFloat(0.002341753491926002), (29, 1) = 27/32, (29, 2) = -.333432730664, (29, 3) = HFloat(-0.333432730640431), (29, 4) = HFloat(-0.33579290693761243), (29, 5) = HFloat(0.0023601762736124576), (30, 1) = 7/8, (30, 2) = -.402900073603, (30, 3) = HFloat(-0.4029000735703046), (30, 4) = HFloat(-0.40535454610762395), (30, 5) = HFloat(0.002454472504623939), (31, 1) = 29/32, (31, 2) = -.473463079722, (31, 3) = HFloat(-0.473463079658178), (31, 4) = HFloat(-0.47598987950290184), (31, 5) = HFloat(0.0025267997809018117), (32, 1) = 15/16, (32, 2) = -.545025404543, (32, 3) = HFloat(-0.5450254044846864), (32, 4) = HFloat(-0.5475146897393868), (32, 5) = HFloat(0.0024892851963868035), (33, 1) = 31/32, (33, 2) = -.617480405530, (33, 3) = HFloat(-0.6174804055204568), (33, 4) = HFloat(-0.619928976817079), (33, 5) = HFloat(0.002448571287078982), (34, 1) = 1, (34, 2) = -.690710824747, (34, 3) = HFloat(-0.6907108249157812), (34, 4) = HFloat(-0.6932327407359784), (34, 5) = HFloat(0.0025219159889784404)})

(2)

#
# Convert resMat to latex format and output to the
# file specified by fileName. OP will have to change
# filename to something appropriate for his/her
# installation
#
  latex(resMat, "C:/Users/TomLeslie/Desktop/LatexFile");

 

Download ODElatex.mw

Your procedure in  Letter_V_kaput.mws starts with

makeV := proc(x0,y0,h,base,w, s::string)
                         local col,col2,hV, opts, alfa,polyV:

ie 's' is a formal parameter of the procedure. However within the procedure, you have the line

s:=LowerCase(s)

You cannot assign a formal parameter!

Eaiest way around this is ussally to create a local copy by using something like

makeV := proc(x0,y0,h,base,w, zz::string)
                         local col,col2,hV, opts, alfa,polyV, s:=zz:

Now the formal paramater name is 'zz', but you now have a local variable called 's', which is initally assigned to zz, but can subsequently be reassigned to within the procedure

 

You need an initial condition somewhere - I just guessed y(0)=0 in the attached. Is this what you are after?

de:=diff(y(x),x)=x^2-y(x)^2;
ivs:=[y(0)=0];
DEtools[DEplot]( de, y(x), x=-3..3, ivs);

diff(y(x), x) = x^2-y(x)^2

 

[y(0) = 0]

 

 

 

 

Download dePhase.mw

I mean just how many syntax errors can you make in one line?

You posted

Matrix(2,1,[A[1],B[1]]):=MatrixInverse([Q[1]])*([Q[2]] )*..* MatrixInverse([Q[j]])*([Q[j+1]])* ..*MatrixInverse([Q[2 n-2]])*([Q[2 n-1]])Matrix(2,1,[A[N],B[N]]);

So lets start with a few questions

  1. The above contains the character sequence '*..*' twice. What si meant by theis sequence of characters - because it means nothing to Maple
  2. The first term on the right hand side is MatrixInverse([Q[1]])*([Q[2]] ), which is some kind of product of the terms MatrixInverse([Q[1]]) and ([Q[2]] ). For the former, what is Q; what is Q[1]; and what is [Q[1]]? Is the last of these suitable as a matrix initializer? For the latter, what is Q, what is Q[2],; what is [Q[2]}; and what is ([Q[2])? Does it result in a vector, a matrix or a scalar? This will impact what mathematical operation (ie sign such as '*') which is permissible between the two components of the first term
  3. The first term is "separated" from the second term with the symbol sequence '*..*'. What does this mean?
  4. For the second term in the original expression, most of the questions in bullet (2) above apply, with the additional question - what is 'j'?
  5. The second term is "separated" from the third term with the symbol sequence '*..*'. What does this mean? See item (3) above
  6. The third term is MatrixInverse()Matrix() with no operand between these two matrices - are you adding them, multiplying them, what? The first component of this term is MatrixInverse([Q[2 n-2]])*([Q[2 n-1]]), so re-read bullet (2) above. Also where is 'n' defined? The second component is Matrix(2,1,[A[N],B[N]]): what is 'A'; what is 'B' and what is 'N'? None of these are defined

Once you fix all of the above, you *might* get somewhere

the following - NB 'KL' i still not defined so I just guessed a few values for this parameter

  restart;
  expr:= T=4*k[1]^2*K^2/(4*k[1]^2*K^2+(k[1]^2+K^2)^2*sinh(KL)^2):
  expr:= lhs(expr) = algsubs( k[1]^2/K^2=Z,
                              numer(rhs(expr))/K^4
                            )
                     /
                     algsubs( k[1]^2/K^2=Z,
                              expand(denom(rhs(expr))/K^4)
                            );
#
# Still don't know what 'KL' is so just pick
# a few values
#
  plot( [ eval(rhs(expr), KL=1),
          eval(rhs(expr), KL=2),
          eval(rhs(expr), KL=3)
        ],
        Z=0..10,
        labels=[typeset( k[1]^2/K^2), T],
        labelfont=[Times, bold, 14],
        color=[red, green, blue]
      );

T = 4*Z/(sinh(KL)^2*Z^2+2*sinh(KL)^2*Z+sinh(KL)^2+4*Z)

 

 

 

Download aplot.mw

exactly what is the independent variable(s); whether you want a 2Dplot or a 3Dplot, but one of the following plot() commands ought to cover it

f:=4*del/(4*del+(1+del)^2*sinh(KL)^2);
plot( eval(f, del=1), KL=-10..10);
plot( eval(f, KL=1), del=-10..10);
plot3d( f, del=-10..10, KL=-10..10);

First 138 139 140 141 142 143 144 Last Page 140 of 207