
(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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (<= x -110000.0) (/ (- x) (tan B)) (if (<= x 5e-17) (/ (- 1.0 x) (sin B)) (- (/ 1.0 B) (/ x (tan B))))))
double code(double B, double x) {
double tmp;
if (x <= -110000.0) {
tmp = -x / tan(B);
} else if (x <= 5e-17) {
tmp = (1.0 - x) / sin(B);
} else {
tmp = (1.0 / B) - (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 <= (-110000.0d0)) then
tmp = -x / tan(b)
else if (x <= 5d-17) then
tmp = (1.0d0 - x) / sin(b)
else
tmp = (1.0d0 / b) - (x / tan(b))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -110000.0) {
tmp = -x / Math.tan(B);
} else if (x <= 5e-17) {
tmp = (1.0 - x) / Math.sin(B);
} else {
tmp = (1.0 / B) - (x / Math.tan(B));
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -110000.0: tmp = -x / math.tan(B) elif x <= 5e-17: tmp = (1.0 - x) / math.sin(B) else: tmp = (1.0 / B) - (x / math.tan(B)) return tmp
function code(B, x) tmp = 0.0 if (x <= -110000.0) tmp = Float64(Float64(-x) / tan(B)); elseif (x <= 5e-17) tmp = Float64(Float64(1.0 - x) / sin(B)); else tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -110000.0) tmp = -x / tan(B); elseif (x <= 5e-17) tmp = (1.0 - x) / sin(B); else tmp = (1.0 / B) - (x / tan(B)); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -110000.0], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-17], N[(N[(1.0 - x), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -110000:\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-17}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\end{array}
\end{array}
if x < -1.1e5Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
tan-quot99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
*-commutative98.0%
neg-mul-198.0%
distribute-lft-neg-in98.0%
*-commutative98.0%
Simplified98.0%
distribute-rgt-neg-out98.0%
distribute-frac-neg98.0%
*-commutative98.0%
associate-/l*98.0%
quot-tan98.1%
Applied egg-rr98.1%
distribute-neg-frac98.1%
Simplified98.1%
if -1.1e5 < x < 4.9999999999999999e-17Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
*-commutative99.8%
div-sub99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 99.1%
if 4.9999999999999999e-17 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in B around 0 99.9%
Final simplification99.1%
(FPCore (B x) :precision binary64 (if (or (<= x -110000.0) (not (<= x 68000000.0))) (/ (- x) (tan B)) (/ (- 1.0 x) (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -110000.0) || !(x <= 68000000.0)) {
tmp = -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 <= (-110000.0d0)) .or. (.not. (x <= 68000000.0d0))) then
tmp = -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 <= -110000.0) || !(x <= 68000000.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = (1.0 - x) / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -110000.0) or not (x <= 68000000.0): tmp = -x / math.tan(B) else: tmp = (1.0 - x) / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -110000.0) || !(x <= 68000000.0)) tmp = Float64(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 <= -110000.0) || ~((x <= 68000000.0))) tmp = -x / tan(B); else tmp = (1.0 - x) / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -110000.0], N[Not[LessEqual[x, 68000000.0]], $MachinePrecision]], N[((-x) / 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 -110000 \lor \neg \left(x \leq 68000000\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x}{\sin B}\\
\end{array}
\end{array}
if x < -1.1e5 or 6.8e7 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
*-commutative98.9%
neg-mul-198.9%
distribute-lft-neg-in98.9%
*-commutative98.9%
Simplified98.9%
distribute-rgt-neg-out98.9%
distribute-frac-neg98.9%
*-commutative98.9%
associate-/l*98.9%
quot-tan99.0%
Applied egg-rr99.0%
distribute-neg-frac99.0%
Simplified99.0%
if -1.1e5 < x < 6.8e7Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in B around inf 99.8%
*-commutative99.8%
div-sub99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in B around 0 99.1%
Final simplification99.1%
(FPCore (B x) :precision binary64 (if (or (<= x -0.95) (not (<= x 1.8))) (/ (- x) (sin B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -0.95) || !(x <= 1.8)) {
tmp = -x / sin(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 <= (-0.95d0)) .or. (.not. (x <= 1.8d0))) then
tmp = -x / sin(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 <= -0.95) || !(x <= 1.8)) {
tmp = -x / Math.sin(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.95) or not (x <= 1.8): tmp = -x / math.sin(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.95) || !(x <= 1.8)) tmp = Float64(Float64(-x) / sin(B)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -0.95) || ~((x <= 1.8))) tmp = -x / sin(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.95], N[Not[LessEqual[x, 1.8]], $MachinePrecision]], N[((-x) / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.95 \lor \neg \left(x \leq 1.8\right):\\
\;\;\;\;\frac{-x}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -0.94999999999999996 or 1.80000000000000004 < 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.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 98.2%
associate-*r/98.2%
*-commutative98.2%
neg-mul-198.2%
distribute-lft-neg-in98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in B around 0 62.8%
mul-1-neg62.8%
Simplified62.8%
if -0.94999999999999996 < x < 1.80000000000000004Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Final simplification82.1%
(FPCore (B x) :precision binary64 (if (or (<= x -1.5) (not (<= x 1.0))) (/ (- x) (tan B)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.5) || !(x <= 1.0)) {
tmp = -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.5d0)) .or. (.not. (x <= 1.0d0))) then
tmp = -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.5) || !(x <= 1.0)) {
tmp = -x / Math.tan(B);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.5) or not (x <= 1.0): tmp = -x / math.tan(B) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.5) || !(x <= 1.0)) tmp = Float64(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.5) || ~((x <= 1.0))) tmp = -x / tan(B); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.5], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.5 or 1 < 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.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 98.2%
associate-*r/98.2%
*-commutative98.2%
neg-mul-198.2%
distribute-lft-neg-in98.2%
*-commutative98.2%
Simplified98.2%
distribute-rgt-neg-out98.2%
distribute-frac-neg98.2%
*-commutative98.2%
associate-/l*98.3%
quot-tan98.4%
Applied egg-rr98.4%
distribute-neg-frac98.4%
Simplified98.4%
if -1.5 < x < 1Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 99.6%
Final simplification99.0%
(FPCore (B x)
:precision binary64
(if (<= x -32000000.0)
(- (* B (- (* x -0.3333333333333333))) (/ x B))
(if (<= x 5e-17)
(/ 1.0 (sin B))
(+ (* (* B x) 0.3333333333333333) (/ (- 1.0 x) B)))))
double code(double B, double x) {
double tmp;
if (x <= -32000000.0) {
tmp = (B * -(x * -0.3333333333333333)) - (x / B);
} else if (x <= 5e-17) {
tmp = 1.0 / sin(B);
} else {
tmp = ((B * x) * 0.3333333333333333) + ((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 (x <= (-32000000.0d0)) then
tmp = (b * -(x * (-0.3333333333333333d0))) - (x / b)
else if (x <= 5d-17) then
tmp = 1.0d0 / sin(b)
else
tmp = ((b * x) * 0.3333333333333333d0) + ((1.0d0 - x) / b)
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -32000000.0) {
tmp = (B * -(x * -0.3333333333333333)) - (x / B);
} else if (x <= 5e-17) {
tmp = 1.0 / Math.sin(B);
} else {
tmp = ((B * x) * 0.3333333333333333) + ((1.0 - x) / B);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -32000000.0: tmp = (B * -(x * -0.3333333333333333)) - (x / B) elif x <= 5e-17: tmp = 1.0 / math.sin(B) else: tmp = ((B * x) * 0.3333333333333333) + ((1.0 - x) / B) return tmp
function code(B, x) tmp = 0.0 if (x <= -32000000.0) tmp = Float64(Float64(B * Float64(-Float64(x * -0.3333333333333333))) - Float64(x / B)); elseif (x <= 5e-17) tmp = Float64(1.0 / sin(B)); else tmp = Float64(Float64(Float64(B * x) * 0.3333333333333333) + Float64(Float64(1.0 - x) / B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -32000000.0) tmp = (B * -(x * -0.3333333333333333)) - (x / B); elseif (x <= 5e-17) tmp = 1.0 / sin(B); else tmp = ((B * x) * 0.3333333333333333) + ((1.0 - x) / B); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -32000000.0], N[(N[(B * (-N[(x * -0.3333333333333333), $MachinePrecision])), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-17], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision], N[(N[(N[(B * x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -32000000:\\
\;\;\;\;B \cdot \left(-x \cdot -0.3333333333333333\right) - \frac{x}{B}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\left(B \cdot x\right) \cdot 0.3333333333333333 + \frac{1 - x}{B}\\
\end{array}
\end{array}
if x < -3.2e7Initial program 99.6%
+-commutative99.6%
unsub-neg99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
tan-quot99.7%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
*-commutative99.6%
neg-mul-199.6%
distribute-lft-neg-in99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in B around 0 59.9%
mul-1-neg59.9%
+-commutative59.9%
unsub-neg59.9%
mul-1-neg59.9%
distribute-rgt-neg-in59.9%
distribute-rgt-out--59.9%
metadata-eval59.9%
Simplified59.9%
if -3.2e7 < x < 4.9999999999999999e-17Initial program 99.8%
distribute-lft-neg-in99.8%
Simplified99.8%
Taylor expanded in x around 0 97.6%
if 4.9999999999999999e-17 < x Initial program 99.7%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in B around 0 99.9%
Taylor expanded in B around 0 60.1%
associate--l+60.1%
*-commutative60.1%
div-sub60.1%
Simplified60.1%
Final simplification80.0%
(FPCore (B x) :precision binary64 (+ (* (* B x) 0.3333333333333333) (/ (- 1.0 x) B)))
double code(double B, double x) {
return ((B * 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 * x) * 0.3333333333333333d0) + ((1.0d0 - x) / b)
end function
public static double code(double B, double x) {
return ((B * x) * 0.3333333333333333) + ((1.0 - x) / B);
}
def code(B, x): return ((B * x) * 0.3333333333333333) + ((1.0 - x) / B)
function code(B, x) return Float64(Float64(Float64(B * x) * 0.3333333333333333) + Float64(Float64(1.0 - x) / B)) end
function tmp = code(B, x) tmp = ((B * x) * 0.3333333333333333) + ((1.0 - x) / B); end
code[B_, x_] := N[(N[(N[(B * x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(B \cdot x\right) \cdot 0.3333333333333333 + \frac{1 - x}{B}
\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 75.4%
Taylor expanded in B around 0 56.5%
associate--l+56.5%
*-commutative56.5%
div-sub56.5%
Simplified56.5%
Final simplification56.5%
(FPCore (B x) :precision binary64 (if (or (<= x -6.2e-12) (not (<= x 1.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -6.2e-12) || !(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 <= (-6.2d-12)) .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 <= -6.2e-12) || !(x <= 1.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -6.2e-12) or not (x <= 1.0): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -6.2e-12) || !(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 <= -6.2e-12) || ~((x <= 1.0))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -6.2e-12], 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 -6.2 \cdot 10^{-12} \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -6.2000000000000002e-12 or 1 < 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.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 97.5%
associate-*r/97.5%
*-commutative97.5%
neg-mul-197.5%
distribute-lft-neg-in97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in B around 0 57.2%
associate-*r/57.2%
mul-1-neg57.2%
Simplified57.2%
if -6.2000000000000002e-12 < x < 1Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 54.8%
Taylor expanded in x around 0 54.7%
Final simplification55.9%
(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 55.9%
mul-1-neg55.9%
sub-neg55.9%
Simplified55.9%
Final simplification55.9%
(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%
+-commutative99.7%
unsub-neg99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in B around 0 75.4%
Taylor expanded in x around 0 29.8%
Final simplification29.8%
herbie shell --seed 2023255
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))