
(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 (/ 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 87.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -110000000.0)
t_0
(if (<= x -5.5e-88)
(/ (* x (/ x y)) (+ x 1.0))
(if (<= x 20000.0) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -110000000.0) {
tmp = t_0;
} else if (x <= -5.5e-88) {
tmp = (x * (x / y)) / (x + 1.0);
} else if (x <= 20000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
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 = 1.0d0 + (x / y)
if (x <= (-110000000.0d0)) then
tmp = t_0
else if (x <= (-5.5d-88)) then
tmp = (x * (x / y)) / (x + 1.0d0)
else if (x <= 20000.0d0) then
tmp = x / (x + 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -110000000.0) {
tmp = t_0;
} else if (x <= -5.5e-88) {
tmp = (x * (x / y)) / (x + 1.0);
} else if (x <= 20000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -110000000.0: tmp = t_0 elif x <= -5.5e-88: tmp = (x * (x / y)) / (x + 1.0) elif x <= 20000.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -110000000.0) tmp = t_0; elseif (x <= -5.5e-88) tmp = Float64(Float64(x * Float64(x / y)) / Float64(x + 1.0)); elseif (x <= 20000.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -110000000.0) tmp = t_0; elseif (x <= -5.5e-88) tmp = (x * (x / y)) / (x + 1.0); elseif (x <= 20000.0) tmp = x / (x + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -110000000.0], t$95$0, If[LessEqual[x, -5.5e-88], N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 20000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -110000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.5 \cdot 10^{-88}:\\
\;\;\;\;\frac{x \cdot \frac{x}{y}}{x + 1}\\
\mathbf{elif}\;x \leq 20000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.1e8 or 2e4 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 98.7%
Taylor expanded in x around 0 98.8%
if -1.1e8 < x < -5.49999999999999971e-88Initial program 99.7%
Taylor expanded in x around inf 67.7%
if -5.49999999999999971e-88 < x < 2e4Initial program 99.9%
Taylor expanded in y around inf 81.3%
Final simplification88.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -92000000.0)
t_0
(if (<= x -5.8e-88)
(* x (/ (/ x y) (+ x 1.0)))
(if (<= x 1100.0) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -92000000.0) {
tmp = t_0;
} else if (x <= -5.8e-88) {
tmp = x * ((x / y) / (x + 1.0));
} else if (x <= 1100.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
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 = 1.0d0 + (x / y)
if (x <= (-92000000.0d0)) then
tmp = t_0
else if (x <= (-5.8d-88)) then
tmp = x * ((x / y) / (x + 1.0d0))
else if (x <= 1100.0d0) then
tmp = x / (x + 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -92000000.0) {
tmp = t_0;
} else if (x <= -5.8e-88) {
tmp = x * ((x / y) / (x + 1.0));
} else if (x <= 1100.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -92000000.0: tmp = t_0 elif x <= -5.8e-88: tmp = x * ((x / y) / (x + 1.0)) elif x <= 1100.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -92000000.0) tmp = t_0; elseif (x <= -5.8e-88) tmp = Float64(x * Float64(Float64(x / y) / Float64(x + 1.0))); elseif (x <= 1100.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -92000000.0) tmp = t_0; elseif (x <= -5.8e-88) tmp = x * ((x / y) / (x + 1.0)); elseif (x <= 1100.0) tmp = x / (x + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -92000000.0], t$95$0, If[LessEqual[x, -5.8e-88], N[(x * N[(N[(x / y), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1100.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -92000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-88}:\\
\;\;\;\;x \cdot \frac{\frac{x}{y}}{x + 1}\\
\mathbf{elif}\;x \leq 1100:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -9.2e7 or 1100 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 98.7%
Taylor expanded in x around 0 98.8%
if -9.2e7 < x < -5.8000000000000003e-88Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in x around inf 67.7%
if -5.8000000000000003e-88 < x < 1100Initial program 99.9%
Taylor expanded in y around inf 81.3%
Final simplification88.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -5200000.0)
t_0
(if (<= x -5.8e-88)
(/ x (+ y (/ y x)))
(if (<= x 49000.0) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -5200000.0) {
tmp = t_0;
} else if (x <= -5.8e-88) {
tmp = x / (y + (y / x));
} else if (x <= 49000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
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 = 1.0d0 + (x / y)
if (x <= (-5200000.0d0)) then
tmp = t_0
else if (x <= (-5.8d-88)) then
tmp = x / (y + (y / x))
else if (x <= 49000.0d0) then
tmp = x / (x + 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -5200000.0) {
tmp = t_0;
} else if (x <= -5.8e-88) {
tmp = x / (y + (y / x));
} else if (x <= 49000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -5200000.0: tmp = t_0 elif x <= -5.8e-88: tmp = x / (y + (y / x)) elif x <= 49000.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -5200000.0) tmp = t_0; elseif (x <= -5.8e-88) tmp = Float64(x / Float64(y + Float64(y / x))); elseif (x <= 49000.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -5200000.0) tmp = t_0; elseif (x <= -5.8e-88) tmp = x / (y + (y / x)); elseif (x <= 49000.0) tmp = x / (x + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5200000.0], t$95$0, If[LessEqual[x, -5.8e-88], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 49000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -5200000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-88}:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\
\mathbf{elif}\;x \leq 49000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.2e6 or 49000 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 98.7%
Taylor expanded in x around 0 98.8%
if -5.2e6 < x < -5.8000000000000003e-88Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
clear-num99.7%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 67.6%
associate-/l*67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in y around 0 67.7%
unpow267.7%
+-commutative67.7%
associate-*l/67.6%
associate-/r/67.6%
associate-*r/67.5%
*-lft-identity67.5%
associate-*l/67.5%
distribute-lft-in67.5%
lft-mult-inverse67.5%
*-rgt-identity67.5%
distribute-rgt-in67.5%
*-lft-identity67.5%
associate-*l/67.6%
*-lft-identity67.6%
Simplified67.6%
if -5.8000000000000003e-88 < x < 49000Initial program 99.9%
Taylor expanded in y around inf 81.3%
Final simplification88.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -1.0)
t_0
(if (<= x -2.6e-89)
(* x (/ x y))
(if (<= x 52000.0) (/ x (+ x 1.0)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -2.6e-89) {
tmp = x * (x / y);
} else if (x <= 52000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
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 = 1.0d0 + (x / y)
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= (-2.6d-89)) then
tmp = x * (x / y)
else if (x <= 52000.0d0) then
tmp = x / (x + 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -2.6e-89) {
tmp = x * (x / y);
} else if (x <= 52000.0) {
tmp = x / (x + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -1.0: tmp = t_0 elif x <= -2.6e-89: tmp = x * (x / y) elif x <= 52000.0: tmp = x / (x + 1.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= -2.6e-89) tmp = Float64(x * Float64(x / y)); elseif (x <= 52000.0) tmp = Float64(x / Float64(x + 1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= -2.6e-89) tmp = x * (x / y); elseif (x <= 52000.0) tmp = x / (x + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -2.6e-89], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 52000.0], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.6 \cdot 10^{-89}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 52000:\\
\;\;\;\;\frac{x}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 52000 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 98.7%
Taylor expanded in x around 0 98.8%
if -1 < x < -2.5999999999999999e-89Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
clear-num99.7%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 67.6%
associate-/l*67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in x around 0 67.3%
div-inv67.4%
associate-/r/67.4%
Applied egg-rr67.4%
if -2.5999999999999999e-89 < x < 52000Initial program 99.9%
Taylor expanded in y around inf 81.3%
Final simplification88.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (/ x y))))
(if (<= x -1.0)
t_0
(if (<= x -5.8e-88)
(* x (/ x y))
(if (<= x 1.9e-5) (* x (- 1.0 x)) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -5.8e-88) {
tmp = x * (x / y);
} else if (x <= 1.9e-5) {
tmp = x * (1.0 - x);
} else {
tmp = t_0;
}
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 = 1.0d0 + (x / y)
if (x <= (-1.0d0)) then
tmp = t_0
else if (x <= (-5.8d-88)) then
tmp = x * (x / y)
else if (x <= 1.9d-5) then
tmp = x * (1.0d0 - x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + (x / y);
double tmp;
if (x <= -1.0) {
tmp = t_0;
} else if (x <= -5.8e-88) {
tmp = x * (x / y);
} else if (x <= 1.9e-5) {
tmp = x * (1.0 - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + (x / y) tmp = 0 if x <= -1.0: tmp = t_0 elif x <= -5.8e-88: tmp = x * (x / y) elif x <= 1.9e-5: tmp = x * (1.0 - x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(x / y)) tmp = 0.0 if (x <= -1.0) tmp = t_0; elseif (x <= -5.8e-88) tmp = Float64(x * Float64(x / y)); elseif (x <= 1.9e-5) tmp = Float64(x * Float64(1.0 - x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + (x / y); tmp = 0.0; if (x <= -1.0) tmp = t_0; elseif (x <= -5.8e-88) tmp = x * (x / y); elseif (x <= 1.9e-5) tmp = x * (1.0 - x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -5.8e-88], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e-5], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x}{y}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{-88}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1 or 1.9000000000000001e-5 < x Initial program 74.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 96.6%
Taylor expanded in x around 0 96.7%
if -1 < x < -5.8000000000000003e-88Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
clear-num99.7%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 67.6%
associate-/l*67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in x around 0 67.3%
div-inv67.4%
associate-/r/67.4%
Applied egg-rr67.4%
if -5.8000000000000003e-88 < x < 1.9000000000000001e-5Initial program 99.9%
Taylor expanded in y around inf 82.6%
Taylor expanded in x around 0 82.5%
neg-mul-182.5%
sub-neg82.5%
Simplified82.5%
Final simplification87.9%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (/ x y) (if (<= x -4e-88) (* x (/ x y)) (if (<= x 0.8) (* x (- 1.0 x)) (/ x y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -4e-88) {
tmp = x * (x / y);
} else if (x <= 0.8) {
tmp = x * (1.0 - x);
} else {
tmp = x / 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 = x / y
else if (x <= (-4d-88)) then
tmp = x * (x / y)
else if (x <= 0.8d0) then
tmp = x * (1.0d0 - x)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = x / y;
} else if (x <= -4e-88) {
tmp = x * (x / y);
} else if (x <= 0.8) {
tmp = x * (1.0 - x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = x / y elif x <= -4e-88: tmp = x * (x / y) elif x <= 0.8: tmp = x * (1.0 - x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = Float64(x / y); elseif (x <= -4e-88) tmp = Float64(x * Float64(x / y)); elseif (x <= 0.8) tmp = Float64(x * Float64(1.0 - x)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = x / y; elseif (x <= -4e-88) tmp = x * (x / y); elseif (x <= 0.8) tmp = x * (1.0 - x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, -4e-88], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.8], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-88}:\\
\;\;\;\;x \cdot \frac{x}{y}\\
\mathbf{elif}\;x \leq 0.8:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1 or 0.80000000000000004 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 73.6%
if -1 < x < -3.99999999999999974e-88Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
clear-num99.7%
un-div-inv99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 67.6%
associate-/l*67.5%
+-commutative67.5%
Simplified67.5%
Taylor expanded in x around 0 67.3%
div-inv67.4%
associate-/r/67.4%
Applied egg-rr67.4%
if -3.99999999999999974e-88 < x < 0.80000000000000004Initial program 99.9%
Taylor expanded in y around inf 81.3%
Taylor expanded in x around 0 80.6%
neg-mul-180.6%
sub-neg80.6%
Simplified80.6%
Final simplification76.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ x y) (* x (- 1.0 x))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = x / y;
} else {
tmp = x * (1.0 - 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 / y
else
tmp = x * (1.0d0 - 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 / y;
} else {
tmp = x * (1.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = x / y else: tmp = x * (1.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(x / y); else tmp = Float64(x * Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = x / y; else tmp = x * (1.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 73.8%
associate-/l*99.9%
Simplified99.9%
clear-num99.7%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 73.6%
if -1 < x < 1Initial program 99.9%
Taylor expanded in y around inf 73.3%
Taylor expanded in x around 0 72.7%
neg-mul-172.7%
sub-neg72.7%
Simplified72.7%
Final simplification73.1%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.9e-5))) (/ x y) x))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.9e-5)) {
tmp = x / y;
} else {
tmp = 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.9d-5))) then
tmp = x / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.9e-5)) {
tmp = x / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.9e-5): tmp = x / y else: tmp = x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.9e-5)) tmp = Float64(x / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.9e-5))) tmp = x / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.9e-5]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.9 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1 or 1.9000000000000001e-5 < x Initial program 74.5%
associate-/l*99.8%
Simplified99.8%
clear-num99.7%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 72.0%
if -1 < x < 1.9000000000000001e-5Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 73.5%
Final simplification72.8%
(FPCore (x y) :precision binary64 (if (<= x -1.0) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 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 <= (-1.0d0)) then
tmp = 1.0d0
else if (x <= 1.0d0) then
tmp = x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = 1.0;
} else if (x <= 1.0) {
tmp = x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = 1.0 elif x <= 1.0: tmp = x else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.0) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = 1.0; elseif (x <= 1.0) tmp = x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 73.8%
Taylor expanded in y around inf 27.0%
+-commutative27.0%
expm1-log1p-u10.1%
expm1-undefine10.1%
Applied egg-rr10.1%
sub-neg10.1%
log1p-undefine10.1%
rem-exp-log27.0%
+-commutative27.0%
associate-+r+27.0%
metadata-eval27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in x around inf 26.6%
if -1 < x < 1Initial program 99.9%
associate-/l*99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 72.1%
(FPCore (x y) :precision binary64 (* x (/ (+ 1.0 (/ x y)) (+ x 1.0))))
double code(double x, double y) {
return x * ((1.0 + (x / y)) / (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)) / (x + 1.0d0))
end function
public static double code(double x, double y) {
return x * ((1.0 + (x / y)) / (x + 1.0));
}
def code(x, y): return x * ((1.0 + (x / y)) / (x + 1.0))
function code(x, y) return Float64(x * Float64(Float64(1.0 + Float64(x / y)) / Float64(x + 1.0))) end
function tmp = code(x, y) tmp = x * ((1.0 + (x / y)) / (x + 1.0)); end
code[x_, y_] := N[(x * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1 + \frac{x}{y}}{x + 1}
\end{array}
Initial program 87.8%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 87.8%
Taylor expanded in y around inf 51.8%
+-commutative51.8%
expm1-log1p-u44.0%
expm1-undefine43.9%
Applied egg-rr43.9%
sub-neg43.9%
log1p-undefine43.9%
rem-exp-log51.8%
+-commutative51.8%
associate-+r+51.8%
metadata-eval51.8%
metadata-eval51.8%
Simplified51.8%
Taylor expanded in x around inf 14.5%
(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 2024137
(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)))