
(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.8%
*-lft-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
(FPCore (B x) :precision binary64 (if (<= x -1700.0) (- (/ 1.0 B) (/ x (tan B))) (if (<= x 1.0) (/ (- 1.0 x) (sin B)) (* x (/ (+ (/ 1.0 x) -1.0) (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -1700.0) {
tmp = (1.0 / B) - (x / tan(B));
} else if (x <= 1.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = x * (((1.0 / x) + -1.0) / 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 <= (-1700.0d0)) then
tmp = (1.0d0 / b) - (x / tan(b))
else if (x <= 1.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = x * (((1.0d0 / x) + (-1.0d0)) / tan(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1700.0) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else if (x <= 1.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = x * (((1.0 / x) + -1.0) / Math.tan(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1700.0: tmp = (1.0 / B) - (x / math.tan(B)) elif x <= 1.0: tmp = (1.0 - x) / math.sin(B) else: tmp = x * (((1.0 / x) + -1.0) / math.tan(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -1700.0) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); elseif (x <= 1.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(x * Float64(Float64(Float64(1.0 / x) + -1.0) / tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1700.0) tmp = (1.0 / B) - (x / tan(B)); elseif (x <= 1.0) tmp = (1.0 - x) / sin(B); else tmp = x * (((1.0 / x) + -1.0) / tan(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1700.0], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1700:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{1}{x} + -1}{\tan B}\\
\end{array}
\end{array}
if x < -1700Initial 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 98.7%
if -1700 < x < 1Initial program 99.8%
+-commutative99.8%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub88.0%
*-un-lft-identity88.0%
*-commutative88.0%
*-un-lft-identity88.0%
Applied egg-rr88.0%
associate-/r*99.6%
associate-/r/69.3%
div-sub69.3%
*-inverses69.3%
Simplified69.3%
Taylor expanded in B around inf 99.6%
Taylor expanded in B around 0 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-rgt-in98.6%
lft-mult-inverse98.7%
mul-1-neg98.7%
unsub-neg98.7%
Simplified98.7%
if 1 < x Initial program 99.6%
+-commutative99.6%
div-inv99.7%
sub-neg99.7%
clear-num99.7%
frac-sub94.2%
*-un-lft-identity94.2%
*-commutative94.2%
*-un-lft-identity94.2%
Applied egg-rr94.2%
associate-/r*99.7%
associate-/r/99.6%
div-sub99.6%
*-inverses99.6%
Simplified99.6%
Taylor expanded in B around 0 96.2%
Final simplification98.2%
(FPCore (B x) :precision binary64 (if (<= x -1700.0) (- (/ 1.0 B) (/ x (tan B))) (if (<= x 1650.0) (/ (- 1.0 x) (sin B)) (/ -1.0 (/ (tan B) x)))))
double code(double B, double x) {
double tmp;
if (x <= -1700.0) {
tmp = (1.0 / B) - (x / tan(B));
} else if (x <= 1650.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = -1.0 / (tan(B) / x);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1700.0d0)) then
tmp = (1.0d0 / b) - (x / tan(b))
else if (x <= 1650.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (-1.0d0) / (tan(b) / x)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1700.0) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else if (x <= 1650.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = -1.0 / (Math.tan(B) / x);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1700.0: tmp = (1.0 / B) - (x / math.tan(B)) elif x <= 1650.0: tmp = (1.0 - x) / math.sin(B) else: tmp = -1.0 / (math.tan(B) / x) return tmp
function code(B, x) tmp = 0.0 if (x <= -1700.0) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); elseif (x <= 1650.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(-1.0 / Float64(tan(B) / x)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1700.0) tmp = (1.0 / B) - (x / tan(B)); elseif (x <= 1650.0) tmp = (1.0 - x) / sin(B); else tmp = -1.0 / (tan(B) / x); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1700.0], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1650.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1700:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 1650:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\tan B}{x}}\\
\end{array}
\end{array}
if x < -1700Initial 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 98.7%
if -1700 < x < 1650Initial program 99.8%
+-commutative99.8%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub88.0%
*-un-lft-identity88.0%
*-commutative88.0%
*-un-lft-identity88.0%
Applied egg-rr88.0%
associate-/r*99.6%
associate-/r/69.3%
div-sub69.3%
*-inverses69.3%
Simplified69.3%
Taylor expanded in B around inf 99.6%
Taylor expanded in B around 0 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-rgt-in98.6%
lft-mult-inverse98.7%
mul-1-neg98.7%
unsub-neg98.7%
Simplified98.7%
if 1650 < x Initial program 99.6%
Taylor expanded in x around inf 96.0%
clear-num95.9%
un-div-inv95.9%
/-rgt-identity95.9%
div-inv95.9%
metadata-eval95.9%
*-commutative95.9%
frac-times95.9%
tan-quot96.0%
div-inv96.1%
Applied egg-rr96.1%
(FPCore (B x) :precision binary64 (if (<= x -55000000.0) (/ x (- (tan B))) (if (<= x 1650.0) (/ (- 1.0 x) (sin B)) (/ -1.0 (/ (tan B) x)))))
double code(double B, double x) {
double tmp;
if (x <= -55000000.0) {
tmp = x / -tan(B);
} else if (x <= 1650.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = -1.0 / (tan(B) / x);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-55000000.0d0)) then
tmp = x / -tan(b)
else if (x <= 1650.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (-1.0d0) / (tan(b) / x)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -55000000.0) {
tmp = x / -Math.tan(B);
} else if (x <= 1650.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = -1.0 / (Math.tan(B) / x);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -55000000.0: tmp = x / -math.tan(B) elif x <= 1650.0: tmp = (1.0 - x) / math.sin(B) else: tmp = -1.0 / (math.tan(B) / x) return tmp
function code(B, x) tmp = 0.0 if (x <= -55000000.0) tmp = Float64(x / Float64(-tan(B))); elseif (x <= 1650.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(-1.0 / Float64(tan(B) / x)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -55000000.0) tmp = x / -tan(B); elseif (x <= 1650.0) tmp = (1.0 - x) / sin(B); else tmp = -1.0 / (tan(B) / x); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -55000000.0], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision], If[LessEqual[x, 1650.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -55000000:\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{elif}\;x \leq 1650:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\tan B}{x}}\\
\end{array}
\end{array}
if x < -5.5e7Initial program 99.5%
Taylor expanded in x around inf 99.5%
div-inv99.6%
associate-*l*99.4%
div-inv99.6%
clear-num99.4%
tan-quot99.5%
un-div-inv99.7%
associate-*r/99.7%
neg-mul-199.7%
Applied egg-rr99.7%
if -5.5e7 < x < 1650Initial program 99.8%
+-commutative99.8%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub88.2%
*-un-lft-identity88.2%
*-commutative88.2%
*-un-lft-identity88.2%
Applied egg-rr88.2%
associate-/r*99.6%
associate-/r/69.9%
div-sub69.9%
*-inverses69.9%
Simplified69.9%
Taylor expanded in B around inf 99.6%
Taylor expanded in B around 0 98.0%
sub-neg98.0%
metadata-eval98.0%
distribute-rgt-in98.0%
lft-mult-inverse98.1%
mul-1-neg98.1%
unsub-neg98.1%
Simplified98.1%
if 1650 < x Initial program 99.6%
Taylor expanded in x around inf 96.0%
clear-num95.9%
un-div-inv95.9%
/-rgt-identity95.9%
div-inv95.9%
metadata-eval95.9%
*-commutative95.9%
frac-times95.9%
tan-quot96.0%
div-inv96.1%
Applied egg-rr96.1%
Final simplification98.1%
(FPCore (B x) :precision binary64 (if (<= x -1.05) (/ x (- (tan B))) (if (<= x 1.0) (/ 1.0 (sin B)) (/ -1.0 (/ (tan B) x)))))
double code(double B, double x) {
double tmp;
if (x <= -1.05) {
tmp = x / -tan(B);
} else if (x <= 1.0) {
tmp = 1.0 / sin(B);
} else {
tmp = -1.0 / (tan(B) / x);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.05d0)) then
tmp = x / -tan(b)
else if (x <= 1.0d0) then
tmp = 1.0d0 / sin(b)
else
tmp = (-1.0d0) / (tan(b) / x)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.05) {
tmp = x / -Math.tan(B);
} else if (x <= 1.0) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = -1.0 / (Math.tan(B) / x);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.05: tmp = x / -math.tan(B) elif x <= 1.0: tmp = 1.0 / math.sin(B) else: tmp = -1.0 / (math.tan(B) / x) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.05) tmp = Float64(x / Float64(-tan(B))); elseif (x <= 1.0) tmp = Float64(1.0 / sin(B)); else tmp = Float64(-1.0 / Float64(tan(B) / x)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.05) tmp = x / -tan(B); elseif (x <= 1.0) tmp = 1.0 / sin(B); else tmp = -1.0 / (tan(B) / x); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.05], N[(x / (-N[Tan[B], $MachinePrecision])), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05:\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\tan B}{x}}\\
\end{array}
\end{array}
if x < -1.05000000000000004Initial program 99.5%
Taylor expanded in x around inf 94.8%
div-inv94.8%
associate-*l*94.7%
div-inv94.8%
clear-num94.7%
tan-quot94.8%
un-div-inv94.9%
associate-*r/94.9%
neg-mul-194.9%
Applied egg-rr94.9%
if -1.05000000000000004 < x < 1Initial program 99.8%
Taylor expanded in x around 0 97.0%
if 1 < x Initial program 99.6%
Taylor expanded in x around inf 96.0%
clear-num95.9%
un-div-inv95.9%
/-rgt-identity95.9%
div-inv95.9%
metadata-eval95.9%
*-commutative95.9%
frac-times95.9%
tan-quot96.0%
div-inv96.1%
Applied egg-rr96.1%
Final simplification96.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.72) (not (<= x 1.0))) (/ x (- (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.72) || !(x <= 1.0)) {
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.72d0)) .or. (.not. (x <= 1.0d0))) 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.72) || !(x <= 1.0)) {
tmp = x / -Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.72) or not (x <= 1.0): tmp = x / -math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.72) || !(x <= 1.0)) 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.72) || ~((x <= 1.0))) tmp = x / -tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.72], N[Not[LessEqual[x, 1.0]], $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.72 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{-\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.71999999999999997 or 1 < x Initial program 99.6%
Taylor expanded in x around inf 95.3%
div-inv95.3%
associate-*l*95.2%
div-inv95.3%
clear-num95.2%
tan-quot95.3%
un-div-inv95.4%
associate-*r/95.4%
neg-mul-195.4%
Applied egg-rr95.4%
if -1.71999999999999997 < x < 1Initial program 99.8%
Taylor expanded in x around 0 97.0%
Final simplification96.3%
(FPCore (B x) :precision binary64 (if (<= B 0.00029) (/ (- 1.0 x) B) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 0.00029) {
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 <= 0.00029d0) 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 <= 0.00029) {
tmp = (1.0 - x) / B;
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 0.00029: tmp = (1.0 - x) / B else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 0.00029) 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 <= 0.00029) tmp = (1.0 - x) / B; else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 0.00029], 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 0.00029:\\
\;\;\;\;\frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 2.9e-4Initial program 99.8%
Taylor expanded in B around 0 68.2%
if 2.9e-4 < B Initial program 99.5%
Taylor expanded in x around 0 45.2%
(FPCore (B x) :precision binary64 (if (or (<= x -0.7) (not (<= x 116000.0))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -0.7) || !(x <= 116000.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 <= (-0.7d0)) .or. (.not. (x <= 116000.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 <= -0.7) || !(x <= 116000.0)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.7) or not (x <= 116000.0): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.7) || !(x <= 116000.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 <= -0.7) || ~((x <= 116000.0))) tmp = x / -B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.7], N[Not[LessEqual[x, 116000.0]], $MachinePrecision]], N[(x / (-B)), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.7 \lor \neg \left(x \leq 116000\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -0.69999999999999996 or 116000 < x Initial program 99.6%
Taylor expanded in B around 0 47.5%
Taylor expanded in x around inf 45.4%
neg-mul-145.4%
Simplified45.4%
if -0.69999999999999996 < x < 116000Initial program 99.8%
Taylor expanded in B around 0 59.8%
Taylor expanded in x around 0 58.3%
Final simplification52.6%
(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 54.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 54.4%
Taylor expanded in x around 0 34.0%
herbie shell --seed 2024175
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))