
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
double code(double x) {
return (exp(x) - exp(-x)) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) - exp(-x)) / 2.0d0
end function
public static double code(double x) {
return (Math.exp(x) - Math.exp(-x)) / 2.0;
}
def code(x): return (math.exp(x) - math.exp(-x)) / 2.0
function code(x) return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0) end
function tmp = code(x) tmp = (exp(x) - exp(-x)) / 2.0; end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x} - e^{-x}}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
double code(double x) {
return (exp(x) - exp(-x)) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) - exp(-x)) / 2.0d0
end function
public static double code(double x) {
return (Math.exp(x) - Math.exp(-x)) / 2.0;
}
def code(x): return (math.exp(x) - math.exp(-x)) / 2.0
function code(x) return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0) end
function tmp = code(x) tmp = (exp(x) - exp(-x)) / 2.0; end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x} - e^{-x}}{2}
\end{array}
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m)
:precision binary64
(let* ((t_0 (- (exp x_m) (exp (- x_m)))))
(*
x_s
(if (<= t_0 0.02)
(+
x_m
(*
(fma (* x_m x_m) 0.008333333333333333 0.16666666666666666)
(pow x_m 3.0)))
(/ t_0 2.0)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double t_0 = exp(x_m) - exp(-x_m);
double tmp;
if (t_0 <= 0.02) {
tmp = x_m + (fma((x_m * x_m), 0.008333333333333333, 0.16666666666666666) * pow(x_m, 3.0));
} else {
tmp = t_0 / 2.0;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) t_0 = Float64(exp(x_m) - exp(Float64(-x_m))) tmp = 0.0 if (t_0 <= 0.02) tmp = Float64(x_m + Float64(fma(Float64(x_m * x_m), 0.008333333333333333, 0.16666666666666666) * (x_m ^ 3.0))); else tmp = Float64(t_0 / 2.0); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := Block[{t$95$0 = N[(N[Exp[x$95$m], $MachinePrecision] - N[Exp[(-x$95$m)], $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, 0.02], N[(x$95$m + N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := e^{x\_m} - e^{-x\_m}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0.02:\\
\;\;\;\;x\_m + \mathsf{fma}\left(x\_m \cdot x\_m, 0.008333333333333333, 0.16666666666666666\right) \cdot {x\_m}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 0.0200000000000000004Initial program 36.7%
Taylor expanded in x around 0 91.3%
distribute-lft-in91.3%
*-commutative91.3%
associate-+r+91.3%
distribute-lft-in91.3%
fma-define91.3%
+-commutative91.3%
fma-define91.3%
*-commutative91.3%
*-commutative91.3%
associate-*l*91.3%
associate-*l*91.3%
pow-sqr91.3%
pow-plus91.3%
metadata-eval91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in x around 0 91.3%
distribute-rgt-in91.3%
*-lft-identity91.3%
*-commutative91.3%
associate-*l*91.3%
+-commutative91.3%
*-commutative91.3%
fma-define91.3%
unpow291.3%
unpow391.3%
Simplified91.3%
unpow291.3%
Applied egg-rr91.3%
if 0.0200000000000000004 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) Initial program 100.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m)
:precision binary64
(let* ((t_0 (- (exp x_m) (exp (- x_m)))))
(*
x_s
(if (<= t_0 4e-7)
(+ x_m (* 0.16666666666666666 (pow x_m 3.0)))
(/ t_0 2.0)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double t_0 = exp(x_m) - exp(-x_m);
double tmp;
if (t_0 <= 4e-7) {
tmp = x_m + (0.16666666666666666 * pow(x_m, 3.0));
} else {
tmp = t_0 / 2.0;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp(x_m) - exp(-x_m)
if (t_0 <= 4d-7) then
tmp = x_m + (0.16666666666666666d0 * (x_m ** 3.0d0))
else
tmp = t_0 / 2.0d0
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double t_0 = Math.exp(x_m) - Math.exp(-x_m);
double tmp;
if (t_0 <= 4e-7) {
tmp = x_m + (0.16666666666666666 * Math.pow(x_m, 3.0));
} else {
tmp = t_0 / 2.0;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m): t_0 = math.exp(x_m) - math.exp(-x_m) tmp = 0 if t_0 <= 4e-7: tmp = x_m + (0.16666666666666666 * math.pow(x_m, 3.0)) else: tmp = t_0 / 2.0 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) t_0 = Float64(exp(x_m) - exp(Float64(-x_m))) tmp = 0.0 if (t_0 <= 4e-7) tmp = Float64(x_m + Float64(0.16666666666666666 * (x_m ^ 3.0))); else tmp = Float64(t_0 / 2.0); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) t_0 = exp(x_m) - exp(-x_m); tmp = 0.0; if (t_0 <= 4e-7) tmp = x_m + (0.16666666666666666 * (x_m ^ 3.0)); else tmp = t_0 / 2.0; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := Block[{t$95$0 = N[(N[Exp[x$95$m], $MachinePrecision] - N[Exp[(-x$95$m)], $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, 4e-7], N[(x$95$m + N[(0.16666666666666666 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := e^{x\_m} - e^{-x\_m}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-7}:\\
\;\;\;\;x\_m + 0.16666666666666666 \cdot {x\_m}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 3.9999999999999998e-7Initial program 36.7%
Taylor expanded in x around 0 91.3%
distribute-lft-in91.3%
*-commutative91.3%
associate-+r+91.3%
distribute-lft-in91.3%
fma-define91.3%
+-commutative91.3%
fma-define91.3%
*-commutative91.3%
*-commutative91.3%
associate-*l*91.3%
associate-*l*91.3%
pow-sqr91.3%
pow-plus91.3%
metadata-eval91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in x around 0 87.2%
distribute-rgt-in87.2%
*-lft-identity87.2%
associate-*r*87.2%
unpow287.2%
unpow387.2%
Simplified87.2%
if 3.9999999999999998e-7 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) Initial program 100.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 2.2)
(+ x_m (* 0.16666666666666666 (pow x_m 3.0)))
(/ (expm1 x_m) 2.0))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 2.2) {
tmp = x_m + (0.16666666666666666 * pow(x_m, 3.0));
} else {
tmp = expm1(x_m) / 2.0;
}
return x_s * tmp;
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 2.2) {
tmp = x_m + (0.16666666666666666 * Math.pow(x_m, 3.0));
} else {
tmp = Math.expm1(x_m) / 2.0;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 2.2: tmp = x_m + (0.16666666666666666 * math.pow(x_m, 3.0)) else: tmp = math.expm1(x_m) / 2.0 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 2.2) tmp = Float64(x_m + Float64(0.16666666666666666 * (x_m ^ 3.0))); else tmp = Float64(expm1(x_m) / 2.0); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 2.2], N[(x$95$m + N[(0.16666666666666666 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Exp[x$95$m] - 1), $MachinePrecision] / 2.0), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 2.2:\\
\;\;\;\;x\_m + 0.16666666666666666 \cdot {x\_m}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(x\_m\right)}{2}\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 37.0%
Taylor expanded in x around 0 91.1%
distribute-lft-in91.1%
*-commutative91.1%
associate-+r+91.1%
distribute-lft-in91.1%
fma-define91.1%
+-commutative91.1%
fma-define91.1%
*-commutative91.1%
*-commutative91.1%
associate-*l*91.1%
associate-*l*91.1%
pow-sqr91.1%
pow-plus91.1%
metadata-eval91.1%
metadata-eval91.1%
Simplified91.1%
Taylor expanded in x around 0 87.0%
distribute-rgt-in87.0%
*-lft-identity87.0%
associate-*r*87.0%
unpow287.0%
unpow387.0%
Simplified87.0%
if 2.2000000000000002 < x Initial program 100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
metadata-eval100.0%
sub-neg100.0%
expm1-define100.0%
Simplified100.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 2.2)
(* x_m (+ 1.0 (* (* x_m x_m) 0.16666666666666666)))
(/ (expm1 x_m) 2.0))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 2.2) {
tmp = x_m * (1.0 + ((x_m * x_m) * 0.16666666666666666));
} else {
tmp = expm1(x_m) / 2.0;
}
return x_s * tmp;
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 2.2) {
tmp = x_m * (1.0 + ((x_m * x_m) * 0.16666666666666666));
} else {
tmp = Math.expm1(x_m) / 2.0;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 2.2: tmp = x_m * (1.0 + ((x_m * x_m) * 0.16666666666666666)) else: tmp = math.expm1(x_m) / 2.0 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 2.2) tmp = Float64(x_m * Float64(1.0 + Float64(Float64(x_m * x_m) * 0.16666666666666666))); else tmp = Float64(expm1(x_m) / 2.0); end return Float64(x_s * tmp) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 2.2], N[(x$95$m * N[(1.0 + N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Exp[x$95$m] - 1), $MachinePrecision] / 2.0), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 2.2:\\
\;\;\;\;x\_m \cdot \left(1 + \left(x\_m \cdot x\_m\right) \cdot 0.16666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(x\_m\right)}{2}\\
\end{array}
\end{array}
if x < 2.2000000000000002Initial program 37.0%
Taylor expanded in x around 0 91.1%
distribute-lft-in91.1%
*-commutative91.1%
associate-+r+91.1%
distribute-lft-in91.1%
fma-define91.1%
+-commutative91.1%
fma-define91.1%
*-commutative91.1%
*-commutative91.1%
associate-*l*91.1%
associate-*l*91.1%
pow-sqr91.1%
pow-plus91.1%
metadata-eval91.1%
metadata-eval91.1%
Simplified91.1%
Taylor expanded in x around 0 87.0%
unpow291.1%
Applied egg-rr87.0%
if 2.2000000000000002 < x Initial program 100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
metadata-eval100.0%
sub-neg100.0%
expm1-define100.0%
Simplified100.0%
Final simplification89.8%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(*
x_m
(+
1.0
(*
x_m
(+ 0.25 (* x_m (+ 0.08333333333333333 (* x_m 0.020833333333333332)))))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * (x_m * (1.0 + (x_m * (0.25 + (x_m * (0.08333333333333333 + (x_m * 0.020833333333333332)))))));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
code = x_s * (x_m * (1.0d0 + (x_m * (0.25d0 + (x_m * (0.08333333333333333d0 + (x_m * 0.020833333333333332d0)))))))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
return x_s * (x_m * (1.0 + (x_m * (0.25 + (x_m * (0.08333333333333333 + (x_m * 0.020833333333333332)))))));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * (x_m * (1.0 + (x_m * (0.25 + (x_m * (0.08333333333333333 + (x_m * 0.020833333333333332)))))))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * Float64(x_m * Float64(1.0 + Float64(x_m * Float64(0.25 + Float64(x_m * Float64(0.08333333333333333 + Float64(x_m * 0.020833333333333332)))))))) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * (x_m * (1.0 + (x_m * (0.25 + (x_m * (0.08333333333333333 + (x_m * 0.020833333333333332))))))); end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * N[(x$95$m * N[(1.0 + N[(x$95$m * N[(0.25 + N[(x$95$m * N[(0.08333333333333333 + N[(x$95$m * 0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(x\_m \cdot \left(1 + x\_m \cdot \left(0.25 + x\_m \cdot \left(0.08333333333333333 + x\_m \cdot 0.020833333333333332\right)\right)\right)\right)
\end{array}
Initial program 50.6%
Taylor expanded in x around 0 27.1%
mul-1-neg27.1%
unsub-neg27.1%
Simplified27.1%
Taylor expanded in x around 0 71.0%
*-commutative71.0%
Simplified71.0%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m) :precision binary64 (* x_s (* x_m (+ 1.0 (* (* x_m x_m) 0.16666666666666666)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * (x_m * (1.0 + ((x_m * x_m) * 0.16666666666666666)));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
code = x_s * (x_m * (1.0d0 + ((x_m * x_m) * 0.16666666666666666d0)))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
return x_s * (x_m * (1.0 + ((x_m * x_m) * 0.16666666666666666)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * (x_m * (1.0 + ((x_m * x_m) * 0.16666666666666666)))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * Float64(x_m * Float64(1.0 + Float64(Float64(x_m * x_m) * 0.16666666666666666)))) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * (x_m * (1.0 + ((x_m * x_m) * 0.16666666666666666))); end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * N[(x$95$m * N[(1.0 + N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(x\_m \cdot \left(1 + \left(x\_m \cdot x\_m\right) \cdot 0.16666666666666666\right)\right)
\end{array}
Initial program 50.6%
Taylor expanded in x around 0 90.4%
distribute-lft-in90.4%
*-commutative90.4%
associate-+r+90.4%
distribute-lft-in90.4%
fma-define90.4%
+-commutative90.4%
fma-define90.4%
*-commutative90.4%
*-commutative90.4%
associate-*l*90.4%
associate-*l*90.4%
pow-sqr90.4%
pow-plus90.4%
metadata-eval90.4%
metadata-eval90.4%
Simplified90.4%
Taylor expanded in x around 0 83.9%
unpow290.4%
Applied egg-rr83.9%
Final simplification83.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m) :precision binary64 (* x_s (* x_m (+ 1.0 (* x_m 0.25)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * (x_m * (1.0 + (x_m * 0.25)));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
code = x_s * (x_m * (1.0d0 + (x_m * 0.25d0)))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
return x_s * (x_m * (1.0 + (x_m * 0.25)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * (x_m * (1.0 + (x_m * 0.25)))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * Float64(x_m * Float64(1.0 + Float64(x_m * 0.25)))) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * (x_m * (1.0 + (x_m * 0.25))); end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * N[(x$95$m * N[(1.0 + N[(x$95$m * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(x\_m \cdot \left(1 + x\_m \cdot 0.25\right)\right)
\end{array}
Initial program 50.6%
Taylor expanded in x around 0 27.1%
mul-1-neg27.1%
unsub-neg27.1%
Simplified27.1%
Taylor expanded in x around 0 64.0%
*-commutative64.0%
Simplified64.0%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m) :precision binary64 (* x_s x_m))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * x_m;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
code = x_s * x_m
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
return x_s * x_m;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * x_m
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * x_m) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * x_m; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot x\_m
\end{array}
Initial program 50.6%
Taylor expanded in x around 0 90.4%
distribute-lft-in90.4%
*-commutative90.4%
associate-+r+90.4%
distribute-lft-in90.4%
fma-define90.4%
+-commutative90.4%
fma-define90.4%
*-commutative90.4%
*-commutative90.4%
associate-*l*90.4%
associate-*l*90.4%
pow-sqr90.4%
pow-plus90.4%
metadata-eval90.4%
metadata-eval90.4%
Simplified90.4%
Taylor expanded in x around 0 56.2%
herbie shell --seed 2024188
(FPCore (x)
:name "Hyperbolic sine"
:precision binary64
(/ (- (exp x) (exp (- x))) 2.0))