Thanks for using Compiler Explorer
Sponsors
C++
Ada
Analysis
Assembly
C
C++ (Circle)
Clean
CMake
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Crystal
C#
CUDA C++
D
Dart
Erlang
Fortran
F#
Go
Haskell
ispc
Java
Kotlin
LLVM IR
Nim
OCaml
OpenCL C
Pascal
Python
Ruby
Rust
Scala
Solidity
Swift
Toit
TypeScript Native
Visual Basic
Zig
c++ source #2
Output
Compile to binary
Execute the code
Intel asm syntax
Demangle identifiers
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Compiler
ARM gcc 10.2 (linux)
ARM gcc 10.2.1 (none)
ARM gcc 10.3 (linux)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.1 (linux)
ARM gcc 11.2 (linux)
ARM gcc 11.2.1 (none)
ARM gcc 11.3 (linux)
ARM gcc 12.1 (linux)
ARM gcc 4.5.4 (linux)
ARM gcc 4.6.4 (linux)
ARM gcc 5.4 (linux)
ARM gcc 5.4.1 (none)
ARM gcc 6.3.0 (linux)
ARM gcc 6.4 (linux)
ARM gcc 7.2.1 (none)
ARM gcc 7.3 (linux)
ARM gcc 7.5 (linux)
ARM gcc 8.2 (WinCE)
ARM gcc 8.2 (linux)
ARM gcc 8.3.1 (none)
ARM gcc 8.5 (linux)
ARM gcc 9.2.1 (none)
ARM gcc 9.3 (linux)
ARM gcc trunk (linux)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 12.1
ARM64 gcc 5.4
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
FRC 2019
FRC 2020
KVX gcc 7.5 (ACB 4.1.0)
KVX gcc 7.5 (ACB 4.1.0-cd1)
KVX gcc 7.5 (ACB 4.2.0)
KVX gcc 7.5 (ACB 4.3.0)
KVX gcc 7.5 (ACB 4.4.0)
KVX gcc 9.4 (ACB 4.6.0)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv32gc gcc 10.2.0
RISC-V rv32gc gcc 10.3.0
RISC-V rv32gc gcc 11.2.0
RISC-V rv32gc gcc 11.3.0
RISC-V rv32gc gcc 12.1.0
RISC-V rv32gc gcc 8.2.0
RISC-V rv32gc gcc 8.5.0
RISC-V rv32gc gcc 9.4.0
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
RISC-V rv64gc gcc 10.2.0
RISC-V rv64gc gcc 10.3.0
RISC-V rv64gc gcc 11.2.0
RISC-V rv64gc gcc 11.3.0
RISC-V rv64gc gcc 12.1.0
RISC-V rv64gc gcc 8.2.0
RISC-V rv64gc gcc 8.5.0
RISC-V rv64gc gcc 9.4.0
Raspbian Buster
Raspbian Stretch
WebAssembly clang (trunk)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30
arm64 msvc v19.31
arm64 msvc v19.32
arm64 msvc v19.latest
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (trunk)
armv8-a clang (trunk, all architectural features)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 9.0.0
armv8-a clang 9.0.1
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
mips gcc 11.2.0
mips gcc 5.4
mips gcc 9.3.0
mips64 (el) gcc 5.4
mips64 gcc 11.2.0
mips64 gcc 5.4
mipsel gcc 5.4
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 6.3.0
powerpc64 clang (trunk)
s390x gcc 11.2.0
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14
x64 msvc v19.14 (WINE)
x64 msvc v19.15
x64 msvc v19.16
x64 msvc v19.20
x64 msvc v19.21
x64 msvc v19.22
x64 msvc v19.23
x64 msvc v19.24
x64 msvc v19.25
x64 msvc v19.26
x64 msvc v19.27
x64 msvc v19.28
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30
x64 msvc v19.31
x64 msvc v19.32
x64 msvc v19.latest
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14
x86 msvc v19.14 (WINE)
x86 msvc v19.15
x86 msvc v19.16
x86 msvc v19.20
x86 msvc v19.21
x86 msvc v19.22
x86 msvc v19.23
x86 msvc v19.24
x86 msvc v19.25
x86 msvc v19.26
x86 msvc v19.27
x86 msvc v19.28
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30
x86 msvc v19.31
x86 msvc v19.32
x86 msvc v19.latest
x86-64 Zapcc 190308
x86-64 clang (assertions trunk)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental auto NSDMI)
x86-64 clang (experimental pattern matching)
x86-64 clang (old concepts branch)
x86-64 clang (reflection)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 3.0.0
x86-64 clang 3.1
x86-64 clang 3.2
x86-64 clang 3.3
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.7
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.1
x86-64 gcc (contract labels)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 11.1
x86-64 gcc 11.2
x86-64 gcc 11.3
x86-64 gcc 12.1
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
#include <iostream> #include<limits> using namespace std; namespace math{ const double mini = double (numeric_limits<double>::min()); const double e = 2.718281828459045; const double pi = 3.141592653589793238462643383; int def_prec = 16; } template <class t = double> t exp(t base, int exponent){ if(exponent<0){ return 1/exp(base,-exponent); } else if(exponent>0){ double output = 1; for(int i=1;i<=exponent;i++){output *= base;} return output; } else {return 1;} } double nsqrt(double x, int precision = math::def_prec){ double sum = 1; for (int i=1;i<=precision;i++){ sum -= ((sum*sum)-x)/(2*sum); } return sum; } double esqrt(double num, double precision = math::def_prec){ double h = num/precision; double y = 1; for (double x=1;x!=num;x+=h){ y += h*(1/(2*y)); } return y; } double sqrt(double num, int precision = math::def_prec){ return nsqrt(num,precision); } double root(double num, int root, int precision = math::def_prec){ double sum = 1; for (int i=1;i<=precision;i++){ sum -= ((exp(sum,root))-num)/(root*exp(sum,root-1)); } return sum; } class complex{ private: double r,i; public: constexpr complex(double r_in,double i_in): r(r_in), i(i_in) {}; double get_re() {return r;} double get_im(){return i;} double magnitude(int precision = math::def_prec){ return sqrt((r*r)+(i*i),precision);} complex operator + (complex a){ r += a.get_re(); i += a.get_im(); return (*this); } complex operator + (double a){r += a;return (*this);} complex operator - (complex a){ r -= a.get_re(); i -= a.get_im(); return (*this); } complex operator - (double a){r -= a;return (*this);} complex operator * (complex a){ r = (r*a.get_re())-(i*a.get_im()); i = (r*a.get_im())+(i*a.get_re()); return (*this); } complex operator * (double a){r *=a;i *= a;return (*this);} complex operator / (complex a){ r = (r/a.get_re())-(i/a.get_im()); i = (r/a.get_im())+(i/a.get_re()); return (*this); } complex operator / (double a){r /=a;i /= a;return (*this);} void operator = (double a[2]){r=a[0];i=a[1];} void operator = (complex a){r=a.get_re();i=a.get_im();} bool operator == (complex a){return (r==a.get_re() && i==a.get_im());} bool operator == (double a[2]){return (r==a[0] && i==a[1]);} bool operator != (complex a){return (r!=a.get_re() || i!=a.get_im());} bool operator != (double a[2]){return (r!=a[0] || i!=a[1]);} void operator += (complex a){ r += a.get_re(); i += a.get_im(); } bool operator > (complex a){return (r==a.get_re())? (i>a.get_im()) : (r>a.get_re());} bool operator < (complex a){return (r==a.get_re())? (i<a.get_im()) : (r<a.get_re());} bool operator <= (complex a){return (r==a.get_re())? (i<=a.get_im()) : (r<=a.get_re());} bool operator >= (complex a){return (r==a.get_re())? (i>=a.get_im()) : (r>=a.get_re());} void operator += (double a){r += a;} void operator -= (complex a){ r -= a.get_re(); i -= a.get_im(); } void operator -= (double a){r -= a;} void operator *= (complex a){ r = (r*a.get_re())-(i*a.get_im()); i = (r*a.get_im())+(i*a.get_re()); } void operator *= (double a){r *= a;i *= a;} void operator /= (complex a){ r = (r/a.get_re())-(i/a.get_im()); i = (r/a.get_im())+(i/a.get_re()); } void operator /= (double a){r /= a;i /= a;} void operator ++ (){r++;} void operator -- (){r--;} ostream& operator<<(ostream& os) { os << r << "+" << i << "i"; return os; } void operator = (int a){r=a;} }; constexpr complex exp(complex base, int exponent){ if(exponent<0){ complex one(1,0); return one/exp(base,-exponent); } else if(exponent>0){ complex output(1,0); for(int i=1;i<=exponent;i++){output *= base;} return output; } else {return base/base;} } template <class t = int> t gcd(t X, t Y) { t pre = 0; if (X%Y == 0) {return (X>Y)? Y : X;} pre = X%Y; X = Y; Y = pre; while (X%Y != 0) { pre = X%Y; X = Y; Y = pre; } return pre; } int round(double x){return (x-int(x)>0.5)? int(x)+1 : int(x);} class fraction{ private: int n,d; public: constexpr fraction(int n_in,int d_in): n(n_in),d(d_in){}; void simplify(){n/=gcd(n,d);d/=gcd(n,d);} double get_double(){return n/d;} int get_num(){return n;} int get_den(){return d;} fraction operator + (fraction a){ n = (n*a.get_den())+(a.get_num()*d); d *= a.get_den(); simplify(); return (*this); } fraction operator + (int a){n += a*d;return (*this);} fraction operator - (fraction a){ n = (n*a.get_den())-(a.get_num()*d); d *= a.get_den(); simplify(); return (*this); } fraction operator - (int a){n -= a*d;return (*this);} fraction operator * (fraction a){ n *= a.get_num(); d *= a.get_den(); simplify(); return (*this); } fraction operator * (int a){n *= a;return (*this);} fraction operator / (fraction a){ n /= a.get_num(); d /= a.get_den(); simplify(); return (*this); } fraction operator / (int a){n /= a;return (*this);} void operator += (fraction a){ n = (n*a.get_den())+(a.get_num()*d); d *= a.get_den(); simplify(); } void operator += (int a){n += a*d;} void operator -= (fraction a){ n = (n*a.get_den())-(a.get_num()*d); d *= a.get_den(); simplify(); } void operator -= (int a){n -= a*d;} void operator *= (fraction a){ n *= a.get_num(); d *= a.get_den(); simplify(); } void operator *= (int a){n*=a;} void operator /= (fraction a){ n /= a.get_num(); d /= a.get_den(); simplify(); } void operator /= (int a){n /= a;} void operator = (fraction a){n = a.get_num();d=a.get_den();} void operator = (int a){n=a;d=1;} bool operator < (fraction a){return (n*a.get_den()<a.get_num()*d);} bool operator > (fraction a){return (n*a.get_den()>a.get_num()*d);} bool operator >= (fraction a){return (n*a.get_den()>=a.get_num()*d);} bool operator <= (fraction a){return (n*a.get_den()<=a.get_num()*d);} bool operator == (fraction a){return (n*a.get_den()==a.get_num()*d);} bool operator != (fraction a){return (n*a.get_den()!=a.get_num()*d);} bool operator < (int a){return (n<a*d);} bool operator > (int a){return (n>a*d);} bool operator >= (int a){return (n>=a*d);} bool operator <= (int a){return (n<=a*d);} bool operator == (int a){return (n==a*d);} bool operator != (int a){return (n!=a*d);} operator double () {return n/d;} }; fraction tofrac(double x, int precision = 1000000000){ long gcd_ = gcd(round(x-int(x) * precision), precision); fraction output(round(x-int(x)*precision)/gcd_,precision/gcd_); return output; } template <class t = double> t limit(double (*f)(t),t to) { return (f(to+math::mini)+f(to-math::mini))/2; } template <class t = double> t derivative(double (*f)(t),t x){ return ((f(x+math::mini)-f(x))/math::mini+(f(x-math::mini)-f(x))/(-math::mini))/2; } template <class t = double> t sigma(double (*f)(t),int from, int to){ t out = 0; for (int n=from;n<=to;n++){out += f(n);} return out; } template <class t = double> t pi(double (*f)(t),int from, int to){ t out = 1; for (int n=from;n<=to;n++){out *= f(n);} return out; } double factorial1(int x) { double out = 1; for(int n=x;n>0;n--){out*=n;} return out; } template <class t = double> t sin(t x, int precision = math::def_prec){ t output = 0; for(int n=0;n<=precision;n++){ output += exp(-1,n)*(exp(x,(2*n)+1)/factorial1((2*n)+1)); } return output; } template <class t = double> t cos(t x, int precision = math::def_prec){ t output = 0; for(int n=0;n<=precision;n++){ output += exp(-1,n)*(exp(x,2*n)/factorial1(2*n)); } return output; } template <class t = double> t tan(t x, int precision = math::def_prec){return sin(x,precision)/cos(x,precision);} template <class t = double> t ln(t x, int precision = math::def_prec){ t output = 0; for(int n=1;n<=precision;n++){ output += (exp(x-2,n)*exp(-1,n-1))/n; } return output; } complex ln(complex x, int precision = math::def_prec){ complex output(0,0); for(int n=1;n<=precision;n++){ output += (exp(x-1,n)*exp(-1,n-1))/n; } return output; } template <class t = double> t log(t base, t x, int precision = math::def_prec){return ln(x,precision)/ln(base,precision);} template <class t = double> t derivative_fast(t (*f)(t),t x){return (f(x+1)-f(x-1))/2;} double pi(int precision = math::def_prec){ double output = 0; for(int i=0;i<=precision+(precision%2);i++){ output += exp(-1.0,i)/((2*i)+1); } return output*4; } //this pi algorithm isn't my work double spigotpi(long digits){ long LEN = (digits / 4 + 1) * 14; //nec. array length long array[LEN]; //array of 4-digit-decimals long b; //nominator prev. base long c = LEN; //index long d; //accumulator and carry long e = 0; //save previous 4 digits long f = 10000; //new base, 4 decimal digits long g; //denom previous base long h = 0; //init switch for (; (b = c -= 14) > 0;) { //outer loop: 4 digits per loop for (; --b > 0;) { //inner loop: radix conv d *= b; //acc *= nom prev base if (h == 0) d += 2000 * f; //first outer loop else d += array[b] * f; //non-first outer loop g = b + b - 1; //denom prev base array[b] = d % g; d /= g; //save carry } h = (("%d"), e + d / f);//print prev 4 digits std::cout << h; d = e = d % f; //save currently 4 digits //assure a small enough d } if (getchar()) { return 0; } return 0; } double pi2(long precision){ double output = 1; for (long k = precision;k>0;k--){ output *= 1.0+(k/((2.0*k)+1.0)); cout << output << endl; } return output; } double e(int precision = math::def_prec){ double output = 0; for(int i=0;i<=precision;i++){ output += 1/factorial1(i); } return output; } double abs(complex x, int precision){return x.magnitude(precision);} template <class t = double> double abs(t x){return (x<0)? -x : x;} complex sqrt(complex x, int precision = math::def_prec){ if (x.get_im()!=0){ complex output((1/sqrt(2,precision))*sqrt(x.magnitude()+x.get_re(),precision),((x.get_im()/abs(x.get_im()))/sqrt(2,precision))*sqrt(x.magnitude()-x.get_re(),precision)); return output; } else { complex output(sqrt(x.get_re()),0); return output; } } template <class t = double> t quadratic(t a,t b, t c,t& otherroot, int precision = math::def_prec){ otherroot = (-b+sqrt((b*b)-4*a*c,precision))/(2*a); return (-b-sqrt((b*b)-4*a*c,precision))/(2*a); } complex e_to_xi(double x, int precision = math::def_prec){ complex output(cos(x,precision),sin(x,precision)); return output; } template <class t> t e_to_x(t x, int precision = math::def_prec){ t output = 0; for(int i=0;i<=precision;i++){ output += exp(x,i)/factorial1(i); } return output; } complex e_to_x(complex x, int precision = math::def_prec){return e_to_xi(x.get_im(),precision)*e_to_x(x.get_re(),precision);} complex exp(complex base, complex exponent, int precision = math::def_prec){return e_to_x(ln(base)*exponent);} template <class t = double> t exp(t base, double exponent, int precision = math::def_prec){ fraction asfrac(0,0); asfrac = tofrac(exponent); return exp(root(base,asfrac.get_den(),precision),asfrac.get_num()); } template <class t = double> t zeta(t s, int precision = math::def_prec){ t output(0,0); for(int n=1.0;n<=precision;n++){output += 1/exp(n,s);} return output; } template <class t = double> t eta(t s, int precision = math::def_prec){ t output = 0; for(int n=1;n<=precision;n++){output += exp(-1,(n-1)%2)/exp(n,s);} return output; } template <class t=double> t inf(t a, t b){return (a<b)? a:b;} template <class t=double> t sup(t a, t b){return (a>b)? a:b;} template <class c=double> c rint(c a, c b, c (*f)(c), int precision=math::def_prec){ c partition[precision]; for(int i=0;i<=precision;i++){ partition[i] = a+(((b-a)/precision)*(i+1)); } return rsum(f, precision, partition, partition); //use the lower bounds as tags } template <class c=double> c udint(c a, c b, c (*f)(c), int precision = math::def_prec){ c P[precision]; } int main() { }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
About the author
Changelog
Version tree