Dynamic Y Bounds
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
public class Main {
|
||||
|
||||
static Bounds bounds = new Bounds(new LinearBounds(0, 20), new LinearBounds(-100, 150000));
|
||||
static double samples = 1_000_000;
|
||||
static Bounds bounds;
|
||||
static final float lowerX = 0;
|
||||
static final float upperX = 20;
|
||||
static double samples = 10_000_000;
|
||||
static int threadCount = 16;
|
||||
|
||||
static class Point {
|
||||
@@ -65,6 +66,25 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
static float getUpperLimit() {
|
||||
float upperLimit = 0;
|
||||
for(float i = lowerX; i< upperX; i+= 0.025F) {
|
||||
if(function(i) > upperLimit) {
|
||||
upperLimit = (float) (function(i) * 1.025);
|
||||
}
|
||||
}
|
||||
return upperLimit;
|
||||
}
|
||||
static float getLowerLimit() {
|
||||
float lowerLimit = 0;
|
||||
for(float i = lowerX; i< upperX; i+= 0.025F) {
|
||||
if(function(i) < lowerLimit) {
|
||||
lowerLimit = (float) (function(i) * 1.025);
|
||||
}
|
||||
}
|
||||
return lowerLimit;
|
||||
}
|
||||
|
||||
static double function(double x) {
|
||||
return Math.pow(x,4)-4*Math.pow(x,3)+18*Math.pow(x,2)-12*x-69;
|
||||
}
|
||||
@@ -86,6 +106,8 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
|
||||
bounds = new Bounds(new LinearBounds(lowerX, upperX), new LinearBounds(getLowerLimit(), getUpperLimit()));
|
||||
|
||||
double pointsInside = 0;
|
||||
long startTime = System.nanoTime();
|
||||
double real_value = getRealIntegral(bounds.getX());
|
||||
|
||||
Reference in New Issue
Block a user