
(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 11 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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -200000.0) (not (<= x 145.0))) (/ (- x) (tan B)) (/ (/ (* B (- 1.0 x)) (sin B)) B)))
double code(double B, double x) {
double tmp;
if ((x <= -200000.0) || !(x <= 145.0)) {
tmp = -x / tan(B);
} else {
tmp = ((B * (1.0 - x)) / sin(B)) / B;
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-200000.0d0)) .or. (.not. (x <= 145.0d0))) then
tmp = -x / tan(b)
else
tmp = ((b * (1.0d0 - x)) / sin(b)) / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -200000.0) || !(x <= 145.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = ((B * (1.0 - x)) / Math.sin(B)) / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -200000.0) or not (x <= 145.0): tmp = -x / math.tan(B) else: tmp = ((B * (1.0 - x)) / math.sin(B)) / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -200000.0) || !(x <= 145.0)) tmp = Float64(Float64(-x) / tan(B)); else tmp = Float64(Float64(Float64(B * Float64(1.0 - x)) / sin(B)) / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -200000.0) || ~((x <= 145.0))) tmp = -x / tan(B); else tmp = ((B * (1.0 - x)) / sin(B)) / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -200000.0], N[Not[LessEqual[x, 145.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(N[(B * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -200000 \lor \neg \left(x \leq 145\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{B \cdot \left(1 - x\right)}{\sin B}}{B}\\
\end{array}
\end{array}
if x < -2e5 or 145 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
un-div-inv99.7%
add-sqr-sqrt49.8%
sqrt-unprod41.3%
sqr-neg41.3%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
frac-2neg0.5%
div-inv0.5%
fma-def0.5%
add-sqr-sqrt0.2%
sqrt-unprod31.9%
sqr-neg31.9%
sqrt-unprod49.6%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
associate-/l*97.4%
Simplified97.4%
associate-/r/97.5%
*-un-lft-identity97.5%
*-commutative97.5%
*-commutative97.5%
clear-num97.5%
un-div-inv97.5%
quot-tan97.6%
Applied egg-rr97.6%
if -2e5 < x < 145Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 98.9%
frac-sub65.7%
associate-/r*98.9%
*-un-lft-identity98.9%
*-commutative98.9%
Applied egg-rr98.9%
Taylor expanded in B around 0 99.0%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -125000.0) (not (<= x 145.0))) (/ (- x) (tan B)) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -125000.0) || !(x <= 145.0)) {
tmp = -x / tan(B);
} else {
tmp = (1.0 / sin(B)) - (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 <= (-125000.0d0)) .or. (.not. (x <= 145.0d0))) then
tmp = -x / tan(b)
else
tmp = (1.0d0 / sin(b)) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -125000.0) || !(x <= 145.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -125000.0) or not (x <= 145.0): tmp = -x / math.tan(B) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -125000.0) || !(x <= 145.0)) tmp = Float64(Float64(-x) / tan(B)); else tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -125000.0) || ~((x <= 145.0))) tmp = -x / tan(B); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -125000.0], N[Not[LessEqual[x, 145.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -125000 \lor \neg \left(x \leq 145\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -125000 or 145 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
un-div-inv99.7%
add-sqr-sqrt49.8%
sqrt-unprod41.3%
sqr-neg41.3%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
frac-2neg0.5%
div-inv0.5%
fma-def0.5%
add-sqr-sqrt0.2%
sqrt-unprod31.9%
sqr-neg31.9%
sqrt-unprod49.6%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
associate-/l*97.4%
Simplified97.4%
associate-/r/97.5%
*-un-lft-identity97.5%
*-commutative97.5%
*-commutative97.5%
clear-num97.5%
un-div-inv97.5%
quot-tan97.6%
Applied egg-rr97.6%
if -125000 < x < 145Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 98.9%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.7) (not (<= x 1.0))) (* x (/ -1.0 (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.7) || !(x <= 1.0)) {
tmp = x * (-1.0 / 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.7d0)) .or. (.not. (x <= 1.0d0))) then
tmp = x * ((-1.0d0) / 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.7) || !(x <= 1.0)) {
tmp = x * (-1.0 / Math.tan(B));
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.7) or not (x <= 1.0): tmp = x * (-1.0 / math.tan(B)) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.7) || !(x <= 1.0)) tmp = Float64(x * Float64(-1.0 / 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.7) || ~((x <= 1.0))) tmp = x * (-1.0 / tan(B)); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.7], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;x \cdot \frac{-1}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.69999999999999996 or 1 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
un-div-inv99.7%
add-sqr-sqrt50.6%
sqrt-unprod42.3%
sqr-neg42.3%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
frac-2neg0.5%
div-inv0.5%
fma-def0.5%
add-sqr-sqrt0.2%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod48.8%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 96.3%
mul-1-neg96.3%
associate-/l*96.2%
Simplified96.2%
associate-/r/96.3%
clear-num96.3%
quot-tan96.3%
Applied egg-rr96.3%
if -1.69999999999999996 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 98.7%
Final simplification97.6%
(FPCore (B x)
:precision binary64
(if (<= B -0.049)
(/ 1.0 (sin B))
(if (<= B 9.0)
(+ (* 0.3333333333333333 (* B x)) (/ (- 1.0 x) B))
(/ (/ B (sin B)) B))))
double code(double B, double x) {
double tmp;
if (B <= -0.049) {
tmp = 1.0 / sin(B);
} else if (B <= 9.0) {
tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
} else {
tmp = (B / sin(B)) / 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.049d0)) then
tmp = 1.0d0 / sin(b)
else if (b <= 9.0d0) then
tmp = (0.3333333333333333d0 * (b * x)) + ((1.0d0 - x) / b)
else
tmp = (b / sin(b)) / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= -0.049) {
tmp = 1.0 / Math.sin(B);
} else if (B <= 9.0) {
tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
} else {
tmp = (B / Math.sin(B)) / B;
}
return tmp;
}
def code(B, x): tmp = 0 if B <= -0.049: tmp = 1.0 / math.sin(B) elif B <= 9.0: tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B) else: tmp = (B / math.sin(B)) / B return tmp
function code(B, x) tmp = 0.0 if (B <= -0.049) tmp = Float64(1.0 / sin(B)); elseif (B <= 9.0) tmp = Float64(Float64(0.3333333333333333 * Float64(B * x)) + Float64(Float64(1.0 - x) / B)); else tmp = Float64(Float64(B / sin(B)) / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= -0.049) tmp = 1.0 / sin(B); elseif (B <= 9.0) tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B); else tmp = (B / sin(B)) / B; end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, -0.049], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 9.0], N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(N[(B / N[Sin[B], $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.049:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{elif}\;B \leq 9:\\
\;\;\;\;0.3333333333333333 \cdot \left(B \cdot x\right) + \frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{B}{\sin B}}{B}\\
\end{array}
\end{array}
if B < -0.049000000000000002Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in x around 0 49.9%
if -0.049000000000000002 < B < 9Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 99.4%
+-commutative99.4%
mul-1-neg99.4%
sub-neg99.4%
associate--l+99.4%
*-commutative99.4%
*-commutative99.4%
div-sub99.4%
Simplified99.4%
Taylor expanded in x around inf 99.4%
if 9 < B Initial program 99.5%
+-commutative99.5%
unsub-neg99.5%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in B around 0 55.2%
frac-sub55.1%
associate-/r*55.2%
*-un-lft-identity55.2%
*-commutative55.2%
Applied egg-rr55.2%
Taylor expanded in B around inf 55.0%
Final simplification76.1%
(FPCore (B x) :precision binary64 (if (or (<= x -1.5) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.5) || !(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.5d0)) .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.5) || !(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.5) 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.5) || !(x <= 1.0)) tmp = Float64(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 <= -1.5) || ~((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.5], 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.5 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.5 or 1 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
un-div-inv99.7%
add-sqr-sqrt50.6%
sqrt-unprod42.3%
sqr-neg42.3%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
frac-2neg0.5%
div-inv0.5%
fma-def0.5%
add-sqr-sqrt0.2%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod48.8%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 96.3%
mul-1-neg96.3%
associate-/l*96.2%
Simplified96.2%
associate-/r/96.3%
*-un-lft-identity96.3%
*-commutative96.3%
*-commutative96.3%
clear-num96.3%
un-div-inv96.3%
quot-tan96.4%
Applied egg-rr96.4%
if -1.5 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 98.7%
Final simplification97.6%
(FPCore (B x) :precision binary64 (if (or (<= B -0.0142) (not (<= B 9.0))) (/ 1.0 (sin B)) (+ (* 0.3333333333333333 (* B x)) (/ (- 1.0 x) B))))
double code(double B, double x) {
double tmp;
if ((B <= -0.0142) || !(B <= 9.0)) {
tmp = 1.0 / sin(B);
} else {
tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / 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.0142d0)) .or. (.not. (b <= 9.0d0))) then
tmp = 1.0d0 / sin(b)
else
tmp = (0.3333333333333333d0 * (b * x)) + ((1.0d0 - x) / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.0142) || !(B <= 9.0)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.0142) or not (B <= 9.0): tmp = 1.0 / math.sin(B) else: tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B) return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.0142) || !(B <= 9.0)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(0.3333333333333333 * Float64(B * x)) + Float64(Float64(1.0 - x) / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.0142) || ~((B <= 9.0))) tmp = 1.0 / sin(B); else tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.0142], N[Not[LessEqual[B, 9.0]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.0142 \lor \neg \left(B \leq 9\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(B \cdot x\right) + \frac{1 - x}{B}\\
\end{array}
\end{array}
if B < -0.014200000000000001 or 9 < B Initial program 99.5%
distribute-lft-neg-in99.5%
Simplified99.5%
Taylor expanded in x around 0 52.2%
if -0.014200000000000001 < B < 9Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 99.4%
+-commutative99.4%
mul-1-neg99.4%
sub-neg99.4%
associate--l+99.4%
*-commutative99.4%
*-commutative99.4%
div-sub99.4%
Simplified99.4%
Taylor expanded in x around inf 99.4%
Final simplification76.1%
(FPCore (B x) :precision binary64 (+ (* 0.3333333333333333 (* B x)) (/ (- 1.0 x) B)))
double code(double B, double x) {
return (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (0.3333333333333333d0 * (b * x)) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return (0.3333333333333333 * (B * x)) + ((1.0 - x) / B);
}
def code(B, x): return (0.3333333333333333 * (B * x)) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(0.3333333333333333 * Float64(B * x)) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = (0.3333333333333333 * (B * x)) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.3333333333333333 \cdot \left(B \cdot x\right) + \frac{1 - x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 52.1%
+-commutative52.1%
mul-1-neg52.1%
sub-neg52.1%
associate--l+52.1%
*-commutative52.1%
*-commutative52.1%
div-sub52.1%
Simplified52.1%
Taylor expanded in x around inf 52.4%
Final simplification52.4%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 195.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 195.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 <= (-1.0d0)) .or. (.not. (x <= 195.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 <= -1.0) || !(x <= 195.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 195.0): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 195.0)) tmp = Float64(Float64(-x) / B); else tmp = Float64(1.0 / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 195.0))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 195.0]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 195\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 195 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 49.7%
mul-1-neg49.7%
sub-neg49.7%
Simplified49.7%
Taylor expanded in x around inf 48.4%
mul-1-neg48.4%
distribute-frac-neg48.4%
Simplified48.4%
if -1 < x < 195Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 54.0%
mul-1-neg54.0%
sub-neg54.0%
Simplified54.0%
Taylor expanded in x around 0 53.9%
Final simplification51.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%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 52.0%
mul-1-neg52.0%
sub-neg52.0%
Simplified52.0%
Final simplification52.0%
(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%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 52.0%
mul-1-neg52.0%
sub-neg52.0%
Simplified52.0%
Taylor expanded in x around 0 30.9%
Final simplification30.9%
herbie shell --seed 2023227
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))