int main( ){

    USING_NAMESPACE_ACADO

    DifferentialState a,b;
    TIME t;

    CFunction myFunction( 1, my_function );

    IntermediateState x(3);

    x(0) = t;
    x(1) = a;
    x(2) = b;

    Function f;
    f << myFunction( x );


    // TEST THE FUNCTION f:
    // --------------------
       int x_index, y_index;

       x_index = f.index(VT_DIFFERENTIAL_STATE,0);
       y_index = f.index(VT_DIFFERENTIAL_STATE,1);

       double *xx    = new double[f.getNumberOfVariables()+1];
       double *seed  = new double[f.getNumberOfVariables()+1];
       double *ff    = new double[f.getDim()                ];
       double *df    = new double[f.getDim()                ];

       xx[x_index] = 1.0;
       xx[y_index] = 1.0;

       seed[x_index] = 0.5;
       seed[y_index] = 0.5;


    // FORWARD DIFFERENTIATION:
    // ------------------------
       f.evaluate  ( 0, xx  , ff );
       f.AD_forward( 0, seed, df );


    // PRINT THE RESULTS:
    // ------------------
       printf("     x = %10.16e \n",   xx[x_index] );
       printf("     y = %10.16e \n",   xx[y_index] );
       printf("seed_x = %10.16e \n", seed[x_index] );
       printf("seed_y = %10.16e \n", seed[y_index] );
       printf("     f = %10.16e \n",   ff[0      ] );
       printf("    df = %10.16e \n",   df[0      ] );

    delete[] xx;
    delete[] seed;
    delete[] ff;
    delete[] df;

    return 0;
}
/* >>> start tutorial code >>> */
int main( ){

    USING_NAMESPACE_ACADO

    // DEFINE VALRIABLES:
    // ---------------------------
       DifferentialState x, y;
       Function f;

       f << x*x + pow(y,2);

    // TEST THE FUNCTION f:
    // --------------------
       EvaluationPoint  z(f);
       EvaluationPoint dz(f);

       Vector xx(2);  Vector dx(2);

       xx(0) =  1.0;  dx(0) =  0.5;
       xx(1) =  1.0;  dx(1) =  0.1;

       z.setX( xx );  dz.setX( dx );


    // FORWARD DIFFERENTIATION:
    // ------------------------
       Vector ff = f.evaluate  ( z  );
       Vector df = f.AD_forward( dz );


    // PRINT THE RESULTS:
    // ------------------
       ff.print("result of evaluation      \n");
       df.print("result for the derivative \n");

    return 0;
}
USING_NAMESPACE_ACADO

/* >>> start tutorial code >>> */
int main()
{
	// DEFINE VALRIABLES:
	// ---------------------------
	DifferentialState	x, y;
	Function f;

	f << x*x + pow(y,2);

	// TEST THE FUNCTION f:
	// --------------------
	EvaluationPoint z(f);
	EvaluationPoint dz(f);

	DVector xx(2); DVector dx(2);

	xx(0) = 1.0; dx(0) = 0.5;
	xx(1) = 1.0; dx(1) = 0.1;

	z.setX( xx ); dz.setX( dx );

	// FORWARD DIFFERENTIATION:
	// ------------------------
	DVector ff = f.evaluate ( z );
	DVector df = f.AD_forward( dz );

	// PRINT THE RESULTS:
	// ------------------
	cout << "result of evaluation    : " << ff;
	cout << "result of the derivative: " << df;

	return 0;
}