
(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 11 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}
(FPCore (x)
:precision binary64
(let* ((t_0 (- (exp x) (exp (- x)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.001)))
(/ t_0 2.0)
(/
(+
(* 0.016666666666666666 (pow x 5.0))
(* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
2.0))))
double code(double x) {
double t_0 = exp(x) - exp(-x);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.001)) {
tmp = t_0 / 2.0;
} else {
tmp = ((0.016666666666666666 * pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.exp(x) - Math.exp(-x);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.001)) {
tmp = t_0 / 2.0;
} else {
tmp = ((0.016666666666666666 * Math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
}
return tmp;
}
def code(x): t_0 = math.exp(x) - math.exp(-x) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 0.001): tmp = t_0 / 2.0 else: tmp = ((0.016666666666666666 * math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0 return tmp
function code(x) t_0 = Float64(exp(x) - exp(Float64(-x))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.001)) tmp = Float64(t_0 / 2.0); else tmp = Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x))))) / 2.0); end return tmp end
function tmp_2 = code(x) t_0 = exp(x) - exp(-x); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 0.001))) tmp = t_0 / 2.0; else tmp = ((0.016666666666666666 * (x ^ 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(t$95$0 / 2.0), $MachinePrecision], N[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x} - e^{-x}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;\frac{t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\
\end{array}
\end{array}
if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < -inf.0 or 1e-3 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 1e-3Initial program 7.8%
Taylor expanded in x around 0 100.0%
unpow3100.0%
associate-*r*100.0%
distribute-rgt-in100.0%
fma-udef100.0%
*-commutative100.0%
Applied egg-rr100.0%
fma-udef100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (or (<= x -34000.0) (not (<= x 13200.0)))
(cast (! :precision binary32 (* 0.008333333333333333 (pow x 5.0))))
(/
(+
(* 0.016666666666666666 (pow x 5.0))
(* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
2.0)))
double code(double x) {
float tmp_1;
if ((x <= -34000.0) || !(x <= 13200.0)) {
float tmp_2 = 0.008333333333333333f * powf(x, 5.0f);
tmp_1 = (double) tmp_2;
} else {
tmp_1 = ((0.016666666666666666f * powf(x, 5.0f)) + (x * (2.0f + (0.3333333333333333f * (x * x))))) / 2.0f;
}
return tmp_1;
}
real(8) function code(x)
real(8), intent (in) :: x
real(4) :: tmp
real(4) :: tmp_1
real(4) :: tmp_2
if ((x <= (-34000.0d0)) .or. (.not. (x <= 13200.0d0))) then
tmp_2 = 0.008333333333333333e0 * (x ** 5.0e0)
tmp_1 = real(tmp_2, 8)
else
tmp_1 = ((0.016666666666666666e0 * (x ** 5.0e0)) + (x * (2.0e0 + (0.3333333333333333e0 * (x * x))))) / 2.0e0
end if
code = tmp_1
end function
function code(x) tmp_1 = Float32(0.0) if ((x <= -34000.0) || !(x <= 13200.0)) tmp_2 = Float32(Float32(0.008333333333333333) * (x ^ Float32(5.0))) tmp_1 = Float64(tmp_2); else tmp_1 = Float32(Float32(Float32(Float32(0.016666666666666666) * (x ^ Float32(5.0))) + Float32(x * Float32(Float32(2.0) + Float32(Float32(0.3333333333333333) * Float32(x * x))))) / Float32(2.0)); end return tmp_1 end
function tmp_4 = code(x) tmp_2 = single(0.0); if ((x <= -34000.0) || ~((x <= 13200.0))) tmp_3 = single(0.008333333333333333) * single((x ^ double(single(5.0)))); tmp_2 = double(tmp_3); else tmp_2 = ((single(0.016666666666666666) * single((x ^ double(single(5.0))))) + single((x * double((single(2.0) + (single(0.3333333333333333) * single((x * x)))))))) / single(2.0); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -34000 \lor \neg \left(x \leq 13200\right):\\
\;\;\;\;\langle \left( 0.008333333333333333 \cdot {x}^{5} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\
\end{array}
\end{array}
if x < -34000 or 13200 < x Initial program 100.0%
Taylor expanded in x around 0 77.6%
Taylor expanded in x around inf 77.6%
rewrite-binary64/binary3299.3%
Applied rewrite-once99.3%
associate-/l*99.3%
associate-/r/99.3%
metadata-eval99.3%
Simplified99.3%
if -34000 < x < 13200Initial program 9.3%
Taylor expanded in x around 0 98.6%
unpow398.6%
associate-*r*98.6%
distribute-rgt-in98.6%
fma-udef98.6%
*-commutative98.6%
Applied egg-rr98.6%
fma-udef98.6%
Applied egg-rr98.6%
Final simplification98.9%
(FPCore (x)
:precision binary64
(if (or (<= x -12600000000000.0) (not (<= x 12500000000000.0)))
(cast
(!
:precision
binary32
(cast (! :precision binary64 (* x (* x (* x 0.16666666666666666)))))))
(/
(+
(* 0.016666666666666666 (pow x 5.0))
(* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
2.0)))
double code(double x) {
double tmp_3;
if ((x <= -12600000000000.0) || !(x <= 12500000000000.0)) {
double tmp_6 = x * (x * (x * 0.16666666666666666));
double tmp_5 = (float) tmp_6;
tmp_3 = (double) tmp_5;
} else {
tmp_3 = ((0.016666666666666666 * pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
}
return tmp_3;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
real(8) :: tmp_5
real(8) :: tmp_6
if ((x <= (-12600000000000.0d0)) .or. (.not. (x <= 12500000000000.0d0))) then
tmp_6 = x * (x * (x * 0.16666666666666666d0))
tmp_5 = real(tmp_6, 4)
tmp_3 = real(tmp_5, 8)
else
tmp_3 = ((0.016666666666666666d0 * (x ** 5.0d0)) + (x * (2.0d0 + (0.3333333333333333d0 * (x * x))))) / 2.0d0
end if
code = tmp_3
end function
function code(x) tmp_3 = 0.0 if ((x <= -12600000000000.0) || !(x <= 12500000000000.0)) tmp_6 = Float64(x * Float64(x * Float64(x * 0.16666666666666666))) tmp_5 = Float32(tmp_6) tmp_3 = Float64(tmp_5); else tmp_3 = Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x))))) / 2.0); end return tmp_3 end
function tmp_8 = code(x) tmp_4 = 0.0; if ((x <= -12600000000000.0) || ~((x <= 12500000000000.0))) tmp_7 = x * (x * (x * 0.16666666666666666)); tmp_6 = single(tmp_7); tmp_4 = double(tmp_6); else tmp_4 = ((0.016666666666666666 * (x ^ 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0; end tmp_8 = tmp_4; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -12600000000000 \lor \neg \left(x \leq 12500000000000\right):\\
\;\;\;\;\langle \left( \langle \left( x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\
\end{array}
\end{array}
if x < -1.26e13 or 1.25e13 < x Initial program 100.0%
Taylor expanded in x around 0 72.4%
*-commutative72.4%
cube-mult72.4%
associate-*l*72.4%
*-commutative72.4%
distribute-lft-out72.4%
*-commutative72.4%
fma-def72.4%
Simplified72.4%
Taylor expanded in x around inf 72.4%
unpow272.4%
associate-*r*72.4%
*-commutative72.4%
Simplified72.4%
div-inv72.4%
*-commutative72.4%
associate-*r*72.4%
associate-*l*71.8%
*-commutative71.8%
*-commutative71.8%
associate-*l*71.8%
metadata-eval71.8%
metadata-eval71.8%
associate-*l*71.8%
Applied egg-rr71.8%
rewrite-binary64/binary32-simplify100.0%
Applied rewrite-once100.0%
if -1.26e13 < x < 1.25e13Initial program 15.6%
Taylor expanded in x around 0 91.9%
unpow391.9%
associate-*r*91.9%
distribute-rgt-in91.9%
fma-udef91.9%
*-commutative91.9%
Applied egg-rr91.9%
fma-udef91.9%
Applied egg-rr91.9%
Final simplification95.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (* x (* x 0.16666666666666666)))))
(if (<= x 3.2e+34)
(/
(+
(* 0.016666666666666666 (pow x 5.0))
(* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
2.0)
(cbrt (* t_0 (* t_0 t_0))))))
double code(double x) {
double t_0 = x * (x * (x * 0.16666666666666666));
double tmp;
if (x <= 3.2e+34) {
tmp = ((0.016666666666666666 * pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
} else {
tmp = cbrt((t_0 * (t_0 * t_0)));
}
return tmp;
}
public static double code(double x) {
double t_0 = x * (x * (x * 0.16666666666666666));
double tmp;
if (x <= 3.2e+34) {
tmp = ((0.016666666666666666 * Math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
} else {
tmp = Math.cbrt((t_0 * (t_0 * t_0)));
}
return tmp;
}
function code(x) t_0 = Float64(x * Float64(x * Float64(x * 0.16666666666666666))) tmp = 0.0 if (x <= 3.2e+34) tmp = Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x))))) / 2.0); else tmp = cbrt(Float64(t_0 * Float64(t_0 * t_0))); end return tmp end
code[x_] := Block[{t$95$0 = N[(x * N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3.2e+34], N[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;x \leq 3.2 \cdot 10^{+34}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}\\
\end{array}
\end{array}
if x < 3.1999999999999998e34Initial program 45.0%
Taylor expanded in x around 0 86.6%
unpow386.6%
associate-*r*86.6%
distribute-rgt-in86.6%
fma-udef86.6%
*-commutative86.6%
Applied egg-rr86.6%
fma-udef86.6%
Applied egg-rr86.6%
if 3.1999999999999998e34 < x Initial program 100.0%
Taylor expanded in x around 0 75.7%
*-commutative75.7%
cube-mult75.7%
associate-*l*75.7%
*-commutative75.7%
distribute-lft-out75.7%
*-commutative75.7%
fma-def75.7%
Simplified75.7%
Taylor expanded in x around inf 75.7%
unpow275.7%
associate-*r*75.7%
*-commutative75.7%
Simplified75.7%
div-inv75.7%
*-commutative75.7%
associate-*r*75.7%
associate-*l*75.7%
*-commutative75.7%
*-commutative75.7%
associate-*l*75.7%
metadata-eval75.7%
metadata-eval75.7%
associate-*l*75.7%
Applied egg-rr75.7%
add-cbrt-cube_binary64100.0%
Applied rewrite-once100.0%
Final simplification89.6%
(FPCore (x) :precision binary64 (/ (+ (* 0.016666666666666666 (pow x 5.0)) (* x (+ 2.0 (* 0.3333333333333333 (* x x))))) 2.0))
double code(double x) {
return ((0.016666666666666666 * pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((0.016666666666666666d0 * (x ** 5.0d0)) + (x * (2.0d0 + (0.3333333333333333d0 * (x * x))))) / 2.0d0
end function
public static double code(double x) {
return ((0.016666666666666666 * Math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
}
def code(x): return ((0.016666666666666666 * math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0
function code(x) return Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x))))) / 2.0) end
function tmp = code(x) tmp = ((0.016666666666666666 * (x ^ 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0; end
code[x_] := N[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 87.4%
unpow387.4%
associate-*r*87.4%
distribute-rgt-in87.4%
fma-udef87.4%
*-commutative87.4%
Applied egg-rr87.4%
fma-udef87.4%
Applied egg-rr87.4%
Final simplification87.4%
(FPCore (x) :precision binary64 (/ (+ (* 0.016666666666666666 (pow x 5.0)) (* x 2.0)) 2.0))
double code(double x) {
return ((0.016666666666666666 * pow(x, 5.0)) + (x * 2.0)) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((0.016666666666666666d0 * (x ** 5.0d0)) + (x * 2.0d0)) / 2.0d0
end function
public static double code(double x) {
return ((0.016666666666666666 * Math.pow(x, 5.0)) + (x * 2.0)) / 2.0;
}
def code(x): return ((0.016666666666666666 * math.pow(x, 5.0)) + (x * 2.0)) / 2.0
function code(x) return Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * 2.0)) / 2.0) end
function tmp = code(x) tmp = ((0.016666666666666666 * (x ^ 5.0)) + (x * 2.0)) / 2.0; end
code[x_] := N[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot 2}{2}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 87.4%
unpow387.4%
associate-*r*87.4%
distribute-rgt-in87.4%
fma-udef87.4%
*-commutative87.4%
Applied egg-rr87.4%
Taylor expanded in x around 0 87.2%
Final simplification87.2%
(FPCore (x) :precision binary64 (if (or (<= x -5.0) (not (<= x 5.0))) (* (pow x 5.0) 0.008333333333333333) (/ (* x (+ 2.0 (* 0.3333333333333333 (* x x)))) 2.0)))
double code(double x) {
double tmp;
if ((x <= -5.0) || !(x <= 5.0)) {
tmp = pow(x, 5.0) * 0.008333333333333333;
} else {
tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5.0d0)) .or. (.not. (x <= 5.0d0))) then
tmp = (x ** 5.0d0) * 0.008333333333333333d0
else
tmp = (x * (2.0d0 + (0.3333333333333333d0 * (x * x)))) / 2.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -5.0) || !(x <= 5.0)) {
tmp = Math.pow(x, 5.0) * 0.008333333333333333;
} else {
tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -5.0) or not (x <= 5.0): tmp = math.pow(x, 5.0) * 0.008333333333333333 else: tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0 return tmp
function code(x) tmp = 0.0 if ((x <= -5.0) || !(x <= 5.0)) tmp = Float64((x ^ 5.0) * 0.008333333333333333); else tmp = Float64(Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x)))) / 2.0); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -5.0) || ~((x <= 5.0))) tmp = (x ^ 5.0) * 0.008333333333333333; else tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -5.0], N[Not[LessEqual[x, 5.0]], $MachinePrecision]], N[(N[Power[x, 5.0], $MachinePrecision] * 0.008333333333333333), $MachinePrecision], N[(N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \lor \neg \left(x \leq 5\right):\\
\;\;\;\;{x}^{5} \cdot 0.008333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\
\end{array}
\end{array}
if x < -5 or 5 < x Initial program 100.0%
Taylor expanded in x around 0 76.6%
Taylor expanded in x around inf 76.6%
Taylor expanded in x around 0 76.6%
*-commutative76.6%
Simplified76.6%
if -5 < x < 5Initial program 7.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
cube-mult100.0%
associate-*l*100.0%
*-commutative100.0%
distribute-lft-out100.0%
*-commutative100.0%
fma-def100.0%
Simplified100.0%
fma-udef100.0%
Applied egg-rr100.0%
Final simplification87.4%
(FPCore (x) :precision binary64 (if (or (<= x -2.4) (not (<= x 2.4))) (* x (* x (* x 0.16666666666666666))) x))
double code(double x) {
double tmp;
if ((x <= -2.4) || !(x <= 2.4)) {
tmp = x * (x * (x * 0.16666666666666666));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-2.4d0)) .or. (.not. (x <= 2.4d0))) then
tmp = x * (x * (x * 0.16666666666666666d0))
else
tmp = x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -2.4) || !(x <= 2.4)) {
tmp = x * (x * (x * 0.16666666666666666));
} else {
tmp = x;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -2.4) or not (x <= 2.4): tmp = x * (x * (x * 0.16666666666666666)) else: tmp = x return tmp
function code(x) tmp = 0.0 if ((x <= -2.4) || !(x <= 2.4)) tmp = Float64(x * Float64(x * Float64(x * 0.16666666666666666))); else tmp = x; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -2.4) || ~((x <= 2.4))) tmp = x * (x * (x * 0.16666666666666666)); else tmp = x; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -2.4], N[Not[LessEqual[x, 2.4]], $MachinePrecision]], N[(x * N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \lor \neg \left(x \leq 2.4\right):\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.39999999999999991 or 2.39999999999999991 < x Initial program 100.0%
Taylor expanded in x around 0 67.0%
*-commutative67.0%
cube-mult67.0%
associate-*l*67.0%
*-commutative67.0%
distribute-lft-out67.0%
*-commutative67.0%
fma-def67.0%
Simplified67.0%
Taylor expanded in x around inf 67.0%
unpow267.0%
associate-*r*67.0%
*-commutative67.0%
Simplified67.0%
div-inv67.0%
*-commutative67.0%
associate-*r*67.0%
associate-*l*66.4%
*-commutative66.4%
*-commutative66.4%
associate-*l*66.4%
metadata-eval66.4%
metadata-eval66.4%
associate-*l*66.4%
Applied egg-rr66.4%
if -2.39999999999999991 < x < 2.39999999999999991Initial program 7.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
cube-mult100.0%
associate-*l*100.0%
*-commutative100.0%
distribute-lft-out100.0%
*-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 99.6%
Final simplification81.7%
(FPCore (x) :precision binary64 (if (<= x -2.4) (* -0.16666666666666666 (/ (* x x) (/ -1.0 x))) (if (<= x 2.4) x (* x (* x (* x 0.16666666666666666))))))
double code(double x) {
double tmp;
if (x <= -2.4) {
tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x));
} else if (x <= 2.4) {
tmp = x;
} else {
tmp = x * (x * (x * 0.16666666666666666));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2.4d0)) then
tmp = (-0.16666666666666666d0) * ((x * x) / ((-1.0d0) / x))
else if (x <= 2.4d0) then
tmp = x
else
tmp = x * (x * (x * 0.16666666666666666d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -2.4) {
tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x));
} else if (x <= 2.4) {
tmp = x;
} else {
tmp = x * (x * (x * 0.16666666666666666));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2.4: tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x)) elif x <= 2.4: tmp = x else: tmp = x * (x * (x * 0.16666666666666666)) return tmp
function code(x) tmp = 0.0 if (x <= -2.4) tmp = Float64(-0.16666666666666666 * Float64(Float64(x * x) / Float64(-1.0 / x))); elseif (x <= 2.4) tmp = x; else tmp = Float64(x * Float64(x * Float64(x * 0.16666666666666666))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.4) tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x)); elseif (x <= 2.4) tmp = x; else tmp = x * (x * (x * 0.16666666666666666)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2.4], N[(-0.16666666666666666 * N[(N[(x * x), $MachinePrecision] / N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4], x, N[(x * N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{x \cdot x}{\frac{-1}{x}}\\
\mathbf{elif}\;x \leq 2.4:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if x < -2.39999999999999991Initial program 100.0%
Taylor expanded in x around 0 73.7%
*-commutative73.7%
cube-mult73.7%
associate-*l*73.7%
*-commutative73.7%
distribute-lft-out73.7%
*-commutative73.7%
fma-def73.7%
Simplified73.7%
Taylor expanded in x around inf 73.7%
unpow273.7%
associate-*r*73.7%
*-commutative73.7%
Simplified73.7%
add-cbrt-cube_binary6485.2%
Applied rewrite-once85.2%
pow385.2%
rem-cbrt-cube73.7%
*-commutative73.7%
*-commutative73.7%
associate-*r*73.7%
associate-/l*72.4%
frac-2neg72.4%
metadata-eval72.4%
div-inv72.4%
times-frac73.7%
metadata-eval73.7%
neg-mul-173.7%
associate-/r*73.7%
Applied egg-rr73.7%
if -2.39999999999999991 < x < 2.39999999999999991Initial program 7.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
cube-mult100.0%
associate-*l*100.0%
*-commutative100.0%
distribute-lft-out100.0%
*-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 99.6%
if 2.39999999999999991 < x Initial program 100.0%
Taylor expanded in x around 0 61.1%
*-commutative61.1%
cube-mult61.1%
associate-*l*61.1%
*-commutative61.1%
distribute-lft-out61.1%
*-commutative61.1%
fma-def61.1%
Simplified61.1%
Taylor expanded in x around inf 61.1%
unpow261.1%
associate-*r*61.1%
*-commutative61.1%
Simplified61.1%
div-inv61.1%
*-commutative61.1%
associate-*r*61.1%
associate-*l*61.1%
*-commutative61.1%
*-commutative61.1%
associate-*l*61.1%
metadata-eval61.1%
metadata-eval61.1%
associate-*l*61.1%
Applied egg-rr61.1%
Final simplification82.1%
(FPCore (x) :precision binary64 (/ (* x (+ 2.0 (* 0.3333333333333333 (* x x)))) 2.0))
double code(double x) {
return (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * (2.0d0 + (0.3333333333333333d0 * (x * x)))) / 2.0d0
end function
public static double code(double x) {
return (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0;
}
def code(x): return (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0
function code(x) return Float64(Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x)))) / 2.0) end
function tmp = code(x) tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0; end
code[x_] := N[(N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 82.2%
*-commutative82.2%
cube-mult82.2%
associate-*l*82.2%
*-commutative82.2%
distribute-lft-out82.2%
*-commutative82.2%
fma-def82.2%
Simplified82.2%
fma-udef87.4%
Applied egg-rr82.2%
Final simplification82.2%
(FPCore (x) :precision binary64 x)
double code(double x) {
return x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x
end function
public static double code(double x) {
return x;
}
def code(x): return x
function code(x) return x end
function tmp = code(x) tmp = x; end
code[x_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 57.5%
Taylor expanded in x around 0 82.2%
*-commutative82.2%
cube-mult82.2%
associate-*l*82.2%
*-commutative82.2%
distribute-lft-out82.2%
*-commutative82.2%
fma-def82.2%
Simplified82.2%
Taylor expanded in x around 0 48.8%
Final simplification48.8%
herbie shell --seed 2023297
(FPCore (x)
:name "Hyperbolic sine"
:precision binary64
(/ (- (exp x) (exp (- x))) 2.0))