tomleslie

13776 Reputation

19 Badges

14 years, 64 days

MaplePrimes Activity


These are answers submitted by tomleslie

  restart:
  f:=(x,y)-> sin(x^2/(y^10+x^8+8))*exp(2*y);
  eval( diff( f(x,y), y$4, x$3), [x=-1.0, y=2.0]);
#
# or
#
  D[1$3,2$4](f)(-1.0, 2.0);

proc (x, y) options operator, arrow; sin(x^2/(y^10+x^8+8))*exp(2*y) end proc

 

205.6236292

 

205.6236267

(1)

 

Download doDiff.mw

you have to ensure that all the data is available for all the plots whihc you want! When you write a piece of code like

for INDEX to 1000 do
    lam := fsolve(eval(MyEqs_cal, ncal2), {lambda__1 = 0 .. infinity, lambda__2 = 0 .. infinity, lambda__3 = 0 .. infinity});
    beta11 := eval(eval(beta__11, cal), lam union ncal2);
    beta12 := eval(eval(beta__12, cal), lam union ncal2);
    beta21 := eval(eval(beta__21, cal), lam union ncal2);
    beta22 := eval(eval(beta__22, cal), lam union ncal2);
    beta31 := eval(eval(beta__31, cal), lam union ncal2);
    beta32 := eval(eval(beta__32, cal), lam union ncal2);
end do:

then  at each new value of 'INDEX', previous values of lam, beta11,..etc will be overwritten. SO when the loop is finiished, the only results you will have available will be for INDEX=1000 - which means that no plots will be available.

The attached code fixes this problem and generates/plots all data for the first three "calibrations". (The othe nine are left as an exercise for you).  Note that since all data is available, then all sorts of plots can be produced. You just have to decide exactly what you want to see.

someplots.mw

Stuff which is generally true for "lines" is not necessarily true for "segments", eg

  1. two non-parallel lines always have an intersection, whilst two non-parallel segments may or may not have an intersection
  2. a point always has a projection on to a line - it may (or may not) have a projection on to a segment
  3. and so on

I see two choices

  1. Allow all operations with lines as input to be valid for segments as input - and get ready to report a lot of failures
  2. Disallow operations which might fail on segments, but would work on lines
  3. Pick one of the above

If f[n] is undefined (which it is in your worksheet), then you cannot assign an expression containing f[n], to f[n]

means that yoiu will be producing a periodic function - are you sure that is what you want.

In any case the attached does this for 10 different values of the variable 'alpha', calculating the necessary values of 'beta'

  restart;
  ulim:=4:
  f := t -> sum(beta*Dirac(t - a), a = 1 .. 10):
  s := dsolve(diff(v(t), t) = alpha*v(t) - f(t), v(t), method = laplace):
  Y := rhs(s):
  v(0) := 6:
  beta := rhs(isolate( eval(Y, t=1/2)=eval(Y, t=ulim-1/2), beta));
  plot( [ seq( eval(Y, alpha=j), j=0.1..1, 0.1)],
        t=0..ulim
      );

(-6*exp((1/2)*alpha)+6*exp((7/2)*alpha))/(exp((5/2)*alpha)+exp((3/2)*alpha)+exp((1/2)*alpha))

 

 

 

Download periodic.mw

something like the attached?

Note that with alpha=0.023, the amount of drug in the bloodstream builds up, even if doses are being given weekly.

  restart;
  doseInt:=7: # dosing every 7 days
  b:= t->local j;add(Heaviside(t-doseInt*j)*exp(-alpha*(t-doseInt*j)), j=0..10);
  plot( [ eval(b(t), alpha=0.023), # drug metabolising "slowly"
          eval(b(t), alpha=0.23)   # drug metabolising "quickly"
        ],
        t=0..10*doseInt,
        color=[red, blue]
       );

proc (t) local j; options operator, arrow; add(Heaviside(t-doseInt*j)*exp(-alpha*(t-doseInt*j)), j = 0 .. 10) end proc

 

 

 

Download dose.mw

 

you want something like the attached???

  restart;
  with(plots):
   display( inequal( [ 0 <= y and y <= 1,
                       (2*y)/3 <= x and x <= 2*y
                     ],
                     x = 0 .. 2,
                     y = 0 .. 1,
                     nolines,
                     color=blue
                   ),
            inequal( [ 1 <= y and y <= 3,
                       (2*y)/3 <= x and x <= 2
                     ],
                     x = 2/3 .. 2,
                     y = 1 .. 3,
                     nolines,
                     color=red
                   )
          );

 

 

