com.tukeof.common.util.MathUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-core Show documentation
Show all versions of common-core Show documentation
a common and useful pure java library
The newest version!
package com.tukeof.common.util;
/**
* @author tuke
*/
public class MathUtil {
//difference quotient
public static double diffq(double[] a, double[] b) {
int n = a.length;
if (n == 2) {
return (b[0] - b[1]) / (a[0] - a[1]);
}
if (n == 1) {
return b[0] / a[0];
}
double[] c = new double[n - 1];
System.arraycopy(a, 0, c, 0, n - 1);
double[] d = new double[n - 1];
System.arraycopy(b, 0, d, 0, n - 1);
return diffq(c, d);
}
}