Calculating the fractional iterates of \(f(z) = e^z-1\) to reasonable accuracy
#8
I took this as a challenge and made an approximation of the nth iteration of \(e^{x} - 1\) for \(x \in [0,\infty]\) and \(n \in \mathbb{R}\) upto somewhat reasonable accuracy.
This is the code(i polished the code to oblivion):
Code:
\\ This is integer recursion for f(x) = exp(f(x-1))-1
repeat(x,n) = {if(n>0, for(i=1,n,x=exp(x)-1), for(i=1,-n,x=log(x+1))); x}
\\ This is a local approximation of f(x) = exp(f(x-1))-1, it has 12 derivatives
initpol(x, k) = k + (x/2)*k^2 + ((3/2*x^2 - 1/2*x)/3!)*k^3 + ((3*x^3 - 5/2*x^2 + 1/2*x)/4!)*k^4 + ((15/2*x^4 - 65/6*x^3 + 5*x^2 - 2/3*x)/5!)*k^5 + ((45/2*x^5 - 385/8*x^4 + 445/12*x^3 - 91/8*x^2 + 11/12*x)/6!)*k^6 + ((315/4*x^6 - 1827/8*x^5 + 6125/24*x^4 - 1043/8*x^3 + 637/24*x^2 - 3/4*x)/7!)*k^7 + ((315*x^7 - 4683/4*x^6 + 10507/6*x^5 - 1295*x^4 + 2737/6*x^3 - 215/4*x^2 - 11/6*x)/8!)*k^8 + ((2835/2*x^8 - 12987/2*x^7 + 98735/8*x^6 - 97601/8*x^5 + 25375/4*x^4 - 11785/8*x^3 + 459/8*x^2 + 29/4*x)/9!)*k^9 + ((14175/2*x^9 - 622215/16*x^8 + 724455/8*x^7 - 681835/6*x^6 + 639191/8*x^5 - 1391225/48*x^4 + 23137/6*x^3 + 1727/24*x^2 + 493/12*x)/10!)*k^10 + ((155925/4*x^10 - 4010325/16*x^9 + 44546535/64*x^8 - 51331115/48*x^7 + 30772049/32*x^6 - 11673541/24*x^5 + 22393129/192*x^4 - 90079/12*x^3 + 53867/48*x^2 - 2711/6*x)/11!)*k^11 + ((467775/2*x^11 - 27715545/16*x^10 + 179794395/32*x^9 - 658520005/64*x^8 + 273281591/24*x^7 - 720672953/96*x^6 + 1284253597/480*x^5 - 78859495/192*x^4 + 712063/16*x^3 - 915187/48*x^2 - 12406/15*x)/12!)*k^12;
\\ Using my numerical method i approximate the superfunction even more
improvedappr(x) = repeat(initpol(x,repeat(1,-300)),300)
globalprecision(p) = {
default(realprecision, p);
global(GLOBPREC = p);
}
\\ initialization function
init() = {
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                          ██╗███╗   ██╗██╗████████╗██╗ █████╗ ██╗     ██╗███████╗██╗███╗   ██╗ ██████╗          ");
print("                          ██║████╗  ██║██║╚══██╔══╝██║██╔══██╗██║     ██║╚══███╔╝██║████╗  ██║██╔════╝          ");
print("                          ██║██╔██╗ ██║██║   ██║   ██║███████║██║     ██║  ███╔╝ ██║██╔██╗ ██║██║  ███╗         ");
print("                          ██║██║╚██╗██║██║   ██║   ██║██╔══██║██║     ██║ ███╔╝  ██║██║╚██╗██║██║   ██║         ");
print("                          ██║██║ ╚████║██║   ██║   ██║██║  ██║███████╗██║███████╗██║██║ ╚████║╚██████╔╝██╗██╗██╗");
print("                          ╚═╝╚═╝  ╚═══╝╚═╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚══════╝╚═╝╚══════╝╚═╝╚═╝  ╚═══╝ ╚═════╝ ╚═╝╚═╝╚═╝");
print("_________________________________________________________________________________________________________________________________________");
default(realprecision,400);
print("precision initialized: 400");
default(seriesprecision, 100);
print("Series Order initialized: 100");
print("Now making local polynomial. Please wait");
print("_________________________________________________________________________________________________________________________________________");
global(LOCALSER = Ser(improvedappr(x),x,100));
print("Initialized LOCALSER");
global(INVLOCALSER = serreverse(Ser(sum(n=1, 99, derivnum(X=0,subst(Pol(LOCALSER),x,X),n)/n! * x^n),x,100)));
print("Initialized INVLOCALSER");
print("_________________________________________________________________________________________________________________________________________");
print("Completed initializing!");
default(realprecision,GLOBPREC);
}
\\ For evaluating the superfunction fast for [-infty, infty]
superf(o) = if(o < 1 && o >= 0, subst(Pol(LOCALSER),x,o), if(o >= 1, exp(superf(o-1)) - 1, if( o < 0, log(superf(o+1)+1))));
\\ For evaluating the inverse of the superfunction fast. accurate upto around 10^-26 for [0,infty]
superinv(o)= if(o >= 1 && o < exp(1)-1, subst(Pol(INVLOCALSER),x,log(o+1)-1)+1, if(o >= exp(1)-1, superinv(log(o+1))+1, if(o < 1, superinv(exp(o)-1)-1)));
\\ The sth iterate of exp(x)-1
iter(x,s) = superf(superinv(x)+s);
start() = {
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                            ███████╗██╗  ██╗██████╗ ███╗   ███╗ ██╗    ██████╗ ██████╗     ██╗   ██╗ ██╗");
print("                            ██╔════╝╚██╗██╔╝██╔══██╗████╗ ████║███║   ██╔════╝ ██╔══██╗    ██║   ██║███║");
print("                            █████╗   ╚███╔╝ ██████╔╝██╔████╔██║╚██║   ██║  ███╗██████╔╝    ██║   ██║╚██║");
print("                            ██╔══╝   ██╔██╗ ██╔═══╝ ██║╚██╔╝██║ ██║   ██║   ██║██╔═══╝     ╚██╗ ██╔╝ ██║");
print("                            ███████╗██╔╝ ██╗██║     ██║ ╚═╝ ██║ ██║██╗╚██████╔╝██║          ╚████╔╝  ██║");
print("                            ╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝     ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝           ╚═══╝   ╚═╝");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("Welcome to expm1.gp! This is version 1");
print("This code was created to calculate the fractional iterates of exp(x) - 1 for the interval x=[0,infty] or the positive real axis");
print("The code uses a computational framework created by RaeesHarris which is explained in https://tetrationforum.org/showthread.php?tid=1825");
print("this code was created by RaeesHarris");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                                    ██████ ██  ██ ███  ██ ▄█████ ██████ ██ ▄████▄ ███  ██ ▄█████ ");
print("                                    ██▄▄   ██  ██ ██ ▀▄██ ██       ██   ██ ██  ██ ██ ▀▄██ ▀▀▀▄▄▄ ");
print("                                    ██     ▀████▀ ██   ██ ▀█████   ██   ██ ▀████▀ ██   ██ █████▀");
print(" ");
print("init();   Initializes everything needed for calculations, run this when starting the program. Usually takes 30 seconds to finish running");
print(" ");
print("superf(x);               Piecewise approximation Superfunction of exp(x)-1 where superf(x) = exp(superf(x-1))-1 for the interval [-∞, ∞]");
print(" ");
print("superinv(x);                                          Piecewise approximation of the Inverse of the Superfunction for the interval [0,∞]");
print(" ");
print("iter(x,s);                                              calculates the s-th iterate of exp(x) - 1 using the superfunctions for x ∈ [0,∞]");
print(" ");
print("iter_Error(n);                     Only for integer n, calculates how good the 1/n-th iterate of exp(x)-1 is on [0.1,10] with 1000 steps");
print(" ");
print("iter_custErr(n,a,b,s);  Only for integer n, calculates how good the 1/n-th iterate of exp(x)-1 is on [a,b] with steps(s) of your chosing");
print(" ");
print("SuperInvError(a,b,s);                    Calculates how good the inverse of the superfunction is on [a,b] with steps(s) of your choosing");
print(" ");
print("repeat(x,n);                                                                                                     iter(x,n) but for n ∈ ℤ");
print(" ");
print("initpol(x,k);                                                initial approximation of the superfunction of exp(x)-1 where initpol(0,k)=k");
print(" ");
print("improvedappr(x);                                                            Improved approximation of initpol(x,1) but it is quite slow.");
print(" ");
print("globalprecision(p);         During the initialization process, it locks the precision to 38, run this function to change that precision.");
print(" ");
print("superf_cheb(n,a,b);                                    Makes a Taylor series of a Chebyshev series for superf(x) for [a,b] with degree n");
print(" ");
print("superinv_cheb(n,a,b);                                Makes a Taylor series of a Chebyshev series for superinv(x) for [a,b] with degree n");
print(" ");
print("iter_cheb(s,n,a,b);                   Makes a Taylor series of a Chebyshev series for iter(x,s)(respective to x) for [a,b] with degree n");
print(" ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("To access this menu again, run the function start().");
}
expm1appr(x,n) = {for(i=1,n,x=iter(x,1/n));x}
iter_custErr(n,a,b,s) = {
global(Errorfunc(x) = abs(expm1appr(x,n) - exp(x) + 1));
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                 ███████╗██████╗ ██████╗  ██████╗ ██████╗      █████╗ ███╗   ██╗ █████╗ ██╗  ██╗   ██╗███████╗██╗███████╗");
print("                 ██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗    ██╔══██╗████╗  ██║██╔══██╗██║  ╚██╗ ██╔╝██╔════╝██║██╔════╝");
print("                 █████╗  ██████╔╝██████╔╝██║   ██║██████╔╝    ███████║██╔██╗ ██║███████║██║   ╚████╔╝ ███████╗██║███████╗");
print("                 ██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██╗    ██╔══██║██║╚██╗██║██╔══██║██║    ╚██╔╝  ╚════██║██║╚════██║");
print("                 ███████╗██║  ██║██║  ██║╚██████╔╝██║  ██║    ██║  ██║██║ ╚████║██║  ██║███████╗██║   ███████║██║███████║");
print("                 ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝    ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝╚═╝   ╚══════╝╚═╝╚══════╝");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("Calculating Error for the interval: [",a,", ",b,"]" );
print(" ");
print("For iterate: " n^(-1));
print(" ");
print("With steps = " s);
print(" ");
print("Average Absolute Error is: ", intnum(x=a,b,Errorfunc(x)))*1/(b-a);
print(" ");
print("Absolute Maximum Error based on steps is: ", vecmax(vector(s, i, Errorfunc(a + (i-1)*(b-a)/s)),&idx));
print(" ");
print("Absolute Maximum Error is at: ", a + (idx - 1) * (b - a) / s );
print(" ");
print("_________________________________________________________________________________________________________________________________________");
}
iter_Error(n) = {
iter_custErr(n,0.1,10,1000);
}
superinv_cheb(n,a,b) = {
default(realprecision, 400);
default(seriesprecision, n+1);
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("      ██████╗██╗  ██╗███████╗██████╗     ███████╗ ██████╗ ██████╗     ███████╗██╗   ██╗██████╗ ███████╗██████╗ ██╗███╗   ██╗██╗   ██╗");
print("     ██╔════╝██║  ██║██╔════╝██╔══██╗    ██╔════╝██╔═══██╗██╔══██╗    ██╔════╝██║   ██║██╔══██╗██╔════╝██╔══██╗██║████╗  ██║██║   ██║");
print("     ██║     ███████║█████╗  ██████╔╝    █████╗  ██║   ██║██████╔╝    ███████╗██║   ██║██████╔╝█████╗  ██████╔╝██║██╔██╗ ██║██║   ██║");
print("     ██║     ██╔══██║██╔══╝  ██╔══██╗    ██╔══╝  ██║   ██║██╔══██╗    ╚════██║██║   ██║██╔═══╝ ██╔══╝  ██╔══██╗██║██║╚██╗██║╚██╗ ██╔╝");
print("     ╚██████╗██║  ██║███████╗██████╔╝    ██║     ╚██████╔╝██║  ██║    ███████║╚██████╔╝██║     ███████╗██║  ██║██║██║ ╚████║ ╚████╔╝ ");
print("      ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝     ╚═╝      ╚═════╝ ╚═╝  ╚═╝    ╚══════╝ ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝  ╚═══╝  ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                              ▄█████ ▄████▄ ██████ ██████ ██████ ██ ▄█████ ██ ██████ ███  ██ ██████ ▄█████");
print("                              ██     ██  ██ ██▄▄   ██▄▄   ██▄▄   ██ ██     ██ ██▄▄   ██ ▀▄██   ██   ▀▀▀▄▄▄");
print("                              ▀█████ ▀████▀ ██▄▄▄▄ ██     ██     ██ ▀█████ ██ ██▄▄▄▄ ██   ██   ██   █████▀");
print(" ");
for(i=0,n,print("C",i," = ",precision(polcoeff(Pol(subst(polinterpolate(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5), vector(n+1, j, superinv((b-a)*(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5)[j])+a))),x,(x-a)/(b-a)))+O(x^(n+1)),i),GLOBPREC)));
print(" ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                                       █████▄ ▄████▄ ██    ██  ██ ███  ██ ▄████▄ ██▄  ▄██ ██ ▄████▄ ██     ");
print("                                       ██▄▄█▀ ██  ██ ██     ▀██▀  ██ ▀▄██ ██  ██ ██ ▀▀ ██ ██ ██▄▄██ ██     ");
print("                                       ██     ▀████▀ ██████  ██   ██   ██ ▀████▀ ██    ██ ██ ██  ██ ██████ ");
print(" ");
print(precision(Pol(subst(polinterpolate(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5), vector(n+1, j, superinv((b-a)*(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5)[j])+a))),x,(x-a)/(b-a))),GLOBPREC));
print(" ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("This was for the interval [",a,", ",b,"] with degree ",n);
default(realprecision, GLOBPREC);
}
superf_cheb(n,a,b) = {
default(realprecision, 400);
default(seriesprecision, n+1);
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("            ██████╗██╗  ██╗███████╗██████╗     ███████╗ ██████╗ ██████╗     ███████╗██╗   ██╗██████╗ ███████╗██████╗ ███████╗");
print("           ██╔════╝██║  ██║██╔════╝██╔══██╗    ██╔════╝██╔═══██╗██╔══██╗    ██╔════╝██║   ██║██╔══██╗██╔════╝██╔══██╗██╔════╝");
print("           ██║     ███████║█████╗  ██████╔╝    █████╗  ██║   ██║██████╔╝    ███████╗██║   ██║██████╔╝█████╗  ██████╔╝█████╗  ");
print("           ██║     ██╔══██║██╔══╝  ██╔══██╗    ██╔══╝  ██║   ██║██╔══██╗    ╚════██║██║   ██║██╔═══╝ ██╔══╝  ██╔══██╗██╔══╝  ");
print("           ╚██████╗██║  ██║███████╗██████╔╝    ██║     ╚██████╔╝██║  ██║    ███████║╚██████╔╝██║     ███████╗██║  ██║██║     ");
print("            ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝     ╚═╝      ╚═════╝ ╚═╝  ╚═╝    ╚══════╝ ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═╝╚═╝     ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                              ▄█████ ▄████▄ ██████ ██████ ██████ ██ ▄█████ ██ ██████ ███  ██ ██████ ▄█████");
print("                              ██     ██  ██ ██▄▄   ██▄▄   ██▄▄   ██ ██     ██ ██▄▄   ██ ▀▄██   ██   ▀▀▀▄▄▄");
print("                              ▀█████ ▀████▀ ██▄▄▄▄ ██     ██     ██ ▀█████ ██ ██▄▄▄▄ ██   ██   ██   █████▀");
print(" ");
for(i=0,n,print("C",i," = ",precision(polcoeff(Pol(subst(polinterpolate(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5), vector(n+1, j, superf((b-a)*(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5)[j])+a))),x,(x-a)/(b-a)))+O(x^(n+1)),i),GLOBPREC)));
print(" ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                                       █████▄ ▄████▄ ██    ██  ██ ███  ██ ▄████▄ ██▄  ▄██ ██ ▄████▄ ██     ");
print("                                       ██▄▄█▀ ██  ██ ██     ▀██▀  ██ ▀▄██ ██  ██ ██ ▀▀ ██ ██ ██▄▄██ ██     ");
print("                                       ██     ▀████▀ ██████  ██   ██   ██ ▀████▀ ██    ██ ██ ██  ██ ██████ ");
print(" ");
print(precision(Pol(subst(polinterpolate(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5), vector(n+1, j, superf((b-a)*(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5)[j])+a))),x,(x-a)/(b-a))),GLOBPREC));
print(" ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("This was for the interval [",a,", ",b,"] with degree ",n);
default(realprecision, GLOBPREC);
}
iter_cheb(s,n,a,b) = {
default(realprecision, 400);
default(seriesprecision, n+1);
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                       ██████╗██╗  ██╗███████╗██████╗     ███████╗ ██████╗ ██████╗     ██╗████████╗███████╗██████╗ ");
print("                      ██╔════╝██║  ██║██╔════╝██╔══██╗    ██╔════╝██╔═══██╗██╔══██╗    ██║╚══██╔══╝██╔════╝██╔══██╗");
print("                      ██║     ███████║█████╗  ██████╔╝    █████╗  ██║   ██║██████╔╝    ██║   ██║   █████╗  ██████╔╝");
print("                      ██║     ██╔══██║██╔══╝  ██╔══██╗    ██╔══╝  ██║   ██║██╔══██╗    ██║   ██║   ██╔══╝  ██╔══██╗");
print("                      ╚██████╗██║  ██║███████╗██████╔╝    ██║     ╚██████╔╝██║  ██║    ██║   ██║   ███████╗██║  ██║");
print("                       ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝     ╚═╝      ╚═════╝ ╚═╝  ╚═╝    ╚═╝   ╚═╝   ╚══════╝╚═╝  ╚═╝");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                              ▄█████ ▄████▄ ██████ ██████ ██████ ██ ▄█████ ██ ██████ ███  ██ ██████ ▄█████");
print("                              ██     ██  ██ ██▄▄   ██▄▄   ██▄▄   ██ ██     ██ ██▄▄   ██ ▀▄██   ██   ▀▀▀▄▄▄");
print("                              ▀█████ ▀████▀ ██▄▄▄▄ ██     ██     ██ ▀█████ ██ ██▄▄▄▄ ██   ██   ██   █████▀");
print(" ");
for(i=0,n,print("C",i," = ",precision(polcoeff(Pol(subst(polinterpolate(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5), vector(n+1, j, iter((b-a)*(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5)[j])+a,s))),x,(x-a)/(b-a)))+O(x^(n+1)),i),GLOBPREC)));
print(" ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                                       █████▄ ▄████▄ ██    ██  ██ ███  ██ ▄████▄ ██▄  ▄██ ██ ▄████▄ ██     ");
print("                                       ██▄▄█▀ ██  ██ ██     ▀██▀  ██ ▀▄██ ██  ██ ██ ▀▀ ██ ██ ██▄▄██ ██     ");
print("                                       ██     ▀████▀ ██████  ██   ██   ██ ▀████▀ ██    ██ ██ ██  ██ ██████ ");
print(" ");
print(precision(Pol(subst(polinterpolate(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5), vector(n+1, j, iter((b-a)*(vector(n+1, j, 0.5 * cos(Pi * (2*j - 1) / (2*n + 2)) + 0.5)[j])+a,s))),x,(x-a)/(b-a))),GLOBPREC));
print(" ");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("This was for the interval [",a,", ",b,"] with degree ",n);
default(realprecision, GLOBPREC);
}
SuperInvError(a,b,s) = {
global(errorfuncinv(x) = abs(superf(superinv(x))-x));
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("                 ███████╗██████╗ ██████╗  ██████╗ ██████╗      █████╗ ███╗   ██╗ █████╗ ██╗  ██╗   ██╗███████╗██╗███████╗");
print("                 ██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗    ██╔══██╗████╗  ██║██╔══██╗██║  ╚██╗ ██╔╝██╔════╝██║██╔════╝");
print("                 █████╗  ██████╔╝██████╔╝██║   ██║██████╔╝    ███████║██╔██╗ ██║███████║██║   ╚████╔╝ ███████╗██║███████╗");
print("                 ██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██╗    ██╔══██║██║╚██╗██║██╔══██║██║    ╚██╔╝  ╚════██║██║╚════██║");
print("                 ███████╗██║  ██║██║  ██║╚██████╔╝██║  ██║    ██║  ██║██║ ╚████║██║  ██║███████╗██║   ███████║██║███████║");
print("                 ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝    ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝╚═╝   ╚══════╝╚═╝╚══════╝");
print("_________________________________________________________________________________________________________________________________________");
print(" ");
print("Calculating Error for the interval: [",a,", ",b,"]" );
print(" ");
print("With steps = " s);
print(" ");
print("Average Absolute Error is: ", intnum(x=a,b,errorfuncinv(x)))*(1/(b-a));
print(" ");
print("Absolute Maximum Error based on steps is: ", vecmax(vector(s, i, errorfuncinv(a + (i-1)*(b-a)/s)),&idx));
print(" ");
print("Absolute Maximum Error is at: ", a + (idx - 1) * (b - a) / s );
print(" ");
print("_________________________________________________________________________________________________________________________________________");
}
start();
globalprecision(38);

