(10-02-2022 12:47 AM)Eddie W. Shore Wrote: [ -> ]Trying the second derivative in a program:
Code:
EXPORT DER2(f,v,n)
BEGIN
LOCAL d;
d:=diff(f,v,2,v=n);
RETURN d;
END;
Home:
DER2(X^3,X,1) -> Error: Bad argument value ("diff(f,v,2,v=n)")]
DER2('X^3','X',1) -> diff(diff(3.006003,2),0)
CAS:
DER2(X^3,X,1) -> Error: Bad argument value ("diff(f,v,2,v=n)")]
DER2(x^3,x,1) -> diff(diff(3*x^2,2),0)
I hope that the next Prime update will allow for numerical differentiation for both first and second derivatives.
another program uses the limits of the function:
Code:
#cas
DER2(funz,grado,num,ds):=
BEGIN
LOCAL dd, risultato;
dd:=(t)->diff(funz(x),x,grado);
risultato:=limit(dd(x),x,num,ds);
RETURN risultato;
END;
#end
grado --> degree of derivation
num --> value of the derivative
ds = -1 --> left limit
ds = +1 --> right limit
ds = 0 --> bidirectional limit
examples:
DER2((t)->t^3,2,4,0) --> 24
DER2((x)->Si(x),1,0,0) --> 1
DER2((x)->ln(x),1,0,1) --> +inf
DER2((x)->ln(x),1,0,-1) --> -inf
DER2((x)->ln(x),1,0,) --> +/-inf
DER2((t)->e^(-2*t),3,7,0) --> -8*exp(-14)