
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
return exp((a * x)) - 1.0;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
return Math.exp((a * x)) - 1.0;
}
def code(a, x): return math.exp((a * x)) - 1.0
function code(a, x) return Float64(exp(Float64(a * x)) - 1.0) end
function tmp = code(a, x) tmp = exp((a * x)) - 1.0; end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{a \cdot x} - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
return exp((a * x)) - 1.0;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
return Math.exp((a * x)) - 1.0;
}
def code(a, x): return math.exp((a * x)) - 1.0
function code(a, x) return Float64(exp(Float64(a * x)) - 1.0) end
function tmp = code(a, x) tmp = exp((a * x)) - 1.0; end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{a \cdot x} - 1
\end{array}
(FPCore (a x) :precision binary64 (expm1 (* a x)))
double code(double a, double x) {
return expm1((a * x));
}
public static double code(double a, double x) {
return Math.expm1((a * x));
}
def code(a, x): return math.expm1((a * x))
function code(a, x) return expm1(Float64(a * x)) end
code[a_, x_] := N[(Exp[N[(a * x), $MachinePrecision]] - 1), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{expm1}\left(a \cdot x\right)
\end{array}
Initial program 65.2%
expm1-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* x (* a (* x (* a 0.5))))))
(if (<= (* a x) -100.0)
(- -2.0 (/ 4.0 (* a x)))
(if (<= (* a x) 4e+81)
(* a (+ x (* x (* a (* x 0.5)))))
(if (<= (* a x) 2e+143)
(/
(- (* (* a x) (* a x)) (* t_0 t_0))
(* a (+ x (* x (* x (* a -0.5))))))
(* (* 0.5 (* a a)) (* x x)))))))
double code(double a, double x) {
double t_0 = x * (a * (x * (a * 0.5)));
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else if ((a * x) <= 4e+81) {
tmp = a * (x + (x * (a * (x * 0.5))));
} else if ((a * x) <= 2e+143) {
tmp = (((a * x) * (a * x)) - (t_0 * t_0)) / (a * (x + (x * (x * (a * -0.5)))));
} else {
tmp = (0.5 * (a * a)) * (x * x);
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x * (a * (x * (a * 0.5d0)))
if ((a * x) <= (-100.0d0)) then
tmp = (-2.0d0) - (4.0d0 / (a * x))
else if ((a * x) <= 4d+81) then
tmp = a * (x + (x * (a * (x * 0.5d0))))
else if ((a * x) <= 2d+143) then
tmp = (((a * x) * (a * x)) - (t_0 * t_0)) / (a * (x + (x * (x * (a * (-0.5d0))))))
else
tmp = (0.5d0 * (a * a)) * (x * x)
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = x * (a * (x * (a * 0.5)));
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else if ((a * x) <= 4e+81) {
tmp = a * (x + (x * (a * (x * 0.5))));
} else if ((a * x) <= 2e+143) {
tmp = (((a * x) * (a * x)) - (t_0 * t_0)) / (a * (x + (x * (x * (a * -0.5)))));
} else {
tmp = (0.5 * (a * a)) * (x * x);
}
return tmp;
}
def code(a, x): t_0 = x * (a * (x * (a * 0.5))) tmp = 0 if (a * x) <= -100.0: tmp = -2.0 - (4.0 / (a * x)) elif (a * x) <= 4e+81: tmp = a * (x + (x * (a * (x * 0.5)))) elif (a * x) <= 2e+143: tmp = (((a * x) * (a * x)) - (t_0 * t_0)) / (a * (x + (x * (x * (a * -0.5))))) else: tmp = (0.5 * (a * a)) * (x * x) return tmp
function code(a, x) t_0 = Float64(x * Float64(a * Float64(x * Float64(a * 0.5)))) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = Float64(-2.0 - Float64(4.0 / Float64(a * x))); elseif (Float64(a * x) <= 4e+81) tmp = Float64(a * Float64(x + Float64(x * Float64(a * Float64(x * 0.5))))); elseif (Float64(a * x) <= 2e+143) tmp = Float64(Float64(Float64(Float64(a * x) * Float64(a * x)) - Float64(t_0 * t_0)) / Float64(a * Float64(x + Float64(x * Float64(x * Float64(a * -0.5)))))); else tmp = Float64(Float64(0.5 * Float64(a * a)) * Float64(x * x)); end return tmp end
function tmp_2 = code(a, x) t_0 = x * (a * (x * (a * 0.5))); tmp = 0.0; if ((a * x) <= -100.0) tmp = -2.0 - (4.0 / (a * x)); elseif ((a * x) <= 4e+81) tmp = a * (x + (x * (a * (x * 0.5)))); elseif ((a * x) <= 2e+143) tmp = (((a * x) * (a * x)) - (t_0 * t_0)) / (a * (x + (x * (x * (a * -0.5))))); else tmp = (0.5 * (a * a)) * (x * x); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(x * N[(a * N[(x * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * x), $MachinePrecision], -100.0], N[(-2.0 - N[(4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 4e+81], N[(a * N[(x + N[(x * N[(a * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 2e+143], N[(N[(N[(N[(a * x), $MachinePrecision] * N[(a * x), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(a * N[(x + N[(x * N[(x * N[(a * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(a \cdot \left(x \cdot \left(a \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-2 - \frac{4}{a \cdot x}\\
\mathbf{elif}\;a \cdot x \leq 4 \cdot 10^{+81}:\\
\;\;\;\;a \cdot \left(x + x \cdot \left(a \cdot \left(x \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;a \cdot x \leq 2 \cdot 10^{+143}:\\
\;\;\;\;\frac{\left(a \cdot x\right) \cdot \left(a \cdot x\right) - t_0 \cdot t_0}{a \cdot \left(x + x \cdot \left(x \cdot \left(a \cdot -0.5\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \left(a \cdot a\right)\right) \cdot \left(x \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
unpow20.4%
associate-*r*0.7%
distribute-rgt-out0.9%
*-commutative0.9%
*-commutative0.9%
unpow20.9%
associate-*l*0.9%
Simplified0.9%
distribute-lft-in0.7%
flip-+0.4%
*-commutative0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.3%
Applied egg-rr0.3%
Taylor expanded in a around 0 3.2%
unpow23.2%
unpow23.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 18.8%
distribute-neg-in18.8%
unsub-neg18.8%
metadata-eval18.8%
associate-*r/18.8%
metadata-eval18.8%
Simplified18.8%
if -100 < (*.f64 a x) < 3.99999999999999969e81Initial program 39.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 84.5%
*-commutative84.5%
associate-*l*84.5%
unpow284.5%
associate-*l*90.5%
distribute-lft-out90.5%
unpow290.5%
associate-*l*90.5%
Simplified90.5%
Taylor expanded in a around 0 90.5%
unpow290.5%
associate-*r*90.5%
*-commutative90.5%
associate-*r*94.2%
*-commutative94.2%
associate-*l*94.2%
Simplified94.2%
if 3.99999999999999969e81 < (*.f64 a x) < 2e143Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 25.8%
+-commutative25.8%
associate-*r*25.8%
unpow225.8%
associate-*r*16.2%
distribute-rgt-out16.2%
*-commutative16.2%
*-commutative16.2%
unpow216.2%
associate-*l*16.2%
Simplified16.2%
distribute-lft-in16.2%
flip-+67.6%
*-commutative67.6%
*-commutative67.6%
*-commutative67.6%
associate-*l*67.6%
*-commutative67.6%
associate-*l*66.7%
*-commutative66.7%
*-commutative66.7%
associate-*l*88.9%
Applied egg-rr88.9%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
associate-*r*77.8%
distribute-lft-out--77.8%
associate-*r*77.8%
*-commutative77.8%
associate-*r*66.7%
Applied egg-rr66.7%
sub-neg66.7%
associate-*l*77.8%
distribute-rgt-neg-in77.8%
distribute-rgt-neg-in77.8%
distribute-rgt-neg-in77.8%
metadata-eval77.8%
Simplified77.8%
if 2e143 < (*.f64 a x) Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
*-commutative100.0%
associate-*l*100.0%
unpow2100.0%
associate-*l*100.0%
distribute-lft-out100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in a around inf 100.0%
unpow2100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification76.9%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) (- -2.0 (/ 4.0 (* a x))) (if (<= (* a x) 0.0001) (* a x) (* a (* x (* a (* x 0.5)))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else if ((a * x) <= 0.0001) {
tmp = a * x;
} else {
tmp = a * (x * (a * (x * 0.5)));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = (-2.0d0) - (4.0d0 / (a * x))
else if ((a * x) <= 0.0001d0) then
tmp = a * x
else
tmp = a * (x * (a * (x * 0.5d0)))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else if ((a * x) <= 0.0001) {
tmp = a * x;
} else {
tmp = a * (x * (a * (x * 0.5)));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -2.0 - (4.0 / (a * x)) elif (a * x) <= 0.0001: tmp = a * x else: tmp = a * (x * (a * (x * 0.5))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = Float64(-2.0 - Float64(4.0 / Float64(a * x))); elseif (Float64(a * x) <= 0.0001) tmp = Float64(a * x); else tmp = Float64(a * Float64(x * Float64(a * Float64(x * 0.5)))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -2.0 - (4.0 / (a * x)); elseif ((a * x) <= 0.0001) tmp = a * x; else tmp = a * (x * (a * (x * 0.5))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], N[(-2.0 - N[(4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 0.0001], N[(a * x), $MachinePrecision], N[(a * N[(x * N[(a * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-2 - \frac{4}{a \cdot x}\\
\mathbf{elif}\;a \cdot x \leq 0.0001:\\
\;\;\;\;a \cdot x\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(x \cdot \left(a \cdot \left(x \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
unpow20.4%
associate-*r*0.7%
distribute-rgt-out0.9%
*-commutative0.9%
*-commutative0.9%
unpow20.9%
associate-*l*0.9%
Simplified0.9%
distribute-lft-in0.7%
flip-+0.4%
*-commutative0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.3%
Applied egg-rr0.3%
Taylor expanded in a around 0 3.2%
unpow23.2%
unpow23.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 18.8%
distribute-neg-in18.8%
unsub-neg18.8%
metadata-eval18.8%
associate-*r/18.8%
metadata-eval18.8%
Simplified18.8%
if -100 < (*.f64 a x) < 1.00000000000000005e-4Initial program 35.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 98.6%
if 1.00000000000000005e-4 < (*.f64 a x) Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 75.4%
*-commutative75.4%
associate-*l*75.4%
unpow275.4%
associate-*l*77.4%
distribute-lft-out77.4%
unpow277.4%
associate-*l*77.4%
Simplified77.4%
Taylor expanded in a around inf 75.4%
*-commutative75.4%
unpow275.4%
unpow275.4%
swap-sqr68.2%
associate-*r*68.2%
associate-*l*68.2%
*-commutative68.2%
associate-*r*76.0%
*-commutative76.0%
*-commutative76.0%
Simplified76.0%
Final simplification74.7%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) (- -2.0 (/ 4.0 (* a x))) (if (<= (* a x) 2e+31) (* a x) (* (* 0.5 (* a a)) (* x x)))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else if ((a * x) <= 2e+31) {
tmp = a * x;
} else {
tmp = (0.5 * (a * a)) * (x * x);
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = (-2.0d0) - (4.0d0 / (a * x))
else if ((a * x) <= 2d+31) then
tmp = a * x
else
tmp = (0.5d0 * (a * a)) * (x * x)
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else if ((a * x) <= 2e+31) {
tmp = a * x;
} else {
tmp = (0.5 * (a * a)) * (x * x);
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -2.0 - (4.0 / (a * x)) elif (a * x) <= 2e+31: tmp = a * x else: tmp = (0.5 * (a * a)) * (x * x) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = Float64(-2.0 - Float64(4.0 / Float64(a * x))); elseif (Float64(a * x) <= 2e+31) tmp = Float64(a * x); else tmp = Float64(Float64(0.5 * Float64(a * a)) * Float64(x * x)); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -2.0 - (4.0 / (a * x)); elseif ((a * x) <= 2e+31) tmp = a * x; else tmp = (0.5 * (a * a)) * (x * x); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], N[(-2.0 - N[(4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * x), $MachinePrecision], 2e+31], N[(a * x), $MachinePrecision], N[(N[(0.5 * N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-2 - \frac{4}{a \cdot x}\\
\mathbf{elif}\;a \cdot x \leq 2 \cdot 10^{+31}:\\
\;\;\;\;a \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \left(a \cdot a\right)\right) \cdot \left(x \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
unpow20.4%
associate-*r*0.7%
distribute-rgt-out0.9%
*-commutative0.9%
*-commutative0.9%
unpow20.9%
associate-*l*0.9%
Simplified0.9%
distribute-lft-in0.7%
flip-+0.4%
*-commutative0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.3%
Applied egg-rr0.3%
Taylor expanded in a around 0 3.2%
unpow23.2%
unpow23.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 18.8%
distribute-neg-in18.8%
unsub-neg18.8%
metadata-eval18.8%
associate-*r/18.8%
metadata-eval18.8%
Simplified18.8%
if -100 < (*.f64 a x) < 1.9999999999999999e31Initial program 37.3%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 95.3%
if 1.9999999999999999e31 < (*.f64 a x) Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 82.2%
*-commutative82.2%
associate-*l*82.2%
unpow282.2%
associate-*l*84.3%
distribute-lft-out84.3%
unpow284.3%
associate-*l*84.3%
Simplified84.3%
Taylor expanded in a around inf 82.2%
unpow282.2%
unpow282.2%
associate-*l*82.2%
Simplified82.2%
Final simplification74.6%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) (- -2.0 (/ 4.0 (* a x))) (+ (* a x) (* x (* a (* x (* a 0.5)))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else {
tmp = (a * x) + (x * (a * (x * (a * 0.5))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = (-2.0d0) - (4.0d0 / (a * x))
else
tmp = (a * x) + (x * (a * (x * (a * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else {
tmp = (a * x) + (x * (a * (x * (a * 0.5))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -2.0 - (4.0 / (a * x)) else: tmp = (a * x) + (x * (a * (x * (a * 0.5)))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = Float64(-2.0 - Float64(4.0 / Float64(a * x))); else tmp = Float64(Float64(a * x) + Float64(x * Float64(a * Float64(x * Float64(a * 0.5))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -2.0 - (4.0 / (a * x)); else tmp = (a * x) + (x * (a * (x * (a * 0.5)))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], N[(-2.0 - N[(4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a * x), $MachinePrecision] + N[(x * N[(a * N[(x * N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-2 - \frac{4}{a \cdot x}\\
\mathbf{else}:\\
\;\;\;\;a \cdot x + x \cdot \left(a \cdot \left(x \cdot \left(a \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
unpow20.4%
associate-*r*0.7%
distribute-rgt-out0.9%
*-commutative0.9%
*-commutative0.9%
unpow20.9%
associate-*l*0.9%
Simplified0.9%
distribute-lft-in0.7%
flip-+0.4%
*-commutative0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.3%
Applied egg-rr0.3%
Taylor expanded in a around 0 3.2%
unpow23.2%
unpow23.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 18.8%
distribute-neg-in18.8%
unsub-neg18.8%
metadata-eval18.8%
associate-*r/18.8%
metadata-eval18.8%
Simplified18.8%
if -100 < (*.f64 a x) Initial program 54.6%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 85.1%
+-commutative85.1%
associate-*r*85.1%
unpow285.1%
associate-*r*87.3%
distribute-rgt-out87.3%
*-commutative87.3%
*-commutative87.3%
unpow287.3%
associate-*l*87.3%
Simplified87.3%
+-commutative87.3%
distribute-lft-in87.3%
*-commutative87.3%
associate-*l*91.4%
*-commutative91.4%
Applied egg-rr91.4%
Final simplification74.4%
(FPCore (a x) :precision binary64 (if (<= (* a x) -100.0) (- -2.0 (/ 4.0 (* a x))) (* a (+ x (* x (* a (* x 0.5)))))))
double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else {
tmp = a * (x + (x * (a * (x * 0.5))));
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-100.0d0)) then
tmp = (-2.0d0) - (4.0d0 / (a * x))
else
tmp = a * (x + (x * (a * (x * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -100.0) {
tmp = -2.0 - (4.0 / (a * x));
} else {
tmp = a * (x + (x * (a * (x * 0.5))));
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -100.0: tmp = -2.0 - (4.0 / (a * x)) else: tmp = a * (x + (x * (a * (x * 0.5)))) return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -100.0) tmp = Float64(-2.0 - Float64(4.0 / Float64(a * x))); else tmp = Float64(a * Float64(x + Float64(x * Float64(a * Float64(x * 0.5))))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -100.0) tmp = -2.0 - (4.0 / (a * x)); else tmp = a * (x + (x * (a * (x * 0.5)))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -100.0], N[(-2.0 - N[(4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[(x + N[(x * N[(a * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -100:\\
\;\;\;\;-2 - \frac{4}{a \cdot x}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(x + x \cdot \left(a \cdot \left(x \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 a x) < -100Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
unpow20.4%
associate-*r*0.7%
distribute-rgt-out0.9%
*-commutative0.9%
*-commutative0.9%
unpow20.9%
associate-*l*0.9%
Simplified0.9%
distribute-lft-in0.7%
flip-+0.4%
*-commutative0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.3%
Applied egg-rr0.3%
Taylor expanded in a around 0 3.2%
unpow23.2%
unpow23.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 18.8%
distribute-neg-in18.8%
unsub-neg18.8%
metadata-eval18.8%
associate-*r/18.8%
metadata-eval18.8%
Simplified18.8%
if -100 < (*.f64 a x) Initial program 54.6%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 85.1%
*-commutative85.1%
associate-*l*85.1%
unpow285.1%
associate-*l*90.1%
distribute-lft-out90.1%
unpow290.1%
associate-*l*90.1%
Simplified90.1%
Taylor expanded in a around 0 90.1%
unpow290.1%
associate-*r*90.1%
*-commutative90.1%
associate-*r*92.3%
*-commutative92.3%
associate-*l*92.3%
Simplified92.3%
Final simplification75.1%
(FPCore (a x) :precision binary64 (if (<= (* a x) -2.4) (- -2.0 (/ 4.0 (* a x))) (* a x)))
double code(double a, double x) {
double tmp;
if ((a * x) <= -2.4) {
tmp = -2.0 - (4.0 / (a * x));
} else {
tmp = a * x;
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-2.4d0)) then
tmp = (-2.0d0) - (4.0d0 / (a * x))
else
tmp = a * x
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -2.4) {
tmp = -2.0 - (4.0 / (a * x));
} else {
tmp = a * x;
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -2.4: tmp = -2.0 - (4.0 / (a * x)) else: tmp = a * x return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -2.4) tmp = Float64(-2.0 - Float64(4.0 / Float64(a * x))); else tmp = Float64(a * x); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -2.4) tmp = -2.0 - (4.0 / (a * x)); else tmp = a * x; end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -2.4], N[(-2.0 - N[(4.0 / N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -2.4:\\
\;\;\;\;-2 - \frac{4}{a \cdot x}\\
\mathbf{else}:\\
\;\;\;\;a \cdot x\\
\end{array}
\end{array}
if (*.f64 a x) < -2.39999999999999991Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
unpow20.4%
associate-*r*0.7%
distribute-rgt-out0.9%
*-commutative0.9%
*-commutative0.9%
unpow20.9%
associate-*l*0.9%
Simplified0.9%
distribute-lft-in0.7%
flip-+0.4%
*-commutative0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.3%
Applied egg-rr0.3%
Taylor expanded in a around 0 3.2%
unpow23.2%
unpow23.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 18.8%
distribute-neg-in18.8%
unsub-neg18.8%
metadata-eval18.8%
associate-*r/18.8%
metadata-eval18.8%
Simplified18.8%
if -2.39999999999999991 < (*.f64 a x) Initial program 54.6%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 81.6%
Final simplification66.9%
(FPCore (a x) :precision binary64 (if (<= (* a x) -2.0) -2.0 (* a x)))
double code(double a, double x) {
double tmp;
if ((a * x) <= -2.0) {
tmp = -2.0;
} else {
tmp = a * x;
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((a * x) <= (-2.0d0)) then
tmp = -2.0d0
else
tmp = a * x
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((a * x) <= -2.0) {
tmp = -2.0;
} else {
tmp = a * x;
}
return tmp;
}
def code(a, x): tmp = 0 if (a * x) <= -2.0: tmp = -2.0 else: tmp = a * x return tmp
function code(a, x) tmp = 0.0 if (Float64(a * x) <= -2.0) tmp = -2.0; else tmp = Float64(a * x); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((a * x) <= -2.0) tmp = -2.0; else tmp = a * x; end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(a * x), $MachinePrecision], -2.0], -2.0, N[(a * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot x \leq -2:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;a \cdot x\\
\end{array}
\end{array}
if (*.f64 a x) < -2Initial program 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 0.4%
+-commutative0.4%
associate-*r*0.4%
unpow20.4%
associate-*r*0.7%
distribute-rgt-out0.9%
*-commutative0.9%
*-commutative0.9%
unpow20.9%
associate-*l*0.9%
Simplified0.9%
distribute-lft-in0.7%
flip-+0.4%
*-commutative0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
associate-*l*0.4%
*-commutative0.4%
*-commutative0.4%
associate-*l*0.3%
Applied egg-rr0.3%
Taylor expanded in a around 0 3.2%
unpow23.2%
unpow23.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 18.8%
if -2 < (*.f64 a x) Initial program 54.6%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 81.6%
Final simplification66.9%
(FPCore (a x) :precision binary64 -2.0)
double code(double a, double x) {
return -2.0;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
code = -2.0d0
end function
public static double code(double a, double x) {
return -2.0;
}
def code(a, x): return -2.0
function code(a, x) return -2.0 end
function tmp = code(a, x) tmp = -2.0; end
code[a_, x_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 65.2%
expm1-def100.0%
Simplified100.0%
Taylor expanded in a around 0 65.2%
+-commutative65.2%
associate-*r*65.2%
unpow265.2%
associate-*r*67.0%
distribute-rgt-out67.1%
*-commutative67.1%
*-commutative67.1%
unpow267.1%
associate-*l*67.1%
Simplified67.1%
distribute-lft-in67.0%
flip-+21.8%
*-commutative21.8%
*-commutative21.8%
*-commutative21.8%
associate-*l*21.8%
*-commutative21.8%
associate-*l*21.8%
*-commutative21.8%
*-commutative21.8%
associate-*l*26.5%
Applied egg-rr26.5%
Taylor expanded in a around 0 10.8%
unpow210.8%
unpow210.8%
*-commutative10.8%
Simplified10.8%
Taylor expanded in x around inf 6.6%
Final simplification6.6%
(FPCore (a x) :precision binary64 (if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1.0 (+ (/ (* a x) 2.0) (/ (pow (* a x) 2.0) 6.0)))) (- (exp (* a x)) 1.0)))
double code(double a, double x) {
double tmp;
if (fabs((a * x)) < 0.1) {
tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (pow((a * x), 2.0) / 6.0)));
} else {
tmp = exp((a * x)) - 1.0;
}
return tmp;
}
real(8) function code(a, x)
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if (abs((a * x)) < 0.1d0) then
tmp = (a * x) * (1.0d0 + (((a * x) / 2.0d0) + (((a * x) ** 2.0d0) / 6.0d0)))
else
tmp = exp((a * x)) - 1.0d0
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if (Math.abs((a * x)) < 0.1) {
tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (Math.pow((a * x), 2.0) / 6.0)));
} else {
tmp = Math.exp((a * x)) - 1.0;
}
return tmp;
}
def code(a, x): tmp = 0 if math.fabs((a * x)) < 0.1: tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (math.pow((a * x), 2.0) / 6.0))) else: tmp = math.exp((a * x)) - 1.0 return tmp
function code(a, x) tmp = 0.0 if (abs(Float64(a * x)) < 0.1) tmp = Float64(Float64(a * x) * Float64(1.0 + Float64(Float64(Float64(a * x) / 2.0) + Float64((Float64(a * x) ^ 2.0) / 6.0)))); else tmp = Float64(exp(Float64(a * x)) - 1.0); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if (abs((a * x)) < 0.1) tmp = (a * x) * (1.0 + (((a * x) / 2.0) + (((a * x) ^ 2.0) / 6.0))); else tmp = exp((a * x)) - 1.0; end tmp_2 = tmp; end
code[a_, x_] := If[Less[N[Abs[N[(a * x), $MachinePrecision]], $MachinePrecision], 0.1], N[(N[(a * x), $MachinePrecision] * N[(1.0 + N[(N[(N[(a * x), $MachinePrecision] / 2.0), $MachinePrecision] + N[(N[Power[N[(a * x), $MachinePrecision], 2.0], $MachinePrecision] / 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|a \cdot x\right| < 0.1:\\
\;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(\frac{a \cdot x}{2} + \frac{{\left(a \cdot x\right)}^{2}}{6}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{a \cdot x} - 1\\
\end{array}
\end{array}
herbie shell --seed 2023238
(FPCore (a x)
:name "expax (section 3.5)"
:precision binary64
:herbie-target
(if (< (fabs (* a x)) 0.1) (* (* a x) (+ 1.0 (+ (/ (* a x) 2.0) (/ (pow (* a x) 2.0) 6.0)))) (- (exp (* a x)) 1.0))
(- (exp (* a x)) 1.0))