Okay so I used my method from https://tetrationforum.org/showthread.php?tid=1825 for \(\lambda = 1\) since \([\frac{d}{dx} e^{x} - 1]_{x=L} = 1 \) where \(L = e^{L} - 1\) so \(L = 0\).
Using the python script mentioned in https://tetrationforum.org/showthread.php?tid=1825 I made a giant series with 12 derivatives, this is initpol(x,k):
\[
\operatorname{initpol}\left(x,k\right)=k+\frac{x}{2}k^{2}+\frac{\left(\frac{3}{2}x^{2}-\frac{1}{2}x\right)}{3!}k^{3}+\frac{\left(3x^{3}-\frac{5}{2}x^{2}+\frac{1}{2}x\right)}{4!}k^{4}+\frac{\left(\frac{15}{2}x^{4}-\frac{65}{6}x^{3}+5x^{2}-\frac{2}{3}x\right)}{5!}k^{5}+\frac{\left(\frac{45}{2}x^{5}-\frac{385}{8}x^{4}+\frac{445}{12}x^{3}-\frac{91}{8}x^{2}+\frac{11}{12}x\right)}{6!}k^{6}+\frac{\left(\frac{315}{4}x^{6}-\frac{1827}{8}x^{5}+\frac{6125}{24}x^{4}-\frac{1043}{8}x^{3}+\frac{637}{24}x^{2}-\frac{3}{4}x\right)}{7!}k^{7}+\frac{\left(315x^{7}-\frac{4683}{4}x^{6}+\frac{10507}{6}x^{5}-1295x^{4}+\frac{2737}{6}x^{3}-\frac{215}{4}x^{2}-\frac{11}{6}x\right)}{8!}k^{8}+\frac{\left(\frac{2835}{2}x^{8}-\frac{12987}{2}x^{7}+\frac{98735}{8}x^{6}-\frac{97601}{8}x^{5}+\frac{25375}{4}x^{4}-\frac{11785}{8}x^{3}+\frac{459}{8}x^{2}+\frac{29}{4}x\right)}{9!}k^{9}+\frac{\left(\frac{14175}{2}x^{9}-\frac{622215}{16}x^{8}+\frac{724455}{8}x^{7}-\frac{681835}{6}x^{6}+\frac{639191}{8}x^{5}-\frac{1391225}{48}x^{4}+\frac{23137}{6}x^{3}+\frac{1727}{24}x^{2}+\frac{493}{12}x\right)}{10!}k^{10}+\frac{\left(\frac{155925}{4}x^{10}-\frac{4010325}{16}x^{9}+\frac{44546535}{64}x^{8}-\frac{51331115}{48}x^{7}+\frac{30772049}{32}x^{6}-\frac{11673541}{24}x^{5}+\frac{22393129}{192}x^{4}-\frac{90079}{12}x^{3}+\frac{53867}{48}x^{2}-\frac{2711}{6}x\right)}{11!}k^{11}+\frac{\left(\frac{467775}{2}x^{11}-\frac{27715545}{16}x^{10}+\frac{179794395}{32}x^{9}-\frac{658520005}{64}x^{8}+\frac{273281591}{24}x^{7}-\frac{720672953}{96}x^{6}+\frac{1284253597}{480}x^{5}-\frac{78859495}{192}x^{4}+\frac{712063}{16}x^{3}-\frac{915187}{48}x^{2}-\frac{12406}{15}x\right)}{12!}k^{12}
\]
 Then i use my recentering technique from my method to make it more accurate, then in initialization(when running \(\operatorname{init}()\)) i take a 100 degree taylor series(LOCALSER) of the recentered function and a taylor series of its inverse(INVLOCALSER).
