
(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 (+ (/ (- x) (tan B)) (pow (sin B) -1.0)))
double code(double B, double x) {
return (-x / tan(B)) + pow(sin(B), -1.0);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (-x / tan(b)) + (sin(b) ** (-1.0d0))
end function
public static double code(double B, double x) {
return (-x / Math.tan(B)) + Math.pow(Math.sin(B), -1.0);
}
def code(B, x): return (-x / math.tan(B)) + math.pow(math.sin(B), -1.0)
function code(B, x) return Float64(Float64(Float64(-x) / tan(B)) + (sin(B) ^ -1.0)) end
function tmp = code(B, x) tmp = (-x / tan(B)) + (sin(B) ^ -1.0); end
code[B_, x_] := N[(N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-x}{\tan B} + {\sin B}^{-1}
\end{array}
Initial program 99.7%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -2.0) (not (<= x 680000.0))) (+ (* x (/ -1.0 (tan B))) (pow B -1.0)) (+ (- (/ x B)) (pow (sin B) -1.0))))
double code(double B, double x) {
double tmp;
if ((x <= -2.0) || !(x <= 680000.0)) {
tmp = (x * (-1.0 / tan(B))) + pow(B, -1.0);
} else {
tmp = -(x / B) + pow(sin(B), -1.0);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-2.0d0)) .or. (.not. (x <= 680000.0d0))) then
tmp = (x * ((-1.0d0) / tan(b))) + (b ** (-1.0d0))
else
tmp = -(x / b) + (sin(b) ** (-1.0d0))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -2.0) || !(x <= 680000.0)) {
tmp = (x * (-1.0 / Math.tan(B))) + Math.pow(B, -1.0);
} else {
tmp = -(x / B) + Math.pow(Math.sin(B), -1.0);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -2.0) or not (x <= 680000.0): tmp = (x * (-1.0 / math.tan(B))) + math.pow(B, -1.0) else: tmp = -(x / B) + math.pow(math.sin(B), -1.0) return tmp
function code(B, x) tmp = 0.0 if ((x <= -2.0) || !(x <= 680000.0)) tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + (B ^ -1.0)); else tmp = Float64(Float64(-Float64(x / B)) + (sin(B) ^ -1.0)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -2.0) || ~((x <= 680000.0))) tmp = (x * (-1.0 / tan(B))) + (B ^ -1.0); else tmp = -(x / B) + (sin(B) ^ -1.0); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -2.0], N[Not[LessEqual[x, 680000.0]], $MachinePrecision]], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[B, -1.0], $MachinePrecision]), $MachinePrecision], N[((-N[(x / B), $MachinePrecision]) + N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \lor \neg \left(x \leq 680000\right):\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + {B}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\left(-\frac{x}{B}\right) + {\sin B}^{-1}\\
\end{array}
\end{array}
if x < -2 or 6.8e5 < x Initial program 99.6%
lift-/.f64N/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
metadata-eval54.7
Applied rewrites54.7%
Taylor expanded in B around 0
lower-/.f6499.2
Applied rewrites99.2%
if -2 < x < 6.8e5Initial program 99.8%
Taylor expanded in B around 0
lower-/.f6499.0
Applied rewrites99.0%
Final simplification99.1%
(FPCore (B x)
:precision binary64
(if (<= x -6200.0)
(/ (* (- x) (cos B)) (sin B))
(if (<= x 680000.0)
(+ (- (/ x B)) (pow (sin B) -1.0))
(+ (* x (/ -1.0 (tan B))) (pow B -1.0)))))
double code(double B, double x) {
double tmp;
if (x <= -6200.0) {
tmp = (-x * cos(B)) / sin(B);
} else if (x <= 680000.0) {
tmp = -(x / B) + pow(sin(B), -1.0);
} else {
tmp = (x * (-1.0 / tan(B))) + pow(B, -1.0);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-6200.0d0)) then
tmp = (-x * cos(b)) / sin(b)
else if (x <= 680000.0d0) then
tmp = -(x / b) + (sin(b) ** (-1.0d0))
else
tmp = (x * ((-1.0d0) / tan(b))) + (b ** (-1.0d0))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -6200.0) {
tmp = (-x * Math.cos(B)) / Math.sin(B);
} else if (x <= 680000.0) {
tmp = -(x / B) + Math.pow(Math.sin(B), -1.0);
} else {
tmp = (x * (-1.0 / Math.tan(B))) + Math.pow(B, -1.0);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -6200.0: tmp = (-x * math.cos(B)) / math.sin(B) elif x <= 680000.0: tmp = -(x / B) + math.pow(math.sin(B), -1.0) else: tmp = (x * (-1.0 / math.tan(B))) + math.pow(B, -1.0) return tmp
function code(B, x) tmp = 0.0 if (x <= -6200.0) tmp = Float64(Float64(Float64(-x) * cos(B)) / sin(B)); elseif (x <= 680000.0) tmp = Float64(Float64(-Float64(x / B)) + (sin(B) ^ -1.0)); else tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + (B ^ -1.0)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -6200.0) tmp = (-x * cos(B)) / sin(B); elseif (x <= 680000.0) tmp = -(x / B) + (sin(B) ^ -1.0); else tmp = (x * (-1.0 / tan(B))) + (B ^ -1.0); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -6200.0], N[(N[((-x) * N[Cos[B], $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 680000.0], N[((-N[(x / B), $MachinePrecision]) + N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[B, -1.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6200:\\
\;\;\;\;\frac{\left(-x\right) \cdot \cos B}{\sin B}\\
\mathbf{elif}\;x \leq 680000:\\
\;\;\;\;\left(-\frac{x}{B}\right) + {\sin B}^{-1}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + {B}^{-1}\\
\end{array}
\end{array}
if x < -6200Initial program 99.5%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
associate-/r/N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in x around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6498.9
Applied rewrites98.9%
if -6200 < x < 6.8e5Initial program 99.8%
Taylor expanded in B around 0
lower-/.f6499.0
Applied rewrites99.0%
if 6.8e5 < x Initial program 99.7%
lift-/.f64N/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
metadata-eval54.6
Applied rewrites54.6%
Taylor expanded in B around 0
lower-/.f6499.7
Applied rewrites99.7%
Final simplification99.1%
(FPCore (B x)
:precision binary64
(if (<= x -6200.0)
(* (- x) (/ (cos B) (sin B)))
(if (<= x 680000.0)
(+ (- (/ x B)) (pow (sin B) -1.0))
(+ (* x (/ -1.0 (tan B))) (pow B -1.0)))))
double code(double B, double x) {
double tmp;
if (x <= -6200.0) {
tmp = -x * (cos(B) / sin(B));
} else if (x <= 680000.0) {
tmp = -(x / B) + pow(sin(B), -1.0);
} else {
tmp = (x * (-1.0 / tan(B))) + pow(B, -1.0);
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-6200.0d0)) then
tmp = -x * (cos(b) / sin(b))
else if (x <= 680000.0d0) then
tmp = -(x / b) + (sin(b) ** (-1.0d0))
else
tmp = (x * ((-1.0d0) / tan(b))) + (b ** (-1.0d0))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (x <= -6200.0) {
tmp = -x * (Math.cos(B) / Math.sin(B));
} else if (x <= 680000.0) {
tmp = -(x / B) + Math.pow(Math.sin(B), -1.0);
} else {
tmp = (x * (-1.0 / Math.tan(B))) + Math.pow(B, -1.0);
}
return tmp;
}
def code(B, x): tmp = 0 if x <= -6200.0: tmp = -x * (math.cos(B) / math.sin(B)) elif x <= 680000.0: tmp = -(x / B) + math.pow(math.sin(B), -1.0) else: tmp = (x * (-1.0 / math.tan(B))) + math.pow(B, -1.0) return tmp
function code(B, x) tmp = 0.0 if (x <= -6200.0) tmp = Float64(Float64(-x) * Float64(cos(B) / sin(B))); elseif (x <= 680000.0) tmp = Float64(Float64(-Float64(x / B)) + (sin(B) ^ -1.0)); else tmp = Float64(Float64(x * Float64(-1.0 / tan(B))) + (B ^ -1.0)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (x <= -6200.0) tmp = -x * (cos(B) / sin(B)); elseif (x <= 680000.0) tmp = -(x / B) + (sin(B) ^ -1.0); else tmp = (x * (-1.0 / tan(B))) + (B ^ -1.0); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[x, -6200.0], N[((-x) * N[(N[Cos[B], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 680000.0], N[((-N[(x / B), $MachinePrecision]) + N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(-1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[B, -1.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6200:\\
\;\;\;\;\left(-x\right) \cdot \frac{\cos B}{\sin B}\\
\mathbf{elif}\;x \leq 680000:\\
\;\;\;\;\left(-\frac{x}{B}\right) + {\sin B}^{-1}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-1}{\tan B} + {B}^{-1}\\
\end{array}
\end{array}
if x < -6200Initial program 99.5%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
associate-/r/N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in x around inf
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
if -6200 < x < 6.8e5Initial program 99.8%
Taylor expanded in B around 0
lower-/.f6499.0
Applied rewrites99.0%
if 6.8e5 < x Initial program 99.7%
lift-/.f64N/A
inv-powN/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
metadata-eval54.6
Applied rewrites54.6%
Taylor expanded in B around 0
lower-/.f6499.7
Applied rewrites99.7%
Final simplification99.1%
(FPCore (B x) :precision binary64 (/ (- 1.0 (* (cos B) x)) (sin B)))
double code(double B, double x) {
return (1.0 - (cos(B) * x)) / sin(B);
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - (cos(b) * x)) / sin(b)
end function
public static double code(double B, double x) {
return (1.0 - (Math.cos(B) * x)) / Math.sin(B);
}
def code(B, x): return (1.0 - (math.cos(B) * x)) / math.sin(B)
function code(B, x) return Float64(Float64(1.0 - Float64(cos(B) * x)) / sin(B)) end
function tmp = code(B, x) tmp = (1.0 - (cos(B) * x)) / sin(B); end
code[B_, x_] := N[(N[(1.0 - N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \cos B \cdot x}{\sin B}
\end{array}
Initial program 99.7%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
associate-/r/N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.8%
(FPCore (B x) :precision binary64 (if (<= B 0.046) (/ (- (fma (fma 0.3333333333333333 x 0.16666666666666666) (* B B) 1.0) x) B) (pow (sin B) -1.0)))
double code(double B, double x) {
double tmp;
if (B <= 0.046) {
tmp = (fma(fma(0.3333333333333333, x, 0.16666666666666666), (B * B), 1.0) - x) / B;
} else {
tmp = pow(sin(B), -1.0);
}
return tmp;
}
function code(B, x) tmp = 0.0 if (B <= 0.046) tmp = Float64(Float64(fma(fma(0.3333333333333333, x, 0.16666666666666666), Float64(B * B), 1.0) - x) / B); else tmp = sin(B) ^ -1.0; end return tmp end
code[B_, x_] := If[LessEqual[B, 0.046], N[(N[(N[(N[(0.3333333333333333 * x + 0.16666666666666666), $MachinePrecision] * N[(B * B), $MachinePrecision] + 1.0), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision], N[Power[N[Sin[B], $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 0.046:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right), B \cdot B, 1\right) - x}{B}\\
\mathbf{else}:\\
\;\;\;\;{\sin B}^{-1}\\
\end{array}
\end{array}
if B < 0.045999999999999999Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6468.6
Applied rewrites68.6%
if 0.045999999999999999 < B Initial program 99.5%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
associate-/r/N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-sin.f6457.8
Applied rewrites57.8%
Final simplification66.6%
(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%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
lift-*.f64N/A
unsub-negN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
associate-/r/N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in B around 0
lower--.f6481.9
Applied rewrites81.9%
(FPCore (B x) :precision binary64 (/ (- (fma (fma 0.3333333333333333 x 0.16666666666666666) (* B B) 1.0) x) B))
double code(double B, double x) {
return (fma(fma(0.3333333333333333, x, 0.16666666666666666), (B * B), 1.0) - x) / B;
}
function code(B, x) return Float64(Float64(fma(fma(0.3333333333333333, x, 0.16666666666666666), Float64(B * B), 1.0) - x) / B) end
code[B_, x_] := N[(N[(N[(N[(0.3333333333333333 * x + 0.16666666666666666), $MachinePrecision] * N[(B * B), $MachinePrecision] + 1.0), $MachinePrecision] - x), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, 0.16666666666666666\right), B \cdot B, 1\right) - x}{B}
\end{array}
Initial program 99.7%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6456.9
Applied rewrites56.9%
(FPCore (B x) :precision binary64 (if (or (<= x -0.00105) (not (<= x 1.0))) (/ (- x) B) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -0.00105) || !(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 <= (-0.00105d0)) .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 <= -0.00105) || !(x <= 1.0)) {
tmp = -x / B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -0.00105) or not (x <= 1.0): tmp = -x / B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -0.00105) || !(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 <= -0.00105) || ~((x <= 1.0))) tmp = -x / B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -0.00105], 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 -0.00105 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -0.00104999999999999994 or 1 < x Initial program 99.6%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6455.9
Applied rewrites55.9%
Taylor expanded in x around inf
Applied rewrites55.1%
if -0.00104999999999999994 < x < 1Initial program 99.8%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6457.6
Applied rewrites57.6%
Taylor expanded in x around 0
Applied rewrites56.2%
Final simplification55.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%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6456.9
Applied rewrites56.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%
Taylor expanded in B around 0
lower-/.f64N/A
lower--.f6456.9
Applied rewrites56.9%
Taylor expanded in x around 0
Applied rewrites32.7%
herbie shell --seed 2024316
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))