- Compute 10000 iterates of the logistic map:
#include "iRRAM.h" using namespace iRRAM; using std::setw; /* Compute logistic map * x_n+1 =c * x_n * (1-x_n) * for c=3.75 and x_0 = 0.5 */ void compute(){ REAL x = 0.5; REAL c = 3.75; cout << setRwidth(40) << setw(6); for ( int i=0; i <= 9999; i++ ) { cout << x << " : " << i << "\n"; x = c * x * (1 -x); } }
Comparison to evaluation using double precision:
- Compute many decimals of the Euler’s number e = 2.7172… as the limit of a sequence
#include "iRRAM.h" using namespace iRRAM; /* Compute an approximation to e=2.71... * up to an error of 2^p */ REAL e_approx (int p) { REAL y = 1, sum = 2; for (int i=2; !bound(y,p-1); i++ ) { y = y / i; sum = sum + y; } return sum; } /* Compute e=2.71... */ void compute(){ REAL euler_number = limit( e_approx ); auto widths= {50, 100, 1000, 10000}; for (int w: widths) { cout << setRwidth(w) << euler_number << "\n\n"; } }