Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ ¹ ² ³ °
 

You are not logged in. #1 20060507 05:54:44
Finding things irrationallyLet's face it, we all hate decimals. Especially when it comes to irrational numbers. Who really wants to write something out for infinity when just writing "e" will do the job. Which of course doesn't cover all irrationals, but it should cover a heck of a lot of them. If anyone can either: 1. Simplify this so that it includes less variables 2. Find an irrational this does not cover I've already made code to handle this, although it takes a heck of a long time to run. And that's only for very small values. It was able to find pi and sqrt(pi) already, although those were easy tests. Right now, I'm having it run on just for kicks, to see if it comes up with anything. For those of you who don't know, we only have an approximation for that summation. Here is my code: Code:#include <iostream> #include <math.h> #define EULER 2.718281828459 #define PI 3.14159265 #define EPSILON 0.0000001 using namespace std; bool test(double n, double m) { if (n  EPSILON < m && n + EPSILON > m) return true; return false; } int main() { double a,b,c,d,f,g,h,i,j,k,l,m,n,o; double input; cout << "Enter number: " << endl; cin >> input; int start = 0; int end = 10; for (a = start; a < end; a++) { for (b = start; b < end; b++) { for (c = start; c < end; c++) { for (d = start; d < end; d++) { for (f = start; f < end; f++) { for (g = start; g < end; g++) { for (h = start; h < end; h++) { for (i = start; i < end; i++) { for (j = start; j < end; j++) { for (k = start; k < end; k++) { for (l = start; l < end; l++) { for (m = start; m < end; m++) { for (n = start; n < end; n++) { for (o = start; o < end; o++) { double part1 = pow(a/b*pow(EULER, c/d)*pow(PI, f/g), h/i); double part2 = j/k*pow(EULER, l/m)*pow(PI, n/o); if (test(input, part1 + part2)) { cout << "(" << a << "/" << b << "e^(" << c << "/" << d << ")pi^(" << f << "/" << g << ")^(" << h << "/" << i << ") + " << j << "/" << k << "e^(" << l << "/" << m << ")pi^(" << n << "/" << o << ") " << endl; return 0; } }}}}}}}}}}}}}} return 0; } "In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..." #2 20060507 10:33:39
Re: Finding things irrationallyUmmm... I think I need more explanation. "The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  Leon M. Lederman #3 20060507 11:20:22
Re: Finding things irrationally
That actually should be faster, however, it certainly isn't the bottle neck of the code. So it won't really be a big increase, but hey, an increase none the less. "In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..." #5 20060508 00:15:22
Re: Finding things irrationallyDang. You're right George. I was hoping since they had to have similar terms they could be be factored out into the same part, but nope. A temporary fix to this is to have 3 different terms, each with the same structure, but different integer coefficents. But that is really unacceptable in terms of performance. "In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..." 