
(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 (cos B)) x) (tan B)))
double code(double B, double x) {
return ((1.0 / cos(B)) - x) / tan(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 / cos(b)) - x) / tan(b)
end function
public static double code(double B, double x) {
return ((1.0 / Math.cos(B)) - x) / Math.tan(B);
}
def code(B, x): return ((1.0 / math.cos(B)) - x) / math.tan(B)
function code(B, x) return Float64(Float64(Float64(1.0 / cos(B)) - x) / tan(B)) end
function tmp = code(B, x) tmp = ((1.0 / cos(B)) - x) / tan(B); end
code[B_, x_] := N[(N[(N[(1.0 / N[Cos[B], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\cos B} - x}{\tan B}
\end{array}
Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
associate-/l*99.6%
un-div-inv99.6%
associate-/r*99.6%
frac-sub99.6%
*-un-lft-identity99.6%
un-div-inv99.6%
tan-quot99.7%
Applied egg-rr99.7%
div-sub99.7%
*-rgt-identity99.7%
times-frac99.6%
/-rgt-identity99.6%
times-frac83.6%
*-commutative83.6%
times-frac99.7%
*-inverses99.7%
*-lft-identity99.7%
Simplified99.7%
sub-neg99.7%
div-inv99.7%
frac-times99.7%
metadata-eval99.7%
Applied egg-rr99.7%
unsub-neg99.7%
associate-/r*99.7%
div-sub99.7%
Simplified99.7%
Final simplification99.7%
(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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (B x) :precision binary64 (if (or (<= x -420000.0) (not (<= x 4e-10))) (/ (- 1.0 x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -420000.0) || !(x <= 4e-10)) {
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 <= (-420000.0d0)) .or. (.not. (x <= 4d-10))) 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 <= -420000.0) || !(x <= 4e-10)) {
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 <= -420000.0) or not (x <= 4e-10): 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 <= -420000.0) || !(x <= 4e-10)) 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 <= -420000.0) || ~((x <= 4e-10))) 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, -420000.0], N[Not[LessEqual[x, 4e-10]], $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 -420000 \lor \neg \left(x \leq 4 \cdot 10^{-10}\right):\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -4.2e5 or 4.00000000000000015e-10 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
associate-/l*99.6%
un-div-inv99.5%
associate-/r*99.6%
frac-sub99.4%
*-un-lft-identity99.4%
un-div-inv99.5%
tan-quot99.7%
Applied egg-rr99.7%
div-sub99.7%
*-rgt-identity99.7%
times-frac99.6%
/-rgt-identity99.6%
times-frac94.2%
*-commutative94.2%
times-frac99.7%
*-inverses99.7%
*-lft-identity99.7%
Simplified99.7%
sub-neg99.7%
div-inv99.7%
frac-times99.7%
metadata-eval99.7%
Applied egg-rr99.7%
unsub-neg99.7%
associate-/r*99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 99.2%
if -4.2e5 < x < 4.00000000000000015e-10Initial 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 x around 0 99.7%
Taylor expanded in x around 0 99.7%
+-commutative99.7%
mul-1-neg99.7%
sub-neg99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 99.4%
Final simplification99.3%
(FPCore (B x) :precision binary64 (if (<= x -420000.0) (- (/ 1.0 B) (/ x (tan B))) (if (<= x 4e-10) (/ (- 1.0 x) (sin B)) (/ (- 1.0 x) (tan B)))))
double code(double B, double x) {
double tmp;
if (x <= -420000.0) {
tmp = (1.0 / B) - (x / tan(B));
} else if (x <= 4e-10) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (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 <= (-420000.0d0)) then
tmp = (1.0d0 / b) - (x / tan(b))
else if (x <= 4d-10) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (1.0d0 - x) / tan(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -420000.0) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else if (x <= 4e-10) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (1.0 - x) / Math.tan(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -420000.0: tmp = (1.0 / B) - (x / math.tan(B)) elif x <= 4e-10: tmp = (1.0 - x) / math.sin(B) else: tmp = (1.0 - x) / math.tan(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -420000.0) tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); elseif (x <= 4e-10) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 - x) / tan(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -420000.0) tmp = (1.0 / B) - (x / tan(B)); elseif (x <= 4e-10) tmp = (1.0 - x) / sin(B); else tmp = (1.0 - x) / tan(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -420000.0], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4e-10], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -420000:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-10}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\tan B}\\
\end{array}
\end{array}
if x < -4.2e5Initial program 99.5%
distribute-lft-neg-in99.5%
+-commutative99.5%
cancel-sign-sub-inv99.5%
*-commutative99.5%
*-commutative99.5%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Taylor expanded in B around 0 99.3%
if -4.2e5 < x < 4.00000000000000015e-10Initial 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 x around 0 99.7%
Taylor expanded in x around 0 99.7%
+-commutative99.7%
mul-1-neg99.7%
sub-neg99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 99.4%
if 4.00000000000000015e-10 < x Initial 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 x around 0 99.7%
associate-/l*99.7%
un-div-inv99.6%
associate-/r*99.6%
frac-sub99.5%
*-un-lft-identity99.5%
un-div-inv99.5%
tan-quot99.7%
Applied egg-rr99.7%
div-sub99.7%
*-rgt-identity99.7%
times-frac99.7%
/-rgt-identity99.7%
times-frac94.9%
*-commutative94.9%
times-frac99.7%
*-inverses99.7%
*-lft-identity99.7%
Simplified99.7%
sub-neg99.7%
div-inv99.7%
frac-times99.7%
metadata-eval99.7%
Applied egg-rr99.7%
unsub-neg99.7%
associate-/r*99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 99.1%
Final simplification99.3%
(FPCore (B x) :precision binary64 (if (or (<= B -0.021) (not (<= B 0.13))) (/ 1.0 (sin B)) (+ (/ (- 1.0 x) B) (* x (* B 0.3333333333333333)))))
double code(double B, double x) {
double tmp;
if ((B <= -0.021) || !(B <= 0.13)) {
tmp = 1.0 / sin(B);
} else {
tmp = ((1.0 - x) / B) + (x * (B * 0.3333333333333333));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((b <= (-0.021d0)) .or. (.not. (b <= 0.13d0))) then
tmp = 1.0d0 / sin(b)
else
tmp = ((1.0d0 - x) / b) + (x * (b * 0.3333333333333333d0))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.021) || !(B <= 0.13)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = ((1.0 - x) / B) + (x * (B * 0.3333333333333333));
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.021) or not (B <= 0.13): tmp = 1.0 / math.sin(B) else: tmp = ((1.0 - x) / B) + (x * (B * 0.3333333333333333)) return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.021) || !(B <= 0.13)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(Float64(1.0 - x) / B) + Float64(x * Float64(B * 0.3333333333333333))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.021) || ~((B <= 0.13))) tmp = 1.0 / sin(B); else tmp = ((1.0 - x) / B) + (x * (B * 0.3333333333333333)); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.021], N[Not[LessEqual[B, 0.13]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(x * N[(B * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.021 \lor \neg \left(B \leq 0.13\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B} + x \cdot \left(B \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if B < -0.0210000000000000013 or 0.13 < B Initial program 99.4%
distribute-lft-neg-in99.4%
+-commutative99.4%
distribute-lft-neg-in99.4%
distribute-rgt-neg-in99.4%
Simplified99.4%
Taylor expanded in x around 0 41.2%
if -0.0210000000000000013 < B < 0.13Initial program 99.9%
distribute-lft-neg-in99.9%
+-commutative99.9%
distribute-lft-neg-in99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 99.9%
Taylor expanded in B around 0 99.9%
neg-mul-199.9%
+-commutative99.9%
associate-+r+99.9%
+-commutative99.9%
sub-neg99.9%
div-sub99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
Final simplification72.9%
(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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around 0 99.7%
+-commutative99.7%
mul-1-neg99.7%
sub-neg99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in B around 0 74.5%
Final simplification74.5%
(FPCore (B x) :precision binary64 (+ (/ (- 1.0 x) B) (* x (* B 0.3333333333333333))))
double code(double B, double x) {
return ((1.0 - x) / B) + (x * (B * 0.3333333333333333));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = ((1.0d0 - x) / b) + (x * (b * 0.3333333333333333d0))
end function
public static double code(double B, double x) {
return ((1.0 - x) / B) + (x * (B * 0.3333333333333333));
}
def code(B, x): return ((1.0 - x) / B) + (x * (B * 0.3333333333333333))
function code(B, x) return Float64(Float64(Float64(1.0 - x) / B) + Float64(x * Float64(B * 0.3333333333333333))) end
function tmp = code(B, x) tmp = ((1.0 - x) / B) + (x * (B * 0.3333333333333333)); end
code[B_, x_] := N[(N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision] + N[(x * N[(B * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{B} + x \cdot \left(B \cdot 0.3333333333333333\right)
\end{array}
Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 81.9%
Taylor expanded in B around 0 55.4%
neg-mul-155.4%
+-commutative55.4%
associate-+r+55.4%
+-commutative55.4%
sub-neg55.4%
div-sub55.4%
*-commutative55.4%
*-commutative55.4%
associate-*l*55.4%
Simplified55.4%
Final simplification55.4%
(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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 55.2%
+-commutative55.2%
mul-1-neg55.2%
sub-neg55.2%
associate--l+55.2%
*-commutative55.2%
div-sub55.3%
Simplified55.3%
Taylor expanded in x around 0 55.3%
*-commutative55.3%
Simplified55.3%
Final simplification55.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.1e+15))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.1e+15)) {
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.1d+15))) 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.1e+15)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.0) or not (x <= 1.1e+15): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.1e+15)) 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.1e+15))) 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.1e+15]], $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.1 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1 or 1.1e15 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 51.8%
neg-mul-151.8%
sub-neg51.8%
Simplified51.8%
Taylor expanded in x around inf 51.4%
neg-mul-151.4%
distribute-neg-frac51.4%
Simplified51.4%
if -1 < x < 1.1e15Initial 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.3%
neg-mul-159.3%
sub-neg59.3%
Simplified59.3%
Taylor expanded in x around 0 57.8%
Final simplification54.3%
(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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 55.2%
neg-mul-155.2%
sub-neg55.2%
Simplified55.2%
Final simplification55.2%
(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.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
Taylor expanded in B around 0 55.2%
neg-mul-155.2%
sub-neg55.2%
Simplified55.2%
Taylor expanded in x around 0 27.7%
Final simplification27.7%
herbie shell --seed 2023311
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))