
(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%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (<= x -5.2e-6) (- (/ 1.0 B) (/ x (tan B))) (if (<= x 2.5e-8) (/ 1.0 (sin B)) (* x (/ (+ -1.0 (/ 1.0 x)) (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -5.2e-6) {
tmp = (1.0 / B) - (x / tan(B));
} else if (x <= 2.5e-8) {
tmp = 1.0 / sin(B);
} else {
tmp = x * ((-1.0 + (1.0 / 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 <= (-5.2d-6)) then
tmp = (1.0d0 / b) - (x / tan(b))
else if (x <= 2.5d-8) then
tmp = 1.0d0 / sin(b)
else
tmp = x * (((-1.0d0) + (1.0d0 / x)) / tan(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -5.2e-6) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else if (x <= 2.5e-8) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = x * ((-1.0 + (1.0 / x)) / Math.tan(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -5.2e-6: tmp = (1.0 / B) - (x / math.tan(B)) elif x <= 2.5e-8: tmp = 1.0 / math.sin(B) else: tmp = x * ((-1.0 + (1.0 / x)) / math.tan(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -5.2e-6) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); elseif (x <= 2.5e-8) tmp = Float64(1.0 / sin(B)); else tmp = Float64(x * Float64(Float64(-1.0 + Float64(1.0 / x)) / tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -5.2e-6) tmp = (1.0 / B) - (x / tan(B)); elseif (x <= 2.5e-8) tmp = 1.0 / sin(B); else tmp = x * ((-1.0 + (1.0 / x)) / tan(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -5.2e-6], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e-8], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1 + \frac{1}{x}}{\tan B}\\
\end{array}
\end{array}
if x < -5.20000000000000019e-6Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 99.3%
if -5.20000000000000019e-6 < x < 2.4999999999999999e-8Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
if 2.4999999999999999e-8 < x Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
distribute-rgt-neg-out99.7%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub90.1%
*-un-lft-identity90.1%
*-commutative90.1%
*-un-lft-identity90.1%
Applied egg-rr90.1%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in B around 0 98.8%
Final simplification99.2%
(FPCore (B x) :precision binary64 (if (<= x -1.25e-5) (- (/ 1.0 B) (/ x (tan B))) (if (<= x 2.5e-8) (/ 1.0 (sin B)) (/ (+ -1.0 (/ 1.0 x)) (/ (tan B) x)))))
double code(double B, double x) {
double tmp;
if (x <= -1.25e-5) {
tmp = (1.0 / B) - (x / tan(B));
} else if (x <= 2.5e-8) {
tmp = 1.0 / sin(B);
} else {
tmp = (-1.0 + (1.0 / x)) / (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.25d-5)) then
tmp = (1.0d0 / b) - (x / tan(b))
else if (x <= 2.5d-8) then
tmp = 1.0d0 / sin(b)
else
tmp = ((-1.0d0) + (1.0d0 / x)) / (tan(b) / x)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -1.25e-5) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else if (x <= 2.5e-8) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (-1.0 + (1.0 / x)) / (Math.tan(B) / x);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -1.25e-5: tmp = (1.0 / B) - (x / math.tan(B)) elif x <= 2.5e-8: tmp = 1.0 / math.sin(B) else: tmp = (-1.0 + (1.0 / x)) / (math.tan(B) / x) return tmp
function code(B, x) tmp = 0.0 if (x <= -1.25e-5) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); elseif (x <= 2.5e-8) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(-1.0 + Float64(1.0 / x)) / Float64(tan(B) / x)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -1.25e-5) tmp = (1.0 / B) - (x / tan(B)); elseif (x <= 2.5e-8) tmp = 1.0 / sin(B); else tmp = (-1.0 + (1.0 / x)) / (tan(B) / x); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -1.25e-5], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e-8], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 + \frac{1}{x}}{\frac{\tan B}{x}}\\
\end{array}
\end{array}
if x < -1.25000000000000006e-5Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in B around 0 99.3%
if -1.25000000000000006e-5 < x < 2.4999999999999999e-8Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
if 2.4999999999999999e-8 < x Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
distribute-rgt-neg-out99.7%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub90.1%
*-un-lft-identity90.1%
*-commutative90.1%
*-un-lft-identity90.1%
Applied egg-rr90.1%
associate-/r*99.7%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
expm1-log1p-u50.7%
expm1-udef50.7%
*-commutative50.7%
sub-neg50.7%
associate-/l/50.7%
metadata-eval50.7%
Applied egg-rr50.7%
expm1-def50.7%
expm1-log1p99.7%
associate-*r/99.8%
*-commutative99.8%
associate-/l*99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 98.8%
Final simplification99.2%
(FPCore (B x) :precision binary64 (if (or (<= x -1.6e-5) (not (<= x 7e-8))) (- (/ 1.0 B) (/ x (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.6e-5) || !(x <= 7e-8)) {
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 <= (-1.6d-5)) .or. (.not. (x <= 7d-8))) 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 <= -1.6e-5) || !(x <= 7e-8)) {
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 <= -1.6e-5) or not (x <= 7e-8): 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 <= -1.6e-5) || !(x <= 7e-8)) 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 <= -1.6e-5) || ~((x <= 7e-8))) 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, -1.6e-5], N[Not[LessEqual[x, 7e-8]], $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 -1.6 \cdot 10^{-5} \lor \neg \left(x \leq 7 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.59999999999999993e-5 or 7.00000000000000048e-8 < x Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
if -1.59999999999999993e-5 < x < 7.00000000000000048e-8Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
Final simplification99.2%
(FPCore (B x)
:precision binary64
(let* ((t_0 (/ (- 1.0 x) B)))
(if (<= x -7.5e-6)
(+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) t_0)
(if (<= x 6.6e-8) (/ 1.0 (sin B)) t_0))))
double code(double B, double x) {
double t_0 = (1.0 - x) / B;
double tmp;
if (x <= -7.5e-6) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0;
} else if (x <= 6.6e-8) {
tmp = 1.0 / sin(B);
} else {
tmp = 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 = (1.0d0 - x) / b
if (x <= (-7.5d-6)) then
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + t_0
else if (x <= 6.6d-8) then
tmp = 1.0d0 / sin(b)
else
tmp = t_0
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 <= -7.5e-6) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0;
} else if (x <= 6.6e-8) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = t_0;
}
return tmp;
}
def code(B, x): t_0 = (1.0 - x) / B tmp = 0 if x <= -7.5e-6: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0 elif x <= 6.6e-8: tmp = 1.0 / math.sin(B) else: tmp = t_0 return tmp
function code(B, x) t_0 = Float64(Float64(1.0 - x) / B) tmp = 0.0 if (x <= -7.5e-6) tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + t_0); elseif (x <= 6.6e-8) tmp = Float64(1.0 / sin(B)); else tmp = t_0; end return tmp end
function tmp_2 = code(B, x) t_0 = (1.0 - x) / B; tmp = 0.0; if (x <= -7.5e-6) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + t_0; elseif (x <= 6.6e-8) tmp = 1.0 / sin(B); else tmp = t_0; end tmp_2 = tmp; end
code[B_, x_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]}, If[LessEqual[x, -7.5e-6], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[x, 6.6e-8], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 - x}{B}\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{-6}:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + t_0\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.50000000000000019e-6Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 44.0%
+-commutative44.0%
mul-1-neg44.0%
sub-neg44.0%
associate--l+44.0%
*-commutative44.0%
div-sub44.0%
Simplified44.0%
if -7.50000000000000019e-6 < x < 6.59999999999999954e-8Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.4%
if 6.59999999999999954e-8 < x Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 60.3%
neg-mul-160.3%
sub-neg60.3%
Simplified60.3%
Final simplification74.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%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 46.7%
+-commutative46.7%
mul-1-neg46.7%
sub-neg46.7%
associate--l+46.7%
*-commutative46.7%
div-sub46.7%
Simplified46.7%
Final simplification46.7%
(FPCore (B x) :precision binary64 (+ (/ 1.0 B) (- (* x (* B 0.3333333333333333)) (/ x B))))
double code(double B, double x) {
return (1.0 / B) + ((x * (B * 0.3333333333333333)) - (x / B));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / b) + ((x * (b * 0.3333333333333333d0)) - (x / b))
end function
public static double code(double B, double x) {
return (1.0 / B) + ((x * (B * 0.3333333333333333)) - (x / B));
}
def code(B, x): return (1.0 / B) + ((x * (B * 0.3333333333333333)) - (x / B))
function code(B, x) return Float64(Float64(1.0 / B) + Float64(Float64(x * Float64(B * 0.3333333333333333)) - Float64(x / B))) end
function tmp = code(B, x) tmp = (1.0 / B) + ((x * (B * 0.3333333333333333)) - (x / B)); end
code[B_, x_] := N[(N[(1.0 / B), $MachinePrecision] + N[(N[(x * N[(B * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B} + \left(x \cdot \left(B \cdot 0.3333333333333333\right) - \frac{x}{B}\right)
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 71.2%
Taylor expanded in B around 0 47.0%
+-commutative47.0%
mul-1-neg47.0%
unsub-neg47.0%
*-commutative47.0%
*-commutative47.0%
associate-*l*47.0%
Simplified47.0%
Final simplification47.0%
(FPCore (B x) :precision binary64 (if (or (<= x -1.02e-10) (not (<= x 1.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.02e-10) || !(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.02d-10)) .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.02e-10) || !(x <= 1.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.02e-10) 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.02e-10) || !(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.02e-10) || ~((x <= 1.0))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.02e-10], 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.02 \cdot 10^{-10} \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1.01999999999999997e-10 or 1 < x Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-sqr-sqrt46.0%
pow246.0%
inv-pow46.0%
sqrt-pow146.0%
metadata-eval46.0%
Applied egg-rr46.0%
Taylor expanded in B around 0 49.8%
Taylor expanded in x around inf 49.5%
Taylor expanded in B around 0 49.4%
associate-*r/49.4%
neg-mul-149.4%
Simplified49.4%
if -1.01999999999999997e-10 < x < 1Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 43.4%
Taylor expanded in x around 0 42.5%
Final simplification46.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%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 46.6%
neg-mul-146.6%
sub-neg46.6%
Simplified46.6%
Final simplification46.6%
(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%
distribute-lft-neg-in99.7%
+-commutative99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
add-sqr-sqrt49.3%
pow249.3%
inv-pow49.3%
sqrt-pow149.3%
metadata-eval49.3%
Applied egg-rr49.3%
Taylor expanded in B around 0 46.7%
Taylor expanded in B around inf 2.7%
Taylor expanded in x around 0 3.0%
*-commutative3.0%
Simplified3.0%
Final simplification3.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%
+-commutative99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 71.2%
Taylor expanded in x around 0 22.3%
Final simplification22.3%
herbie shell --seed 2023309
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))