
(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 3 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}
(FPCore (x y) :precision binary64 (/ (- 1.0 x) (/ (* 3.0 y) (- 3.0 x))))
double code(double x, double y) {
return (1.0 - x) / ((3.0 * y) / (3.0 - x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) / ((3.0d0 * y) / (3.0d0 - x))
end function
public static double code(double x, double y) {
return (1.0 - x) / ((3.0 * y) / (3.0 - x));
}
def code(x, y): return (1.0 - x) / ((3.0 * y) / (3.0 - x))
function code(x, y) return Float64(Float64(1.0 - x) / Float64(Float64(3.0 * y) / Float64(3.0 - x))) end
function tmp = code(x, y) tmp = (1.0 - x) / ((3.0 * y) / (3.0 - x)); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] / N[(N[(3.0 * y), $MachinePrecision] / N[(3.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - x}{\frac{3 \cdot y}{3 - x}}
\end{array}
Initial program 99.7%
associate-/l*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (* (- 3.0 x) (/ (- 1.0 x) (* 3.0 y))))
double code(double x, double y) {
return (3.0 - x) * ((1.0 - x) / (3.0 * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 - x) * ((1.0d0 - x) / (3.0d0 * y))
end function
public static double code(double x, double y) {
return (3.0 - x) * ((1.0 - x) / (3.0 * y));
}
def code(x, y): return (3.0 - x) * ((1.0 - x) / (3.0 * y))
function code(x, y) return Float64(Float64(3.0 - x) * Float64(Float64(1.0 - x) / Float64(3.0 * y))) end
function tmp = code(x, y) tmp = (3.0 - x) * ((1.0 - x) / (3.0 * y)); end
code[x_, y_] := N[(N[(3.0 - x), $MachinePrecision] * N[(N[(1.0 - x), $MachinePrecision] / N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 - x\right) \cdot \frac{1 - x}{3 \cdot y}
\end{array}
Initial program 99.7%
associate-*l/99.6%
*-commutative99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (* (- 3.0 x) (/ (/ (- 1.0 x) y) 3.0)))
double code(double x, double y) {
return (3.0 - x) * (((1.0 - x) / y) / 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 - x) * (((1.0d0 - x) / y) / 3.0d0)
end function
public static double code(double x, double y) {
return (3.0 - x) * (((1.0 - x) / y) / 3.0);
}
def code(x, y): return (3.0 - x) * (((1.0 - x) / y) / 3.0)
function code(x, y) return Float64(Float64(3.0 - x) * Float64(Float64(Float64(1.0 - x) / y) / 3.0)) end
function tmp = code(x, y) tmp = (3.0 - x) * (((1.0 - x) / y) / 3.0); end
code[x_, y_] := N[(N[(3.0 - x), $MachinePrecision] * N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 - x\right) \cdot \frac{\frac{1 - x}{y}}{3}
\end{array}
Initial program 99.7%
associate-*l/99.6%
*-commutative99.6%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
(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 2023278
(FPCore (x y)
:name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(* (/ (- 1.0 x) y) (/ (- 3.0 x) 3.0))
(/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))