I believe the idea was that functions with a greater rate of change are "less" accurately differentiable, in a sense.
read more
import java.util.Scanner;
public class degreeOfDifferentiability {
/**
* e^x, as array, differentiate at two points using the same h, then compare
* with instantaneous rate of change with smaller h.
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
double x1;
double x2;
double h1 = .0001;
double h2 = .00001;
double instantaneousy1h1;
double instantaneousy2h1;
double instantaneousy1h2;
double instantaneousy2h2;
grapher function = new grapher();
String point;
System.out
.println("Do you want to compare the differentiability of the entire function 2^x or at a point? Respond 'function' or 'point'");
point = scan.next();
if (point == "point") {
System.out
.println("The equation is 2^x, at what points do you want to compare the degree of differentiability?");
x1 = scan.nextDouble();
x2 = scan.nextDouble();
instantaneousy1h1 = ((function.evaluateAtPoint(2, x1 + h1) - function
.evaluateAtPoint(2, x1))
/ h1
+ function.evaluateAtPoint(2, x1) - function
.evaluateAtPoint(2, x1 - h1)) / 2;
instantaneousy2h1 = ((function.evaluateAtPoint(2, x2 + h1) - function
.evaluateAtPoint(2, x2))
/ h1
+ function.evaluateAtPoint(2, x2) - function
.evaluateAtPoint(2, x2 - h1)) / 2;
instantaneousy1h2 = ((function.evaluateAtPoint(2, x1 + h2) - function
.evaluateAtPoint(2, x1))
/ h2
+ function.evaluateAtPoint(2, x1) - function
.evaluateAtPoint(2, x1 - h2)) / 2;
instantaneousy2h2 = ((function.evaluateAtPoint(2, x2 + h2) - function
.evaluateAtPoint(2, x2))
/ h2
+ function.evaluateAtPoint(2, x2) - function
.evaluateAtPoint(2, x2 - h2)) / 2;
System.out.println(instantaneousy1h1 + "," + instantaneousy2h1
+ "," + instantaneousy1h2 + "," + instantaneousy2h2);
System.out.println(instantaneousy1h1 - instantaneousy1h2);
System.out.println(instantaneousy2h1 - instantaneousy2h2);
}
if (point == "function") {
for (double i = 0; i < 10; i += .01) {
instantaneousy1h1 = ((function.evaluateAtPoint(2, i + h1) - function
.evaluateAtPoint(2, i))
/ h1
+ function.evaluateAtPoint(2, i) - function
.evaluateAtPoint(2, i - h1)) / 2;
instantaneousy2h1 = ((function.evaluateAtPoint(2, i + h1) - function
.evaluateAtPoint(2, i))
/ h1
+ function.evaluateAtPoint(2, i) - function
.evaluateAtPoint(2, i - h1)) / 2;
instantaneousy1h2 = ((function.evaluateAtPoint(2, i + h2) - function
.evaluateAtPoint(2, i))
/ h2
+ function.evaluateAtPoint(2, i) - function
.evaluateAtPoint(2, i - h2)) / 2;
instantaneousy2h2 = ((function.evaluateAtPoint(2, i + h2) - function
.evaluateAtPoint(2, i))
/ h2
+ function.evaluateAtPoint(2, i) - function
.evaluateAtPoint(2, i - h2)) / 2;
System.out.println(instantaneousy1h1 - instantaneousy1h2);
System.out.println(instantaneousy2h1 - instantaneousy2h2);
}
}
}
}