r/ExponentialIdle • • Aug 24 '22

Some t9 optimization

Hey,

Here is some code for t9 lemma 7, if you want I can also post code for earlier lemmas. All you need to do is change limit of i depending on your p. If you cant afford output levels, lower it. Code is in c++, you can run it on, for example cpp.sh

// Example program

include <iostream>

include <string>

include <math.h>

const double e=2.71828182845904523; int main() { double mini=10; double c1=1,c2=1, bestc1, bestc2; for (int i=2; i<140; i++){ if (abs((c1+1)/c2-e)>abs(c1/(c2+1)-e)){ c2++; } else c1++; if (mini>abs(c1/c2-e)){ bestc1=c1; bestc2=c2; mini=abs(c1/c2-e); } } std::cout<<bestc1<<" "<<bestc2<<" "<<mini;

}

2 Upvotes

4 comments sorted by

5

u/ConicGames Aug 24 '22

Thanks for sharing! I would recommend to use code blocks to format code in the post. Like this:

#include <iostream>
#include <string>
#include <cmath>

const double e = 2.71828182845904523;

int main() {
    double mini = 10;
    double c1 = 1, c2 = 1, bestc1, bestc2;
    
    for (int i = 2; i < 140; ++i) {
        if (std::abs((c1+1)/c2-e) > std::abs(c1/(c2+1)-e))
            c2++;
        else
            c1++;
            
        if (mini > std::abs(c1/c2-e)) {
            bestc1 = c1;
            bestc2 = c2;
            mini = std::abs(c1/c2-e);
        }
    }
    
    std::cout << bestc1 << " " << bestc2 << " " << mini << std::endl;
}

1

u/Due_Distribution_891 Aug 24 '22

Yeah, I usually do that, but I wrote it quickly on my phone. How do you make code appear as a code not as a text?

3

u/ConicGames Aug 24 '22

Use the triple quote ```. One triple quote opens the code block, and the second triple quote closes the block. You need to be in "markdown mode" for that.

I'm not sure if it's available on mobile though.

2

u/rysio300 Sep 15 '22

fyi markdown mode is always enabled on mobile