
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
double code(double B, double x) {
return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
public static double code(double B, double x) {
return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
def code(B, x): return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
function code(B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B))) end
function tmp = code(B, x) tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B)); end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\end{array}
(FPCore (B x) :precision binary64 (fma (/ x (sin B)) (- (cos B)) (/ 1.0 (sin B))))
double code(double B, double x) {
return fma((x / sin(B)), -cos(B), (1.0 / sin(B)));
}
function code(B, x) return fma(Float64(x / sin(B)), Float64(-cos(B)), Float64(1.0 / sin(B))) end
code[B_, x_] := N[(N[(x / N[Sin[B], $MachinePrecision]), $MachinePrecision] * (-N[Cos[B], $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{\sin B}, -\cos B, \frac{1}{\sin B}\right)
\end{array}
Initial program 99.6%
Applied egg-rr99.8%
(FPCore (B x) :precision binary64 (/ (- 1.0 (* x (cos B))) (sin B)))
double code(double B, double x) {
return (1.0 - (x * cos(B))) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - (x * cos(b))) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - (x * Math.cos(B))) / Math.sin(B);
}
def code(B, x): return (1.0 - (x * math.cos(B))) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - Float64(x * cos(B))) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - (x * cos(B))) / sin(B); end
code[B_, x_] := N[(N[(1.0 - N[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x \cdot \cos B}{\sin B}
\end{array}
Initial program 99.6%
Applied egg-rr99.8%
lift-sin.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8
Applied egg-rr99.8%
(FPCore (B x)
:precision binary64
(if (<= x -1300.0)
(/ (- x) (tan B))
(if (<= x 2.2e-18)
(/ (- 1.0 x) (sin B))
(-
(/
1.0
(fma
(fma
(* B B)
(fma (* B B) -0.0001984126984126984 0.008333333333333333)
-0.16666666666666666)
(* B (* B B))
B))
(/ x (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1300.0) {
tmp = -x / tan(B);
} else if (x <= 2.2e-18) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (1.0 / fma(fma((B * B), fma((B * B), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), (B * (B * B)), B)) - (x / tan(B));
}
return tmp;
}
function code(B, x) tmp = 0.0 if (x <= -1300.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 2.2e-18) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 / fma(fma(Float64(B * B), fma(Float64(B * B), -0.0001984126984126984, 0.008333333333333333), -0.16666666666666666), Float64(B * Float64(B * B)), B)) - Float64(x / tan(B))); end return tmp end
code[B_, x_] := If[LessEqual[x, -1300.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e-18], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(B * B), $MachinePrecision] * N[(N[(B * B), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(B * N[(B * B), $MachinePrecision]), $MachinePrecision] + B), $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(B \cdot B, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), B \cdot \left(B \cdot B\right), B\right)} - \frac{x}{\tan B}\\
\end{array}
\end{array}
if x < -1300Initial program 99.6%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6496.4
Simplified96.4%
lift-cos.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift-sin.f64N/A
lift-neg.f64N/A
remove-double-negN/A
frac-2negN/A
frac-2negN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
associate-/r*N/A
clear-numN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
neg-mul-1N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6496.5
Applied egg-rr96.5%
if -1300 < x < 2.1999999999999998e-18Initial program 99.8%
Applied egg-rr99.8%
lift-sin.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8
Applied egg-rr99.8%
Taylor expanded in B around 0
lower--.f6499.1
Simplified99.1%
if 2.1999999999999998e-18 < x Initial program 99.5%
Applied egg-rr99.7%
Taylor expanded in B around 0
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
unpow3N/A
lower-fma.f64N/A
Simplified97.0%
(FPCore (B x)
:precision binary64
(if (<= x -1300.0)
(/ (- x) (tan B))
(if (<= x 2.2e-18)
(/ (- 1.0 x) (sin B))
(-
(/
1.0
(fma
(* B B)
(* B (fma B (* B 0.008333333333333333) -0.16666666666666666))
B))
(/ x (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1300.0) {
tmp = -x / tan(B);
} else if (x <= 2.2e-18) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (1.0 / fma((B * B), (B * fma(B, (B * 0.008333333333333333), -0.16666666666666666)), B)) - (x / tan(B));
}
return tmp;
}
function code(B, x) tmp = 0.0 if (x <= -1300.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 2.2e-18) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 / fma(Float64(B * B), Float64(B * fma(B, Float64(B * 0.008333333333333333), -0.16666666666666666)), B)) - Float64(x / tan(B))); end return tmp end
code[B_, x_] := If[LessEqual[x, -1300.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e-18], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(B * B), $MachinePrecision] * N[(B * N[(B * N[(B * 0.008333333333333333), $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + B), $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(B \cdot B, B \cdot \mathsf{fma}\left(B, B \cdot 0.008333333333333333, -0.16666666666666666\right), B\right)} - \frac{x}{\tan B}\\
\end{array}
\end{array}
if x < -1300Initial program 99.6%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6496.4
Simplified96.4%
lift-cos.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift-sin.f64N/A
lift-neg.f64N/A
remove-double-negN/A
frac-2negN/A
frac-2negN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
associate-/r*N/A
clear-numN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
neg-mul-1N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6496.5
Applied egg-rr96.5%
if -1300 < x < 2.1999999999999998e-18Initial program 99.8%
Applied egg-rr99.8%
lift-sin.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8
Applied egg-rr99.8%
Taylor expanded in B around 0
lower--.f6499.1
Simplified99.1%
if 2.1999999999999998e-18 < x Initial program 99.5%
Applied egg-rr99.7%
Taylor expanded in B around 0
+-commutativeN/A
distribute-rgt-inN/A
associate-*l*N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6496.9
Simplified96.9%
Final simplification97.8%
(FPCore (B x)
:precision binary64
(if (<= x -1300.0)
(/ (- x) (tan B))
(if (<= x 2.2e-18)
(/ (- 1.0 x) (sin B))
(- (/ 1.0 (fma B (* (* B B) -0.16666666666666666) B)) (/ x (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1300.0) {
tmp = -x / tan(B);
} else if (x <= 2.2e-18) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (1.0 / fma(B, ((B * B) * -0.16666666666666666), B)) - (x / tan(B));
}
return tmp;
}
function code(B, x) tmp = 0.0 if (x <= -1300.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 2.2e-18) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 / fma(B, Float64(Float64(B * B) * -0.16666666666666666), B)) - Float64(x / tan(B))); end return tmp end
code[B_, x_] := If[LessEqual[x, -1300.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e-18], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(B * N[(N[(B * B), $MachinePrecision] * -0.16666666666666666), $MachinePrecision] + B), $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(B, \left(B \cdot B\right) \cdot -0.16666666666666666, B\right)} - \frac{x}{\tan B}\\
\end{array}
\end{array}
if x < -1300Initial program 99.6%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6496.4
Simplified96.4%
lift-cos.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift-sin.f64N/A
lift-neg.f64N/A
remove-double-negN/A
frac-2negN/A
frac-2negN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
associate-/r*N/A
clear-numN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
neg-mul-1N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6496.5
Applied egg-rr96.5%
if -1300 < x < 2.1999999999999998e-18Initial program 99.8%
Applied egg-rr99.8%
lift-sin.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8
Applied egg-rr99.8%
Taylor expanded in B around 0
lower--.f6499.1
Simplified99.1%
if 2.1999999999999998e-18 < x Initial program 99.5%
Applied egg-rr99.7%
Taylor expanded in B around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.8
Simplified96.8%
(FPCore (B x) :precision binary64 (if (<= x -1300.0) (/ (- x) (tan B)) (if (<= x 2.2e-18) (/ (- 1.0 x) (sin B)) (- (/ 1.0 B) (/ x (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1300.0) {
tmp = -x / tan(B);
} else if (x <= 2.2e-18) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (1.0 / B) - (x / tan(B));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1300.0d0)) then
tmp = -x / tan(b)
else if (x <= 2.2d-18) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (1.0d0 / b) - (x / tan(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1300.0) {
tmp = -x / Math.tan(B);
} else if (x <= 2.2e-18) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (1.0 / B) - (x / Math.tan(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1300.0: tmp = -x / math.tan(B) elif x <= 2.2e-18: tmp = (1.0 - x) / math.sin(B) else: tmp = (1.0 / B) - (x / math.tan(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -1300.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 2.2e-18) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1300.0) tmp = -x / tan(B); elseif (x <= 2.2e-18) tmp = (1.0 - x) / sin(B); else tmp = (1.0 / B) - (x / tan(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1300.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e-18], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\end{array}
\end{array}
if x < -1300Initial program 99.6%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6496.4
Simplified96.4%
lift-cos.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift-sin.f64N/A
lift-neg.f64N/A
remove-double-negN/A
frac-2negN/A
frac-2negN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
associate-/r*N/A
clear-numN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
neg-mul-1N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6496.5
Applied egg-rr96.5%
if -1300 < x < 2.1999999999999998e-18Initial program 99.8%
Applied egg-rr99.8%
lift-sin.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8
Applied egg-rr99.8%
Taylor expanded in B around 0
lower--.f6499.1
Simplified99.1%
if 2.1999999999999998e-18 < x Initial program 99.5%
Taylor expanded in B around 0
lower-/.f6496.5
Simplified96.5%
lift-tan.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6496.5
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6496.7
Applied egg-rr96.7%
(FPCore (B x) :precision binary64 (let* ((t_0 (/ (- x) (tan B)))) (if (<= x -1300.0) t_0 (if (<= x 35.0) (/ (- 1.0 x) (sin B)) t_0))))
double code(double B, double x) {
double t_0 = -x / tan(B);
double tmp;
if (x <= -1300.0) {
tmp = t_0;
} else if (x <= 35.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = -x / tan(b)
if (x <= (-1300.0d0)) then
tmp = t_0
else if (x <= 35.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = -x / Math.tan(B);
double tmp;
if (x <= -1300.0) {
tmp = t_0;
} else if (x <= 35.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = t_0;
}
return tmp;
}
def code(B, x): t_0 = -x / math.tan(B) tmp = 0 if x <= -1300.0: tmp = t_0 elif x <= 35.0: tmp = (1.0 - x) / math.sin(B) else: tmp = t_0 return tmp
function code(B, x) t_0 = Float64(Float64(-x) / tan(B)) tmp = 0.0 if (x <= -1300.0) tmp = t_0; elseif (x <= 35.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = t_0; end return tmp end
function tmp_2 = code(B, x) t_0 = -x / tan(B); tmp = 0.0; if (x <= -1300.0) tmp = t_0; elseif (x <= 35.0) tmp = (1.0 - x) / sin(B); else tmp = t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1300.0], t$95$0, If[LessEqual[x, 35.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{\tan B}\\
\mathbf{if}\;x \leq -1300:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 35:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1300 or 35 < x Initial program 99.5%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6496.2
Simplified96.2%
lift-cos.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift-sin.f64N/A
lift-neg.f64N/A
remove-double-negN/A
frac-2negN/A
frac-2negN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
associate-/r*N/A
clear-numN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
neg-mul-1N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6496.2
Applied egg-rr96.2%
if -1300 < x < 35Initial program 99.8%
Applied egg-rr99.8%
lift-sin.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f6499.8
Applied egg-rr99.8%
Taylor expanded in B around 0
lower--.f6499.1
Simplified99.1%
(FPCore (B x) :precision binary64 (let* ((t_0 (/ (- x) (tan B)))) (if (<= x -1.8) t_0 (if (<= x 1.0) (/ 1.0 (sin B)) t_0))))
double code(double B, double x) {
double t_0 = -x / tan(B);
double tmp;
if (x <= -1.8) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = 1.0 / sin(B);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = -x / tan(b)
if (x <= (-1.8d0)) then
tmp = t_0
else if (x <= 1.0d0) then
tmp = 1.0d0 / sin(b)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = -x / Math.tan(B);
double tmp;
if (x <= -1.8) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = t_0;
}
return tmp;
}
def code(B, x): t_0 = -x / math.tan(B) tmp = 0 if x <= -1.8: tmp = t_0 elif x <= 1.0: tmp = 1.0 / math.sin(B) else: tmp = t_0 return tmp
function code(B, x) t_0 = Float64(Float64(-x) / tan(B)) tmp = 0.0 if (x <= -1.8) tmp = t_0; elseif (x <= 1.0) tmp = Float64(1.0 / sin(B)); else tmp = t_0; end return tmp end
function tmp_2 = code(B, x) t_0 = -x / tan(B); tmp = 0.0; if (x <= -1.8) tmp = t_0; elseif (x <= 1.0) tmp = 1.0 / sin(B); else tmp = t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.8], t$95$0, If[LessEqual[x, 1.0], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{\tan B}\\
\mathbf{if}\;x \leq -1.8:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.80000000000000004 or 1 < x Initial program 99.5%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6496.2
Simplified96.2%
lift-cos.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift-sin.f64N/A
lift-neg.f64N/A
remove-double-negN/A
frac-2negN/A
frac-2negN/A
clear-numN/A
lift-neg.f64N/A
neg-mul-1N/A
lift-*.f64N/A
times-fracN/A
associate-/r*N/A
clear-numN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
neg-mul-1N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6496.2
Applied egg-rr96.2%
if -1.80000000000000004 < x < 1Initial program 99.8%
Taylor expanded in x around 0
lower-/.f64N/A
lower-sin.f6498.4
Simplified98.4%
(FPCore (B x)
:precision binary64
(if (<= B 1.0)
(/
(fma
(* B B)
(fma
x
0.3333333333333333
(fma
(* B B)
(fma
B
(* B (fma x 0.0021164021164021165 0.00205026455026455))
(fma x 0.022222222222222223 0.019444444444444445))
0.16666666666666666))
(- 1.0 x))
B)
(/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 1.0) {
tmp = fma((B * B), fma(x, 0.3333333333333333, fma((B * B), fma(B, (B * fma(x, 0.0021164021164021165, 0.00205026455026455)), fma(x, 0.022222222222222223, 0.019444444444444445)), 0.16666666666666666)), (1.0 - x)) / B;
} else {
tmp = 1.0 / sin(B);
}
return tmp;
}
function code(B, x) tmp = 0.0 if (B <= 1.0) tmp = Float64(fma(Float64(B * B), fma(x, 0.3333333333333333, fma(Float64(B * B), fma(B, Float64(B * fma(x, 0.0021164021164021165, 0.00205026455026455)), fma(x, 0.022222222222222223, 0.019444444444444445)), 0.16666666666666666)), Float64(1.0 - x)) / B); else tmp = Float64(1.0 / sin(B)); end return tmp end
code[B_, x_] := If[LessEqual[B, 1.0], N[(N[(N[(B * B), $MachinePrecision] * N[(x * 0.3333333333333333 + N[(N[(B * B), $MachinePrecision] * N[(B * N[(B * N[(x * 0.0021164021164021165 + 0.00205026455026455), $MachinePrecision]), $MachinePrecision] + N[(x * 0.022222222222222223 + 0.019444444444444445), $MachinePrecision]), $MachinePrecision] + 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(x, 0.3333333333333333, \mathsf{fma}\left(B \cdot B, \mathsf{fma}\left(B, B \cdot \mathsf{fma}\left(x, 0.0021164021164021165, 0.00205026455026455\right), \mathsf{fma}\left(x, 0.022222222222222223, 0.019444444444444445\right)\right), 0.16666666666666666\right)\right), 1 - x\right)}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 1Initial program 99.7%
Taylor expanded in B around 0
Simplified69.4%
if 1 < B Initial program 99.3%
Taylor expanded in x around 0
lower-/.f64N/A
lower-sin.f6439.7
Simplified39.7%
(FPCore (B x) :precision binary64 (/ (fma x (fma (* B B) 0.3333333333333333 -1.0) 1.0) B))
double code(double B, double x) {
return fma(x, fma((B * B), 0.3333333333333333, -1.0), 1.0) / B;
}
function code(B, x) return Float64(fma(x, fma(Float64(B * B), 0.3333333333333333, -1.0), 1.0) / B) end
code[B_, x_] := N[(N[(x * N[(N[(B * B), $MachinePrecision] * 0.3333333333333333 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(B \cdot B, 0.3333333333333333, -1\right), 1\right)}{B}
\end{array}
Initial program 99.6%
Taylor expanded in B around 0
lower-/.f6479.1
Simplified79.1%
Taylor expanded in B around 0
lower-/.f64N/A
associate--l+N/A
+-commutativeN/A
sub-negN/A
associate-*r*N/A
mul-1-negN/A
distribute-rgt-outN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6454.2
Simplified54.2%
(FPCore (B x) :precision binary64 (let* ((t_0 (- (/ x B)))) (if (<= x -1.0) t_0 (if (<= x 9000000.0) (/ 1.0 B) t_0))))
double code(double B, double x) {
double t_0 = -(x / B);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 9000000.0) {
tmp = 1.0 / B;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = -(x / b)
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= 9000000.0d0) then
tmp = 1.0d0 / b
else
tmp = t_0
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = -(x / B);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= 9000000.0) {
tmp = 1.0 / B;
} else {
tmp = t_0;
}
return tmp;
}
def code(B, x): t_0 = -(x / B) tmp = 0 if x <= -1.0: tmp = t_0 elif x <= 9000000.0: tmp = 1.0 / B else: tmp = t_0 return tmp
function code(B, x) t_0 = Float64(-Float64(x / B)) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= 9000000.0) tmp = Float64(1.0 / B); else tmp = t_0; end return tmp end
function tmp_2 = code(B, x) t_0 = -(x / B); tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= 9000000.0) tmp = 1.0 / B; else tmp = t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = (-N[(x / B), $MachinePrecision])}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, 9000000.0], N[(1.0 / B), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\frac{x}{B}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9000000:\\
\;\;\;\;\frac{1}{B}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 9e6 < x Initial program 99.5%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6449.9
Simplified49.9%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6449.6
Simplified49.6%
if -1 < x < 9e6Initial program 99.8%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6458.0
Simplified58.0%
Taylor expanded in x around 0
lower-/.f6457.4
Simplified57.4%
Final simplification53.3%
(FPCore (B x) :precision binary64 (/ (- 1.0 x) B))
double code(double B, double x) {
return (1.0 - x) / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - x) / b
end function
public static double code(double B, double x) {
return (1.0 - x) / B;
}
def code(B, x): return (1.0 - x) / B
function code(B, x) return Float64(Float64(1.0 - x) / B) end
function tmp = code(B, x) tmp = (1.0 - x) / B; end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B}
\end{array}
Initial program 99.6%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6453.8
Simplified53.8%
(FPCore (B x) :precision binary64 (/ 1.0 B))
double code(double B, double x) {
return 1.0 / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = 1.0d0 / b
end function
public static double code(double B, double x) {
return 1.0 / B;
}
def code(B, x): return 1.0 / B
function code(B, x) return Float64(1.0 / B) end
function tmp = code(B, x) tmp = 1.0 / B; end
code[B_, x_] := N[(1.0 / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B}
\end{array}
Initial program 99.6%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6453.8
Simplified53.8%
Taylor expanded in x around 0
lower-/.f6428.9
Simplified28.9%
herbie shell --seed 2024208
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))