Then i use that LOCALSER as a seed function then propogate it to other intervals using recursion which makes it a piecewise function(\(\operatorname{superf}(x)\)) and i do the same for \(\operatorname{superinv}(x)\) too. Then using superfunction and its inverse i define its non-integer iterate for \(x \in [0,\infty]\) and \(n \in \mathbb{R}\):
\[
\operatorname{iter}(x,s) = \operatorname{superf}(\operatorname{superinv}(x)+s) 
\]
I will give a quick rundown of how to use the code. First download the attatched .gp script, then you run:
Code:
\r \path\to\expm1.gp

You will be immediately met with a start menu which briefs you on what each function is:
Code:
_________________________________________________________________________________________________________________________________________

                            ███████╗██╗  ██╗██████╗ ███╗   ███╗ ██╗    ██████╗ ██████╗     ██╗   ██╗ ██╗
                            ██╔════╝╚██╗██╔╝██╔══██╗████╗ ████║███║   ██╔════╝ ██╔══██╗    ██║   ██║███║
                            █████╗   ╚███╔╝ ██████╔╝██╔████╔██║╚██║   ██║  ███╗██████╔╝    ██║   ██║╚██║
                            ██╔══╝   ██╔██╗ ██╔═══╝ ██║╚██╔╝██║ ██║   ██║   ██║██╔═══╝     ╚██╗ ██╔╝ ██║
                            ███████╗██╔╝ ██╗██║     ██║ ╚═╝ ██║ ██║██╗╚██████╔╝██║          ╚████╔╝  ██║
                            ╚══════╝╚═╝  ╚═╝╚═╝     ╚═╝     ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝           ╚═══╝   ╚═╝
