
(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%
associate-*l/99.7%
*-lft-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
(FPCore (B x) :precision binary64 (if (or (<= x -4.1e-7) (not (<= x 8.5e-21))) (- (/ 1.0 B) (/ x (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -4.1e-7) || !(x <= 8.5e-21)) {
tmp = (1.0 / B) - (x / tan(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 ((x <= (-4.1d-7)) .or. (.not. (x <= 8.5d-21))) then
tmp = (1.0d0 / b) - (x / tan(b))
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -4.1e-7) || !(x <= 8.5e-21)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -4.1e-7) or not (x <= 8.5e-21): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -4.1e-7) || !(x <= 8.5e-21)) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -4.1e-7) || ~((x <= 8.5e-21))) tmp = (1.0 / B) - (x / tan(B)); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -4.1e-7], N[Not[LessEqual[x, 8.5e-21]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{-7} \lor \neg \left(x \leq 8.5 \cdot 10^{-21}\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -4.0999999999999999e-7 or 8.4999999999999993e-21 < 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%
associate-*l/99.7%
*-lft-identity99.7%
tan-neg99.7%
distribute-neg-frac299.7%
distribute-neg-frac99.7%
remove-double-neg99.7%
Simplified99.7%
Taylor expanded in B around 0 97.9%
if -4.0999999999999999e-7 < x < 8.4999999999999993e-21Initial program 99.8%
Taylor expanded in x around 0 99.8%
Final simplification98.7%
(FPCore (B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= x -9.2e-5)
(* t_0 (+ -1.0 (/ 1.0 x)))
(if (<= x 8.5e-21) (/ 1.0 (sin B)) (- (/ 1.0 B) t_0)))))
double code(double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (x <= -9.2e-5) {
tmp = t_0 * (-1.0 + (1.0 / x));
} else if (x <= 8.5e-21) {
tmp = 1.0 / 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 <= (-9.2d-5)) then
tmp = t_0 * ((-1.0d0) + (1.0d0 / x))
else if (x <= 8.5d-21) then
tmp = 1.0d0 / 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 <= -9.2e-5) {
tmp = t_0 * (-1.0 + (1.0 / x));
} else if (x <= 8.5e-21) {
tmp = 1.0 / 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 <= -9.2e-5: tmp = t_0 * (-1.0 + (1.0 / x)) elif x <= 8.5e-21: tmp = 1.0 / 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 <= -9.2e-5) tmp = Float64(t_0 * Float64(-1.0 + Float64(1.0 / x))); elseif (x <= 8.5e-21) tmp = Float64(1.0 / 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 <= -9.2e-5) tmp = t_0 * (-1.0 + (1.0 / x)); elseif (x <= 8.5e-21) tmp = 1.0 / 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, -9.2e-5], N[(t$95$0 * N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.5e-21], N[(1.0 / 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 -9.2 \cdot 10^{-5}:\\
\;\;\;\;t\_0 \cdot \left(-1 + \frac{1}{x}\right)\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-21}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B} - t\_0\\
\end{array}
\end{array}
if x < -9.20000000000000001e-5Initial program 99.5%
+-commutative99.5%
div-inv99.6%
sub-neg99.6%
clear-num99.5%
frac-sub87.7%
*-un-lft-identity87.7%
*-commutative87.7%
*-un-lft-identity87.7%
Applied egg-rr87.7%
associate-/r*99.5%
associate-/r/99.5%
div-sub99.5%
*-inverses99.5%
Simplified99.5%
Taylor expanded in B around 0 97.0%
*-commutative97.0%
clear-num97.0%
un-div-inv97.1%
sub-neg97.1%
metadata-eval97.1%
Applied egg-rr97.1%
associate-/r/97.1%
+-commutative97.1%
Simplified97.1%
if -9.20000000000000001e-5 < x < 8.4999999999999993e-21Initial program 99.8%
Taylor expanded in x around 0 99.8%
if 8.4999999999999993e-21 < x 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%
associate-*l/99.8%
*-lft-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.7%
(FPCore (B x) :precision binary64 (if (or (<= x -1.08) (not (<= x 1.05))) (/ x (- (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.08) || !(x <= 1.05)) {
tmp = x / -tan(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 ((x <= (-1.08d0)) .or. (.not. (x <= 1.05d0))) then
tmp = x / -tan(b)
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -1.08) || !(x <= 1.05)) {
tmp = x / -Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.08) or not (x <= 1.05): tmp = x / -math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.08) || !(x <= 1.05)) tmp = Float64(x / Float64(-tan(B))); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.08) || ~((x <= 1.05))) tmp = x / -tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.08], N[Not[LessEqual[x, 1.05]], $MachinePrecision]], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.08 \lor \neg \left(x \leq 1.05\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.0800000000000001 or 1.05000000000000004 < x Initial program 99.6%
Taylor expanded in x around inf 96.8%
mul-1-neg96.8%
div-inv96.6%
associate-*l*96.7%
div-inv96.8%
clear-num96.7%
tan-quot96.8%
un-div-inv96.9%
distribute-neg-frac96.9%
Applied egg-rr96.9%
if -1.0800000000000001 < x < 1.05000000000000004Initial program 99.8%
Taylor expanded in x around 0 99.0%
Final simplification97.8%
(FPCore (B x) :precision binary64 (if (<= x -1.6) (/ (- -1.0 x) (tan B)) (if (<= x 1.3) (/ 1.0 (sin B)) (/ x (- (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1.6) {
tmp = (-1.0 - x) / tan(B);
} else if (x <= 1.3) {
tmp = 1.0 / sin(B);
} else {
tmp = 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 <= (-1.6d0)) then
tmp = ((-1.0d0) - x) / tan(b)
else if (x <= 1.3d0) then
tmp = 1.0d0 / sin(b)
else
tmp = x / -tan(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.6) {
tmp = (-1.0 - x) / Math.tan(B);
} else if (x <= 1.3) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = x / -Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.6: tmp = (-1.0 - x) / math.tan(B) elif x <= 1.3: tmp = 1.0 / math.sin(B) else: tmp = x / -math.tan(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.6) tmp = Float64(Float64(-1.0 - x) / tan(B)); elseif (x <= 1.3) tmp = Float64(1.0 / sin(B)); else tmp = Float64(x / Float64(-tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.6) tmp = (-1.0 - x) / tan(B); elseif (x <= 1.3) tmp = 1.0 / sin(B); else tmp = x / -tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.6], N[(N[(-1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.3], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6:\\
\;\;\;\;\frac{-1 - x}{\tan B}\\
\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{-\tan B}\\
\end{array}
\end{array}
if x < -1.6000000000000001Initial program 99.5%
+-commutative99.5%
div-inv99.6%
sub-neg99.6%
clear-num99.5%
frac-sub87.7%
*-un-lft-identity87.7%
*-commutative87.7%
*-un-lft-identity87.7%
Applied egg-rr87.7%
associate-/r*99.5%
associate-/r/99.5%
div-sub99.5%
*-inverses99.5%
Simplified99.5%
Taylor expanded in B around 0 97.0%
frac-2neg97.0%
associate-*l/97.1%
distribute-lft-neg-in97.1%
distribute-rgt-neg-in97.1%
add-sqr-sqrt96.8%
sqrt-unprod63.8%
sqr-neg63.8%
sqrt-unprod0.0%
add-sqr-sqrt0.4%
*-commutative0.4%
sub-neg0.4%
metadata-eval0.4%
distribute-lft-in0.4%
div-inv0.4%
*-inverses0.4%
*-commutative0.4%
neg-mul-10.4%
add-sqr-sqrt0.4%
sqrt-unprod0.4%
sqr-neg0.4%
sqrt-unprod0.0%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
distribute-frac-neg295.1%
distribute-neg-frac95.1%
neg-sub095.1%
associate--r+95.1%
metadata-eval95.1%
Simplified95.1%
if -1.6000000000000001 < x < 1.30000000000000004Initial program 99.8%
Taylor expanded in x around 0 99.0%
if 1.30000000000000004 < x Initial program 99.7%
Taylor expanded in x around inf 98.4%
mul-1-neg98.4%
div-inv98.2%
associate-*l*98.4%
div-inv98.4%
clear-num98.3%
tan-quot98.4%
un-div-inv98.6%
distribute-neg-frac98.6%
Applied egg-rr98.6%
Final simplification97.8%
(FPCore (B x) :precision binary64 (if (<= B 360.0) (/ (- 1.0 x) B) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 360.0) {
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 <= 360.0d0) 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 <= 360.0) {
tmp = (1.0 - x) / B;
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 360.0: tmp = (1.0 - x) / B else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 360.0) 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 <= 360.0) tmp = (1.0 - x) / B; else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 360.0], 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 360:\\
\;\;\;\;\frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 360Initial program 99.8%
Taylor expanded in B around 0 67.0%
if 360 < B Initial program 99.4%
Taylor expanded in x around 0 50.4%
(FPCore (B x) :precision binary64 (if (or (<= x -6.2e-21) (not (<= x 3.2e-5))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -6.2e-21) || !(x <= 3.2e-5)) {
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 <= (-6.2d-21)) .or. (.not. (x <= 3.2d-5))) 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 <= -6.2e-21) || !(x <= 3.2e-5)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -6.2e-21) or not (x <= 3.2e-5): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -6.2e-21) || !(x <= 3.2e-5)) 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 <= -6.2e-21) || ~((x <= 3.2e-5))) tmp = x / -B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -6.2e-21], N[Not[LessEqual[x, 3.2e-5]], $MachinePrecision]], N[(x / (-B)), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-21} \lor \neg \left(x \leq 3.2 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -6.1999999999999997e-21 or 3.19999999999999986e-5 < x Initial program 99.6%
Taylor expanded in B around 0 51.6%
Taylor expanded in x around inf 50.0%
neg-mul-150.0%
Simplified50.0%
if -6.1999999999999997e-21 < x < 3.19999999999999986e-5Initial program 99.8%
Taylor expanded in B around 0 51.0%
Taylor expanded in x around 0 50.7%
Final simplification50.3%
(FPCore (B x) :precision binary64 (if (<= x -1.8e-28) (/ (- -1.0 x) B) (if (<= x 3.2e-5) (/ 1.0 B) (/ x (- B)))))
double code(double B, double x) {
double tmp;
if (x <= -1.8e-28) {
tmp = (-1.0 - x) / B;
} else if (x <= 3.2e-5) {
tmp = 1.0 / B;
} else {
tmp = x / -B;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.8d-28)) then
tmp = ((-1.0d0) - x) / b
else if (x <= 3.2d-5) then
tmp = 1.0d0 / b
else
tmp = x / -b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.8e-28) {
tmp = (-1.0 - x) / B;
} else if (x <= 3.2e-5) {
tmp = 1.0 / B;
} else {
tmp = x / -B;
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.8e-28: tmp = (-1.0 - x) / B elif x <= 3.2e-5: tmp = 1.0 / B else: tmp = x / -B return tmp
function code(B, x) tmp = 0.0 if (x <= -1.8e-28) tmp = Float64(Float64(-1.0 - x) / B); elseif (x <= 3.2e-5) tmp = Float64(1.0 / B); else tmp = Float64(x / Float64(-B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.8e-28) tmp = (-1.0 - x) / B; elseif (x <= 3.2e-5) tmp = 1.0 / B; else tmp = x / -B; end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.8e-28], N[(N[(-1.0 - x), $MachinePrecision] / B), $MachinePrecision], If[LessEqual[x, 3.2e-5], N[(1.0 / B), $MachinePrecision], N[(x / (-B)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-28}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{-B}\\
\end{array}
\end{array}
if x < -1.7999999999999999e-28Initial program 99.5%
Taylor expanded in B around 0 45.0%
Taylor expanded in x around inf 45.0%
frac-2neg45.0%
div-inv45.0%
distribute-lft-neg-in45.0%
add-sqr-sqrt44.9%
sqrt-unprod39.8%
sqr-neg39.8%
sqrt-unprod0.0%
add-sqr-sqrt2.0%
sub-neg2.0%
metadata-eval2.0%
distribute-lft-in2.0%
div-inv2.0%
*-inverses2.0%
*-commutative2.0%
neg-mul-12.0%
add-sqr-sqrt2.0%
sqrt-unprod2.2%
sqr-neg2.2%
sqrt-unprod0.0%
add-sqr-sqrt43.2%
Applied egg-rr43.2%
associate-*r/43.2%
*-rgt-identity43.2%
distribute-neg-frac243.2%
distribute-neg-frac43.2%
neg-sub043.2%
associate--r+43.2%
metadata-eval43.2%
Simplified43.2%
if -1.7999999999999999e-28 < x < 3.19999999999999986e-5Initial program 99.8%
Taylor expanded in B around 0 51.9%
Taylor expanded in x around 0 51.6%
if 3.19999999999999986e-5 < x Initial program 99.7%
Taylor expanded in B around 0 56.7%
Taylor expanded in x around inf 55.5%
neg-mul-155.5%
Simplified55.5%
Final simplification50.4%
(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 51.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 51.4%
Taylor expanded in x around 0 23.8%
herbie shell --seed 2024181
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))