#include #include "StatTools/Funct/Variables.h" #include "StatTools/Funct/FunctManip.h" #include "StatTools/Funct/FunctIO.h" using namespace Funct; using namespace std; int main() { X x; Y y; #ifndef __STRICT_ANSI__ typeof( sin( x ) + cos( x ) ) f = sin( x ) + cos( x ); typeof( derivative( f ) ) d = derivative( f ); typeof( derivative( d ) ) d2 = derivative( d ); typeof( derivative( d2 ) ) d3 = derivative( d2 ); typeof( derivative( d3 ) ) d4 = derivative( d3 ); cout << "d/d" << x << "( " << f << " ) = " << d << endl; cout << "d/d" << x << "( " << d << " ) = " << d2 << endl; cout << "d/d" << x << "( " << d2 << " ) = " << d3 << endl; cout << "d/d" << x << "( " << d3 << " ) = " << d4 << endl; #endif cout << "d/d" << x << "( " << sqrt( x ) << " ) = " << derivative( sqrt( x ) ) << endl; cout << "d/d" << x << "( " << pow( sin( x ), num<2>() ) << " ) = " << derivative( pow( sin( x ), num<2>() ) ) << endl; cout << "d/d" << x << "( " << tan( x ) << " ) = " << derivative( tan( x ) ) << endl; cout << "d2/d" << x << "2 ( " << tan( x ) << " ) = " << nth_derivative<2, X>( tan( x ) ) << endl; cout << "d3/d" << x << "3 ( " << tan( x ) << " ) = " << nth_derivative<3, X>( tan( x ) ) << endl; cout << "d4/d" << x << "4 ( " << tan( x ) << " ) = " << nth_derivative<4, X>( tan( x ) ) << endl; cout << "d5/d" << x << "5 ( " << tan( x ) << " ) = " << nth_derivative<5, X>( tan( x ) ) << endl; cout << "d/d" << x << "( " << pow( x, num<2>() ) << " ) = " << derivative( pow( x, num<2>() ) ) << endl; cout << "d/d" << x << "( " << exp( pow( x, num<2>() ) ) << " ) = " << derivative( exp( pow( x, num<2>() ) ) ) << endl; cout << "d2/d" << x << "2 ( " << exp( pow( x, num<2>() ) ) << " ) = " << nth_derivative<2, X>( exp( pow( x, num<2>() ) ) ) << endl; cout << "d3/d" << x << "3 ( " << exp( pow( x, num<2>() ) ) << " ) = " << nth_derivative<3, X>( exp( pow( x, num<2>() ) ) ) << endl; cout << "d/d" << x << "( " << exp( sin( x ) )<< " ) = " << derivative( exp( sin( x ) ) )<< endl; cout << "d/d" << x << "( " << log( x )<< " ) = " << derivative( log( x ) )<< endl; cout << "d/d" << x << "( " << y << " ) = " << derivative( y )<< endl; cout << "d/d" << x << "( " << x << " ) = " << derivative( x )<< endl; cout << y << " independent of " << x << " ? : " << Independent< X, Y >::value << endl; cout << x << " independent of " << x << " ? : " << Independent< X, X >::value << endl; cout << "d/d" << x << "( " << sin( x ) * cos( x ) << " ) = " << nth_derivative<1, X>( sin( x ) * cos( x ) ) << endl; cout << "d2/d" << x << "2( " << sin( x ) * cos( x ) << " ) = " << nth_derivative<2, X>( sin( x ) * cos( x ) ) << endl; cout << "d3/d" << x << "3( " << sin( x ) * cos( x ) << " ) = " << nth_derivative<3, X>( sin( x ) * cos( x ) ) << endl; cout << "d4/d" << x << "4( " << sin( x ) * cos( x ) << " ) = " << nth_derivative<4, X>( sin( x ) * cos( x ) ) << endl; cout << "d/d" << x << "( " << sin( x ) * pow( cos( x ), num( 2 ) ) << " ) = " << nth_derivative<1, X>( sin( x ) * pow( cos( x ), num( 2 ) ) ) << endl; cout << "d2/d" << x << "2( " << sin( x ) * pow( cos( x ), num( 2 ) ) << " ) = " << nth_derivative<2, X>( sin( x ) * pow( cos( x ), num( 2 ) ) ) << endl; cout << "d3/d" << x << "3( " << sin( x ) * pow( cos( x ), num( 2 ) ) << " ) = " << nth_derivative<3, X>( sin( x ) * pow( cos( x ), num( 2 ) ) ) << endl; cout << "d4/d" << x << "4( " << sin( x ) * pow( cos( x ), num( 2 ) ) << " ) = " << nth_derivative<4, X>( sin( x ) * pow( cos( x ), num( 2 ) ) ) << endl; return 0; }