_________________________________________________________________________________________________________________________________________

Welcome to expm1.gp! This is version 1
This code was created to calculate the fractional iterates of exp(x) - 1 for the interval x=[0,infty] or the positive real axis
The code uses a computational framework created by RaeesHarris which is explained in https://tetrationforum.org/showthread.php?tid=1825
this code was created by RaeesHarris
_________________________________________________________________________________________________________________________________________

                                    ██████ ██  ██ ███  ██ ▄█████ ██████ ██ ▄████▄ ███  ██ ▄█████
                                    ██▄▄   ██  ██ ██ ▀▄██ ██       ██   ██ ██  ██ ██ ▀▄██ ▀▀▀▄▄▄
                                    ██     ▀████▀ ██   ██ ▀█████   ██   ██ ▀████▀ ██   ██ █████▀

init();   Initializes everything needed for calculations, run this when starting the program. Usually takes 30 seconds to finish running

superf(x);               Piecewise approximation Superfunction of exp(x)-1 where superf(x) = exp(superf(x-1))-1 for the interval [-∞, ∞]

superinv(x);                                          Piecewise approximation of the Inverse of the Superfunction for the interval [0,∞]

iter(x,s);                                              calculates the s-th iterate of exp(x) - 1 using the superfunctions for x ∈ [0,∞]