Download ineqplot.mw

is shown in the attached (where I have added a few linestyles, colors, line thicknesses etc, just to show the kind of flexibility which is available)

restart; with(plots); with(plottools); A := 2; p0 := display(sphere([0, 0, 0], .5, color = green, style = surface), seq(spacecurve([A*sin(phi)^2, j, phi], phi = 0 .. 2*Pi, coords = spherical, scaling = constrained, color = red, thickness = 4, linestyle = dot), j = 0 .. evalf(5*Pi*(1/6)), evalf((1/6)*Pi)), spacecurve({[sqrt(theta), 1, 1/10], [sqrt(theta), 2, 1/10], [sqrt(theta), 3, -1/10], [sqrt(theta), 1.7, 1/7]}, theta = 0 .. 2*Pi, coords = spherical, scaling = constrained, color = cyan, thickness = 4)); animate(rotate, [p0, 0, 0, j], j = 0 .. 2*Pi, frames = 20)

 

 

 

Download pul.mw

in a one-element list?

See the attached

6600.0*theta(q)-17000.0*theta(q-1)+14400.0*theta(q-2)-4000.0*theta(q-3) = v(q)-.20*theta(q)+.20*theta(q-1)

6600.0*theta(q)-17000.0*theta(q-1)+14400.0*theta(q-2)-4000.0*theta(q-3) = v(q)-.20*theta(q)+.20*theta(q-1)

(1)

isolate(6600.0*theta(q)-17000.0*theta(q-1)+14400.0*theta(q-2)-4000.0*theta(q-3) = v(q)-.20*theta(q)+.20*theta(q-1), theta(q))

theta(q) = 2.575709827*theta(q-1)-2.181752068*theta(q-2)+.6060422412*theta(q-3)+0.1515105603e-3*v(q)

(2)

``

Download isol.mw

where yoiu will find under

?CUDA

the useful information (emphasis added)

use CUDA(R) technology to accelerate certain LinearAlgebra routines

For more information about the routines that are accelerated when CUDA technology is turned on, see the Routines Accelerated by the CUDA Package help page.

and under

?Routines accelerated by the CUDA Package

You will find that (at the moment?) there is only one routine which can be accelerated, namely linearAlgebra[MatrixMatrixMultiply]

The file C:/Users/TomLeslie/Desktop/test.mpl, contains the "toy" code

j:=cos(x);
for k from 1 to 5 do
     M:=Matrix(2,2, fill=M); # recursive assignment
od;

If I attempt to read this mpl file using

   restart;
   stoperror(`recursive assignment`);
   read "C:/Users/TomLeslie/Desktop/test.mpl";
   unstoperror(`recursive assignment`);

Then Maple's debugger pops up a debug window, whose contents are

Error, recursive assignment
`unknown/toplevel`:
   1   M := Matrix(2,2,fill = M)

Whether or not this will find *all* types of recursive assignments, I don't know - but it certainly seems worth trying

  1. OP's code "works" in Maple 2022.2, but (sometimes?) doesn't work in Maple 2023.0.
  2. Comment out the setoptions3d() command and code works in Maple 2023 - although why setting a font option makes any difference to the arrow() command - beats me
  3. Problem only occurs when the 'shape' option is set to 'cylindrical_arrow', which happens to be the default for 3d arrows. Setting shape=harpoon, shape=arrow, or shape=double_arrow, then everything "works" - see the attached.

So I guess I'd call this one a bug

#
# OP's original - produces error!
#
  restart;
  kernelopts(version);
  with(plots):
  setoptions3d(font=[times, roman, 12]);
  arrow(<1,1,1>);

`Maple 2023.0, X86 64 WINDOWS, Mar 06 2023, Build ID 1689885`

 

Error, (in plottools:-rotate) invalid arguments for 3-D transformation

 

#
# Comment out the setoptions3d() command - no error!
#
  restart;
  kernelopts(version);
  with(plots):
 # setoptions3d(font=[times, roman, 12]);
  arrow(<1,1,1>):

`Maple 2023.0, X86 64 WINDOWS, Mar 06 2023, Build ID 1689885`

(1)

#
# Error only occurs when shape=cylindrical_arrow (which
# happens to be the default for 3D arrows
#
  restart;
  kernelopts(version);
  with(plots):
  setoptions3d(font=[times, roman, 12]):

`Maple 2023.0, X86 64 WINDOWS, Mar 06 2023, Build ID 1689885`

