
(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 12 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 -750000.0) (not (<= x 525000000.0))) (- (/ (cos B) (/ (sin B) x))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -750000.0) || !(x <= 525000000.0)) {
tmp = -(cos(B) / (sin(B) / x));
} 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 <= (-750000.0d0)) .or. (.not. (x <= 525000000.0d0))) then
tmp = -(cos(b) / (sin(b) / x))
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 <= -750000.0) || !(x <= 525000000.0)) {
tmp = -(Math.cos(B) / (Math.sin(B) / x));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -750000.0) or not (x <= 525000000.0): tmp = -(math.cos(B) / (math.sin(B) / x)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -750000.0) || !(x <= 525000000.0)) tmp = Float64(-Float64(cos(B) / Float64(sin(B) / x))); else tmp = Float64(Float64(1.0 - x) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -750000.0) || ~((x <= 525000000.0))) tmp = -(cos(B) / (sin(B) / x)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -750000.0], N[Not[LessEqual[x, 525000000.0]], $MachinePrecision]], (-N[(N[Cos[B], $MachinePrecision] / N[(N[Sin[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -750000 \lor \neg \left(x \leq 525000000\right):\\
\;\;\;\;-\frac{\cos B}{\frac{\sin B}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -7.5e5 or 5.25e8 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.6%
mul-1-neg99.6%
sub-neg99.6%
*-commutative99.6%
div-sub99.6%
Simplified99.6%
Taylor expanded in x around inf 99.4%
mul-1-neg99.4%
associate-/l*99.4%
Simplified99.4%
if -7.5e5 < x < 5.25e8Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
mul-1-neg99.8%
sub-neg99.8%
*-commutative99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 98.4%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -31000000.0) (not (<= x 840000000.0))) (/ (* (cos B) (- x)) (sin B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -31000000.0) || !(x <= 840000000.0)) {
tmp = (cos(B) * -x) / sin(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 <= (-31000000.0d0)) .or. (.not. (x <= 840000000.0d0))) then
tmp = (cos(b) * -x) / sin(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 <= -31000000.0) || !(x <= 840000000.0)) {
tmp = (Math.cos(B) * -x) / Math.sin(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -31000000.0) or not (x <= 840000000.0): tmp = (math.cos(B) * -x) / math.sin(B) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -31000000.0) || !(x <= 840000000.0)) tmp = Float64(Float64(cos(B) * Float64(-x)) / sin(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 <= -31000000.0) || ~((x <= 840000000.0))) tmp = (cos(B) * -x) / sin(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -31000000.0], N[Not[LessEqual[x, 840000000.0]], $MachinePrecision]], N[(N[(N[Cos[B], $MachinePrecision] * (-x)), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -31000000 \lor \neg \left(x \leq 840000000\right):\\
\;\;\;\;\frac{\cos B \cdot \left(-x\right)}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -3.1e7 or 8.4e8 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.6%
mul-1-neg99.6%
sub-neg99.6%
*-commutative99.6%
div-sub99.6%
Simplified99.6%
Taylor expanded in x around inf 99.4%
associate-*r/99.4%
*-commutative99.4%
neg-mul-199.4%
*-commutative99.4%
distribute-rgt-neg-out99.4%
Simplified99.4%
if -3.1e7 < x < 8.4e8Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
mul-1-neg99.8%
sub-neg99.8%
*-commutative99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 98.4%
Final simplification98.9%
(FPCore (B x) :precision binary64 (if (or (<= x -124000000000.0) (not (<= x 1.22e+48))) (- (+ (/ 1.0 B) (* B 0.16666666666666666)) (/ x (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -124000000000.0) || !(x <= 1.22e+48)) {
tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (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 <= (-124000000000.0d0)) .or. (.not. (x <= 1.22d+48))) then
tmp = ((1.0d0 / b) + (b * 0.16666666666666666d0)) - (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 <= -124000000000.0) || !(x <= 1.22e+48)) {
tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / Math.tan(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -124000000000.0) or not (x <= 1.22e+48): tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / math.tan(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -124000000000.0) || !(x <= 1.22e+48)) tmp = Float64(Float64(Float64(1.0 / B) + Float64(B * 0.16666666666666666)) - 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 <= -124000000000.0) || ~((x <= 1.22e+48))) tmp = ((1.0 / B) + (B * 0.16666666666666666)) - (x / tan(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -124000000000.0], N[Not[LessEqual[x, 1.22e+48]], $MachinePrecision]], N[(N[(N[(1.0 / B), $MachinePrecision] + N[(B * 0.16666666666666666), $MachinePrecision]), $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 -124000000000 \lor \neg \left(x \leq 1.22 \cdot 10^{+48}\right):\\
\;\;\;\;\left(\frac{1}{B} + B \cdot 0.16666666666666666\right) - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.24e11 or 1.22000000000000004e48 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 76.9%
if -1.24e11 < x < 1.22000000000000004e48Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
mul-1-neg99.8%
sub-neg99.8%
*-commutative99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in B around 0 95.2%
Final simplification86.5%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.05))) (/ (- x) (sin B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.05)) {
tmp = -x / sin(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.0d0)) .or. (.not. (x <= 1.05d0))) then
tmp = -x / sin(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.0) || !(x <= 1.05)) {
tmp = -x / Math.sin(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 1.05): tmp = -x / math.sin(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.05)) tmp = Float64(Float64(-x) / sin(B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.05))) tmp = -x / sin(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.05]], $MachinePrecision]], N[((-x) / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.05\right):\\
\;\;\;\;\frac{-x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1 or 1.05000000000000004 < x Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.6%
mul-1-neg99.6%
sub-neg99.6%
*-commutative99.6%
div-sub99.6%
Simplified99.6%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
*-commutative97.9%
neg-mul-197.9%
*-commutative97.9%
distribute-rgt-neg-out97.9%
Simplified97.9%
Taylor expanded in B around 0 47.7%
mul-1-neg47.7%
Simplified47.7%
if -1 < x < 1.05000000000000004Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 98.6%
Final simplification72.2%
(FPCore (B x)
:precision binary64
(let* ((t_0 (/ (- 1.0 x) B)))
(if (<= x -0.009)
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) t_0)
(if (<= x 6.2e-12) (/ 1.0 (sin B)) (+ t_0 (* B 0.16666666666666666))))))
double code(double B, double x) {
double t_0 = (1.0 - x) / B;
double tmp;
if (x <= -0.009) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0;
} else if (x <= 6.2e-12) {
tmp = 1.0 / sin(B);
} else {
tmp = t_0 + (B * 0.16666666666666666);
}
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 = (1.0d0 - x) / b
if (x <= (-0.009d0)) then
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + t_0
else if (x <= 6.2d-12) then
tmp = 1.0d0 / sin(b)
else
tmp = t_0 + (b * 0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double B, double x) {
double t_0 = (1.0 - x) / B;
double tmp;
if (x <= -0.009) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0;
} else if (x <= 6.2e-12) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = t_0 + (B * 0.16666666666666666);
}
return tmp;
}
def code(B, x): t_0 = (1.0 - x) / B tmp = 0 if x <= -0.009: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0 elif x <= 6.2e-12: tmp = 1.0 / math.sin(B) else: tmp = t_0 + (B * 0.16666666666666666) return tmp
function code(B, x) t_0 = Float64(Float64(1.0 - x) / B) tmp = 0.0 if (x <= -0.009) tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + t_0); elseif (x <= 6.2e-12) tmp = Float64(1.0 / sin(B)); else tmp = Float64(t_0 + Float64(B * 0.16666666666666666)); end return tmp end
function tmp_2 = code(B, x) t_0 = (1.0 - x) / B; tmp = 0.0; if (x <= -0.009) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0; elseif (x <= 6.2e-12) tmp = 1.0 / sin(B); else tmp = t_0 + (B * 0.16666666666666666); end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[x, -0.009], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[x, 6.2e-12], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(B * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{B}\\
\mathbf{if}\;x \leq -0.009:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + t_0\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;t_0 + B \cdot 0.16666666666666666\\
\end{array}
\end{array}
if x < -0.00899999999999999932Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 47.4%
+-commutative47.4%
mul-1-neg47.4%
sub-neg47.4%
associate--l+47.4%
*-commutative47.4%
*-commutative47.4%
div-sub47.4%
Simplified47.4%
if -0.00899999999999999932 < x < 6.2000000000000002e-12Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 98.8%
if 6.2000000000000002e-12 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 74.7%
Taylor expanded in B around 0 44.1%
associate--l+44.1%
*-commutative44.1%
sub-div44.1%
Applied egg-rr44.1%
Final simplification71.0%
(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%
Simplified99.7%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.7%
mul-1-neg99.7%
sub-neg99.7%
*-commutative99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 73.0%
Final simplification73.0%
(FPCore (B x) :precision binary64 (+ (/ (- 1.0 x) B) (* 0.3333333333333333 (* B x))))
double code(double B, double x) {
return ((1.0 - x) / B) + (0.3333333333333333 * (B * x));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 - x) / b) + (0.3333333333333333d0 * (b * x))
end function
public static double code(double B, double x) {
return ((1.0 - x) / B) + (0.3333333333333333 * (B * x));
}
def code(B, x): return ((1.0 - x) / B) + (0.3333333333333333 * (B * x))
function code(B, x) return Float64(Float64(Float64(1.0 - x) / B) + Float64(0.3333333333333333 * Float64(B * x))) end
function tmp = code(B, x) tmp = ((1.0 - x) / B) + (0.3333333333333333 * (B * x)); end
code[B_, x_] := N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B} + 0.3333333333333333 \cdot \left(B \cdot x\right)
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
un-div-inv99.8%
neg-mul-199.8%
associate-/l*99.7%
Applied egg-rr99.7%
Taylor expanded in B around inf 99.7%
mul-1-neg99.7%
sub-neg99.7%
*-commutative99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 44.5%
associate--l+44.5%
*-commutative44.5%
cancel-sign-sub-inv44.5%
*-commutative44.5%
metadata-eval44.5%
div-sub44.5%
Simplified44.5%
Taylor expanded in x around inf 45.1%
Final simplification45.1%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(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 <= (-1.0d0)) .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 <= -1.0) || !(x <= 1.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.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 <= 1.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, 1.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 1\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 74.6%
Taylor expanded in B around 0 44.7%
Taylor expanded in x around inf 43.4%
mul-1-neg43.4%
distribute-frac-neg43.4%
Simplified43.4%
if -1 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 44.2%
mul-1-neg44.2%
sub-neg44.2%
Simplified44.2%
Taylor expanded in x around 0 43.9%
Final simplification43.7%
(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 44.4%
mul-1-neg44.4%
sub-neg44.4%
Simplified44.4%
Final simplification44.4%
(FPCore (B x) :precision binary64 (* B 0.16666666666666666))
double code(double B, double x) {
return B * 0.16666666666666666;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = b * 0.16666666666666666d0
end function
public static double code(double B, double x) {
return B * 0.16666666666666666;
}
def code(B, x): return B * 0.16666666666666666
function code(B, x) return Float64(B * 0.16666666666666666) end
function tmp = code(B, x) tmp = B * 0.16666666666666666; end
code[B_, x_] := N[(B * 0.16666666666666666), $MachinePrecision]
\begin{array}{l}
\\
B \cdot 0.16666666666666666
\end{array}
Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 59.8%
Taylor expanded in B around inf 2.9%
*-commutative2.9%
Simplified2.9%
Final simplification2.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 44.4%
mul-1-neg44.4%
sub-neg44.4%
Simplified44.4%
Taylor expanded in x around 0 22.5%
Final simplification22.5%
herbie shell --seed 2023213
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))