
(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 12 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 (if (<= x -4.9e+14) (- 1.0 (/ (- x) y)) (if (<= x 2e+14) (/ (fma (/ x y) x x) (- x -1.0)) (/ (- (+ y x) 1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= -4.9e+14) {
tmp = 1.0 - (-x / y);
} else if (x <= 2e+14) {
tmp = fma((x / y), x, x) / (x - -1.0);
} else {
tmp = ((y + x) - 1.0) / y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -4.9e+14) tmp = Float64(1.0 - Float64(Float64(-x) / y)); elseif (x <= 2e+14) tmp = Float64(fma(Float64(x / y), x, x) / Float64(x - -1.0)); else tmp = Float64(Float64(Float64(y + x) - 1.0) / y); end return tmp end
code[x_, y_] := If[LessEqual[x, -4.9e+14], N[(1.0 - N[((-x) / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e+14], N[(N[(N[(x / y), $MachinePrecision] * x + x), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] - 1.0), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.9 \cdot 10^{+14}:\\
\;\;\;\;1 - \frac{-x}{y}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{y}, x, x\right)}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y + x\right) - 1}{y}\\
\end{array}
\end{array}
if x < -4.9e14Initial program 71.3%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6431.1
Applied rewrites31.1%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
if -4.9e14 < x < 2e14Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.9
Applied rewrites99.9%
if 2e14 < x Initial program 75.3%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.5
Applied rewrites37.5%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0))))
(if (<= t_0 -50000000000000.0)
(/ x y)
(if (<= t_0 5e+18) (/ x (- x -1.0)) (/ (- x 1.0) y)))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if (t_0 <= -50000000000000.0) {
tmp = x / y;
} else if (t_0 <= 5e+18) {
tmp = x / (x - -1.0);
} else {
tmp = (x - 1.0) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x * ((x / y) + 1.0d0)) / (x - (-1.0d0))
if (t_0 <= (-50000000000000.0d0)) then
tmp = x / y
else if (t_0 <= 5d+18) then
tmp = x / (x - (-1.0d0))
else
tmp = (x - 1.0d0) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if (t_0 <= -50000000000000.0) {
tmp = x / y;
} else if (t_0 <= 5e+18) {
tmp = x / (x - -1.0);
} else {
tmp = (x - 1.0) / y;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x - -1.0) tmp = 0 if t_0 <= -50000000000000.0: tmp = x / y elif t_0 <= 5e+18: tmp = x / (x - -1.0) else: tmp = (x - 1.0) / y return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if (t_0 <= -50000000000000.0) tmp = Float64(x / y); elseif (t_0 <= 5e+18) tmp = Float64(x / Float64(x - -1.0)); else tmp = Float64(Float64(x - 1.0) / y); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x - -1.0); tmp = 0.0; if (t_0 <= -50000000000000.0) tmp = x / y; elseif (t_0 <= 5e+18) tmp = x / (x - -1.0); else tmp = (x - 1.0) / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50000000000000.0], N[(x / y), $MachinePrecision], If[LessEqual[t$95$0, 5e+18], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -50000000000000:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - 1}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e13Initial program 66.3%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f646.5
Applied rewrites6.5%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites88.4%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
mul-1-negN/A
remove-double-negN/A
lower-/.f6488.8
Applied rewrites88.8%
if -5e13 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5e18Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
rgt-mult-inverseN/A
cancel-sign-subN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6480.9
Applied rewrites80.9%
if 5e18 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 78.6%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6469.1
Applied rewrites69.1%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites80.9%
Taylor expanded in x around 0
Applied rewrites81.1%
Taylor expanded in y around 0
Applied rewrites81.1%
Final simplification82.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* x (+ (/ x y) 1.0)) (- x -1.0))))
(if (or (<= t_0 -50000000000000.0) (not (<= t_0 5e-9)))
(/ x y)
(* (- 1.0 x) x))))
double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if ((t_0 <= -50000000000000.0) || !(t_0 <= 5e-9)) {
tmp = x / y;
} else {
tmp = (1.0 - x) * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x * ((x / y) + 1.0d0)) / (x - (-1.0d0))
if ((t_0 <= (-50000000000000.0d0)) .or. (.not. (t_0 <= 5d-9))) then
tmp = x / y
else
tmp = (1.0d0 - x) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * ((x / y) + 1.0)) / (x - -1.0);
double tmp;
if ((t_0 <= -50000000000000.0) || !(t_0 <= 5e-9)) {
tmp = x / y;
} else {
tmp = (1.0 - x) * x;
}
return tmp;
}
def code(x, y): t_0 = (x * ((x / y) + 1.0)) / (x - -1.0) tmp = 0 if (t_0 <= -50000000000000.0) or not (t_0 <= 5e-9): tmp = x / y else: tmp = (1.0 - x) * x return tmp
function code(x, y) t_0 = Float64(Float64(x * Float64(Float64(x / y) + 1.0)) / Float64(x - -1.0)) tmp = 0.0 if ((t_0 <= -50000000000000.0) || !(t_0 <= 5e-9)) tmp = Float64(x / y); else tmp = Float64(Float64(1.0 - x) * x); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * ((x / y) + 1.0)) / (x - -1.0); tmp = 0.0; if ((t_0 <= -50000000000000.0) || ~((t_0 <= 5e-9))) tmp = x / y; else tmp = (1.0 - x) * x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -50000000000000.0], N[Not[LessEqual[t$95$0, 5e-9]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x - -1}\\
\mathbf{if}\;t\_0 \leq -50000000000000 \lor \neg \left(t\_0 \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - x\right) \cdot x\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < -5e13 or 5.0000000000000001e-9 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) Initial program 77.8%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.9
Applied rewrites37.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites84.8%
Taylor expanded in x around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r/N/A
mul-1-negN/A
remove-double-negN/A
lower-/.f6468.3
Applied rewrites68.3%
if -5e13 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) #s(literal 1 binary64))) (+.f64 x #s(literal 1 binary64))) < 5.0000000000000001e-9Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-+.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6499.5
Applied rewrites99.5%
Taylor expanded in y around inf
Applied rewrites79.0%
Final simplification73.0%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (- 1.0 (/ (- 1.0 x) y)) (if (<= x 1.0) (* (* (- 1.0 x) x) (+ 1.0 (/ x y))) (/ (- (+ y x) 1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0 - ((1.0 - x) / y);
} else if (x <= 1.0) {
tmp = ((1.0 - x) * x) * (1.0 + (x / y));
} else {
tmp = ((y + x) - 1.0) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = 1.0d0 - ((1.0d0 - x) / y)
else if (x <= 1.0d0) then
tmp = ((1.0d0 - x) * x) * (1.0d0 + (x / y))
else
tmp = ((y + x) - 1.0d0) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0 - ((1.0 - x) / y);
} else if (x <= 1.0) {
tmp = ((1.0 - x) * x) * (1.0 + (x / y));
} else {
tmp = ((y + x) - 1.0) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 - ((1.0 - x) / y) elif x <= 1.0: tmp = ((1.0 - x) * x) * (1.0 + (x / y)) else: tmp = ((y + x) - 1.0) / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(1.0 - Float64(Float64(1.0 - x) / y)); elseif (x <= 1.0) tmp = Float64(Float64(Float64(1.0 - x) * x) * Float64(1.0 + Float64(x / y))); else tmp = Float64(Float64(Float64(y + x) - 1.0) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = 1.0 - ((1.0 - x) / y); elseif (x <= 1.0) tmp = ((1.0 - x) * x) * (1.0 + (x / y)); else tmp = ((y + x) - 1.0) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(1.0 - N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision] * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] - 1.0), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1 - \frac{1 - x}{y}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\left(\left(1 - x\right) \cdot x\right) \cdot \left(1 + \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y + x\right) - 1}{y}\\
\end{array}
\end{array}
if x < -1Initial program 72.2%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6431.7
Applied rewrites31.7%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites98.9%
if -1 < x < 1Initial program 99.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-lft-identityN/A
lower--.f6499.5
Applied rewrites99.5%
if 1 < x Initial program 76.9%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6438.3
Applied rewrites38.3%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites96.4%
Taylor expanded in x around 0
Applied rewrites96.5%
Taylor expanded in x around 0
Applied rewrites96.5%
Final simplification98.6%
(FPCore (x y) :precision binary64 (* (/ x (+ 1.0 x)) (+ 1.0 (/ x y))))
double code(double x, double y) {
return (x / (1.0 + x)) * (1.0 + (x / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (1.0d0 + x)) * (1.0d0 + (x / y))
end function
public static double code(double x, double y) {
return (x / (1.0 + x)) * (1.0 + (x / y));
}
def code(x, y): return (x / (1.0 + x)) * (1.0 + (x / y))
function code(x, y) return Float64(Float64(x / Float64(1.0 + x)) * Float64(1.0 + Float64(x / y))) end
function tmp = code(x, y) tmp = (x / (1.0 + x)) * (1.0 + (x / y)); end
code[x_, y_] := N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + x} \cdot \left(1 + \frac{x}{y}\right)
\end{array}
Initial program 87.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (- 1.0 (/ (- 1.0 x) y)) (if (<= x 1.0) (fma (- (/ x y) x) x x) (/ (- (+ y x) 1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0 - ((1.0 - x) / y);
} else if (x <= 1.0) {
tmp = fma(((x / y) - x), x, x);
} else {
tmp = ((y + x) - 1.0) / y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(1.0 - Float64(Float64(1.0 - x) / y)); elseif (x <= 1.0) tmp = fma(Float64(Float64(x / y) - x), x, x); else tmp = Float64(Float64(Float64(y + x) - 1.0) / y); end return tmp end
code[x_, y_] := If[LessEqual[x, -1.0], N[(1.0 - N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision] * x + x), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] - 1.0), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1 - \frac{1 - x}{y}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y} - x, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y + x\right) - 1}{y}\\
\end{array}
\end{array}
if x < -1Initial program 72.2%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6431.7
Applied rewrites31.7%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites98.9%
if -1 < x < 1Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-+.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
Taylor expanded in x around inf
Applied rewrites98.7%
if 1 < x Initial program 76.9%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6438.3
Applied rewrites38.3%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites96.4%
Taylor expanded in x around 0
Applied rewrites96.5%
Taylor expanded in x around 0
Applied rewrites96.5%
Final simplification98.3%
(FPCore (x y) :precision binary64 (if (or (<= x -98000.0) (not (<= x 1.75e+14))) (- 1.0 (/ (- 1.0 x) y)) (/ x (- x -1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -98000.0) || !(x <= 1.75e+14)) {
tmp = 1.0 - ((1.0 - x) / y);
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-98000.0d0)) .or. (.not. (x <= 1.75d+14))) then
tmp = 1.0d0 - ((1.0d0 - x) / y)
else
tmp = x / (x - (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -98000.0) || !(x <= 1.75e+14)) {
tmp = 1.0 - ((1.0 - x) / y);
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -98000.0) or not (x <= 1.75e+14): tmp = 1.0 - ((1.0 - x) / y) else: tmp = x / (x - -1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -98000.0) || !(x <= 1.75e+14)) tmp = Float64(1.0 - Float64(Float64(1.0 - x) / y)); else tmp = Float64(x / Float64(x - -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -98000.0) || ~((x <= 1.75e+14))) tmp = 1.0 - ((1.0 - x) / y); else tmp = x / (x - -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -98000.0], N[Not[LessEqual[x, 1.75e+14]], $MachinePrecision]], N[(1.0 - N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -98000 \lor \neg \left(x \leq 1.75 \cdot 10^{+14}\right):\\
\;\;\;\;1 - \frac{1 - x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - -1}\\
\end{array}
\end{array}
if x < -98000 or 1.75e14 < x Initial program 73.5%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6434.7
Applied rewrites34.7%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.9%
if -98000 < x < 1.75e14Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
rgt-mult-inverseN/A
cancel-sign-subN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6469.6
Applied rewrites69.6%
Final simplification83.8%
(FPCore (x y) :precision binary64 (if (<= x -98000.0) (- 1.0 (/ (- 1.0 x) y)) (if (<= x 1.75e+14) (/ x (- x -1.0)) (/ (- (+ y x) 1.0) y))))
double code(double x, double y) {
double tmp;
if (x <= -98000.0) {
tmp = 1.0 - ((1.0 - x) / y);
} else if (x <= 1.75e+14) {
tmp = x / (x - -1.0);
} else {
tmp = ((y + x) - 1.0) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-98000.0d0)) then
tmp = 1.0d0 - ((1.0d0 - x) / y)
else if (x <= 1.75d+14) then
tmp = x / (x - (-1.0d0))
else
tmp = ((y + x) - 1.0d0) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -98000.0) {
tmp = 1.0 - ((1.0 - x) / y);
} else if (x <= 1.75e+14) {
tmp = x / (x - -1.0);
} else {
tmp = ((y + x) - 1.0) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -98000.0: tmp = 1.0 - ((1.0 - x) / y) elif x <= 1.75e+14: tmp = x / (x - -1.0) else: tmp = ((y + x) - 1.0) / y return tmp
function code(x, y) tmp = 0.0 if (x <= -98000.0) tmp = Float64(1.0 - Float64(Float64(1.0 - x) / y)); elseif (x <= 1.75e+14) tmp = Float64(x / Float64(x - -1.0)); else tmp = Float64(Float64(Float64(y + x) - 1.0) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -98000.0) tmp = 1.0 - ((1.0 - x) / y); elseif (x <= 1.75e+14) tmp = x / (x - -1.0); else tmp = ((y + x) - 1.0) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -98000.0], N[(1.0 - N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.75e+14], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] - 1.0), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -98000:\\
\;\;\;\;1 - \frac{1 - x}{y}\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+14}:\\
\;\;\;\;\frac{x}{x - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y + x\right) - 1}{y}\\
\end{array}
\end{array}
if x < -98000Initial program 71.8%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6432.2
Applied rewrites32.2%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites99.8%
if -98000 < x < 1.75e14Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
rgt-mult-inverseN/A
cancel-sign-subN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6469.6
Applied rewrites69.6%
if 1.75e14 < x Initial program 75.3%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.5
Applied rewrites37.5%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification83.8%
(FPCore (x y) :precision binary64 (if (or (<= x -105000.0) (not (<= x 1.75e+14))) (- 1.0 (/ (- x) y)) (/ x (- x -1.0))))
double code(double x, double y) {
double tmp;
if ((x <= -105000.0) || !(x <= 1.75e+14)) {
tmp = 1.0 - (-x / y);
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-105000.0d0)) .or. (.not. (x <= 1.75d+14))) then
tmp = 1.0d0 - (-x / y)
else
tmp = x / (x - (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -105000.0) || !(x <= 1.75e+14)) {
tmp = 1.0 - (-x / y);
} else {
tmp = x / (x - -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -105000.0) or not (x <= 1.75e+14): tmp = 1.0 - (-x / y) else: tmp = x / (x - -1.0) return tmp
function code(x, y) tmp = 0.0 if ((x <= -105000.0) || !(x <= 1.75e+14)) tmp = Float64(1.0 - Float64(Float64(-x) / y)); else tmp = Float64(x / Float64(x - -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -105000.0) || ~((x <= 1.75e+14))) tmp = 1.0 - (-x / y); else tmp = x / (x - -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -105000.0], N[Not[LessEqual[x, 1.75e+14]], $MachinePrecision]], N[(1.0 - N[((-x) / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -105000 \lor \neg \left(x \leq 1.75 \cdot 10^{+14}\right):\\
\;\;\;\;1 - \frac{-x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x - -1}\\
\end{array}
\end{array}
if x < -105000 or 1.75e14 < x Initial program 73.5%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6434.7
Applied rewrites34.7%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites99.6%
if -105000 < x < 1.75e14Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
rgt-mult-inverseN/A
cancel-sign-subN/A
distribute-lft-neg-outN/A
rgt-mult-inverseN/A
metadata-evalN/A
lower--.f6469.6
Applied rewrites69.6%
Final simplification83.7%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (- x 1.0) y) (* (- 1.0 x) x)))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (x - 1.0) / y;
} else {
tmp = (1.0 - x) * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (x - 1.0d0) / y
else
tmp = (1.0d0 - x) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (x - 1.0) / y;
} else {
tmp = (1.0 - x) * x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = (x - 1.0) / y else: tmp = (1.0 - x) * x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(Float64(x - 1.0) / y); else tmp = Float64(Float64(1.0 - x) * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = (x - 1.0) / y; else tmp = (1.0 - x) * x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(x - 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x - 1}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - x\right) \cdot x\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 74.5%
lift-+.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6434.9
Applied rewrites34.9%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites97.7%
Taylor expanded in y around 0
Applied rewrites78.4%
if -1 < x < 1Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-+.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
Taylor expanded in y around inf
Applied rewrites68.1%
Final simplification73.1%
(FPCore (x y) :precision binary64 (* (- 1.0 x) x))
double code(double x, double y) {
return (1.0 - x) * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) * x
end function
public static double code(double x, double y) {
return (1.0 - x) * x;
}
def code(x, y): return (1.0 - x) * x
function code(x, y) return Float64(Float64(1.0 - x) * x) end
function tmp = code(x, y) tmp = (1.0 - x) * x; end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) \cdot x
\end{array}
Initial program 87.5%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-+.f64N/A
lower-*.f6487.5
Applied rewrites87.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6458.4
Applied rewrites58.4%
Taylor expanded in y around inf
Applied rewrites42.2%
Final simplification42.2%
(FPCore (x y) :precision binary64 (* 1.0 x))
double code(double x, double y) {
return 1.0 * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 * x
end function
public static double code(double x, double y) {
return 1.0 * x;
}
def code(x, y): return 1.0 * x
function code(x, y) return Float64(1.0 * x) end
function tmp = code(x, y) tmp = 1.0 * x; end
code[x_, y_] := N[(1.0 * x), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot x
\end{array}
Initial program 87.5%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-+.f64N/A
lower-*.f6487.5
Applied rewrites87.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6458.4
Applied rewrites58.4%
Taylor expanded in x around 0
Applied rewrites36.4%
Final simplification36.4%
(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 2024339
(FPCore (x y)
:name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
:precision binary64
:alt
(! :herbie-platform default (* (/ x 1) (/ (+ (/ x y) 1) (+ x 1))))
(/ (* x (+ (/ x y) 1.0)) (+ x 1.0)))