
(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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (<= x -4600000000000.0) (/ (- x) (tan B)) (if (<= x 52.0) (- (/ 1.0 (sin B)) (/ x B)) (/ (* x (- (cos B))) (sin B)))))
double code(double B, double x) {
double tmp;
if (x <= -4600000000000.0) {
tmp = -x / tan(B);
} else if (x <= 52.0) {
tmp = (1.0 / sin(B)) - (x / B);
} else {
tmp = (x * -cos(B)) / 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 <= (-4600000000000.0d0)) then
tmp = -x / tan(b)
else if (x <= 52.0d0) then
tmp = (1.0d0 / sin(b)) - (x / b)
else
tmp = (x * -cos(b)) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -4600000000000.0) {
tmp = -x / Math.tan(B);
} else if (x <= 52.0) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = (x * -Math.cos(B)) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -4600000000000.0: tmp = -x / math.tan(B) elif x <= 52.0: tmp = (1.0 / math.sin(B)) - (x / B) else: tmp = (x * -math.cos(B)) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -4600000000000.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 52.0) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); else tmp = Float64(Float64(x * Float64(-cos(B))) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -4600000000000.0) tmp = -x / tan(B); elseif (x <= 52.0) tmp = (1.0 / sin(B)) - (x / B); else tmp = (x * -cos(B)) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -4600000000000.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 52.0], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(x * (-N[Cos[B], $MachinePrecision])), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4600000000000:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 52:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\
\end{array}
\end{array}
if x < -4.6e12Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.3%
mul-1-neg99.3%
associate-*l/99.4%
distribute-rgt-neg-in99.4%
Simplified99.4%
distribute-rgt-neg-out99.4%
neg-sub099.4%
clear-num99.3%
associate-*l/99.4%
*-un-lft-identity99.4%
quot-tan99.5%
Applied egg-rr99.5%
neg-sub099.5%
distribute-neg-frac99.5%
Simplified99.5%
if -4.6e12 < x < 52Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 98.2%
if 52 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
sub-div99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 97.5%
associate-*r*97.5%
neg-mul-197.5%
Simplified97.5%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -4600000000000.0) (not (<= x 52.0))) (/ (- x) (tan B)) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -4600000000000.0) || !(x <= 52.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 <= (-4600000000000.0d0)) .or. (.not. (x <= 52.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 <= -4600000000000.0) || !(x <= 52.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 <= -4600000000000.0) or not (x <= 52.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 <= -4600000000000.0) || !(x <= 52.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 <= -4600000000000.0) || ~((x <= 52.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, -4600000000000.0], N[Not[LessEqual[x, 52.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 -4600000000000 \lor \neg \left(x \leq 52\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -4.6e12 or 52 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
associate-*l/98.3%
distribute-rgt-neg-in98.3%
Simplified98.3%
distribute-rgt-neg-out98.3%
neg-sub098.3%
clear-num98.3%
associate-*l/98.3%
*-un-lft-identity98.3%
quot-tan98.4%
Applied egg-rr98.4%
neg-sub098.4%
distribute-neg-frac98.4%
Simplified98.4%
if -4.6e12 < x < 52Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 98.2%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -4800000000000.0) (not (<= x 52.0))) (/ (- x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -4800000000000.0) || !(x <= 52.0)) {
tmp = -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 <= (-4800000000000.0d0)) .or. (.not. (x <= 52.0d0))) then
tmp = -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 <= -4800000000000.0) || !(x <= 52.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -4800000000000.0) or not (x <= 52.0): tmp = -x / math.tan(B) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -4800000000000.0) || !(x <= 52.0)) tmp = Float64(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 <= -4800000000000.0) || ~((x <= 52.0))) tmp = -x / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -4800000000000.0], N[Not[LessEqual[x, 52.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4800000000000 \lor \neg \left(x \leq 52\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -4.8e12 or 52 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 98.3%
mul-1-neg98.3%
associate-*l/98.3%
distribute-rgt-neg-in98.3%
Simplified98.3%
distribute-rgt-neg-out98.3%
neg-sub098.3%
clear-num98.3%
associate-*l/98.3%
*-un-lft-identity98.3%
quot-tan98.4%
Applied egg-rr98.4%
neg-sub098.4%
distribute-neg-frac98.4%
Simplified98.4%
if -4.8e12 < x < 52Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
sub-div99.8%
Applied egg-rr99.8%
Taylor expanded in B around 0 98.2%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.35) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.35) || !(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.35d0)) .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.35) || !(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.35) 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.35) || !(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.35) || ~((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.35], 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.35 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.3500000000000001 or 1 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 96.3%
mul-1-neg96.3%
associate-*l/96.3%
distribute-rgt-neg-in96.3%
Simplified96.3%
distribute-rgt-neg-out96.3%
neg-sub096.3%
clear-num96.2%
associate-*l/96.3%
*-un-lft-identity96.3%
quot-tan96.4%
Applied egg-rr96.4%
neg-sub096.4%
distribute-neg-frac96.4%
Simplified96.4%
if -1.3500000000000001 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 98.3%
Final simplification97.4%
(FPCore (B x)
:precision binary64
(if (<= x -9.5e-14)
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B))
(if (<= x 780000.0)
(/ 1.0 (sin B))
(- (* x (* B 0.3333333333333333)) (/ x B)))))
double code(double B, double x) {
double tmp;
if (x <= -9.5e-14) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
} else if (x <= 780000.0) {
tmp = 1.0 / sin(B);
} else {
tmp = (x * (B * 0.3333333333333333)) - (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 <= (-9.5d-14)) then
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
else if (x <= 780000.0d0) then
tmp = 1.0d0 / sin(b)
else
tmp = (x * (b * 0.3333333333333333d0)) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -9.5e-14) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
} else if (x <= 780000.0) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (x * (B * 0.3333333333333333)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -9.5e-14: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B) elif x <= 780000.0: tmp = 1.0 / math.sin(B) else: tmp = (x * (B * 0.3333333333333333)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if (x <= -9.5e-14) tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)); elseif (x <= 780000.0) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(x * Float64(B * 0.3333333333333333)) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -9.5e-14) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); elseif (x <= 780000.0) tmp = 1.0 / sin(B); else tmp = (x * (B * 0.3333333333333333)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -9.5e-14], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 780000.0], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(B * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{-14}:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\
\mathbf{elif}\;x \leq 780000:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(B \cdot 0.3333333333333333\right) - \frac{x}{B}\\
\end{array}
\end{array}
if x < -9.4999999999999999e-14Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 67.0%
+-commutative67.0%
mul-1-neg67.0%
sub-neg67.0%
associate--l+67.0%
*-commutative67.0%
*-commutative67.0%
div-sub67.0%
Simplified67.0%
if -9.4999999999999999e-14 < x < 7.8e5Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 97.7%
if 7.8e5 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
associate-*l/99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 48.4%
expm1-log1p-u22.1%
expm1-udef22.1%
+-commutative22.1%
*-commutative22.1%
fma-def22.1%
*-commutative22.1%
distribute-rgt-out--22.1%
metadata-eval22.1%
mul-1-neg22.1%
Applied egg-rr22.1%
expm1-def22.1%
expm1-log1p48.4%
fma-neg48.4%
associate-*r*48.4%
associate-*l*48.4%
metadata-eval48.4%
*-commutative48.4%
*-commutative48.4%
*-commutative48.4%
associate-*l*48.4%
Simplified48.4%
Final simplification78.7%
(FPCore (B x) :precision binary64 (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B)))
double code(double B, double x) {
return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
}
def code(B, x): return (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 54.2%
+-commutative54.2%
mul-1-neg54.2%
sub-neg54.2%
associate--l+54.2%
*-commutative54.2%
*-commutative54.2%
div-sub54.2%
Simplified54.2%
Final simplification54.2%
(FPCore (B x) :precision binary64 (if (or (<= x -2.35e-5) (not (<= x 6.2e+34))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -2.35e-5) || !(x <= 6.2e+34)) {
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 <= (-2.35d-5)) .or. (.not. (x <= 6.2d+34))) 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 <= -2.35e-5) || !(x <= 6.2e+34)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2.35e-5) or not (x <= 6.2e+34): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -2.35e-5) || !(x <= 6.2e+34)) 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 <= -2.35e-5) || ~((x <= 6.2e+34))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2.35e-5], N[Not[LessEqual[x, 6.2e+34]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.35 \cdot 10^{-5} \lor \neg \left(x \leq 6.2 \cdot 10^{+34}\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -2.34999999999999986e-5 or 6.19999999999999955e34 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 56.6%
mul-1-neg56.6%
sub-neg56.6%
Simplified56.6%
Taylor expanded in x around inf 55.1%
neg-mul-155.1%
distribute-neg-frac55.1%
Simplified55.1%
if -2.34999999999999986e-5 < x < 6.19999999999999955e34Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 51.5%
mul-1-neg51.5%
sub-neg51.5%
Simplified51.5%
Taylor expanded in x around 0 51.1%
Final simplification53.0%
(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 53.9%
mul-1-neg53.9%
sub-neg53.9%
Simplified53.9%
Final simplification53.9%
(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 53.9%
mul-1-neg53.9%
sub-neg53.9%
Simplified53.9%
Taylor expanded in x around 0 28.9%
Final simplification28.9%
herbie shell --seed 2023278
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))