Java - How would you find the differential of a function (eg. f(x) = 2x^2+2x-1) with given values for x using apache commons? -
i have looked in user guide, , still not understand. sorry may bad post.
public static void main(string[] args) { // change different results int xvalue = 2; int howmanyunknowparamshasfunction = 1; int howmanyderiviationwillyoutake = 1; int whatistheindexofthisparameterx = 0; derivativestructure x = new derivativestructure(howmanyunknowparamshasfunction, howmanyderiviationwillyoutake, whatistheindexofthisparameterx, xvalue); // x --> x^2. derivativestructure x2 = x.pow(2); //y = 2x^2 + 2x - 1 derivativestructure y = new derivativestructure(2.0, x2, 2.0, x).subtract(1); system.out.println("y = " + y.getvalue()); system.out.println("y' = " + y.getpartialderivative(1)); }
Comments
Post a Comment