
(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 1 x)
(FPCore (x_s x_m)
:precision binary64
(let* ((t_0 (- (exp x_m) (exp (- x_m)))))
(*
x_s
(if (<= t_0 0.1)
(/
(+
(+
(* -0.016666666666666666 (pow x_m 5.0))
(* -0.3333333333333333 (pow x_m 3.0)))
(+ (* -0.0003968253968253968 (pow x_m 7.0)) (* x_m -2.0)))
-2.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.1) {
tmp = (((-0.016666666666666666 * pow(x_m, 5.0)) + (-0.3333333333333333 * pow(x_m, 3.0))) + ((-0.0003968253968253968 * pow(x_m, 7.0)) + (x_m * -2.0))) / -2.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 <= 0.1d0) then
tmp = ((((-0.016666666666666666d0) * (x_m ** 5.0d0)) + ((-0.3333333333333333d0) * (x_m ** 3.0d0))) + (((-0.0003968253968253968d0) * (x_m ** 7.0d0)) + (x_m * (-2.0d0)))) / (-2.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 <= 0.1) {
tmp = (((-0.016666666666666666 * Math.pow(x_m, 5.0)) + (-0.3333333333333333 * Math.pow(x_m, 3.0))) + ((-0.0003968253968253968 * Math.pow(x_m, 7.0)) + (x_m * -2.0))) / -2.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 <= 0.1: tmp = (((-0.016666666666666666 * math.pow(x_m, 5.0)) + (-0.3333333333333333 * math.pow(x_m, 3.0))) + ((-0.0003968253968253968 * math.pow(x_m, 7.0)) + (x_m * -2.0))) / -2.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.1) tmp = Float64(Float64(Float64(Float64(-0.016666666666666666 * (x_m ^ 5.0)) + Float64(-0.3333333333333333 * (x_m ^ 3.0))) + Float64(Float64(-0.0003968253968253968 * (x_m ^ 7.0)) + Float64(x_m * -2.0))) / -2.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 <= 0.1) tmp = (((-0.016666666666666666 * (x_m ^ 5.0)) + (-0.3333333333333333 * (x_m ^ 3.0))) + ((-0.0003968253968253968 * (x_m ^ 7.0)) + (x_m * -2.0))) / -2.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, 0.1], N[(N[(N[(N[(-0.016666666666666666 * N[Power[x$95$m, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.0003968253968253968 * N[Power[x$95$m, 7.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $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.1:\\
\;\;\;\;\frac{\left(-0.016666666666666666 \cdot {x\_m}^{5} + -0.3333333333333333 \cdot {x\_m}^{3}\right) + \left(-0.0003968253968253968 \cdot {x\_m}^{7} + x\_m \cdot -2\right)}{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 0.10000000000000001Initial program 36.5%
sub-neg36.5%
remove-double-neg36.5%
remove-double-neg36.5%
distribute-neg-in36.5%
+-commutative36.5%
sub-neg36.5%
distribute-neg-frac36.5%
distribute-neg-frac236.5%
remove-double-neg36.5%
metadata-eval36.5%
Simplified36.5%
Taylor expanded in x around 0 97.3%
associate-+r+97.3%
+-commutative97.3%
associate-+r+97.3%
+-commutative97.3%
fma-define97.3%
associate-+l+97.3%
fma-define97.3%
+-commutative97.3%
fma-define97.3%
Simplified97.3%
fma-undefine97.3%
Applied egg-rr97.3%
fma-undefine97.3%
+-commutative97.3%
fma-undefine97.3%
+-commutative97.3%
associate-+r+97.3%
associate-+r+97.3%
+-commutative97.3%
associate-+r+97.3%
+-commutative97.3%
associate-+r+97.3%
associate-+l+97.3%
fma-define97.3%
*-commutative97.3%
Applied egg-rr97.3%
fma-undefine97.3%
+-commutative97.3%
Applied egg-rr97.3%
if 0.10000000000000001 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) Initial program 100.0%
Final simplification97.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(let* ((t_0 (- (exp x_m) (exp (- x_m)))))
(*
x_s
(if (<= t_0 0.1)
(/
(+
(* x_m -2.0)
(+
(* -0.3333333333333333 (pow x_m 3.0))
(+
(* -0.016666666666666666 (pow x_m 5.0))
(* -0.0003968253968253968 (pow x_m 7.0)))))
-2.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.1) {
tmp = ((x_m * -2.0) + ((-0.3333333333333333 * pow(x_m, 3.0)) + ((-0.016666666666666666 * pow(x_m, 5.0)) + (-0.0003968253968253968 * pow(x_m, 7.0))))) / -2.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 <= 0.1d0) then
tmp = ((x_m * (-2.0d0)) + (((-0.3333333333333333d0) * (x_m ** 3.0d0)) + (((-0.016666666666666666d0) * (x_m ** 5.0d0)) + ((-0.0003968253968253968d0) * (x_m ** 7.0d0))))) / (-2.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 <= 0.1) {
tmp = ((x_m * -2.0) + ((-0.3333333333333333 * Math.pow(x_m, 3.0)) + ((-0.016666666666666666 * Math.pow(x_m, 5.0)) + (-0.0003968253968253968 * Math.pow(x_m, 7.0))))) / -2.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 <= 0.1: tmp = ((x_m * -2.0) + ((-0.3333333333333333 * math.pow(x_m, 3.0)) + ((-0.016666666666666666 * math.pow(x_m, 5.0)) + (-0.0003968253968253968 * math.pow(x_m, 7.0))))) / -2.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.1) tmp = Float64(Float64(Float64(x_m * -2.0) + Float64(Float64(-0.3333333333333333 * (x_m ^ 3.0)) + Float64(Float64(-0.016666666666666666 * (x_m ^ 5.0)) + Float64(-0.0003968253968253968 * (x_m ^ 7.0))))) / -2.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 <= 0.1) tmp = ((x_m * -2.0) + ((-0.3333333333333333 * (x_m ^ 3.0)) + ((-0.016666666666666666 * (x_m ^ 5.0)) + (-0.0003968253968253968 * (x_m ^ 7.0))))) / -2.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, 0.1], N[(N[(N[(x$95$m * -2.0), $MachinePrecision] + N[(N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.016666666666666666 * N[Power[x$95$m, 5.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0003968253968253968 * N[Power[x$95$m, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / -2.0), $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.1:\\
\;\;\;\;\frac{x\_m \cdot -2 + \left(-0.3333333333333333 \cdot {x\_m}^{3} + \left(-0.016666666666666666 \cdot {x\_m}^{5} + -0.0003968253968253968 \cdot {x\_m}^{7}\right)\right)}{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 0.10000000000000001Initial program 36.5%
sub-neg36.5%
remove-double-neg36.5%
remove-double-neg36.5%
distribute-neg-in36.5%
+-commutative36.5%
sub-neg36.5%
distribute-neg-frac36.5%
distribute-neg-frac236.5%
remove-double-neg36.5%
metadata-eval36.5%
Simplified36.5%
Taylor expanded in x around 0 97.3%
if 0.10000000000000001 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) Initial program 100.0%
Final simplification97.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(let* ((t_0 (- (exp x_m) (exp (- x_m)))))
(*
x_s
(if (<= t_0 1e-7)
(/ (+ (* -0.3333333333333333 (pow x_m 3.0)) (* x_m -2.0)) -2.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 <= 1e-7) {
tmp = ((-0.3333333333333333 * pow(x_m, 3.0)) + (x_m * -2.0)) / -2.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 <= 1d-7) then
tmp = (((-0.3333333333333333d0) * (x_m ** 3.0d0)) + (x_m * (-2.0d0))) / (-2.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 <= 1e-7) {
tmp = ((-0.3333333333333333 * Math.pow(x_m, 3.0)) + (x_m * -2.0)) / -2.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 <= 1e-7: tmp = ((-0.3333333333333333 * math.pow(x_m, 3.0)) + (x_m * -2.0)) / -2.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 <= 1e-7) tmp = Float64(Float64(Float64(-0.3333333333333333 * (x_m ^ 3.0)) + Float64(x_m * -2.0)) / -2.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 <= 1e-7) tmp = ((-0.3333333333333333 * (x_m ^ 3.0)) + (x_m * -2.0)) / -2.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, 1e-7], N[(N[(N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / -2.0), $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 10^{-7}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot {x\_m}^{3} + x\_m \cdot -2}{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
\end{array}
if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 9.9999999999999995e-8Initial program 36.5%
sub-neg36.5%
remove-double-neg36.5%
remove-double-neg36.5%
distribute-neg-in36.5%
+-commutative36.5%
sub-neg36.5%
distribute-neg-frac36.5%
distribute-neg-frac236.5%
remove-double-neg36.5%
metadata-eval36.5%
Simplified36.5%
Taylor expanded in x around 0 92.3%
if 9.9999999999999995e-8 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) Initial program 100.0%
Final simplification94.0%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 5.5)
(/ (+ (* -0.3333333333333333 (pow x_m 3.0)) (* x_m -2.0)) -2.0)
(sqrt (* (pow x_m 14.0) 3.936759889140842e-8)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 5.5) {
tmp = ((-0.3333333333333333 * pow(x_m, 3.0)) + (x_m * -2.0)) / -2.0;
} else {
tmp = sqrt((pow(x_m, 14.0) * 3.936759889140842e-8));
}
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) :: tmp
if (x_m <= 5.5d0) then
tmp = (((-0.3333333333333333d0) * (x_m ** 3.0d0)) + (x_m * (-2.0d0))) / (-2.0d0)
else
tmp = sqrt(((x_m ** 14.0d0) * 3.936759889140842d-8))
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 tmp;
if (x_m <= 5.5) {
tmp = ((-0.3333333333333333 * Math.pow(x_m, 3.0)) + (x_m * -2.0)) / -2.0;
} else {
tmp = Math.sqrt((Math.pow(x_m, 14.0) * 3.936759889140842e-8));
}
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 <= 5.5: tmp = ((-0.3333333333333333 * math.pow(x_m, 3.0)) + (x_m * -2.0)) / -2.0 else: tmp = math.sqrt((math.pow(x_m, 14.0) * 3.936759889140842e-8)) 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 <= 5.5) tmp = Float64(Float64(Float64(-0.3333333333333333 * (x_m ^ 3.0)) + Float64(x_m * -2.0)) / -2.0); else tmp = sqrt(Float64((x_m ^ 14.0) * 3.936759889140842e-8)); 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) tmp = 0.0; if (x_m <= 5.5) tmp = ((-0.3333333333333333 * (x_m ^ 3.0)) + (x_m * -2.0)) / -2.0; else tmp = sqrt(((x_m ^ 14.0) * 3.936759889140842e-8)); 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_] := N[(x$95$s * If[LessEqual[x$95$m, 5.5], N[(N[(N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision], N[Sqrt[N[(N[Power[x$95$m, 14.0], $MachinePrecision] * 3.936759889140842e-8), $MachinePrecision]], $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 5.5:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot {x\_m}^{3} + x\_m \cdot -2}{-2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{x\_m}^{14} \cdot 3.936759889140842 \cdot 10^{-8}}\\
\end{array}
\end{array}
if x < 5.5Initial program 36.5%
sub-neg36.5%
remove-double-neg36.5%
remove-double-neg36.5%
distribute-neg-in36.5%
+-commutative36.5%
sub-neg36.5%
distribute-neg-frac36.5%
distribute-neg-frac236.5%
remove-double-neg36.5%
metadata-eval36.5%
Simplified36.5%
Taylor expanded in x around 0 92.3%
if 5.5 < x Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
distribute-neg-frac100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 95.1%
Taylor expanded in x around inf 95.1%
add-sqr-sqrt95.1%
sqrt-unprod96.7%
div-inv96.7%
div-inv96.7%
swap-sqr96.7%
*-commutative96.7%
*-commutative96.7%
swap-sqr96.7%
pow-prod-up96.7%
metadata-eval96.7%
metadata-eval96.7%
metadata-eval96.7%
metadata-eval96.7%
metadata-eval96.7%
Applied egg-rr96.7%
associate-*l*96.7%
metadata-eval96.7%
Simplified96.7%
Final simplification93.3%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 5.5)
(/ (+ (* -0.3333333333333333 (pow x_m 3.0)) (* x_m -2.0)) -2.0)
(* (pow x_m 7.0) 0.0001984126984126984))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 5.5) {
tmp = ((-0.3333333333333333 * pow(x_m, 3.0)) + (x_m * -2.0)) / -2.0;
} else {
tmp = pow(x_m, 7.0) * 0.0001984126984126984;
}
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) :: tmp
if (x_m <= 5.5d0) then
tmp = (((-0.3333333333333333d0) * (x_m ** 3.0d0)) + (x_m * (-2.0d0))) / (-2.0d0)
else
tmp = (x_m ** 7.0d0) * 0.0001984126984126984d0
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 tmp;
if (x_m <= 5.5) {
tmp = ((-0.3333333333333333 * Math.pow(x_m, 3.0)) + (x_m * -2.0)) / -2.0;
} else {
tmp = Math.pow(x_m, 7.0) * 0.0001984126984126984;
}
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 <= 5.5: tmp = ((-0.3333333333333333 * math.pow(x_m, 3.0)) + (x_m * -2.0)) / -2.0 else: tmp = math.pow(x_m, 7.0) * 0.0001984126984126984 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 <= 5.5) tmp = Float64(Float64(Float64(-0.3333333333333333 * (x_m ^ 3.0)) + Float64(x_m * -2.0)) / -2.0); else tmp = Float64((x_m ^ 7.0) * 0.0001984126984126984); 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) tmp = 0.0; if (x_m <= 5.5) tmp = ((-0.3333333333333333 * (x_m ^ 3.0)) + (x_m * -2.0)) / -2.0; else tmp = (x_m ^ 7.0) * 0.0001984126984126984; 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_] := N[(x$95$s * If[LessEqual[x$95$m, 5.5], N[(N[(N[(-0.3333333333333333 * N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x$95$m * -2.0), $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision], N[(N[Power[x$95$m, 7.0], $MachinePrecision] * 0.0001984126984126984), $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 5.5:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot {x\_m}^{3} + x\_m \cdot -2}{-2}\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{7} \cdot 0.0001984126984126984\\
\end{array}
\end{array}
if x < 5.5Initial program 36.5%
sub-neg36.5%
remove-double-neg36.5%
remove-double-neg36.5%
distribute-neg-in36.5%
+-commutative36.5%
sub-neg36.5%
distribute-neg-frac36.5%
distribute-neg-frac236.5%
remove-double-neg36.5%
metadata-eval36.5%
Simplified36.5%
Taylor expanded in x around 0 92.3%
if 5.5 < x Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
distribute-neg-frac100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 95.1%
Taylor expanded in x around inf 95.1%
*-commutative95.1%
associate-/l*95.1%
metadata-eval95.1%
Applied egg-rr95.1%
Final simplification92.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 4.2)
(/ (* x_m -2.0) -2.0)
(* (pow x_m 7.0) 0.0001984126984126984))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 4.2) {
tmp = (x_m * -2.0) / -2.0;
} else {
tmp = pow(x_m, 7.0) * 0.0001984126984126984;
}
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) :: tmp
if (x_m <= 4.2d0) then
tmp = (x_m * (-2.0d0)) / (-2.0d0)
else
tmp = (x_m ** 7.0d0) * 0.0001984126984126984d0
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 tmp;
if (x_m <= 4.2) {
tmp = (x_m * -2.0) / -2.0;
} else {
tmp = Math.pow(x_m, 7.0) * 0.0001984126984126984;
}
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 <= 4.2: tmp = (x_m * -2.0) / -2.0 else: tmp = math.pow(x_m, 7.0) * 0.0001984126984126984 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 <= 4.2) tmp = Float64(Float64(x_m * -2.0) / -2.0); else tmp = Float64((x_m ^ 7.0) * 0.0001984126984126984); 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) tmp = 0.0; if (x_m <= 4.2) tmp = (x_m * -2.0) / -2.0; else tmp = (x_m ^ 7.0) * 0.0001984126984126984; 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_] := N[(x$95$s * If[LessEqual[x$95$m, 4.2], N[(N[(x$95$m * -2.0), $MachinePrecision] / -2.0), $MachinePrecision], N[(N[Power[x$95$m, 7.0], $MachinePrecision] * 0.0001984126984126984), $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 4.2:\\
\;\;\;\;\frac{x\_m \cdot -2}{-2}\\
\mathbf{else}:\\
\;\;\;\;{x\_m}^{7} \cdot 0.0001984126984126984\\
\end{array}
\end{array}
if x < 4.20000000000000018Initial program 36.5%
sub-neg36.5%
remove-double-neg36.5%
remove-double-neg36.5%
distribute-neg-in36.5%
+-commutative36.5%
sub-neg36.5%
distribute-neg-frac36.5%
distribute-neg-frac236.5%
remove-double-neg36.5%
metadata-eval36.5%
Simplified36.5%
Taylor expanded in x around 0 70.1%
if 4.20000000000000018 < x Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
distribute-neg-frac100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 95.1%
Taylor expanded in x around inf 95.1%
*-commutative95.1%
associate-/l*95.1%
metadata-eval95.1%
Applied egg-rr95.1%
Final simplification75.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (/ (* x_m -2.0) -2.0)))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * ((x_m * -2.0) / -2.0);
}
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 * (-2.0d0)) / (-2.0d0))
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 * -2.0) / -2.0);
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * ((x_m * -2.0) / -2.0)
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * Float64(Float64(x_m * -2.0) / -2.0)) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * ((x_m * -2.0) / -2.0); 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[(N[(x$95$m * -2.0), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \frac{x\_m \cdot -2}{-2}
\end{array}
Initial program 50.8%
sub-neg50.8%
remove-double-neg50.8%
remove-double-neg50.8%
distribute-neg-in50.8%
+-commutative50.8%
sub-neg50.8%
distribute-neg-frac50.8%
distribute-neg-frac250.8%
remove-double-neg50.8%
metadata-eval50.8%
Simplified50.8%
Taylor expanded in x around 0 55.4%
Final simplification55.4%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s 1.0))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * 1.0;
}
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 * 1.0d0
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 * 1.0;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * 1.0
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * 1.0) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * 1.0; 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 * 1.0), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot 1
\end{array}
Initial program 50.8%
sub-neg50.8%
remove-double-neg50.8%
remove-double-neg50.8%
distribute-neg-in50.8%
+-commutative50.8%
sub-neg50.8%
distribute-neg-frac50.8%
distribute-neg-frac250.8%
remove-double-neg50.8%
metadata-eval50.8%
Simplified50.8%
Applied egg-rr2.8%
Final simplification2.8%
herbie shell --seed 2024052
(FPCore (x)
:name "Hyperbolic sine"
:precision binary64
(/ (- (exp x) (exp (- x))) 2.0))