
(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 (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%
*-commutative99.7%
remove-double-neg99.7%
distribute-frac-neg299.7%
tan-neg99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
(FPCore (B x) :precision binary64 (if (or (<= x -1.4e-6) (not (<= x 0.012))) (- (/ 1.0 B) (/ x (tan B))) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.4e-6) || !(x <= 0.012)) {
tmp = (1.0 / B) - (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.4d-6)) .or. (.not. (x <= 0.012d0))) then
tmp = (1.0d0 / b) - (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.4e-6) || !(x <= 0.012)) {
tmp = (1.0 / B) - (x / Math.tan(B));
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.4e-6) or not (x <= 0.012): tmp = (1.0 / B) - (x / math.tan(B)) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.4e-6) || !(x <= 0.012)) tmp = Float64(Float64(1.0 / B) - 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.4e-6) || ~((x <= 0.012))) tmp = (1.0 / B) - (x / tan(B)); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.4e-6], N[Not[LessEqual[x, 0.012]], $MachinePrecision]], N[(N[(1.0 / B), $MachinePrecision] - N[(x / 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 \cdot 10^{-6} \lor \neg \left(x \leq 0.012\right):\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.39999999999999994e-6 or 0.012 < x Initial program 99.6%
distribute-lft-neg-in99.6%
+-commutative99.6%
*-commutative99.6%
remove-double-neg99.6%
distribute-frac-neg299.6%
tan-neg99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in B around 0 99.8%
if -1.39999999999999994e-6 < x < 0.012Initial program 99.8%
Taylor expanded in x around 0 98.9%
Final simplification99.3%
(FPCore (B x) :precision binary64 (if (or (<= x -1.2e-6) (not (<= x 0.00145))) (* x (+ (/ (+ (/ 1.0 x) -1.0) B) -1.0)) (/ 1.0 (sin B))))
double code(double B, double x) {
double tmp;
if ((x <= -1.2e-6) || !(x <= 0.00145)) {
tmp = x * ((((1.0 / x) + -1.0) / B) + -1.0);
} 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.2d-6)) .or. (.not. (x <= 0.00145d0))) then
tmp = x * ((((1.0d0 / x) + (-1.0d0)) / b) + (-1.0d0))
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.2e-6) || !(x <= 0.00145)) {
tmp = x * ((((1.0 / x) + -1.0) / B) + -1.0);
} else {
tmp = 1.0 / Math.sin(B);
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1.2e-6) or not (x <= 0.00145): tmp = x * ((((1.0 / x) + -1.0) / B) + -1.0) else: tmp = 1.0 / math.sin(B) return tmp
function code(B, x) tmp = 0.0 if ((x <= -1.2e-6) || !(x <= 0.00145)) tmp = Float64(x * Float64(Float64(Float64(Float64(1.0 / x) + -1.0) / B) + -1.0)); else tmp = Float64(1.0 / sin(B)); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1.2e-6) || ~((x <= 0.00145))) tmp = x * ((((1.0 / x) + -1.0) / B) + -1.0); else tmp = 1.0 / sin(B); end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1.2e-6], N[Not[LessEqual[x, 0.00145]], $MachinePrecision]], N[(x * N[(N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / B), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-6} \lor \neg \left(x \leq 0.00145\right):\\
\;\;\;\;x \cdot \left(\frac{\frac{1}{x} + -1}{B} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B}\\
\end{array}
\end{array}
if x < -1.1999999999999999e-6 or 0.00145 < x Initial program 99.6%
Taylor expanded in B around 0 49.0%
Taylor expanded in x around inf 48.9%
expm1-log1p-u21.3%
expm1-undefine21.0%
sub-neg21.0%
distribute-neg-frac21.0%
metadata-eval21.0%
Applied egg-rr21.0%
sub-neg21.0%
log1p-undefine21.0%
rem-exp-log48.6%
metadata-eval48.6%
distribute-neg-frac48.6%
sub-neg48.6%
associate-/l/48.6%
div-sub48.6%
sub-neg48.6%
metadata-eval48.6%
metadata-eval48.6%
Simplified48.6%
Taylor expanded in B around 0 51.0%
if -1.1999999999999999e-6 < x < 0.00145Initial program 99.8%
Taylor expanded in x around 0 98.9%
Final simplification77.4%
(FPCore (B x)
:precision binary64
(if (<= B 3.1)
(/
(+
1.0
(-
(*
(* B B)
(+
(* x 0.3333333333333333)
(*
(* B B)
(+
(* x 0.022222222222222223)
(*
(* B B)
(+
(* (* x 0.022222222222222223) -0.3333333333333333)
(* x 0.009523809523809525)))))))
x))
B)
(* x (+ -1.0 (/ 1.0 (* B x))))))
double code(double B, double x) {
double tmp;
if (B <= 3.1) {
tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * ((x * 0.022222222222222223) + ((B * B) * (((x * 0.022222222222222223) * -0.3333333333333333) + (x * 0.009523809523809525))))))) - x)) / B;
} else {
tmp = x * (-1.0 + (1.0 / (B * x)));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= 3.1d0) then
tmp = (1.0d0 + (((b * b) * ((x * 0.3333333333333333d0) + ((b * b) * ((x * 0.022222222222222223d0) + ((b * b) * (((x * 0.022222222222222223d0) * (-0.3333333333333333d0)) + (x * 0.009523809523809525d0))))))) - x)) / b
else
tmp = x * ((-1.0d0) + (1.0d0 / (b * x)))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= 3.1) {
tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * ((x * 0.022222222222222223) + ((B * B) * (((x * 0.022222222222222223) * -0.3333333333333333) + (x * 0.009523809523809525))))))) - x)) / B;
} else {
tmp = x * (-1.0 + (1.0 / (B * x)));
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 3.1: tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * ((x * 0.022222222222222223) + ((B * B) * (((x * 0.022222222222222223) * -0.3333333333333333) + (x * 0.009523809523809525))))))) - x)) / B else: tmp = x * (-1.0 + (1.0 / (B * x))) return tmp
function code(B, x) tmp = 0.0 if (B <= 3.1) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(B * B) * Float64(Float64(x * 0.3333333333333333) + Float64(Float64(B * B) * Float64(Float64(x * 0.022222222222222223) + Float64(Float64(B * B) * Float64(Float64(Float64(x * 0.022222222222222223) * -0.3333333333333333) + Float64(x * 0.009523809523809525))))))) - x)) / B); else tmp = Float64(x * Float64(-1.0 + Float64(1.0 / Float64(B * x)))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 3.1) tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * ((x * 0.022222222222222223) + ((B * B) * (((x * 0.022222222222222223) * -0.3333333333333333) + (x * 0.009523809523809525))))))) - x)) / B; else tmp = x * (-1.0 + (1.0 / (B * x))); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 3.1], N[(N[(1.0 + N[(N[(N[(B * B), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] + N[(N[(B * B), $MachinePrecision] * N[(N[(x * 0.022222222222222223), $MachinePrecision] + N[(N[(B * B), $MachinePrecision] * N[(N[(N[(x * 0.022222222222222223), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + N[(x * 0.009523809523809525), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision], N[(x * N[(-1.0 + N[(1.0 / N[(B * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 3.1:\\
\;\;\;\;\frac{1 + \left(\left(B \cdot B\right) \cdot \left(x \cdot 0.3333333333333333 + \left(B \cdot B\right) \cdot \left(x \cdot 0.022222222222222223 + \left(B \cdot B\right) \cdot \left(\left(x \cdot 0.022222222222222223\right) \cdot -0.3333333333333333 + x \cdot 0.009523809523809525\right)\right)\right) - x\right)}{B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-1 + \frac{1}{B \cdot x}\right)\\
\end{array}
\end{array}
if B < 3.10000000000000009Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.9%
*-rgt-identity99.9%
tan-neg99.9%
distribute-neg-frac299.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in B around 0 84.0%
Taylor expanded in B around 0 66.1%
Simplified66.1%
if 3.10000000000000009 < B Initial program 99.6%
Taylor expanded in B around 0 3.8%
Taylor expanded in x around inf 3.8%
expm1-log1p-u3.3%
expm1-undefine3.0%
sub-neg3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
Applied egg-rr3.0%
sub-neg3.0%
log1p-undefine3.0%
rem-exp-log3.5%
metadata-eval3.5%
distribute-neg-frac3.5%
sub-neg3.5%
associate-/l/3.5%
div-sub3.5%
sub-neg3.5%
metadata-eval3.5%
metadata-eval3.5%
Simplified3.5%
Taylor expanded in x around 0 6.5%
Final simplification50.0%
(FPCore (B x)
:precision binary64
(if (<= B 3.1)
(/
(+
1.0
(-
(*
(* B B)
(+ (* x 0.3333333333333333) (* (* B B) (* x 0.022222222222222223))))
x))
B)
(* x (+ -1.0 (/ 1.0 (* B x))))))
double code(double B, double x) {
double tmp;
if (B <= 3.1) {
tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * (x * 0.022222222222222223)))) - x)) / B;
} else {
tmp = x * (-1.0 + (1.0 / (B * x)));
}
return tmp;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: tmp
if (b <= 3.1d0) then
tmp = (1.0d0 + (((b * b) * ((x * 0.3333333333333333d0) + ((b * b) * (x * 0.022222222222222223d0)))) - x)) / b
else
tmp = x * ((-1.0d0) + (1.0d0 / (b * x)))
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if (B <= 3.1) {
tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * (x * 0.022222222222222223)))) - x)) / B;
} else {
tmp = x * (-1.0 + (1.0 / (B * x)));
}
return tmp;
}
def code(B, x): tmp = 0 if B <= 3.1: tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * (x * 0.022222222222222223)))) - x)) / B else: tmp = x * (-1.0 + (1.0 / (B * x))) return tmp
function code(B, x) tmp = 0.0 if (B <= 3.1) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(B * B) * Float64(Float64(x * 0.3333333333333333) + Float64(Float64(B * B) * Float64(x * 0.022222222222222223)))) - x)) / B); else tmp = Float64(x * Float64(-1.0 + Float64(1.0 / Float64(B * x)))); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if (B <= 3.1) tmp = (1.0 + (((B * B) * ((x * 0.3333333333333333) + ((B * B) * (x * 0.022222222222222223)))) - x)) / B; else tmp = x * (-1.0 + (1.0 / (B * x))); end tmp_2 = tmp; end
code[B_, x_] := If[LessEqual[B, 3.1], N[(N[(1.0 + N[(N[(N[(B * B), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] + N[(N[(B * B), $MachinePrecision] * N[(x * 0.022222222222222223), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision], N[(x * N[(-1.0 + N[(1.0 / N[(B * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 3.1:\\
\;\;\;\;\frac{1 + \left(\left(B \cdot B\right) \cdot \left(x \cdot 0.3333333333333333 + \left(B \cdot B\right) \cdot \left(x \cdot 0.022222222222222223\right)\right) - x\right)}{B}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-1 + \frac{1}{B \cdot x}\right)\\
\end{array}
\end{array}
if B < 3.10000000000000009Initial program 99.8%
distribute-lft-neg-in99.8%
+-commutative99.8%
*-commutative99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
tan-neg99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
associate-*r/99.9%
*-rgt-identity99.9%
tan-neg99.9%
distribute-neg-frac299.9%
distribute-neg-frac99.9%
remove-double-neg99.9%
Simplified99.9%
Taylor expanded in B around 0 84.0%
Taylor expanded in B around 0 66.1%
associate--l+66.1%
unpow266.1%
+-commutative66.1%
unpow266.1%
distribute-rgt-out66.1%
metadata-eval66.1%
*-commutative66.1%
Simplified66.1%
if 3.10000000000000009 < B Initial program 99.6%
Taylor expanded in B around 0 3.8%
Taylor expanded in x around inf 3.8%
expm1-log1p-u3.3%
expm1-undefine3.0%
sub-neg3.0%
distribute-neg-frac3.0%
metadata-eval3.0%
Applied egg-rr3.0%
sub-neg3.0%
log1p-undefine3.0%
rem-exp-log3.5%
metadata-eval3.5%
distribute-neg-frac3.5%
sub-neg3.5%
associate-/l/3.5%
div-sub3.5%
sub-neg3.5%
metadata-eval3.5%
metadata-eval3.5%
Simplified3.5%
Taylor expanded in x around 0 6.5%
Final simplification50.0%
(FPCore (B x) :precision binary64 (if (or (<= x -1e+25) (not (<= x 6.8e-15))) (/ x (- B)) (/ (+ 1.0 x) B)))
double code(double B, double x) {
double tmp;
if ((x <= -1e+25) || !(x <= 6.8e-15)) {
tmp = x / -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 ((x <= (-1d+25)) .or. (.not. (x <= 6.8d-15))) then
tmp = x / -b
else
tmp = (1.0d0 + x) / b
end if
code = tmp
end function
public static double code(double B, double x) {
double tmp;
if ((x <= -1e+25) || !(x <= 6.8e-15)) {
tmp = x / -B;
} else {
tmp = (1.0 + x) / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1e+25) or not (x <= 6.8e-15): tmp = x / -B else: tmp = (1.0 + x) / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1e+25) || !(x <= 6.8e-15)) tmp = Float64(x / Float64(-B)); else tmp = Float64(Float64(1.0 + x) / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1e+25) || ~((x <= 6.8e-15))) tmp = x / -B; else tmp = (1.0 + x) / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1e+25], N[Not[LessEqual[x, 6.8e-15]], $MachinePrecision]], N[(x / (-B)), $MachinePrecision], N[(N[(1.0 + x), $MachinePrecision] / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+25} \lor \neg \left(x \leq 6.8 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + x}{B}\\
\end{array}
\end{array}
if x < -1.00000000000000009e25 or 6.8000000000000001e-15 < x Initial program 99.6%
Taylor expanded in B around 0 47.3%
Taylor expanded in x around inf 47.4%
if -1.00000000000000009e25 < x < 6.8000000000000001e-15Initial program 99.8%
add-cube-cbrt98.0%
pow398.0%
Applied egg-rr96.4%
Taylor expanded in B around 0 49.4%
Final simplification48.5%
(FPCore (B x) :precision binary64 (if (or (<= x -1e+25) (not (<= x 6.8e-15))) (/ x (- B)) (/ 1.0 B)))
double code(double B, double x) {
double tmp;
if ((x <= -1e+25) || !(x <= 6.8e-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 <= (-1d+25)) .or. (.not. (x <= 6.8d-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 <= -1e+25) || !(x <= 6.8e-15)) {
tmp = x / -B;
} else {
tmp = 1.0 / B;
}
return tmp;
}
def code(B, x): tmp = 0 if (x <= -1e+25) or not (x <= 6.8e-15): tmp = x / -B else: tmp = 1.0 / B return tmp
function code(B, x) tmp = 0.0 if ((x <= -1e+25) || !(x <= 6.8e-15)) tmp = Float64(x / Float64(-B)); else tmp = Float64(1.0 / B); end return tmp end
function tmp_2 = code(B, x) tmp = 0.0; if ((x <= -1e+25) || ~((x <= 6.8e-15))) tmp = x / -B; else tmp = 1.0 / B; end tmp_2 = tmp; end
code[B_, x_] := If[Or[LessEqual[x, -1e+25], N[Not[LessEqual[x, 6.8e-15]], $MachinePrecision]], N[(x / (-B)), $MachinePrecision], N[(1.0 / B), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+25} \lor \neg \left(x \leq 6.8 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{B}\\
\end{array}
\end{array}
if x < -1.00000000000000009e25 or 6.8000000000000001e-15 < x Initial program 99.6%
Taylor expanded in B around 0 47.3%
Taylor expanded in x around inf 47.4%
if -1.00000000000000009e25 < x < 6.8000000000000001e-15Initial program 99.8%
Taylor expanded in B around 0 50.2%
Taylor expanded in x around 0 49.4%
Final simplification48.5%
(FPCore (B x) :precision binary64 (+ (/ 1.0 B) (* x (+ (* B 0.3333333333333333) (/ -1.0 B)))))
double code(double B, double x) {
return (1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)));
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 / b) + (x * ((b * 0.3333333333333333d0) + ((-1.0d0) / b)))
end function
public static double code(double B, double x) {
return (1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)));
}
def code(B, x): return (1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B)))
function code(B, x) return Float64(Float64(1.0 / B) + Float64(x * Float64(Float64(B * 0.3333333333333333) + Float64(-1.0 / B)))) end
function tmp = code(B, x) tmp = (1.0 / B) + (x * ((B * 0.3333333333333333) + (-1.0 / B))); end
code[B_, x_] := N[(N[(1.0 / B), $MachinePrecision] + N[(x * N[(N[(B * 0.3333333333333333), $MachinePrecision] + N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{B} + x \cdot \left(B \cdot 0.3333333333333333 + \frac{-1}{B}\right)
\end{array}
Initial program 99.7%
distribute-lft-neg-in99.7%
+-commutative99.7%
*-commutative99.7%
remove-double-neg99.7%
distribute-frac-neg299.7%
tan-neg99.7%
cancel-sign-sub-inv99.7%
*-commutative99.7%
associate-*r/99.8%
*-rgt-identity99.8%
tan-neg99.8%
distribute-neg-frac299.8%
distribute-neg-frac99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in B around 0 71.8%
clear-num71.6%
frac-sub61.1%
*-un-lft-identity61.1%
metadata-eval61.1%
div-inv61.1%
/-rgt-identity61.1%
Applied egg-rr61.1%
Taylor expanded in B around 0 48.9%
sub-neg48.9%
metadata-eval48.9%
unpow248.9%
sub-neg48.9%
*-commutative48.9%
distribute-rgt-neg-in48.9%
sub-neg48.9%
metadata-eval48.9%
metadata-eval48.9%
Simplified48.9%
Taylor expanded in x around 0 49.4%
+-commutative49.4%
sub-neg49.4%
*-commutative49.4%
distribute-neg-frac49.4%
metadata-eval49.4%
Simplified49.4%
(FPCore (B x) :precision binary64 (/ (- 1.0 (/ (* B x) B)) B))
double code(double B, double x) {
return (1.0 - ((B * x) / B)) / B;
}
real(8) function code(b, x)
real(8), intent (in) :: b
real(8), intent (in) :: x
code = (1.0d0 - ((b * x) / b)) / b
end function
public static double code(double B, double x) {
return (1.0 - ((B * x) / B)) / B;
}
def code(B, x): return (1.0 - ((B * x) / B)) / B
function code(B, x) return Float64(Float64(1.0 - Float64(Float64(B * x) / B)) / B) end
function tmp = code(B, x) tmp = (1.0 - ((B * x) / B)) / B; end
code[B_, x_] := N[(N[(1.0 - N[(N[(B * x), $MachinePrecision] / B), $MachinePrecision]), $MachinePrecision] / B), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \frac{B \cdot x}{B}}{B}
\end{array}
Initial program 99.7%
Taylor expanded in B around 0 48.9%
div-sub48.9%
frac-sub34.6%
*-un-lft-identity34.6%
Applied egg-rr34.6%
associate-/r*49.0%
div-sub49.0%
*-inverses49.0%
Simplified49.0%
(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 48.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 48.9%
Taylor expanded in x around 0 28.5%
herbie shell --seed 2024098
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))