iter_Error(n);                     Only for integer n, calculates how good the 1/n-th iterate of exp(x)-1 is on [0.1,10] with 1000 steps

iter_custErr(n,a,b,s);  Only for integer n, calculates how good the 1/n-th iterate of exp(x)-1 is on [a,b] with steps(s) of your chosing

SuperInvError(a,b,s);                    Calculates how good the inverse of the superfunction is on [a,b] with steps(s) of your choosing

repeat(x,n);                                                                                                     iter(x,n) but for n ∈ ℤ

initpol(x,k);                                                initial approximation of the superfunction of exp(x)-1 where initpol(0,k)=k

improvedappr(x);                                                            Improved approximation of initpol(x,1) but it is quite slow.

globalprecision(p);         During the initialization process, it locks the precision to 38, run this function to change that precision.

superf_cheb(n,a,b);                                    Makes a Taylor series of a Chebyshev series for superf(x) for [a,b] with degree n

superinv_cheb(n,a,b);                                Makes a Taylor series of a Chebyshev series for superinv(x) for [a,b] with degree n

iter_cheb(s,n,a,b);                   Makes a Taylor series of a Chebyshev series for iter(x,s)(respective to x) for [a,b] with degree n

_________________________________________________________________________________________________________________________________________

To access this menu again, run the function start().

