
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ (+ x y) t_0)))
(if (or (<= t_1 -2e-268) (not (<= t_1 0.0)))
(+ (/ y t_0) (/ x t_0))
(/ z (/ y (- (- x) y))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = (x + y) / t_0;
double tmp;
if ((t_1 <= -2e-268) || !(t_1 <= 0.0)) {
tmp = (y / t_0) + (x / t_0);
} else {
tmp = z / (y / (-x - y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = (x + y) / t_0
if ((t_1 <= (-2d-268)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = (y / t_0) + (x / t_0)
else
tmp = z / (y / (-x - y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = (x + y) / t_0;
double tmp;
if ((t_1 <= -2e-268) || !(t_1 <= 0.0)) {
tmp = (y / t_0) + (x / t_0);
} else {
tmp = z / (y / (-x - y));
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = (x + y) / t_0 tmp = 0 if (t_1 <= -2e-268) or not (t_1 <= 0.0): tmp = (y / t_0) + (x / t_0) else: tmp = z / (y / (-x - y)) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(Float64(x + y) / t_0) tmp = 0.0 if ((t_1 <= -2e-268) || !(t_1 <= 0.0)) tmp = Float64(Float64(y / t_0) + Float64(x / t_0)); else tmp = Float64(z / Float64(y / Float64(Float64(-x) - y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = (x + y) / t_0; tmp = 0.0; if ((t_1 <= -2e-268) || ~((t_1 <= 0.0))) tmp = (y / t_0) + (x / t_0); else tmp = z / (y / (-x - y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] / t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-268], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(y / t$95$0), $MachinePrecision] + N[(x / t$95$0), $MachinePrecision]), $MachinePrecision], N[(z / N[(y / N[((-x) - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{x + y}{t\_0}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-268} \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\frac{y}{t\_0} + \frac{x}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.99999999999999992e-268 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
Taylor expanded in x around 0 99.9%
+-commutative99.9%
Simplified99.9%
if -1.99999999999999992e-268 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0Initial program 8.4%
Taylor expanded in z around 0 96.6%
mul-1-neg96.6%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
+-commutative99.9%
Simplified99.9%
associate-*r/96.6%
distribute-frac-neg296.6%
add-sqr-sqrt39.4%
sqrt-unprod8.3%
sqr-neg8.3%
sqrt-unprod2.0%
add-sqr-sqrt3.7%
associate-*r/3.6%
clear-num3.6%
un-div-inv3.6%
add-sqr-sqrt2.0%
sqrt-unprod11.5%
sqr-neg11.5%
sqrt-unprod42.5%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ y t_0)) (t_2 (/ x t_0)))
(if (<= x -2.25e-12)
t_2
(if (<= x -3.8e-25)
t_1
(if (<= x -5e-63)
(+ x y)
(if (<= x -5.2e-91)
(- z)
(if (<= x -6.3e-218) (+ x y) (if (<= x 2.6e-71) t_1 t_2))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = y / t_0;
double t_2 = x / t_0;
double tmp;
if (x <= -2.25e-12) {
tmp = t_2;
} else if (x <= -3.8e-25) {
tmp = t_1;
} else if (x <= -5e-63) {
tmp = x + y;
} else if (x <= -5.2e-91) {
tmp = -z;
} else if (x <= -6.3e-218) {
tmp = x + y;
} else if (x <= 2.6e-71) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = y / t_0
t_2 = x / t_0
if (x <= (-2.25d-12)) then
tmp = t_2
else if (x <= (-3.8d-25)) then
tmp = t_1
else if (x <= (-5d-63)) then
tmp = x + y
else if (x <= (-5.2d-91)) then
tmp = -z
else if (x <= (-6.3d-218)) then
tmp = x + y
else if (x <= 2.6d-71) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = y / t_0;
double t_2 = x / t_0;
double tmp;
if (x <= -2.25e-12) {
tmp = t_2;
} else if (x <= -3.8e-25) {
tmp = t_1;
} else if (x <= -5e-63) {
tmp = x + y;
} else if (x <= -5.2e-91) {
tmp = -z;
} else if (x <= -6.3e-218) {
tmp = x + y;
} else if (x <= 2.6e-71) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = y / t_0 t_2 = x / t_0 tmp = 0 if x <= -2.25e-12: tmp = t_2 elif x <= -3.8e-25: tmp = t_1 elif x <= -5e-63: tmp = x + y elif x <= -5.2e-91: tmp = -z elif x <= -6.3e-218: tmp = x + y elif x <= 2.6e-71: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(y / t_0) t_2 = Float64(x / t_0) tmp = 0.0 if (x <= -2.25e-12) tmp = t_2; elseif (x <= -3.8e-25) tmp = t_1; elseif (x <= -5e-63) tmp = Float64(x + y); elseif (x <= -5.2e-91) tmp = Float64(-z); elseif (x <= -6.3e-218) tmp = Float64(x + y); elseif (x <= 2.6e-71) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = y / t_0; t_2 = x / t_0; tmp = 0.0; if (x <= -2.25e-12) tmp = t_2; elseif (x <= -3.8e-25) tmp = t_1; elseif (x <= -5e-63) tmp = x + y; elseif (x <= -5.2e-91) tmp = -z; elseif (x <= -6.3e-218) tmp = x + y; elseif (x <= 2.6e-71) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(x / t$95$0), $MachinePrecision]}, If[LessEqual[x, -2.25e-12], t$95$2, If[LessEqual[x, -3.8e-25], t$95$1, If[LessEqual[x, -5e-63], N[(x + y), $MachinePrecision], If[LessEqual[x, -5.2e-91], (-z), If[LessEqual[x, -6.3e-218], N[(x + y), $MachinePrecision], If[LessEqual[x, 2.6e-71], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{y}{t\_0}\\
t_2 := \frac{x}{t\_0}\\
\mathbf{if}\;x \leq -2.25 \cdot 10^{-12}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq -3.8 \cdot 10^{-25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-63}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-91}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq -6.3 \cdot 10^{-218}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-71}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if x < -2.2499999999999999e-12 or 2.5999999999999999e-71 < x Initial program 89.2%
Taylor expanded in x around inf 77.7%
if -2.2499999999999999e-12 < x < -3.7999999999999998e-25 or -6.2999999999999996e-218 < x < 2.5999999999999999e-71Initial program 95.4%
Taylor expanded in x around 0 79.0%
if -3.7999999999999998e-25 < x < -5.0000000000000002e-63 or -5.20000000000000028e-91 < x < -6.2999999999999996e-218Initial program 89.6%
Taylor expanded in z around inf 81.5%
+-commutative81.5%
Simplified81.5%
if -5.0000000000000002e-63 < x < -5.20000000000000028e-91Initial program 56.7%
Taylor expanded in y around inf 71.4%
mul-1-neg71.4%
Simplified71.4%
Final simplification78.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (+ x y) (- 1.0 (/ y z))))) (if (or (<= t_0 -2e-268) (not (<= t_0 0.0))) t_0 (/ z (/ y (- (- x) y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -2e-268) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z / (y / (-x - y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if ((t_0 <= (-2d-268)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = z / (y / (-x - y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -2e-268) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z / (y / (-x - y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -2e-268) or not (t_0 <= 0.0): tmp = t_0 else: tmp = z / (y / (-x - y)) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if ((t_0 <= -2e-268) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(z / Float64(y / Float64(Float64(-x) - y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if ((t_0 <= -2e-268) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = z / (y / (-x - y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e-268], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(z / N[(y / N[((-x) - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-268} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -1.99999999999999992e-268 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.9%
if -1.99999999999999992e-268 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0Initial program 8.4%
Taylor expanded in z around 0 96.6%
mul-1-neg96.6%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
+-commutative99.9%
Simplified99.9%
associate-*r/96.6%
distribute-frac-neg296.6%
add-sqr-sqrt39.4%
sqrt-unprod8.3%
sqr-neg8.3%
sqrt-unprod2.0%
add-sqr-sqrt3.7%
associate-*r/3.6%
clear-num3.6%
un-div-inv3.6%
add-sqr-sqrt2.0%
sqrt-unprod11.5%
sqr-neg11.5%
sqrt-unprod42.5%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= z -3.3e-54)
(+ x y)
(if (<= z -1.5e-168)
(- z)
(if (<= z 2.5e-137)
(/ x (- 1.0 (/ y z)))
(if (<= z 3.5e-27) (- z) (+ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.3e-54) {
tmp = x + y;
} else if (z <= -1.5e-168) {
tmp = -z;
} else if (z <= 2.5e-137) {
tmp = x / (1.0 - (y / z));
} else if (z <= 3.5e-27) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3.3d-54)) then
tmp = x + y
else if (z <= (-1.5d-168)) then
tmp = -z
else if (z <= 2.5d-137) then
tmp = x / (1.0d0 - (y / z))
else if (z <= 3.5d-27) then
tmp = -z
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.3e-54) {
tmp = x + y;
} else if (z <= -1.5e-168) {
tmp = -z;
} else if (z <= 2.5e-137) {
tmp = x / (1.0 - (y / z));
} else if (z <= 3.5e-27) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.3e-54: tmp = x + y elif z <= -1.5e-168: tmp = -z elif z <= 2.5e-137: tmp = x / (1.0 - (y / z)) elif z <= 3.5e-27: tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.3e-54) tmp = Float64(x + y); elseif (z <= -1.5e-168) tmp = Float64(-z); elseif (z <= 2.5e-137) tmp = Float64(x / Float64(1.0 - Float64(y / z))); elseif (z <= 3.5e-27) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.3e-54) tmp = x + y; elseif (z <= -1.5e-168) tmp = -z; elseif (z <= 2.5e-137) tmp = x / (1.0 - (y / z)); elseif (z <= 3.5e-27) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.3e-54], N[(x + y), $MachinePrecision], If[LessEqual[z, -1.5e-168], (-z), If[LessEqual[z, 2.5e-137], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.5e-27], (-z), N[(x + y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{-54}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq -1.5 \cdot 10^{-168}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-137}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-27}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -3.29999999999999993e-54 or 3.5000000000000001e-27 < z Initial program 99.3%
Taylor expanded in z around inf 78.2%
+-commutative78.2%
Simplified78.2%
if -3.29999999999999993e-54 < z < -1.49999999999999996e-168 or 2.5e-137 < z < 3.5000000000000001e-27Initial program 73.0%
Taylor expanded in y around inf 67.5%
mul-1-neg67.5%
Simplified67.5%
if -1.49999999999999996e-168 < z < 2.5e-137Initial program 81.0%
Taylor expanded in x around inf 64.9%
Final simplification73.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -7.3e-31) (not (<= z 1.85e-6))) (+ x y) (/ z (/ y (- (- x) y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7.3e-31) || !(z <= 1.85e-6)) {
tmp = x + y;
} else {
tmp = z / (y / (-x - y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-7.3d-31)) .or. (.not. (z <= 1.85d-6))) then
tmp = x + y
else
tmp = z / (y / (-x - y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -7.3e-31) || !(z <= 1.85e-6)) {
tmp = x + y;
} else {
tmp = z / (y / (-x - y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7.3e-31) or not (z <= 1.85e-6): tmp = x + y else: tmp = z / (y / (-x - y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7.3e-31) || !(z <= 1.85e-6)) tmp = Float64(x + y); else tmp = Float64(z / Float64(y / Float64(Float64(-x) - y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -7.3e-31) || ~((z <= 1.85e-6))) tmp = x + y; else tmp = z / (y / (-x - y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7.3e-31], N[Not[LessEqual[z, 1.85e-6]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(z / N[(y / N[((-x) - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.3 \cdot 10^{-31} \lor \neg \left(z \leq 1.85 \cdot 10^{-6}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\
\end{array}
\end{array}
if z < -7.3000000000000003e-31 or 1.8500000000000001e-6 < z Initial program 99.2%
Taylor expanded in z around inf 80.6%
+-commutative80.6%
Simplified80.6%
if -7.3000000000000003e-31 < z < 1.8500000000000001e-6Initial program 79.4%
Taylor expanded in z around 0 69.6%
mul-1-neg69.6%
associate-/l*72.4%
distribute-rgt-neg-in72.4%
distribute-neg-frac272.4%
+-commutative72.4%
Simplified72.4%
associate-*r/69.6%
distribute-frac-neg269.6%
add-sqr-sqrt34.5%
sqrt-unprod23.7%
sqr-neg23.7%
sqrt-unprod1.7%
add-sqr-sqrt3.3%
associate-*r/3.1%
clear-num3.1%
un-div-inv3.1%
add-sqr-sqrt1.6%
sqrt-unprod26.2%
sqr-neg26.2%
sqrt-unprod37.6%
add-sqr-sqrt73.1%
Applied egg-rr73.1%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.5e+52) (not (<= y 5.2e+67))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.5e+52) || !(y <= 5.2e+67)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-2.5d+52)) .or. (.not. (y <= 5.2d+67))) then
tmp = -z
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.5e+52) || !(y <= 5.2e+67)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.5e+52) or not (y <= 5.2e+67): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.5e+52) || !(y <= 5.2e+67)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.5e+52) || ~((y <= 5.2e+67))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.5e+52], N[Not[LessEqual[y, 5.2e+67]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+52} \lor \neg \left(y \leq 5.2 \cdot 10^{+67}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -2.5e52 or 5.2000000000000001e67 < y Initial program 72.0%
Taylor expanded in y around inf 65.6%
mul-1-neg65.6%
Simplified65.6%
if -2.5e52 < y < 5.2000000000000001e67Initial program 99.9%
Taylor expanded in z around inf 70.7%
+-commutative70.7%
Simplified70.7%
Final simplification68.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.5e-10) (not (<= y 1.05e-22))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.5e-10) || !(y <= 1.05e-22)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-3.5d-10)) .or. (.not. (y <= 1.05d-22))) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.5e-10) || !(y <= 1.05e-22)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.5e-10) or not (y <= 1.05e-22): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.5e-10) || !(y <= 1.05e-22)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.5e-10) || ~((y <= 1.05e-22))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.5e-10], N[Not[LessEqual[y, 1.05e-22]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-10} \lor \neg \left(y \leq 1.05 \cdot 10^{-22}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -3.4999999999999998e-10 or 1.05000000000000004e-22 < y Initial program 79.0%
Taylor expanded in y around inf 56.4%
mul-1-neg56.4%
Simplified56.4%
if -3.4999999999999998e-10 < y < 1.05000000000000004e-22Initial program 99.9%
Taylor expanded in y around 0 59.4%
Final simplification58.0%
(FPCore (x y z) :precision binary64 (if (<= x -5.5e-203) x (if (<= x 1.7e-77) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.5e-203) {
tmp = x;
} else if (x <= 1.7e-77) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-5.5d-203)) then
tmp = x
else if (x <= 1.7d-77) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.5e-203) {
tmp = x;
} else if (x <= 1.7e-77) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.5e-203: tmp = x elif x <= 1.7e-77: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.5e-203) tmp = x; elseif (x <= 1.7e-77) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.5e-203) tmp = x; elseif (x <= 1.7e-77) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.5e-203], x, If[LessEqual[x, 1.7e-77], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-203}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-77}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -5.5000000000000002e-203 or 1.69999999999999991e-77 < x Initial program 87.8%
Taylor expanded in y around 0 46.5%
if -5.5000000000000002e-203 < x < 1.69999999999999991e-77Initial program 94.2%
Taylor expanded in x around 0 77.1%
Taylor expanded in y around 0 39.1%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 89.9%
Taylor expanded in y around 0 36.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024084
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (- y)) z)))
(/ (+ x y) (- 1.0 (/ y z))))