-
Notifications
You must be signed in to change notification settings - Fork 0
/
strange.cpp
46 lines (39 loc) · 1.23 KB
/
strange.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <fstream>
#include <cmath>
#include <chrono>
using namespace std;
bool conv(double x, double y, double z) {
for (long i = 0; i < 100; i++) {
double dx = (-1.4*x)-(4*y)-(4*z)-(y*y);
double dy = -(4*x)-(1.4*y)-(4*z)-(z*z);
double dz = -(4*x)-(4*y)-(1.4*z)-(x*x);
x += dx*.005;
y += dy*.005;
z += dz*.005;
}
// cout << x << " " << y << " " << z << endl;
if (isnan(x) || isnan(y) || isnan(z)) {
return false;
}
return true;
}
int main () {
ofstream f ("out.txt");
auto start = chrono::high_resolution_clock::now();
for (double x = -100; x < 100; x += .5) {
for (double y = -100; y < 100; y += .5) {
for (double z = -100; z < 100; z += .5) {
if (conv(x, y, z)) {
f << x << " " << y << " " << z << endl;
}
}
}
}
auto stop = chrono::high_resolution_clock::now();
auto duration = chrono::duration_cast<chrono::seconds>(stop - start);
cout << "Time taken by function: " << duration.count() << " seconds" << endl;
cout << "Count: " << count << endl;
f.close();
return 0;
}