then to initialize, you run this function:
Code:
init();

Which intializes everything needed for fast computations.
This is my result for iter_Error(2):
Code:
_________________________________________________________________________________________________________________________________________

                 ███████╗██████╗ ██████╗  ██████╗ ██████╗      █████╗ ███╗   ██╗ █████╗ ██╗  ██╗   ██╗███████╗██╗███████╗
                 ██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗    ██╔══██╗████╗  ██║██╔══██╗██║  ╚██╗ ██╔╝██╔════╝██║██╔════╝
                 █████╗  ██████╔╝██████╔╝██║   ██║██████╔╝    ███████║██╔██╗ ██║███████║██║   ╚████╔╝ ███████╗██║███████╗
                 ██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██╗    ██╔══██║██║╚██╗██║██╔══██║██║    ╚██╔╝  ╚════██║██║╚════██║
                 ███████╗██║  ██║██║  ██║╚██████╔╝██║  ██║    ██║  ██║██║ ╚████║██║  ██║███████╗██║   ███████║██║███████║
                 ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝    ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝╚═╝   ╚══════╝╚═╝╚══════╝
_________________________________________________________________________________________________________________________________________

Calculating Error for the interval: [0.10000000000000000000000000000000000000, 10]

For iterate: 1/2

With steps = 1000

