
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\end{array}
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m)
:precision binary64
(*
y_s
(if (<= (/ (* (- 1.0 x) (- 3.0 x)) (* 3.0 y_m)) 2e+306)
(/ (* (- 1.0 x) (fma x -0.3333333333333333 1.0)) y_m)
(* x (* x (/ 0.3333333333333333 y_m))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
double tmp;
if ((((1.0 - x) * (3.0 - x)) / (3.0 * y_m)) <= 2e+306) {
tmp = ((1.0 - x) * fma(x, -0.3333333333333333, 1.0)) / y_m;
} else {
tmp = x * (x * (0.3333333333333333 / y_m));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) tmp = 0.0 if (Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(3.0 * y_m)) <= 2e+306) tmp = Float64(Float64(Float64(1.0 - x) * fma(x, -0.3333333333333333, 1.0)) / y_m); else tmp = Float64(x * Float64(x * Float64(0.3333333333333333 / y_m))); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * If[LessEqual[N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(3.0 * y$95$m), $MachinePrecision]), $MachinePrecision], 2e+306], N[(N[(N[(1.0 - x), $MachinePrecision] * N[(x * -0.3333333333333333 + 1.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(x * N[(x * N[(0.3333333333333333 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{3 \cdot y\_m} \leq 2 \cdot 10^{+306}:\\
\;\;\;\;\frac{\left(1 - x\right) \cdot \mathsf{fma}\left(x, -0.3333333333333333, 1\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y\_m}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) (*.f64 y #s(literal 3 binary64))) < 2.00000000000000003e306Initial program 95.8%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval96.0
Simplified96.0%
if 2.00000000000000003e306 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) (*.f64 y #s(literal 3 binary64))) Initial program 86.5%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval86.5
Simplified86.5%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64100.0
Simplified100.0%
Final simplification96.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m)
:precision binary64
(*
y_s
(if (<= (/ (* (- 1.0 x) (- 3.0 x)) (* 3.0 y_m)) 2e+306)
(/ (fma x (fma x 0.3333333333333333 -1.3333333333333333) 1.0) y_m)
(* x (* x (/ 0.3333333333333333 y_m))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
double tmp;
if ((((1.0 - x) * (3.0 - x)) / (3.0 * y_m)) <= 2e+306) {
tmp = fma(x, fma(x, 0.3333333333333333, -1.3333333333333333), 1.0) / y_m;
} else {
tmp = x * (x * (0.3333333333333333 / y_m));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) tmp = 0.0 if (Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(3.0 * y_m)) <= 2e+306) tmp = Float64(fma(x, fma(x, 0.3333333333333333, -1.3333333333333333), 1.0) / y_m); else tmp = Float64(x * Float64(x * Float64(0.3333333333333333 / y_m))); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * If[LessEqual[N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(3.0 * y$95$m), $MachinePrecision]), $MachinePrecision], 2e+306], N[(N[(x * N[(x * 0.3333333333333333 + -1.3333333333333333), $MachinePrecision] + 1.0), $MachinePrecision] / y$95$m), $MachinePrecision], N[(x * N[(x * N[(0.3333333333333333 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{3 \cdot y\_m} \leq 2 \cdot 10^{+306}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.3333333333333333, -1.3333333333333333\right), 1\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y\_m}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) (*.f64 y #s(literal 3 binary64))) < 2.00000000000000003e306Initial program 95.8%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval96.0
Simplified96.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6495.9
Simplified95.9%
if 2.00000000000000003e306 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) (*.f64 y #s(literal 3 binary64))) Initial program 86.5%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval86.5
Simplified86.5%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64100.0
Simplified100.0%
Final simplification96.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m)
:precision binary64
(*
y_s
(if (<= (* (- 1.0 x) (- 3.0 x)) 5.0)
(/ (fma -1.3333333333333333 x 1.0) y_m)
(* x (/ (fma x 0.3333333333333333 -1.3333333333333333) y_m)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y_m;
} else {
tmp = x * (fma(x, 0.3333333333333333, -1.3333333333333333) / y_m);
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y_m); else tmp = Float64(x * Float64(fma(x, 0.3333333333333333, -1.3333333333333333) / y_m)); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y$95$m), $MachinePrecision], N[(x * N[(N[(x * 0.3333333333333333 + -1.3333333333333333), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\mathsf{fma}\left(x, 0.3333333333333333, -1.3333333333333333\right)}{y\_m}\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 99.6%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval100.0
Simplified100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
mul-1-negN/A
rgt-mult-inverseN/A
mul-1-negN/A
distribute-neg-frac2N/A
associate-*r/N/A
distribute-neg-fracN/A
associate-/r*N/A
distribute-lft-inN/A
sub-negN/A
Simplified100.0%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 89.4%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval89.3
Simplified89.3%
Taylor expanded in x around inf
Simplified98.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m)
:precision binary64
(*
y_s
(if (<= (* (- 1.0 x) (- 3.0 x)) 5.0)
(/ (fma -1.3333333333333333 x 1.0) y_m)
(* x (* x (/ 0.3333333333333333 y_m))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y_m;
} else {
tmp = x * (x * (0.3333333333333333 / y_m));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y_m); else tmp = Float64(x * Float64(x * Float64(0.3333333333333333 / y_m))); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y$95$m), $MachinePrecision], N[(x * N[(x * N[(0.3333333333333333 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y\_m}\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 99.6%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval100.0
Simplified100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
mul-1-negN/A
rgt-mult-inverseN/A
mul-1-negN/A
distribute-neg-frac2N/A
associate-*r/N/A
distribute-neg-fracN/A
associate-/r*N/A
distribute-lft-inN/A
sub-negN/A
Simplified100.0%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 89.4%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval89.3
Simplified89.3%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6496.7
Simplified96.7%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m)
:precision binary64
(*
y_s
(if (<= (* (- 1.0 x) (- 3.0 x)) 5.0)
(/ (fma -1.3333333333333333 x 1.0) y_m)
(* 0.3333333333333333 (/ (* x x) y_m)))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y_m;
} else {
tmp = 0.3333333333333333 * ((x * x) / y_m);
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y_m); else tmp = Float64(0.3333333333333333 * Float64(Float64(x * x) / y_m)); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y$95$m), $MachinePrecision], N[(0.3333333333333333 * N[(N[(x * x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{x \cdot x}{y\_m}\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 99.6%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval100.0
Simplified100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
mul-1-negN/A
rgt-mult-inverseN/A
mul-1-negN/A
distribute-neg-frac2N/A
associate-*r/N/A
distribute-neg-fracN/A
associate-/r*N/A
distribute-lft-inN/A
sub-negN/A
Simplified100.0%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 89.4%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval89.3
Simplified89.3%
Taylor expanded in x around inf
*-commutativeN/A
unpow2N/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6496.7
Simplified96.7%
Taylor expanded in x around 0
associate-*r/N/A
*-rgt-identityN/A
associate-*r/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
unpow2N/A
lower-*.f6486.4
Simplified86.4%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m) :precision binary64 (* y_s (if (<= x -0.75) (* x (/ -1.3333333333333333 y_m)) (/ 1.0 y_m))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
double tmp;
if (x <= -0.75) {
tmp = x * (-1.3333333333333333 / y_m);
} else {
tmp = 1.0 / y_m;
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8) :: tmp
if (x <= (-0.75d0)) then
tmp = x * ((-1.3333333333333333d0) / y_m)
else
tmp = 1.0d0 / y_m
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m) {
double tmp;
if (x <= -0.75) {
tmp = x * (-1.3333333333333333 / y_m);
} else {
tmp = 1.0 / y_m;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m): tmp = 0 if x <= -0.75: tmp = x * (-1.3333333333333333 / y_m) else: tmp = 1.0 / y_m return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) tmp = 0.0 if (x <= -0.75) tmp = Float64(x * Float64(-1.3333333333333333 / y_m)); else tmp = Float64(1.0 / y_m); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m) tmp = 0.0; if (x <= -0.75) tmp = x * (-1.3333333333333333 / y_m); else tmp = 1.0 / y_m; end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * If[LessEqual[x, -0.75], N[(x * N[(-1.3333333333333333 / y$95$m), $MachinePrecision]), $MachinePrecision], N[(1.0 / y$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq -0.75:\\
\;\;\;\;x \cdot \frac{-1.3333333333333333}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m}\\
\end{array}
\end{array}
if x < -0.75Initial program 91.6%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval91.5
Simplified91.5%
Taylor expanded in x around inf
Simplified98.0%
Taylor expanded in x around 0
lower-/.f6426.3
Simplified26.3%
if -0.75 < x Initial program 95.2%
Taylor expanded in x around 0
lower-/.f6466.5
Simplified66.5%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m) :precision binary64 (* y_s (/ (fma -1.3333333333333333 x 1.0) y_m)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
return y_s * (fma(-1.3333333333333333, x, 1.0) / y_m);
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) return Float64(y_s * Float64(fma(-1.3333333333333333, x, 1.0) / y_m)) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y\_m}
\end{array}
Initial program 94.3%
Taylor expanded in y around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval94.4
Simplified94.4%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
mul-1-negN/A
rgt-mult-inverseN/A
mul-1-negN/A
distribute-neg-frac2N/A
associate-*r/N/A
distribute-neg-fracN/A
associate-/r*N/A
distribute-lft-inN/A
sub-negN/A
Simplified54.8%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m) :precision binary64 (* y_s (/ 1.0 y_m)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m) {
return y_s * (1.0 / y_m);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = y_s * (1.0d0 / y_m)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m) {
return y_s * (1.0 / y_m);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m): return y_s * (1.0 / y_m)
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m) return Float64(y_s * Float64(1.0 / y_m)) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m) tmp = y_s * (1.0 / y_m); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_] := N[(y$95$s * N[(1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \frac{1}{y\_m}
\end{array}
Initial program 94.3%
Taylor expanded in x around 0
lower-/.f6450.2
Simplified50.2%
(FPCore (x y) :precision binary64 (* (/ (- 1.0 x) y) (/ (- 3.0 x) 3.0)))
double code(double x, double y) {
return ((1.0 - x) / y) * ((3.0 - x) / 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) / y) * ((3.0d0 - x) / 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) / y) * ((3.0 - x) / 3.0);
}
def code(x, y): return ((1.0 - x) / y) * ((3.0 - x) / 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) / y) * Float64(Float64(3.0 - x) / 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) / y) * ((3.0 - x) / 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] * N[(N[(3.0 - x), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{y} \cdot \frac{3 - x}{3}
\end{array}
herbie shell --seed 2024215
(FPCore (x y)
:name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (* (/ (- 1 x) y) (/ (- 3 x) 3)))
(/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))