## 13776 Reputation

14 years, 64 days

## Like this...

 > 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);
 (1)
 >

## First of all...

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

## Don't think this is a "functionality" is...

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

## Recursive definition...

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       );
 >

## Maybe you wanted...

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]        );
 >

## If I understand correctly...

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                    )           );
 >

## How I'd (probably?) do it...

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)

 >
 >
 >

## Why is your equation...

in a one-element list?

See the attached

 (1)

 (2)

## Read the maple help...

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]

## Worth trying the stoperror() command...

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`);
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

## Looks like a bug - some observations...

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

## Two points...

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);
 (1)
 >

## The free DirectSearch() package...

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);
 (1)
 >