Average Absolute Error is: 2.4307243572099761224591641778168243796 E-21

Absolute Maximum Error based on steps is: 1.4665767901514788456954843863590764675 E-21

Absolute Maximum Error is at: 9.9901000000000000000000000000000000000

_________________________________________________________________________________________________________________________________________

And for iter_Error(3):
Code:
_________________________________________________________________________________________________________________________________________

                 ███████╗██████╗ ██████╗  ██████╗ ██████╗      █████╗ ███╗   ██╗ █████╗ ██╗  ██╗   ██╗███████╗██╗███████╗
                 ██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗    ██╔══██╗████╗  ██║██╔══██╗██║  ╚██╗ ██╔╝██╔════╝██║██╔════╝
                 █████╗  ██████╔╝██████╔╝██║   ██║██████╔╝    ███████║██╔██╗ ██║███████║██║   ╚████╔╝ ███████╗██║███████╗
                 ██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██╗    ██╔══██║██║╚██╗██║██╔══██║██║    ╚██╔╝  ╚════██║██║╚════██║
                 ███████╗██║  ██║██║  ██║╚██████╔╝██║  ██║    ██║  ██║██║ ╚████║██║  ██║███████╗██║   ███████║██║███████║
                 ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝    ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝╚═╝   ╚══════╝╚═╝╚══════╝