(2)

  arrow(<1,1,1>, shape=harpoon):

  arrow(<1,1,1>, shape=arrow):

  arrow(<1,1,1>, shape=double_arrow):

  arrow(<1,1,1>, shape=cylindrical_arrow):

Error, (in plottools:-rotate) invalid arguments for 3-D transformation

 

 

Download pltArr.mw

  1. You are missing the absolute value function (ie abs()  ) in all of the error terms - This makes a significant difference when one of the derivatives is negative.
  2. You are using the acceleration due to gravity (ie 9.81 m/s2) rather than the gravitational constant (ie 6.674e-11 m3kg-1s-2 which doesn't matter too much for the calculation, since whatever value you use "cancels" in the relative error calculation.

See the attached for my $0.02.

  restart;

  params1:= [R=1.5, dR=0.5, i=2.5, di=0.05, t=10, dt=0.5]:
  Q:= R*i^2*t;
  dQ:= abs(diff(Q, R)*dR) + abs(diff(Q,i)*di) + abs(diff(Q,t)*dt);
  eval(dQ, params1)/eval(Q, params1);

  params2:= [M=7.0, dM=0.05, m=2.0, dm=0.02, r=5, dr=0.05, G=6.674e-11]:
  F:= G*M*m/r^2;
  dF:= abs(diff(F,M)*dM) + abs(diff(F,m)*dm) + abs(diff(F,r)*dr);
  eval(dF, params2)/eval(F, params2);

R*i^2*t

 

abs(i)^2*abs(t*dR)+2*abs(R*i*t*di)+abs(i)^2*abs(R*dt)

 

.4233333333

 

G*M*m/r^2

 

abs(G*m*dM)/abs(r)^2+abs(G*M*dm)/abs(r)^2+2*abs(G*M*m*dr)/abs(r)^3

 

0.3714285714e-1

(1)

 

Download relErr.mw

from the Maple Application Centre does a reasonable job of finding the four solutions you listed - see the attached.

  restart;

  Digits += Digits;
  nsd := 16*a*b*c*(a^2 + b^2 + c^2 + 9)*(a*(b + c) + 3*(a + b + c) + b*c) - (a + b + c + 3)^2*(a*b + 3*c)*(a*c + 3*b)*(b*c + 3*a):
  DirectSearch:-SolveEquations(nsd, [a::posint, b::posint, c::posint], AllSolutions=true);

Digits := 20

 

Matrix(%id = 36893488148091378012)

(1)

 

Download DS.mw

is in the attached

  restart;  
  with(geometry):  
  with(plots):  
  _EnvHorizontalName = 'x':  _EnvVerticalName = 'y':
  point(A, -1, 9):                                                                                                       
  point(B, -5, 0):
  point(C, 6, 0):
  triangle(ABC,[A,B,C]):
  midpoint(M1,A,C):
  midpoint(M2,B,C):
  midpoint(M3,A,B):
  rotation(J, C, Pi/2, 'counterclockwise', M1):
  triangle(AJC,[A,J,C]):
  rotation(Ii, C, Pi/2, 'counterclockwise', M2):
  triangle(BIC,[B,Ii,C]):
  rotation(K, A, Pi/2, 'counterclockwise', M3):
  triangle(AKB,[A,K,B]):
  midpoint(O1,K,J):
  coordinates(O1):
  midpoint(O2,A,Ii):
  coordinates(O2):  
  poly:=[coordinates(A),coordinates(J),coordinates(Ii),coordinates(K)]:   

  display(draw( [ A(color = black, symbol = solidcircle, symbolsize = 12),
                  B(color = black, symbol = solidcircle, symbolsize = 12),
                  C(color = black, symbol = solidcircle, symbolsize = 12),
                  J(color = black, symbol = solidcircle, symbolsize = 12),
                  ABC(color = red, filled=true, transparency=0.8 ),
                  BIC(color = green, filled=true, transparency=0.8),
                  AKB(color = grey, filled=true, transparency=0.8),
                  AJC(color = blue, filled=true, transparency=0.8)
                ]
              ),
          polygonplot(poly, color = "DarkGreen", transparency = 0.5),
          textplot( [ [coordinates(A)[], "A"],
                      [coordinates(J)[], "J"],
                      [coordinates(Ii)[], "I"],   
                      [coordinates(B)[], "B"],
                      [coordinates(K)[], "K"],
                      [coordinates(C)[], "C"]
                    ],
                    align = [above, right]
                  ),
          axes = none
         );

 

 

Download geomDraw.mw

1 2 3 4 5 6 7 Last Page 3 of 207