
(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%
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 -820.0) (/ (- 1.0 x) (tan B)) (if (<= x 1.0) (/ (- 1.0 x) (sin B)) (* (/ x (tan B)) (+ -1.0 (/ 1.0 x))))))
double code(double B, double x) {
double tmp;
if (x <= -820.0) {
tmp = (1.0 - x) / tan(B);
} else if (x <= 1.0) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (x / tan(B)) * (-1.0 + (1.0 / x));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-820.0d0)) then
tmp = (1.0d0 - x) / tan(b)
else if (x <= 1.0d0) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (x / tan(b)) * ((-1.0d0) + (1.0d0 / x))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -820.0) {
tmp = (1.0 - x) / Math.tan(B);
} else if (x <= 1.0) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (x / Math.tan(B)) * (-1.0 + (1.0 / x));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -820.0: tmp = (1.0 - x) / math.tan(B) elif x <= 1.0: tmp = (1.0 - x) / math.sin(B) else: tmp = (x / math.tan(B)) * (-1.0 + (1.0 / x)) return tmp
function code(B, x) tmp = 0.0 if (x <= -820.0) tmp = Float64(Float64(1.0 - x) / tan(B)); elseif (x <= 1.0) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(x / tan(B)) * Float64(-1.0 + Float64(1.0 / x))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -820.0) tmp = (1.0 - x) / tan(B); elseif (x <= 1.0) tmp = (1.0 - x) / sin(B); else tmp = (x / tan(B)) * (-1.0 + (1.0 / x)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -820.0], N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -820:\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\tan B} \cdot \left(-1 + \frac{1}{x}\right)\\
\end{array}
\end{array}
if x < -820Initial program 99.6%
+-commutative99.6%
div-inv99.8%
sub-neg99.8%
clear-num99.6%
frac-sub91.8%
*-un-lft-identity91.8%
*-commutative91.8%
*-un-lft-identity91.8%
Applied egg-rr91.8%
associate-/r*99.6%
associate-/r/99.6%
div-sub99.6%
*-inverses99.6%
Simplified99.6%
Taylor expanded in B around 0 99.6%
*-commutative99.6%
clear-num99.6%
un-div-inv99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
associate-/l*99.8%
distribute-rgt-in99.8%
neg-mul-199.8%
unsub-neg99.8%
lft-mult-inverse99.8%
Simplified99.8%
if -820 < x < 1Initial program 99.8%
+-commutative99.8%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub87.2%
*-un-lft-identity87.2%
*-commutative87.2%
*-un-lft-identity87.2%
Applied egg-rr87.2%
associate-/r*99.5%
associate-/r/80.4%
div-sub80.4%
*-inverses80.4%
Simplified80.4%
Taylor expanded in B around inf 99.6%
Taylor expanded in B around 0 98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-in99.0%
neg-mul-199.0%
unsub-neg99.0%
lft-mult-inverse99.0%
Simplified99.0%
if 1 < x Initial program 99.7%
+-commutative99.7%
div-inv99.8%
sub-neg99.8%
clear-num99.6%
frac-sub93.0%
*-un-lft-identity93.0%
*-commutative93.0%
*-un-lft-identity93.0%
Applied egg-rr93.0%
associate-/r*99.6%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in B around 0 98.3%
*-commutative98.3%
clear-num98.3%
un-div-inv98.4%
sub-neg98.4%
metadata-eval98.4%
Applied egg-rr98.4%
associate-/r/98.4%
+-commutative98.4%
Simplified98.4%
Final simplification99.1%
(FPCore (B x) :precision binary64 (if (or (<= x -1.4) (not (<= x 1.0))) (* x (/ -1.0 (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.4) || !(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.4d0)) .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.4) || !(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.4) 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.4) || !(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.4) || ~((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.4], 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.4 \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.3999999999999999 or 1 < x Initial program 99.7%
+-commutative99.7%
div-inv99.8%
sub-neg99.8%
clear-num99.6%
frac-sub91.7%
*-un-lft-identity91.7%
*-commutative91.7%
*-un-lft-identity91.7%
Applied egg-rr91.7%
associate-/r*99.6%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in B around 0 99.0%
Taylor expanded in x around inf 98.5%
if -1.3999999999999999 < x < 1Initial program 99.8%
Taylor expanded in x around 0 98.0%
Final simplification98.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1150000.0) (not (<= x 980000.0))) (* x (/ -1.0 (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1150000.0) || !(x <= 980000.0)) {
tmp = x * (-1.0 / 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 <= (-1150000.0d0)) .or. (.not. (x <= 980000.0d0))) then
tmp = x * ((-1.0d0) / 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 <= -1150000.0) || !(x <= 980000.0)) {
tmp = x * (-1.0 / Math.tan(B));
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1150000.0) or not (x <= 980000.0): tmp = x * (-1.0 / math.tan(B)) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1150000.0) || !(x <= 980000.0)) tmp = Float64(x * Float64(-1.0 / 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 <= -1150000.0) || ~((x <= 980000.0))) tmp = x * (-1.0 / tan(B)); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1150000.0], N[Not[LessEqual[x, 980000.0]], $MachinePrecision]], N[(x * N[(-1.0 / 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 -1150000 \lor \neg \left(x \leq 980000\right):\\
\;\;\;\;x \cdot \frac{-1}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.15e6 or 9.8e5 < x Initial program 99.7%
+-commutative99.7%
div-inv99.8%
sub-neg99.8%
clear-num99.6%
frac-sub92.3%
*-un-lft-identity92.3%
*-commutative92.3%
*-un-lft-identity92.3%
Applied egg-rr92.3%
associate-/r*99.6%
associate-/r/99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
Taylor expanded in B around 0 99.0%
Taylor expanded in x around inf 99.0%
if -1.15e6 < x < 9.8e5Initial program 99.8%
+-commutative99.8%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub87.2%
*-un-lft-identity87.2%
*-commutative87.2%
*-un-lft-identity87.2%
Applied egg-rr87.2%
associate-/r*99.5%
associate-/r/80.4%
div-sub80.4%
*-inverses80.4%
Simplified80.4%
Taylor expanded in B around inf 99.6%
Taylor expanded in B around 0 98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-in99.0%
neg-mul-199.0%
unsub-neg99.0%
lft-mult-inverse99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (B x) :precision binary64 (if (or (<= x -820.0) (not (<= x 2.8e-9))) (/ (- 1.0 x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -820.0) || !(x <= 2.8e-9)) {
tmp = (1.0 - 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 <= (-820.0d0)) .or. (.not. (x <= 2.8d-9))) then
tmp = (1.0d0 - 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 <= -820.0) || !(x <= 2.8e-9)) {
tmp = (1.0 - x) / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -820.0) or not (x <= 2.8e-9): tmp = (1.0 - x) / math.tan(B) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -820.0) || !(x <= 2.8e-9)) tmp = Float64(Float64(1.0 - 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 <= -820.0) || ~((x <= 2.8e-9))) tmp = (1.0 - x) / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -820.0], N[Not[LessEqual[x, 2.8e-9]], $MachinePrecision]], N[(N[(1.0 - x), $MachinePrecision] / 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 -820 \lor \neg \left(x \leq 2.8 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -820 or 2.79999999999999984e-9 < x Initial program 99.7%
+-commutative99.7%
div-inv99.8%
sub-neg99.8%
clear-num99.6%
frac-sub91.7%
*-un-lft-identity91.7%
*-commutative91.7%
*-un-lft-identity91.7%
Applied egg-rr91.7%
associate-/r*99.5%
associate-/r/99.6%
div-sub99.6%
*-inverses99.6%
Simplified99.6%
Taylor expanded in B around 0 99.0%
*-commutative99.0%
clear-num99.0%
un-div-inv99.2%
sub-neg99.2%
metadata-eval99.2%
Applied egg-rr99.2%
associate-/l*99.2%
distribute-rgt-in99.2%
neg-mul-199.2%
unsub-neg99.2%
lft-mult-inverse99.2%
Simplified99.2%
if -820 < x < 2.79999999999999984e-9Initial program 99.8%
+-commutative99.8%
div-inv99.8%
sub-neg99.8%
clear-num99.8%
frac-sub87.8%
*-un-lft-identity87.8%
*-commutative87.8%
*-un-lft-identity87.8%
Applied egg-rr87.8%
associate-/r*99.5%
associate-/r/80.1%
div-sub80.1%
*-inverses80.1%
Simplified80.1%
Taylor expanded in B around inf 99.6%
Taylor expanded in B around 0 98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-in98.9%
neg-mul-198.9%
unsub-neg98.9%
lft-mult-inverse99.0%
Simplified99.0%
Final simplification99.1%
(FPCore (B x) :precision binary64 (if (<= B 0.062) (+ (* B (+ 0.16666666666666666 (* x 0.3333333333333333))) (/ (- 1.0 x) B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if (B <= 0.062) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / 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 (b <= 0.062d0) then
tmp = (b * (0.16666666666666666d0 + (x * 0.3333333333333333d0))) + ((1.0d0 - x) / b)
else
tmp = 1.0d0 / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= 0.062) {
tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 0.062: tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (B <= 0.062) tmp = Float64(Float64(B * Float64(0.16666666666666666 + Float64(x * 0.3333333333333333))) + Float64(Float64(1.0 - x) / B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 0.062) tmp = (B * (0.16666666666666666 + (x * 0.3333333333333333))) + ((1.0 - x) / B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 0.062], N[(N[(B * N[(0.16666666666666666 + N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.062:\\
\;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if B < 0.062Initial program 99.8%
Taylor expanded in B around 0 63.8%
associate--l+63.8%
*-commutative63.8%
div-sub63.8%
Simplified63.8%
if 0.062 < B Initial program 99.6%
Taylor expanded in x around 0 54.4%
Final simplification61.3%
(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.7%
Taylor expanded in B around 0 46.3%
Taylor expanded in x around inf 45.8%
neg-mul-145.8%
distribute-neg-frac45.8%
Simplified45.8%
if -1 < x < 1Initial program 99.8%
Taylor expanded in B around 0 49.3%
Taylor expanded in x around 0 48.2%
Final simplification47.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%
Taylor expanded in B around 0 75.3%
Taylor expanded in B around 0 48.1%
associate--l+48.1%
*-commutative48.1%
*-commutative48.1%
div-sub48.1%
Simplified48.1%
Final simplification48.1%
(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%
Taylor expanded in B around 0 47.8%
Final simplification47.8%
(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%
Taylor expanded in B around 0 47.8%
Taylor expanded in x around 0 24.8%
Final simplification24.8%
herbie shell --seed 2024030
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))