
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))
double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * ((x / y) + 1.0d0)) / (x + 1.0d0)
end function
public static double code(double x, double y) {
return (x * ((x / y) + 1.0)) / (x + 1.0);
}
def code(x, y): return (x * ((x / y) + 1.0)) / (x + 1.0)
function code(x, y) return Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = (x * ((x / y) + 1.0)) / (x + 1.0); end
code[x_, y_] := N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}
(FPCore (x y) :precision binary64 (/ x (/ (+ x 1.0) (+ 1.0 (/ x y)))))
double code(double x, double y) {
return x / ((x + 1.0) / (1.0 + (x / y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / ((x + 1.0d0) / (1.0d0 + (x / y)))
end function
public static double code(double x, double y) {
return x / ((x + 1.0) / (1.0 + (x / y)));
}
def code(x, y): return x / ((x + 1.0) / (1.0 + (x / y)))
function code(x, y) return Float64(x / Float64(Float64(x + 1.0) / Float64(1.0 + Float64(x / y)))) end
function tmp = code(x, y) tmp = x / ((x + 1.0) / (1.0 + (x / y))); end
code[x_, y_] := N[(x / N[(N[(x + 1.0), $MachinePrecision] / N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x + 1}{1 + \frac{x}{y}}}
\end{array}
Initial program 86.8%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (+ 1.0 (/ (+ x -1.0) y)))
double code(double x, double y) {
return 1.0 + ((x + -1.0) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + ((x + (-1.0d0)) / y)
end function
public static double code(double x, double y) {
return 1.0 + ((x + -1.0) / y);
}
def code(x, y): return 1.0 + ((x + -1.0) / y)
function code(x, y) return Float64(1.0 + Float64(Float64(x + -1.0) / y)) end
function tmp = code(x, y) tmp = 1.0 + ((x + -1.0) / y); end
code[x_, y_] := N[(1.0 + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{x + -1}{y}
\end{array}
Initial program 86.8%
*-commutative86.8%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-lft-identity99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in x around inf 53.3%
+-commutative53.3%
associate-+r-53.3%
+-commutative53.3%
associate-+l-53.3%
div-sub53.3%
Simplified53.3%
Final simplification53.3%
(FPCore (x y) :precision binary64 (/ x (+ x 1.0)))
double code(double x, double y) {
return x / (x + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (x + 1.0d0)
end function
public static double code(double x, double y) {
return x / (x + 1.0);
}
def code(x, y): return x / (x + 1.0)
function code(x, y) return Float64(x / Float64(x + 1.0)) end
function tmp = code(x, y) tmp = x / (x + 1.0); end
code[x_, y_] := N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + 1}
\end{array}
Initial program 86.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 49.3%
Final simplification49.3%
(FPCore (x y) :precision binary64 (+ 1.0 (/ x y)))
double code(double x, double y) {
return 1.0 + (x / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + (x / y)
end function
public static double code(double x, double y) {
return 1.0 + (x / y);
}
def code(x, y): return 1.0 + (x / y)
function code(x, y) return Float64(1.0 + Float64(x / y)) end
function tmp = code(x, y) tmp = 1.0 + (x / y); end
code[x_, y_] := N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{x}{y}
\end{array}
Initial program 86.8%
*-commutative86.8%
associate-/l*99.8%
remove-double-neg99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
*-inverses99.8%
div-sub99.8%
associate-/r*99.8%
*-commutative99.8%
neg-mul-199.8%
remove-double-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-lft-identity99.8%
associate-*l/99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in x around inf 53.3%
+-commutative53.3%
associate-+r-53.3%
+-commutative53.3%
associate-+l-53.3%
div-sub53.3%
Simplified53.3%
Taylor expanded in x around inf 53.1%
mul-1-neg53.1%
distribute-frac-neg53.1%
Simplified53.1%
Final simplification53.1%
(FPCore (x y) :precision binary64 (/ x y))
double code(double x, double y) {
return x / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
public static double code(double x, double y) {
return x / y;
}
def code(x, y): return x / y
function code(x, y) return Float64(x / y) end
function tmp = code(x, y) tmp = x / y; end
code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 86.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 41.9%
Final simplification41.9%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 86.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around 0 37.2%
Final simplification37.2%
(FPCore (x y) :precision binary64 (* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0))))
double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / 1.0d0) * (((x / y) + 1.0d0) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0));
}
def code(x, y): return (x / 1.0) * (((x / y) + 1.0) / (x + 1.0))
function code(x, y) return Float64(Float64(x / 1.0) * Float64(Float64(Float64(x / y) + 1.0) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = (x / 1.0) * (((x / y) + 1.0) / (x + 1.0)); end
code[x_, y_] := N[(N[(x / 1.0), $MachinePrecision] * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1} \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}
herbie shell --seed 2024033
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:herbie-target
(* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))