nth derivative
2009-10-15 by gems_tux
I wrote a simple program for calculating the nth derivative:
\<< \-> F V N
\<< F XQ 1 N
FOR K V DERIV SIMPLIFY
NEXT
\>>
\>> 'DERVN' STO
'Function' 'Variable' 'N' --> nth derivative
Examples of use of DERVN program:
'1/\v/X' 'X' 3 --> '-(15*\v/X/(8*X^4))'
'\.S(-\oo,1/X,EXP(-Y^2),Y)' 'X' 2 --> '(2*X^2-2)/(X^5*EXP(1/X^2))'
'F(X,Y,Z)' 'Z' 2 --> 'd3d3F(X,Y,Z)'
If I apply my DERVN program this function:
'F(X,Y)=X*Y/(X^2+Y^2)' 'Y' 2 --> "Error: Invalid User Function"
Why am I getting that message?
If I delete 'SIMPLIFY' then get the correct result, obviously not
simplified:
\<< \-> F V N
\<< F XQ 1 N
FOR K V DERIV
NEXT
\>>
\>> 'DERVN' STO
'F(X,Y)=X*Y/(X^2+Y^2)' 'Y' 2 --> 'd2d2F(X,Y)=(SQ(X^2+Y^2)*(X*(2*Y)-(X*
(2*Y)+2*(X*Y)))-(X*(X^2+Y^2)-X*Y*(2*Y))*(2*((X^2+Y^2)*(2*Y))))/SQ(SQ
(X^2+Y^2))'
then SIMPLIFY: 'd2d2F(X,Y)=-((6*Y*X^3-2*Y^3*X)/
(X^6+3*Y^2*X^4+3*Y^4*X^2+Y^6))'
Cheers,
Simone.
\<< \-> F V N
\<< F XQ 1 N
FOR K V DERIV SIMPLIFY
NEXT
\>>
\>> 'DERVN' STO
'Function' 'Variable' 'N' --> nth derivative
Examples of use of DERVN program:
'1/\v/X' 'X' 3 --> '-(15*\v/X/(8*X^4))'
'\.S(-\oo,1/X,EXP(-Y^2),Y)' 'X' 2 --> '(2*X^2-2)/(X^5*EXP(1/X^2))'
'F(X,Y,Z)' 'Z' 2 --> 'd3d3F(X,Y,Z)'
If I apply my DERVN program this function:
'F(X,Y)=X*Y/(X^2+Y^2)' 'Y' 2 --> "Error: Invalid User Function"
Why am I getting that message?
If I delete 'SIMPLIFY' then get the correct result, obviously not
simplified:
\<< \-> F V N
\<< F XQ 1 N
FOR K V DERIV
NEXT
\>>
\>> 'DERVN' STO
'F(X,Y)=X*Y/(X^2+Y^2)' 'Y' 2 --> 'd2d2F(X,Y)=(SQ(X^2+Y^2)*(X*(2*Y)-(X*
(2*Y)+2*(X*Y)))-(X*(X^2+Y^2)-X*Y*(2*Y))*(2*((X^2+Y^2)*(2*Y))))/SQ(SQ
(X^2+Y^2))'
then SIMPLIFY: 'd2d2F(X,Y)=-((6*Y*X^3-2*Y^3*X)/
(X^6+3*Y^2*X^4+3*Y^4*X^2+Y^6))'
Cheers,
Simone.
