
(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 x) -1.0) (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 / 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 <= (-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 / x) + (-1.0d0)) / 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 / x) + -1.0) / 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 / x) + -1.0) / 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(Float64(1.0 / x) + -1.0) / 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 / x) + -1.0) / 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[(N[(1.0 / x), $MachinePrecision] + -1.0), $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{\frac{1}{x} + -1}{\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%
frac-2neg99.8%
metadata-eval99.8%
clear-num99.8%
frac-sub90.1%
Applied egg-rr90.1%
associate-/r*99.7%
associate-/r/99.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 x) -1.0) (/ (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 / x) + -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.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 / x) + (-1.0d0)) / (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 / x) + -1.0) / (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 / x) + -1.0) / (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(Float64(1.0 / x) + -1.0) / 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 / x) + -1.0) / (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[(N[(1.0 / x), $MachinePrecision] + -1.0), $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{\frac{1}{x} + -1}{\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%
div-sub99.8%
*-inverses99.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 (if (or (<= x -1.9) (not (<= x 1.05))) (/ -1.0 (/ (tan B) x)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.9) || !(x <= 1.05)) {
tmp = -1.0 / (tan(B) / x);
} 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.9d0)) .or. (.not. (x <= 1.05d0))) then
tmp = (-1.0d0) / (tan(b) / x)
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.9) || !(x <= 1.05)) {
tmp = -1.0 / (Math.tan(B) / x);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.9) or not (x <= 1.05): tmp = -1.0 / (math.tan(B) / x) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.9) || !(x <= 1.05)) tmp = Float64(-1.0 / Float64(tan(B) / x)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.9) || ~((x <= 1.05))) tmp = -1.0 / (tan(B) / x); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.9], N[Not[LessEqual[x, 1.05]], $MachinePrecision]], N[(-1.0 / N[(N[Tan[B], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \lor \neg \left(x \leq 1.05\right):\\
\;\;\;\;\frac{-1}{\frac{\tan B}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.8999999999999999 or 1.05000000000000004 < 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.7%
frac-sub92.4%
*-un-lft-identity92.4%
*-commutative92.4%
*-un-lft-identity92.4%
Applied egg-rr92.4%
associate-/r*99.6%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in x around inf 98.5%
if -1.8999999999999999 < x < 1.05000000000000004Initial 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 x around 0 98.5%
Final simplification98.5%
(FPCore (B x)
:precision binary64
(let* ((t_0 (/ (- 1.0 x) B)))
(if (<= x -3.2e-6)
(+ (* 0.3333333333333333 (* B x)) t_0)
(if (<= x 7e-8) (/ 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 <= -3.2e-6) {
tmp = (0.3333333333333333 * (B * x)) + t_0;
} else if (x <= 7e-8) {
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 <= (-3.2d-6)) then
tmp = (0.3333333333333333d0 * (b * x)) + t_0
else if (x <= 7d-8) 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 <= -3.2e-6) {
tmp = (0.3333333333333333 * (B * x)) + t_0;
} else if (x <= 7e-8) {
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 <= -3.2e-6: tmp = (0.3333333333333333 * (B * x)) + t_0 elif x <= 7e-8: 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 <= -3.2e-6) tmp = Float64(Float64(0.3333333333333333 * Float64(B * x)) + t_0); elseif (x <= 7e-8) 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 <= -3.2e-6) tmp = (0.3333333333333333 * (B * x)) + t_0; elseif (x <= 7e-8) 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, -3.2e-6], N[(N[(0.3333333333333333 * N[(B * x), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[x, 7e-8], 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 -3.2 \cdot 10^{-6}:\\
\;\;\;\;0.3333333333333333 \cdot \left(B \cdot x\right) + t_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-8}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;t_0 + B \cdot 0.16666666666666666\\
\end{array}
\end{array}
if x < -3.1999999999999999e-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%
*-commutative44.0%
div-sub44.0%
Simplified44.0%
Taylor expanded in x around inf 44.0%
if -3.1999999999999999e-6 < 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%
if 7.00000000000000048e-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 59.7%
+-commutative59.7%
mul-1-neg59.7%
sub-neg59.7%
associate--l+59.7%
*-commutative59.7%
*-commutative59.7%
div-sub59.7%
Simplified59.7%
Taylor expanded in x around 0 60.3%
*-commutative60.3%
Simplified60.3%
Final simplification74.7%
(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%
+-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%
*-commutative46.7%
div-sub46.7%
Simplified46.7%
Taylor expanded in x around inf 47.0%
Final simplification47.0%
(FPCore (B x) :precision binary64 (+ (/ (- 1.0 x) B) (* B 0.16666666666666666)))
double code(double B, double x) {
return ((1.0 - x) / B) + (B * 0.16666666666666666);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 - x) / b) + (b * 0.16666666666666666d0)
end function
public static double code(double B, double x) {
return ((1.0 - x) / B) + (B * 0.16666666666666666);
}
def code(B, x): return ((1.0 - x) / B) + (B * 0.16666666666666666)
function code(B, x) return Float64(Float64(Float64(1.0 - x) / B) + Float64(B * 0.16666666666666666)) end
function tmp = code(B, x) tmp = ((1.0 - x) / B) + (B * 0.16666666666666666); end
code[B_, x_] := N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(B * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B} + B \cdot 0.16666666666666666
\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%
*-commutative46.7%
div-sub46.7%
Simplified46.7%
Taylor expanded in x around 0 46.8%
*-commutative46.8%
Simplified46.8%
Final simplification46.8%
(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%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 49.8%
neg-mul-149.8%
sub-neg49.8%
Simplified49.8%
clear-num49.7%
inv-pow49.7%
Applied egg-rr49.7%
unpow-149.7%
Simplified49.7%
Taylor expanded in x around inf 49.4%
mul-1-neg49.4%
distribute-neg-frac49.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%
neg-mul-143.4%
sub-neg43.4%
Simplified43.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 (/ 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 46.6%
neg-mul-146.6%
sub-neg46.6%
Simplified46.6%
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))))