
(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 -6.8) (not (<= x 450000.0))) (* x (/ (- (cos B)) (sin B))) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -6.8) || !(x <= 450000.0)) {
tmp = x * (-cos(B) / sin(B));
} else {
tmp = (1.0 / sin(B)) - (x / B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-6.8d0)) .or. (.not. (x <= 450000.0d0))) then
tmp = x * (-cos(b) / sin(b))
else
tmp = (1.0d0 / sin(b)) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -6.8) || !(x <= 450000.0)) {
tmp = x * (-Math.cos(B) / Math.sin(B));
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -6.8) or not (x <= 450000.0): tmp = x * (-math.cos(B) / math.sin(B)) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -6.8) || !(x <= 450000.0)) tmp = Float64(x * Float64(Float64(-cos(B)) / sin(B))); else tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -6.8) || ~((x <= 450000.0))) tmp = x * (-cos(B) / sin(B)); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -6.8], N[Not[LessEqual[x, 450000.0]], $MachinePrecision]], N[(x * N[((-N[Cos[B], $MachinePrecision]) / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \lor \neg \left(x \leq 450000\right):\\
\;\;\;\;x \cdot \frac{-\cos B}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -6.79999999999999982 or 4.5e5 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
*-commutative98.0%
associate-*r/98.0%
distribute-rgt-neg-in98.0%
Simplified98.0%
if -6.79999999999999982 < x < 4.5e5Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
Final simplification98.4%
(FPCore (B x) :precision binary64 (if (or (<= x -6.8) (not (<= x 85000.0))) (* (cos B) (/ (- x) (sin B))) (- (/ 1.0 (sin B)) (/ x B))))
double code(double B, double x) {
double tmp;
if ((x <= -6.8) || !(x <= 85000.0)) {
tmp = cos(B) * (-x / sin(B));
} else {
tmp = (1.0 / sin(B)) - (x / B);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-6.8d0)) .or. (.not. (x <= 85000.0d0))) then
tmp = cos(b) * (-x / sin(b))
else
tmp = (1.0d0 / sin(b)) - (x / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -6.8) || !(x <= 85000.0)) {
tmp = Math.cos(B) * (-x / Math.sin(B));
} else {
tmp = (1.0 / Math.sin(B)) - (x / B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -6.8) or not (x <= 85000.0): tmp = math.cos(B) * (-x / math.sin(B)) else: tmp = (1.0 / math.sin(B)) - (x / B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -6.8) || !(x <= 85000.0)) tmp = Float64(cos(B) * Float64(Float64(-x) / sin(B))); else tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -6.8) || ~((x <= 85000.0))) tmp = cos(B) * (-x / sin(B)); else tmp = (1.0 / sin(B)) - (x / B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -6.8], N[Not[LessEqual[x, 85000.0]], $MachinePrecision]], N[(N[Cos[B], $MachinePrecision] * N[((-x) / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \lor \neg \left(x \leq 85000\right):\\
\;\;\;\;\cos B \cdot \frac{-x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\end{array}
\end{array}
if x < -6.79999999999999982 or 85000 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
associate-*r/98.0%
distribute-rgt-neg-in98.0%
distribute-neg-frac98.0%
Simplified98.0%
if -6.79999999999999982 < x < 85000Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
Final simplification98.5%
(FPCore (B x)
:precision binary64
(if (<= x -6.8)
(* (cos B) (/ (- x) (sin B)))
(if (<= x 5500000.0)
(- (/ 1.0 (sin B)) (/ x B))
(/ (* x (- (cos B))) (sin B)))))
double code(double B, double x) {
double tmp;
if (x <= -6.8) {
tmp = cos(B) * (-x / sin(B));
} else if (x <= 5500000.0) {
tmp = (1.0 / sin(B)) - (x / B);
} else {
tmp = (x * -cos(B)) / 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 <= (-6.8d0)) then
tmp = cos(b) * (-x / sin(b))
else if (x <= 5500000.0d0) then
tmp = (1.0d0 / sin(b)) - (x / b)
else
tmp = (x * -cos(b)) / sin(b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -6.8) {
tmp = Math.cos(B) * (-x / Math.sin(B));
} else if (x <= 5500000.0) {
tmp = (1.0 / Math.sin(B)) - (x / B);
} else {
tmp = (x * -Math.cos(B)) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -6.8: tmp = math.cos(B) * (-x / math.sin(B)) elif x <= 5500000.0: tmp = (1.0 / math.sin(B)) - (x / B) else: tmp = (x * -math.cos(B)) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if (x <= -6.8) tmp = Float64(cos(B) * Float64(Float64(-x) / sin(B))); elseif (x <= 5500000.0) tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B)); else tmp = Float64(Float64(x * Float64(-cos(B))) / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -6.8) tmp = cos(B) * (-x / sin(B)); elseif (x <= 5500000.0) tmp = (1.0 / sin(B)) - (x / B); else tmp = (x * -cos(B)) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -6.8], N[(N[Cos[B], $MachinePrecision] * N[((-x) / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5500000.0], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(x * (-N[Cos[B], $MachinePrecision])), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8:\\
\;\;\;\;\cos B \cdot \frac{-x}{\sin B}\\
\mathbf{elif}\;x \leq 5500000:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-\cos B\right)}{\sin B}\\
\end{array}
\end{array}
if x < -6.79999999999999982Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
associate-*r/97.3%
distribute-rgt-neg-in97.3%
distribute-neg-frac97.3%
Simplified97.3%
if -6.79999999999999982 < x < 5.5e6Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 99.0%
if 5.5e6 < x Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.7%
Taylor expanded in x around inf 99.1%
associate-*r/99.1%
neg-mul-199.1%
distribute-rgt-neg-in99.1%
Simplified99.1%
Final simplification98.5%
(FPCore (B x) :precision binary64 (if (or (<= x -4.7e+83) (not (<= x 6.5e+33))) (- (+ (/ 1.0 B) (* B 0.16666666666666666)) (/ x (tan B))) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -4.7e+83) || !(x <= 6.5e+33)) {
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 <= (-4.7d+83)) .or. (.not. (x <= 6.5d+33))) 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 <= -4.7e+83) || !(x <= 6.5e+33)) {
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 <= -4.7e+83) or not (x <= 6.5e+33): 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 <= -4.7e+83) || !(x <= 6.5e+33)) 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 <= -4.7e+83) || ~((x <= 6.5e+33))) 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, -4.7e+83], N[Not[LessEqual[x, 6.5e+33]], $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 -4.7 \cdot 10^{+83} \lor \neg \left(x \leq 6.5 \cdot 10^{+33}\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 < -4.6999999999999999e83 or 6.49999999999999993e33 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 83.4%
if -4.6999999999999999e83 < x < 6.49999999999999993e33Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
sub-div99.7%
Applied egg-rr99.7%
Taylor expanded in B around 0 88.4%
Final simplification86.2%
(FPCore (B x) :precision binary64 (if (or (<= B -0.0005) (not (<= B 0.0145))) (/ 1.0 (sin B)) (/ (- 1.0 x) B)))
double code(double B, double x) {
double tmp;
if ((B <= -0.0005) || !(B <= 0.0145)) {
tmp = 1.0 / sin(B);
} else {
tmp = (1.0 - x) / 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.0005d0)) .or. (.not. (b <= 0.0145d0))) then
tmp = 1.0d0 / sin(b)
else
tmp = (1.0d0 - x) / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((B <= -0.0005) || !(B <= 0.0145)) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = (1.0 - x) / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (B <= -0.0005) or not (B <= 0.0145): tmp = 1.0 / math.sin(B) else: tmp = (1.0 - x) / B return tmp
function code(B, x) tmp = 0.0 if ((B <= -0.0005) || !(B <= 0.0145)) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(1.0 - x) / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((B <= -0.0005) || ~((B <= 0.0145))) tmp = 1.0 / sin(B); else tmp = (1.0 - x) / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[B, -0.0005], N[Not[LessEqual[B, 0.0145]], $MachinePrecision]], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -0.0005 \lor \neg \left(B \leq 0.0145\right):\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{B}\\
\end{array}
\end{array}
if B < -5.0000000000000001e-4 or 0.0145000000000000007 < B Initial program 99.6%
distribute-lft-neg-in99.6%
Simplified99.6%
Taylor expanded in x around 0 44.6%
if -5.0000000000000001e-4 < B < 0.0145000000000000007Initial program 99.9%
distribute-lft-neg-in99.9%
Simplified99.9%
Taylor expanded in B around 0 100.0%
mul-1-neg100.0%
sub-neg100.0%
Simplified100.0%
Final simplification69.1%
(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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in x around 0 99.7%
sub-div99.7%
Applied egg-rr99.7%
Taylor expanded in B around 0 71.4%
Final simplification71.4%
(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%
Taylor expanded in B around 0 46.3%
+-commutative46.3%
mul-1-neg46.3%
sub-neg46.3%
associate--l+46.3%
*-commutative46.3%
*-commutative46.3%
div-sub46.3%
Simplified46.3%
Taylor expanded in x around inf 46.4%
Final simplification46.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.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 69.2%
Taylor expanded in B around 0 46.4%
associate--l+46.4%
*-commutative46.4%
div-sub46.4%
Simplified46.4%
Final simplification46.4%
(FPCore (B x) :precision binary64 (if (or (<= x -32500000000.0) (not (<= x 2000000000000.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -32500000000.0) || !(x <= 2000000000000.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 <= (-32500000000.0d0)) .or. (.not. (x <= 2000000000000.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 <= -32500000000.0) || !(x <= 2000000000000.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -32500000000.0) or not (x <= 2000000000000.0): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -32500000000.0) || !(x <= 2000000000000.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 <= -32500000000.0) || ~((x <= 2000000000000.0))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -32500000000.0], N[Not[LessEqual[x, 2000000000000.0]], $MachinePrecision]], N[((-x) / B), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -32500000000 \lor \neg \left(x \leq 2000000000000\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -3.25e10 or 2e12 < x Initial program 99.7%
distribute-lft-neg-in99.7%
Simplified99.7%
Taylor expanded in B around 0 45.7%
mul-1-neg45.7%
sub-neg45.7%
Simplified45.7%
Taylor expanded in x around inf 45.7%
neg-mul-145.7%
Simplified45.7%
if -3.25e10 < x < 2e12Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in B around 0 46.8%
mul-1-neg46.8%
sub-neg46.8%
Simplified46.8%
Taylor expanded in x around 0 45.7%
Final simplification45.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 46.3%
mul-1-neg46.3%
sub-neg46.3%
Simplified46.3%
Final simplification46.3%
(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 46.3%
mul-1-neg46.3%
sub-neg46.3%
Simplified46.3%
Taylor expanded in x around 0 23.0%
Final simplification23.0%
herbie shell --seed 2023240
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))