
(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 10 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 (- (/ 1.0 (sin B)) (/ x (tan B))))
double code(double B, double x) {
return (1.0 / sin(B)) - (x / tan(B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / sin(b)) - (x / tan(b))
end function
public static double code(double B, double x) {
return (1.0 / Math.sin(B)) - (x / Math.tan(B));
}
def code(B, x): return (1.0 / math.sin(B)) - (x / math.tan(B))
function code(B, x) return Float64(Float64(1.0 / sin(B)) - Float64(x / tan(B))) end
function tmp = code(B, x) tmp = (1.0 / sin(B)) - (x / tan(B)); end
code[B_, x_] := N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sin B} - \frac{x}{\tan B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
*-commutative99.7%
remove-double-neg99.7%
distribute-frac-neg299.7%
tan-neg99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
(FPCore (B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= x -2450000.0)
(- (sin B) t_0)
(if (<= x 2.4e-7) (/ (- 1.0 x) (sin B)) (- (/ 1.0 B) t_0)))))
double code(double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (x <= -2450000.0) {
tmp = sin(B) - t_0;
} else if (x <= 2.4e-7) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (1.0 / B) - 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 <= (-2450000.0d0)) then
tmp = sin(b) - t_0
else if (x <= 2.4d-7) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (1.0d0 / b) - 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 <= -2450000.0) {
tmp = Math.sin(B) - t_0;
} else if (x <= 2.4e-7) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (1.0 / B) - t_0;
}
return tmp;
}
def code(B, x): t_0 = x / math.tan(B) tmp = 0 if x <= -2450000.0: tmp = math.sin(B) - t_0 elif x <= 2.4e-7: tmp = (1.0 - x) / math.sin(B) else: tmp = (1.0 / B) - t_0 return tmp
function code(B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (x <= -2450000.0) tmp = Float64(sin(B) - t_0); elseif (x <= 2.4e-7) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 / B) - t_0); end return tmp end
function tmp_2 = code(B, x) t_0 = x / tan(B); tmp = 0.0; if (x <= -2450000.0) tmp = sin(B) - t_0; elseif (x <= 2.4e-7) tmp = (1.0 - x) / sin(B); else tmp = (1.0 / B) - t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2450000.0], N[(N[Sin[B], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 2.4e-7], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / B), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;x \leq -2450000:\\
\;\;\;\;\sin B - t\_0\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B} - t\_0\\
\end{array}
\end{array}
if x < -2.45e6Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
*-commutative99.5%
remove-double-neg99.5%
distribute-frac-neg299.5%
tan-neg99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.7%
div-sub99.7%
Simplified99.7%
div-sub99.7%
clear-num99.5%
associate-/l/99.5%
tan-quot99.6%
add-exp-log55.8%
exp-neg55.8%
clear-num55.8%
sub-neg55.8%
add-sqr-sqrt55.8%
sqrt-unprod55.8%
sqr-neg55.8%
sqrt-unprod0.0%
add-sqr-sqrt55.1%
add-exp-log98.8%
distribute-neg-frac98.8%
Applied egg-rr98.8%
distribute-frac-neg98.8%
sub-neg98.8%
Simplified98.8%
if -2.45e6 < x < 2.39999999999999979e-7Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 98.7%
if 2.39999999999999979e-7 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in B around 0 98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -130.0) (not (<= x 2.4e-7))) (- (/ 1.0 B) (/ x (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -130.0) || !(x <= 2.4e-7)) {
tmp = (1.0 / B) - (x / tan(B));
} else {
tmp = (1.0 - x) / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-130.0d0)) .or. (.not. (x <= 2.4d-7))) then
tmp = (1.0d0 / b) - (x / tan(b))
else
tmp = (1.0d0 - x) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -130.0) || !(x <= 2.4e-7)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -130.0) or not (x <= 2.4e-7): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -130.0) || !(x <= 2.4e-7)) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); else tmp = Float64(Float64(1.0 - x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -130.0) || ~((x <= 2.4e-7))) tmp = (1.0 / B) - (x / tan(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -130.0], N[Not[LessEqual[x, 2.4e-7]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -130 \lor \neg \left(x \leq 2.4 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -130 or 2.39999999999999979e-7 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in B around 0 98.8%
if -130 < x < 2.39999999999999979e-7Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 98.7%
Final simplification98.7%
(FPCore (B x) :precision binary64 (if (or (<= x -10500000.0) (not (<= x 29000000000000.0))) (* x (/ -1.0 (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -10500000.0) || !(x <= 29000000000000.0)) {
tmp = x * (-1.0 / tan(B));
} else {
tmp = (1.0 - x) / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-10500000.0d0)) .or. (.not. (x <= 29000000000000.0d0))) then
tmp = x * ((-1.0d0) / tan(b))
else
tmp = (1.0d0 - x) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -10500000.0) || !(x <= 29000000000000.0)) {
tmp = x * (-1.0 / Math.tan(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -10500000.0) or not (x <= 29000000000000.0): tmp = x * (-1.0 / math.tan(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -10500000.0) || !(x <= 29000000000000.0)) tmp = Float64(x * Float64(-1.0 / tan(B))); else tmp = Float64(Float64(1.0 - x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -10500000.0) || ~((x <= 29000000000000.0))) tmp = x * (-1.0 / tan(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -10500000.0], N[Not[LessEqual[x, 29000000000000.0]], $MachinePrecision]], N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10500000 \lor \neg \left(x \leq 29000000000000\right):\\
\;\;\;\;x \cdot \frac{-1}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.05e7 or 2.9e13 < x Initial program 99.6%
Taylor expanded in x around inf 99.1%
mul-1-neg99.1%
associate-/l*99.0%
distribute-lft-neg-in99.0%
Simplified99.0%
*-un-lft-identity99.0%
clear-num98.9%
tan-quot99.0%
Applied egg-rr99.0%
*-lft-identity99.0%
Simplified99.0%
if -1.05e7 < x < 2.9e13Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 98.2%
Final simplification98.6%
(FPCore (B x) :precision binary64 (if (<= B 1.3e-6) (/ (- 1.0 x) B) (/ (+ 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 1.3e-6) {
tmp = (1.0 - x) / B;
} else {
tmp = (1.0 + x) / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= 1.3d-6) then
tmp = (1.0d0 - x) / b
else
tmp = (1.0d0 + x) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= 1.3e-6) {
tmp = (1.0 - x) / B;
} else {
tmp = (1.0 + x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 1.3e-6: tmp = (1.0 - x) / B else: tmp = (1.0 + x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 1.3e-6) tmp = Float64(Float64(1.0 - x) / B); else tmp = Float64(Float64(1.0 + x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 1.3e-6) tmp = (1.0 - x) / B; else tmp = (1.0 + x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 1.3e-6], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision], N[(N[(1.0 + x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.3 \cdot 10^{-6}:\\
\;\;\;\;\frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + x}{\sin B}\\
\end{array}
\end{array}
if B < 1.30000000000000005e-6Initial program 99.8%
Taylor expanded in B around 0 70.8%
if 1.30000000000000005e-6 < B Initial program 99.4%
distribute-lft-neg-in99.4%
+-commutative99.4%
*-commutative99.4%
remove-double-neg99.4%
distribute-frac-neg299.4%
tan-neg99.4%
cancel-sign-sub-inv99.4%
*-commutative99.4%
associate-*r/99.6%
*-rgt-identity99.6%
tan-neg99.6%
distribute-neg-frac299.6%
distribute-neg-frac99.6%
remove-double-neg99.6%
Simplified99.6%
tan-quot99.5%
associate-/r/99.3%
Applied egg-rr99.3%
Taylor expanded in B around inf 99.4%
div-sub99.4%
Simplified99.4%
Taylor expanded in B around 0 61.7%
sub-neg61.7%
+-commutative61.7%
add-sqr-sqrt30.5%
sqrt-unprod59.1%
sqr-neg59.1%
sqrt-unprod29.9%
add-sqr-sqrt60.6%
Applied egg-rr60.6%
Final simplification68.1%
(FPCore (B x) :precision binary64 (if (<= B 1.3e-6) (/ (- 1.0 x) B) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 1.3e-6) {
tmp = (1.0 - x) / B;
} else {
tmp = 1.0 / sin(B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= 1.3d-6) then
tmp = (1.0d0 - x) / b
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= 1.3e-6) {
tmp = (1.0 - x) / B;
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 1.3e-6: tmp = (1.0 - x) / B else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 1.3e-6) tmp = Float64(Float64(1.0 - x) / B); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 1.3e-6) tmp = (1.0 - x) / B; else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 1.3e-6], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.3 \cdot 10^{-6}:\\
\;\;\;\;\frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 1.30000000000000005e-6Initial program 99.8%
Taylor expanded in B around 0 70.8%
if 1.30000000000000005e-6 < B Initial program 99.4%
Taylor expanded in x around 0 57.9%
(FPCore (B x) :precision binary64 (/ (- 1.0 x) (sin B)))
double code(double B, double x) {
return (1.0 - x) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - x) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - x) / Math.sin(B);
}
def code(B, x): return (1.0 - x) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - x) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - x) / sin(B); end
code[B_, x_] := N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{\sin B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
*-commutative99.7%
remove-double-neg99.7%
distribute-frac-neg299.7%
tan-neg99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 80.0%
(FPCore (B x) :precision binary64 (if (or (<= x -5.8e-7) (not (<= x 1.0))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -5.8e-7) || !(x <= 1.0)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5.8d-7)) .or. (.not. (x <= 1.0d0))) then
tmp = x / -b
else
tmp = 1.0d0 / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -5.8e-7) || !(x <= 1.0)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -5.8e-7) or not (x <= 1.0): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -5.8e-7) || !(x <= 1.0)) tmp = Float64(x / Float64(-B)); else tmp = Float64(1.0 / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -5.8e-7) || ~((x <= 1.0))) tmp = x / -B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -5.8e-7], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(x / (-B)), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{-7} \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -5.7999999999999995e-7 or 1 < x Initial program 99.6%
Taylor expanded in B around 0 54.0%
Taylor expanded in x around inf 52.3%
mul-1-neg52.3%
Simplified52.3%
if -5.7999999999999995e-7 < x < 1Initial program 99.8%
Taylor expanded in B around 0 52.8%
Taylor expanded in x around 0 51.6%
Final simplification51.9%
(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.7%
Taylor expanded in B around 0 53.4%
(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.7%
Taylor expanded in B around 0 53.4%
Taylor expanded in x around 0 28.5%
herbie shell --seed 2024137
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))