Dynamic Y Bounds

This commit is contained in:
Parric007
2024-05-02 08:45:09 +02:00
parent dc4583a6ce
commit f16c0880bc
2 changed files with 41 additions and 15 deletions

28
.idea/workspace.xml generated
View File

@@ -7,24 +7,27 @@
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="Git.Settings">
"customColor": "", <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
"associatedIndex": 3 </component>
}]]></component> <component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 3
}</component>
<component name="ProjectId" id="2f8GfgPc4SNisU2YtrGzKkx27b1" /> <component name="ProjectId" id="2f8GfgPc4SNisU2YtrGzKkx27b1" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"kotlin-language-version-configured": "true", &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="SharedIndexes"> <component name="SharedIndexes">
<attachedChunks> <attachedChunks>
<set> <set>
@@ -41,6 +44,7 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1713175398866</updated> <updated>1713175398866</updated>
<workItem from="1713175399721" duration="45000" /> <workItem from="1713175399721" duration="45000" />
<workItem from="1714631445701" duration="14000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@@ -1,7 +1,8 @@
public class Main { public class Main {
static Bounds bounds;
static Bounds bounds = new Bounds(new LinearBounds(0, 20), new LinearBounds(-100, 150000)); static final float lowerX = 0;
static double samples = 1_000_000; static final float upperX = 20;
static double samples = 10_000_000;
static int threadCount = 16; static int threadCount = 16;
static class Point { 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) { static double function(double x) {
return Math.pow(x,4)-4*Math.pow(x,3)+18*Math.pow(x,2)-12*x-69; 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 { public static void main(String[] args) throws InterruptedException {
bounds = new Bounds(new LinearBounds(lowerX, upperX), new LinearBounds(getLowerLimit(), getUpperLimit()));
double pointsInside = 0; double pointsInside = 0;
long startTime = System.nanoTime(); long startTime = System.nanoTime();
double real_value = getRealIntegral(bounds.getX()); double real_value = getRealIntegral(bounds.getX());