_________________________________________________________________________________________________________________________________________

Calculating Error for the interval: [0.10000000000000000000000000000000000000, 10]

For iterate: 1/3

With steps = 1000

Average Absolute Error is: 4.3374495145739362616197796974282937282 E-20

Absolute Maximum Error based on steps is: 4.3406514372244915621461987773921561004 E-20

Absolute Maximum Error is at: 9.9901000000000000000000000000000000000

_________________________________________________________________________________________________________________________________________

And for iter_Error(100)(took ~26 seconds):
Code:
_________________________________________________________________________________________________________________________________________

                 ███████╗██████╗ ██████╗  ██████╗ ██████╗      █████╗ ███╗   ██╗ █████╗ ██╗  ██╗   ██╗███████╗██╗███████╗
                 ██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗    ██╔══██╗████╗  ██║██╔══██╗██║  ╚██╗ ██╔╝██╔════╝██║██╔════╝
                 █████╗  ██████╔╝██████╔╝██║   ██║██████╔╝    ███████║██╔██╗ ██║███████║██║   ╚████╔╝ ███████╗██║███████╗
                 ██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██╗    ██╔══██║██║╚██╗██║██╔══██║██║    ╚██╔╝  ╚════██║██║╚════██║
                 ███████╗██║  ██║██║  ██║╚██████╔╝██║  ██║    ██║  ██║██║ ╚████║██║  ██║███████╗██║   ███████║██║███████║
                 ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝    ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝╚═╝   ╚══════╝╚═╝╚══════╝
_________________________________________________________________________________________________________________________________________

Calculating Error for the interval: [0.10000000000000000000000000000000000000, 10]

For iterate: 1/100

With steps = 1000

Average Absolute Error is: 8.9032029492006981711838932348516532438 E-19

Absolute Maximum Error based on steps is: 1.0227089287176574524366322147838997610 E-18

Absolute Maximum Error is at: 9.9901000000000000000000000000000000000

_________________________________________________________________________________________________________________________________________

Also, i ran SuperInvError(0.1,100,10000) and got:
Code:
_________________________________________________________________________________________________________________________________________

                 ███████╗██████╗ ██████╗  ██████╗ ██████╗      █████╗ ███╗   ██╗ █████╗ ██╗  ██╗   ██╗███████╗██╗███████╗
                 ██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗    ██╔══██╗████╗  ██║██╔══██╗██║  ╚██╗ ██╔╝██╔════╝██║██╔════╝
                 █████╗  ██████╔╝██████╔╝██║   ██║██████╔╝    ███████║██╔██╗ ██║███████║██║   ╚████╔╝ ███████╗██║███████╗
                 ██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██╗    ██╔══██║██║╚██╗██║██╔══██║██║    ╚██╔╝  ╚════██║██║╚════██║
                 ███████╗██║  ██║██║  ██║╚██████╔╝██║  ██║    ██║  ██║██║ ╚████║██║  ██║███████╗██║   ███████║██║███████║
                 ╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝    ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝╚══════╝╚═╝   ╚══════╝╚═╝╚══════╝
_________________________________________________________________________________________________________________________________________

Calculating Error for the interval: [0.10000000000000000000000000000000000000, 100]

With steps = 10000

Average Absolute Error is: 4.2281113780598546159076197900572321334 E-22

Absolute Maximum Error based on steps is: 1.1269022102410442822375503206738072758 E-22

Absolute Maximum Error is at: 99.990010000000000000000000000000000000

_________________________________________________________________________________________________________________________________________

I jam-packed the program with a lot of exporting and error analysis tools.
This was quite a fun challenge!


Attached Files
.gp   expm1.gp (Size: 28.47 KB / Downloads: 6)
Reply


Messages In This Thread
RE: Calculating the fractional iterates of \(f(z) = e^z-1\) to reasonable accuracy - by RaeesHarris - 08/04/2026, 03:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  fractional iteration/another progress Gottfried 2 12,150 07/26/2008, 02:13 PM
Last Post: Gottfried
  fractional iteration with complex bases/a bit of progress Gottfried 1 10,019 07/21/2008, 10:58 PM
Last Post: Gottfried
  numerical examples for approximation for half-iterates for exp(x)-1 Gottfried 0 7,151 08/14/2007, 11:57 AM
Last Post: Gottfried



Users browsing this thread: 1 Guest(s)