
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
def code(x, y): return (x - y) / (2.0 - (x + y))
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{2 - \left(x + y\right)}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (/ y x) -1.0)))
(if (<= y -1.52e+60)
1.0
(if (<= y -1.3e-281)
t_0
(if (<= y 1.12e-238)
(* x 0.5)
(if (<= y 4.2e-156)
-1.0
(if (<= y 2.4e-147)
(* x 0.5)
(if (<= y 8.6e-124)
(* y -0.5)
(if (<= y 1.35e+66) t_0 1.0)))))))))
double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (y <= -1.52e+60) {
tmp = 1.0;
} else if (y <= -1.3e-281) {
tmp = t_0;
} else if (y <= 1.12e-238) {
tmp = x * 0.5;
} else if (y <= 4.2e-156) {
tmp = -1.0;
} else if (y <= 2.4e-147) {
tmp = x * 0.5;
} else if (y <= 8.6e-124) {
tmp = y * -0.5;
} else if (y <= 1.35e+66) {
tmp = t_0;
} else {
tmp = 1.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 = (y / x) + (-1.0d0)
if (y <= (-1.52d+60)) then
tmp = 1.0d0
else if (y <= (-1.3d-281)) then
tmp = t_0
else if (y <= 1.12d-238) then
tmp = x * 0.5d0
else if (y <= 4.2d-156) then
tmp = -1.0d0
else if (y <= 2.4d-147) then
tmp = x * 0.5d0
else if (y <= 8.6d-124) then
tmp = y * (-0.5d0)
else if (y <= 1.35d+66) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (y / x) + -1.0;
double tmp;
if (y <= -1.52e+60) {
tmp = 1.0;
} else if (y <= -1.3e-281) {
tmp = t_0;
} else if (y <= 1.12e-238) {
tmp = x * 0.5;
} else if (y <= 4.2e-156) {
tmp = -1.0;
} else if (y <= 2.4e-147) {
tmp = x * 0.5;
} else if (y <= 8.6e-124) {
tmp = y * -0.5;
} else if (y <= 1.35e+66) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = (y / x) + -1.0 tmp = 0 if y <= -1.52e+60: tmp = 1.0 elif y <= -1.3e-281: tmp = t_0 elif y <= 1.12e-238: tmp = x * 0.5 elif y <= 4.2e-156: tmp = -1.0 elif y <= 2.4e-147: tmp = x * 0.5 elif y <= 8.6e-124: tmp = y * -0.5 elif y <= 1.35e+66: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(Float64(y / x) + -1.0) tmp = 0.0 if (y <= -1.52e+60) tmp = 1.0; elseif (y <= -1.3e-281) tmp = t_0; elseif (y <= 1.12e-238) tmp = Float64(x * 0.5); elseif (y <= 4.2e-156) tmp = -1.0; elseif (y <= 2.4e-147) tmp = Float64(x * 0.5); elseif (y <= 8.6e-124) tmp = Float64(y * -0.5); elseif (y <= 1.35e+66) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = (y / x) + -1.0; tmp = 0.0; if (y <= -1.52e+60) tmp = 1.0; elseif (y <= -1.3e-281) tmp = t_0; elseif (y <= 1.12e-238) tmp = x * 0.5; elseif (y <= 4.2e-156) tmp = -1.0; elseif (y <= 2.4e-147) tmp = x * 0.5; elseif (y <= 8.6e-124) tmp = y * -0.5; elseif (y <= 1.35e+66) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[y, -1.52e+60], 1.0, If[LessEqual[y, -1.3e-281], t$95$0, If[LessEqual[y, 1.12e-238], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4.2e-156], -1.0, If[LessEqual[y, 2.4e-147], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 8.6e-124], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.35e+66], t$95$0, 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x} + -1\\
\mathbf{if}\;y \leq -1.52 \cdot 10^{+60}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.3 \cdot 10^{-281}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{-238}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-156}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{-124}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+66}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.52e60 or 1.35e66 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 87.4%
if -1.52e60 < y < -1.30000000000000002e-281 or 8.6e-124 < y < 1.35e66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
clear-num99.9%
associate-/r/99.8%
associate--l-99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 60.2%
Taylor expanded in x around 0 60.3%
if -1.30000000000000002e-281 < y < 1.12000000000000005e-238 or 4.20000000000000025e-156 < y < 2.39999999999999998e-147Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 91.6%
Taylor expanded in x around 0 69.1%
*-commutative69.1%
Simplified69.1%
if 1.12000000000000005e-238 < y < 4.20000000000000025e-156Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 61.7%
if 2.39999999999999998e-147 < y < 8.6e-124Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 59.9%
mul-1-neg59.9%
distribute-neg-frac59.9%
Simplified59.9%
Taylor expanded in y around 0 59.9%
*-commutative59.9%
Simplified59.9%
Final simplification71.7%
(FPCore (x y)
:precision binary64
(if (<= y -1.4e+60)
1.0
(if (<= y -4.8e-282)
-1.0
(if (<= y 2.9e-242)
(* x 0.5)
(if (<= y 1.3e-155)
-1.0
(if (<= y 2.4e-147)
(* x 0.5)
(if (<= y 7.5e-125) (* y -0.5) (if (<= y 2.2e+65) -1.0 1.0))))))))
double code(double x, double y) {
double tmp;
if (y <= -1.4e+60) {
tmp = 1.0;
} else if (y <= -4.8e-282) {
tmp = -1.0;
} else if (y <= 2.9e-242) {
tmp = x * 0.5;
} else if (y <= 1.3e-155) {
tmp = -1.0;
} else if (y <= 2.4e-147) {
tmp = x * 0.5;
} else if (y <= 7.5e-125) {
tmp = y * -0.5;
} else if (y <= 2.2e+65) {
tmp = -1.0;
} 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 (y <= (-1.4d+60)) then
tmp = 1.0d0
else if (y <= (-4.8d-282)) then
tmp = -1.0d0
else if (y <= 2.9d-242) then
tmp = x * 0.5d0
else if (y <= 1.3d-155) then
tmp = -1.0d0
else if (y <= 2.4d-147) then
tmp = x * 0.5d0
else if (y <= 7.5d-125) then
tmp = y * (-0.5d0)
else if (y <= 2.2d+65) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.4e+60) {
tmp = 1.0;
} else if (y <= -4.8e-282) {
tmp = -1.0;
} else if (y <= 2.9e-242) {
tmp = x * 0.5;
} else if (y <= 1.3e-155) {
tmp = -1.0;
} else if (y <= 2.4e-147) {
tmp = x * 0.5;
} else if (y <= 7.5e-125) {
tmp = y * -0.5;
} else if (y <= 2.2e+65) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.4e+60: tmp = 1.0 elif y <= -4.8e-282: tmp = -1.0 elif y <= 2.9e-242: tmp = x * 0.5 elif y <= 1.3e-155: tmp = -1.0 elif y <= 2.4e-147: tmp = x * 0.5 elif y <= 7.5e-125: tmp = y * -0.5 elif y <= 2.2e+65: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.4e+60) tmp = 1.0; elseif (y <= -4.8e-282) tmp = -1.0; elseif (y <= 2.9e-242) tmp = Float64(x * 0.5); elseif (y <= 1.3e-155) tmp = -1.0; elseif (y <= 2.4e-147) tmp = Float64(x * 0.5); elseif (y <= 7.5e-125) tmp = Float64(y * -0.5); elseif (y <= 2.2e+65) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.4e+60) tmp = 1.0; elseif (y <= -4.8e-282) tmp = -1.0; elseif (y <= 2.9e-242) tmp = x * 0.5; elseif (y <= 1.3e-155) tmp = -1.0; elseif (y <= 2.4e-147) tmp = x * 0.5; elseif (y <= 7.5e-125) tmp = y * -0.5; elseif (y <= 2.2e+65) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.4e+60], 1.0, If[LessEqual[y, -4.8e-282], -1.0, If[LessEqual[y, 2.9e-242], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.3e-155], -1.0, If[LessEqual[y, 2.4e-147], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 7.5e-125], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 2.2e+65], -1.0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+60}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-282}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-242}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-155}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-147}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-125}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+65}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.4e60 or 2.1999999999999998e65 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 87.4%
if -1.4e60 < y < -4.79999999999999994e-282 or 2.9000000000000001e-242 < y < 1.30000000000000004e-155 or 7.5e-125 < y < 2.1999999999999998e65Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 60.3%
if -4.79999999999999994e-282 < y < 2.9000000000000001e-242 or 1.30000000000000004e-155 < y < 2.39999999999999998e-147Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 91.6%
Taylor expanded in x around 0 69.1%
*-commutative69.1%
Simplified69.1%
if 2.39999999999999998e-147 < y < 7.5e-125Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around 0 59.9%
mul-1-neg59.9%
distribute-neg-frac59.9%
Simplified59.9%
Taylor expanded in y around 0 59.9%
*-commutative59.9%
Simplified59.9%
Final simplification71.6%
(FPCore (x y) :precision binary64 (if (or (<= y -2.1e+60) (not (<= y 2.2e+65))) (+ 1.0 (/ (* x -2.0) y)) (/ x (- 2.0 x))))
double code(double x, double y) {
double tmp;
if ((y <= -2.1e+60) || !(y <= 2.2e+65)) {
tmp = 1.0 + ((x * -2.0) / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-2.1d+60)) .or. (.not. (y <= 2.2d+65))) then
tmp = 1.0d0 + ((x * (-2.0d0)) / y)
else
tmp = x / (2.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2.1e+60) || !(y <= 2.2e+65)) {
tmp = 1.0 + ((x * -2.0) / y);
} else {
tmp = x / (2.0 - x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.1e+60) or not (y <= 2.2e+65): tmp = 1.0 + ((x * -2.0) / y) else: tmp = x / (2.0 - x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.1e+60) || !(y <= 2.2e+65)) tmp = Float64(1.0 + Float64(Float64(x * -2.0) / y)); else tmp = Float64(x / Float64(2.0 - x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.1e+60) || ~((y <= 2.2e+65))) tmp = 1.0 + ((x * -2.0) / y); else tmp = x / (2.0 - x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.1e+60], N[Not[LessEqual[y, 2.2e+65]], $MachinePrecision]], N[(1.0 + N[(N[(x * -2.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+60} \lor \neg \left(y \leq 2.2 \cdot 10^{+65}\right):\\
\;\;\;\;1 + \frac{x \cdot -2}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 - x}\\
\end{array}
\end{array}
if y < -2.1000000000000001e60 or 2.1999999999999998e65 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 88.2%
associate--l+88.2%
associate-*r/88.2%
associate-*r/88.2%
div-sub88.2%
cancel-sign-sub-inv88.2%
metadata-eval88.2%
*-lft-identity88.2%
+-commutative88.2%
mul-1-neg88.2%
unsub-neg88.2%
Simplified88.2%
Taylor expanded in x around inf 88.2%
associate-*r/88.2%
*-commutative88.2%
Simplified88.2%
if -2.1000000000000001e60 < y < 2.1999999999999998e65Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 77.1%
Final simplification81.5%
(FPCore (x y)
:precision binary64
(if (<= y -3e+60)
1.0
(if (<= y -3.2e-282)
-1.0
(if (<= y 8.2e-236) (* x 0.5) (if (<= y 4e+66) -1.0 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -3e+60) {
tmp = 1.0;
} else if (y <= -3.2e-282) {
tmp = -1.0;
} else if (y <= 8.2e-236) {
tmp = x * 0.5;
} else if (y <= 4e+66) {
tmp = -1.0;
} 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 (y <= (-3d+60)) then
tmp = 1.0d0
else if (y <= (-3.2d-282)) then
tmp = -1.0d0
else if (y <= 8.2d-236) then
tmp = x * 0.5d0
else if (y <= 4d+66) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3e+60) {
tmp = 1.0;
} else if (y <= -3.2e-282) {
tmp = -1.0;
} else if (y <= 8.2e-236) {
tmp = x * 0.5;
} else if (y <= 4e+66) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3e+60: tmp = 1.0 elif y <= -3.2e-282: tmp = -1.0 elif y <= 8.2e-236: tmp = x * 0.5 elif y <= 4e+66: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -3e+60) tmp = 1.0; elseif (y <= -3.2e-282) tmp = -1.0; elseif (y <= 8.2e-236) tmp = Float64(x * 0.5); elseif (y <= 4e+66) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3e+60) tmp = 1.0; elseif (y <= -3.2e-282) tmp = -1.0; elseif (y <= 8.2e-236) tmp = x * 0.5; elseif (y <= 4e+66) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3e+60], 1.0, If[LessEqual[y, -3.2e-282], -1.0, If[LessEqual[y, 8.2e-236], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 4e+66], -1.0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+60}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{-282}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-236}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+66}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.9999999999999998e60 or 3.99999999999999978e66 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 87.4%
if -2.9999999999999998e60 < y < -3.19999999999999983e-282 or 8.2000000000000006e-236 < y < 3.99999999999999978e66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 57.8%
if -3.19999999999999983e-282 < y < 8.2000000000000006e-236Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around 0 94.8%
Taylor expanded in x around 0 67.3%
*-commutative67.3%
Simplified67.3%
Final simplification70.0%
(FPCore (x y) :precision binary64 (if (<= y -1.35e+61) 1.0 (if (<= y 6.2e+66) (/ x (- 2.0 x)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.35e+61) {
tmp = 1.0;
} else if (y <= 6.2e+66) {
tmp = x / (2.0 - 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 (y <= (-1.35d+61)) then
tmp = 1.0d0
else if (y <= 6.2d+66) then
tmp = x / (2.0d0 - x)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.35e+61) {
tmp = 1.0;
} else if (y <= 6.2e+66) {
tmp = x / (2.0 - x);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.35e+61: tmp = 1.0 elif y <= 6.2e+66: tmp = x / (2.0 - x) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.35e+61) tmp = 1.0; elseif (y <= 6.2e+66) tmp = Float64(x / Float64(2.0 - x)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.35e+61) tmp = 1.0; elseif (y <= 6.2e+66) tmp = x / (2.0 - x); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.35e+61], 1.0, If[LessEqual[y, 6.2e+66], N[(x / N[(2.0 - x), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+61}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+66}:\\
\;\;\;\;\frac{x}{2 - x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.3500000000000001e61 or 6.20000000000000037e66 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 87.4%
if -1.3500000000000001e61 < y < 6.20000000000000037e66Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in y around 0 77.1%
Final simplification81.1%
(FPCore (x y) :precision binary64 (if (<= y -6.5e+60) 1.0 (if (<= y 4e+65) -1.0 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -6.5e+60) {
tmp = 1.0;
} else if (y <= 4e+65) {
tmp = -1.0;
} 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 (y <= (-6.5d+60)) then
tmp = 1.0d0
else if (y <= 4d+65) then
tmp = -1.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -6.5e+60) {
tmp = 1.0;
} else if (y <= 4e+65) {
tmp = -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.5e+60: tmp = 1.0 elif y <= 4e+65: tmp = -1.0 else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -6.5e+60) tmp = 1.0; elseif (y <= 4e+65) tmp = -1.0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6.5e+60) tmp = 1.0; elseif (y <= 4e+65) tmp = -1.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6.5e+60], 1.0, If[LessEqual[y, 4e+65], -1.0, 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+60}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+65}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.49999999999999931e60 or 4e65 < y Initial program 99.9%
associate--r+99.9%
Simplified99.9%
Taylor expanded in y around inf 87.4%
if -6.49999999999999931e60 < y < 4e65Initial program 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 54.7%
Final simplification67.5%
(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 100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in x around inf 37.9%
Final simplification37.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}
herbie shell --seed 2023224
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))