
(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 (/ (+ x y) (- 1.0 (/ y z))))) (if (or (<= t_0 -5e-250) (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 <= -5e-250) || !(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 <= (-5d-250)) .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 <= -5e-250) || !(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 <= -5e-250) 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 <= -5e-250) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(-z) / Float64(y / 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 <= -5e-250) || ~((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, -5e-250], 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 -5 \cdot 10^{-250} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{y}{x + y}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -5.00000000000000027e-250 or 0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -5.00000000000000027e-250 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 0.0Initial program 14.8%
Taylor expanded in z around 0 94.0%
mul-1-neg94.0%
associate-/l*100.0%
distribute-neg-frac100.0%
+-commutative100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- 1.0 (/ y z)))))
(if (<= y -4.8e+173)
(- z)
(if (<= y -2.5e+58)
(* (+ x y) (/ (- z) y))
(if (<= y -30000000000000.0)
(+ x y)
(if (<= y -5.4e-41)
t_0
(if (<= y -2.8e-170) (+ x y) (if (<= y 2.35e+83) t_0 (- z)))))))))
double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double tmp;
if (y <= -4.8e+173) {
tmp = -z;
} else if (y <= -2.5e+58) {
tmp = (x + y) * (-z / y);
} else if (y <= -30000000000000.0) {
tmp = x + y;
} else if (y <= -5.4e-41) {
tmp = t_0;
} else if (y <= -2.8e-170) {
tmp = x + y;
} else if (y <= 2.35e+83) {
tmp = t_0;
} else {
tmp = -z;
}
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 / (1.0d0 - (y / z))
if (y <= (-4.8d+173)) then
tmp = -z
else if (y <= (-2.5d+58)) then
tmp = (x + y) * (-z / y)
else if (y <= (-30000000000000.0d0)) then
tmp = x + y
else if (y <= (-5.4d-41)) then
tmp = t_0
else if (y <= (-2.8d-170)) then
tmp = x + y
else if (y <= 2.35d+83) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double tmp;
if (y <= -4.8e+173) {
tmp = -z;
} else if (y <= -2.5e+58) {
tmp = (x + y) * (-z / y);
} else if (y <= -30000000000000.0) {
tmp = x + y;
} else if (y <= -5.4e-41) {
tmp = t_0;
} else if (y <= -2.8e-170) {
tmp = x + y;
} else if (y <= 2.35e+83) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x / (1.0 - (y / z)) tmp = 0 if y <= -4.8e+173: tmp = -z elif y <= -2.5e+58: tmp = (x + y) * (-z / y) elif y <= -30000000000000.0: tmp = x + y elif y <= -5.4e-41: tmp = t_0 elif y <= -2.8e-170: tmp = x + y elif y <= 2.35e+83: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (y <= -4.8e+173) tmp = Float64(-z); elseif (y <= -2.5e+58) tmp = Float64(Float64(x + y) * Float64(Float64(-z) / y)); elseif (y <= -30000000000000.0) tmp = Float64(x + y); elseif (y <= -5.4e-41) tmp = t_0; elseif (y <= -2.8e-170) tmp = Float64(x + y); elseif (y <= 2.35e+83) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (1.0 - (y / z)); tmp = 0.0; if (y <= -4.8e+173) tmp = -z; elseif (y <= -2.5e+58) tmp = (x + y) * (-z / y); elseif (y <= -30000000000000.0) tmp = x + y; elseif (y <= -5.4e-41) tmp = t_0; elseif (y <= -2.8e-170) tmp = x + y; elseif (y <= 2.35e+83) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.8e+173], (-z), If[LessEqual[y, -2.5e+58], N[(N[(x + y), $MachinePrecision] * N[((-z) / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -30000000000000.0], N[(x + y), $MachinePrecision], If[LessEqual[y, -5.4e-41], t$95$0, If[LessEqual[y, -2.8e-170], N[(x + y), $MachinePrecision], If[LessEqual[y, 2.35e+83], t$95$0, (-z)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 - \frac{y}{z}}\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{+173}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{+58}:\\
\;\;\;\;\left(x + y\right) \cdot \frac{-z}{y}\\
\mathbf{elif}\;y \leq -30000000000000:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -5.4 \cdot 10^{-41}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.8 \cdot 10^{-170}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{+83}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -4.7999999999999998e173 or 2.3499999999999999e83 < y Initial program 69.4%
Taylor expanded in y around inf 72.6%
mul-1-neg72.6%
Simplified72.6%
if -4.7999999999999998e173 < y < -2.49999999999999993e58Initial program 82.3%
Taylor expanded in z around 0 81.4%
mul-1-neg81.4%
associate-/l*85.2%
associate-/r/70.0%
distribute-rgt-neg-in70.0%
+-commutative70.0%
distribute-neg-in70.0%
sub-neg70.0%
Simplified70.0%
if -2.49999999999999993e58 < y < -3e13 or -5.4e-41 < y < -2.79999999999999995e-170Initial program 100.0%
Taylor expanded in z around inf 77.0%
+-commutative77.0%
Simplified77.0%
if -3e13 < y < -5.4e-41 or -2.79999999999999995e-170 < y < 2.3499999999999999e83Initial program 99.9%
Taylor expanded in x around inf 84.2%
Final simplification78.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- 1.0 (/ y z)))) (t_1 (/ (- z) (/ y (+ x y)))))
(if (<= y -1.4e+58)
t_1
(if (<= y -580.0)
(+ x y)
(if (<= y -1.6e-45)
t_0
(if (<= y -2.7e-173) (+ x y) (if (<= y 1.12e+82) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double t_1 = -z / (y / (x + y));
double tmp;
if (y <= -1.4e+58) {
tmp = t_1;
} else if (y <= -580.0) {
tmp = x + y;
} else if (y <= -1.6e-45) {
tmp = t_0;
} else if (y <= -2.7e-173) {
tmp = x + y;
} else if (y <= 1.12e+82) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = x / (1.0d0 - (y / z))
t_1 = -z / (y / (x + y))
if (y <= (-1.4d+58)) then
tmp = t_1
else if (y <= (-580.0d0)) then
tmp = x + y
else if (y <= (-1.6d-45)) then
tmp = t_0
else if (y <= (-2.7d-173)) then
tmp = x + y
else if (y <= 1.12d+82) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double t_1 = -z / (y / (x + y));
double tmp;
if (y <= -1.4e+58) {
tmp = t_1;
} else if (y <= -580.0) {
tmp = x + y;
} else if (y <= -1.6e-45) {
tmp = t_0;
} else if (y <= -2.7e-173) {
tmp = x + y;
} else if (y <= 1.12e+82) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x / (1.0 - (y / z)) t_1 = -z / (y / (x + y)) tmp = 0 if y <= -1.4e+58: tmp = t_1 elif y <= -580.0: tmp = x + y elif y <= -1.6e-45: tmp = t_0 elif y <= -2.7e-173: tmp = x + y elif y <= 1.12e+82: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x / Float64(1.0 - Float64(y / z))) t_1 = Float64(Float64(-z) / Float64(y / Float64(x + y))) tmp = 0.0 if (y <= -1.4e+58) tmp = t_1; elseif (y <= -580.0) tmp = Float64(x + y); elseif (y <= -1.6e-45) tmp = t_0; elseif (y <= -2.7e-173) tmp = Float64(x + y); elseif (y <= 1.12e+82) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (1.0 - (y / z)); t_1 = -z / (y / (x + y)); tmp = 0.0; if (y <= -1.4e+58) tmp = t_1; elseif (y <= -580.0) tmp = x + y; elseif (y <= -1.6e-45) tmp = t_0; elseif (y <= -2.7e-173) tmp = x + y; elseif (y <= 1.12e+82) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.4e+58], t$95$1, If[LessEqual[y, -580.0], N[(x + y), $MachinePrecision], If[LessEqual[y, -1.6e-45], t$95$0, If[LessEqual[y, -2.7e-173], N[(x + y), $MachinePrecision], If[LessEqual[y, 1.12e+82], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 - \frac{y}{z}}\\
t_1 := \frac{-z}{\frac{y}{x + y}}\\
\mathbf{if}\;y \leq -1.4 \cdot 10^{+58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -580:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -1.6 \cdot 10^{-45}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.7 \cdot 10^{-173}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -1.3999999999999999e58 or 1.11999999999999998e82 < y Initial program 72.8%
Taylor expanded in z around 0 67.5%
mul-1-neg67.5%
associate-/l*83.5%
distribute-neg-frac83.5%
+-commutative83.5%
Simplified83.5%
if -1.3999999999999999e58 < y < -580 or -1.60000000000000004e-45 < y < -2.7e-173Initial program 100.0%
Taylor expanded in z around inf 78.5%
+-commutative78.5%
Simplified78.5%
if -580 < y < -1.60000000000000004e-45 or -2.7e-173 < y < 1.11999999999999998e82Initial program 99.9%
Taylor expanded in x around inf 82.9%
Final simplification82.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- 1.0 (/ y z)))) (t_1 (/ (- z) (/ y (+ x y)))))
(if (<= y -9e+59)
t_1
(if (<= y -2.1e+16)
(+ x y)
(if (<= y -2.95e-46)
t_0
(if (<= y -3.3e-172)
(+ x (+ y (/ (* x y) z)))
(if (<= y 1.12e+82) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double t_1 = -z / (y / (x + y));
double tmp;
if (y <= -9e+59) {
tmp = t_1;
} else if (y <= -2.1e+16) {
tmp = x + y;
} else if (y <= -2.95e-46) {
tmp = t_0;
} else if (y <= -3.3e-172) {
tmp = x + (y + ((x * y) / z));
} else if (y <= 1.12e+82) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = x / (1.0d0 - (y / z))
t_1 = -z / (y / (x + y))
if (y <= (-9d+59)) then
tmp = t_1
else if (y <= (-2.1d+16)) then
tmp = x + y
else if (y <= (-2.95d-46)) then
tmp = t_0
else if (y <= (-3.3d-172)) then
tmp = x + (y + ((x * y) / z))
else if (y <= 1.12d+82) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double t_1 = -z / (y / (x + y));
double tmp;
if (y <= -9e+59) {
tmp = t_1;
} else if (y <= -2.1e+16) {
tmp = x + y;
} else if (y <= -2.95e-46) {
tmp = t_0;
} else if (y <= -3.3e-172) {
tmp = x + (y + ((x * y) / z));
} else if (y <= 1.12e+82) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x / (1.0 - (y / z)) t_1 = -z / (y / (x + y)) tmp = 0 if y <= -9e+59: tmp = t_1 elif y <= -2.1e+16: tmp = x + y elif y <= -2.95e-46: tmp = t_0 elif y <= -3.3e-172: tmp = x + (y + ((x * y) / z)) elif y <= 1.12e+82: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x / Float64(1.0 - Float64(y / z))) t_1 = Float64(Float64(-z) / Float64(y / Float64(x + y))) tmp = 0.0 if (y <= -9e+59) tmp = t_1; elseif (y <= -2.1e+16) tmp = Float64(x + y); elseif (y <= -2.95e-46) tmp = t_0; elseif (y <= -3.3e-172) tmp = Float64(x + Float64(y + Float64(Float64(x * y) / z))); elseif (y <= 1.12e+82) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (1.0 - (y / z)); t_1 = -z / (y / (x + y)); tmp = 0.0; if (y <= -9e+59) tmp = t_1; elseif (y <= -2.1e+16) tmp = x + y; elseif (y <= -2.95e-46) tmp = t_0; elseif (y <= -3.3e-172) tmp = x + (y + ((x * y) / z)); elseif (y <= 1.12e+82) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-z) / N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9e+59], t$95$1, If[LessEqual[y, -2.1e+16], N[(x + y), $MachinePrecision], If[LessEqual[y, -2.95e-46], t$95$0, If[LessEqual[y, -3.3e-172], N[(x + N[(y + N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.12e+82], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 - \frac{y}{z}}\\
t_1 := \frac{-z}{\frac{y}{x + y}}\\
\mathbf{if}\;y \leq -9 \cdot 10^{+59}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{+16}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq -2.95 \cdot 10^{-46}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3.3 \cdot 10^{-172}:\\
\;\;\;\;x + \left(y + \frac{x \cdot y}{z}\right)\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -8.99999999999999919e59 or 1.11999999999999998e82 < y Initial program 72.8%
Taylor expanded in z around 0 67.5%
mul-1-neg67.5%
associate-/l*83.5%
distribute-neg-frac83.5%
+-commutative83.5%
Simplified83.5%
if -8.99999999999999919e59 < y < -2.1e16Initial program 100.0%
Taylor expanded in z around inf 71.8%
+-commutative71.8%
Simplified71.8%
if -2.1e16 < y < -2.95e-46 or -3.3e-172 < y < 1.11999999999999998e82Initial program 99.9%
Taylor expanded in x around inf 82.9%
if -2.95e-46 < y < -3.3e-172Initial program 100.0%
Taylor expanded in y around 0 83.0%
mul-1-neg83.0%
Simplified83.0%
Taylor expanded in x around 0 83.1%
Final simplification82.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- 1.0 (/ y z)))))
(if (<= y -2.8e+85)
(- z)
(if (<= y -3e-41)
t_0
(if (<= y -1.2e-170) (+ x y) (if (<= y 8.5e+84) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double tmp;
if (y <= -2.8e+85) {
tmp = -z;
} else if (y <= -3e-41) {
tmp = t_0;
} else if (y <= -1.2e-170) {
tmp = x + y;
} else if (y <= 8.5e+84) {
tmp = t_0;
} else {
tmp = -z;
}
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 / (1.0d0 - (y / z))
if (y <= (-2.8d+85)) then
tmp = -z
else if (y <= (-3d-41)) then
tmp = t_0
else if (y <= (-1.2d-170)) then
tmp = x + y
else if (y <= 8.5d+84) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (1.0 - (y / z));
double tmp;
if (y <= -2.8e+85) {
tmp = -z;
} else if (y <= -3e-41) {
tmp = t_0;
} else if (y <= -1.2e-170) {
tmp = x + y;
} else if (y <= 8.5e+84) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x / (1.0 - (y / z)) tmp = 0 if y <= -2.8e+85: tmp = -z elif y <= -3e-41: tmp = t_0 elif y <= -1.2e-170: tmp = x + y elif y <= 8.5e+84: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (y <= -2.8e+85) tmp = Float64(-z); elseif (y <= -3e-41) tmp = t_0; elseif (y <= -1.2e-170) tmp = Float64(x + y); elseif (y <= 8.5e+84) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (1.0 - (y / z)); tmp = 0.0; if (y <= -2.8e+85) tmp = -z; elseif (y <= -3e-41) tmp = t_0; elseif (y <= -1.2e-170) tmp = x + y; elseif (y <= 8.5e+84) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.8e+85], (-z), If[LessEqual[y, -3e-41], t$95$0, If[LessEqual[y, -1.2e-170], N[(x + y), $MachinePrecision], If[LessEqual[y, 8.5e+84], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 - \frac{y}{z}}\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{+85}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq -3 \cdot 10^{-41}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.2 \cdot 10^{-170}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+84}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if y < -2.7999999999999999e85 or 8.5000000000000008e84 < y Initial program 71.2%
Taylor expanded in y around inf 69.7%
mul-1-neg69.7%
Simplified69.7%
if -2.7999999999999999e85 < y < -2.99999999999999989e-41 or -1.2e-170 < y < 8.5000000000000008e84Initial program 99.9%
Taylor expanded in x around inf 79.9%
if -2.99999999999999989e-41 < y < -1.2e-170Initial program 100.0%
Taylor expanded in z around inf 79.3%
+-commutative79.3%
Simplified79.3%
Final simplification76.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.25e+68) (not (<= y 1.26e+82))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e+68) || !(y <= 1.26e+82)) {
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 <= (-1.25d+68)) .or. (.not. (y <= 1.26d+82))) 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 <= -1.25e+68) || !(y <= 1.26e+82)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.25e+68) or not (y <= 1.26e+82): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.25e+68) || !(y <= 1.26e+82)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.25e+68) || ~((y <= 1.26e+82))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.25e+68], N[Not[LessEqual[y, 1.26e+82]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+68} \lor \neg \left(y \leq 1.26 \cdot 10^{+82}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -1.2500000000000001e68 or 1.2600000000000001e82 < y Initial program 72.0%
Taylor expanded in y around inf 68.7%
mul-1-neg68.7%
Simplified68.7%
if -1.2500000000000001e68 < y < 1.2600000000000001e82Initial program 99.9%
Taylor expanded in z around inf 75.0%
+-commutative75.0%
Simplified75.0%
Final simplification72.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.95e+59) (not (<= y 1.12e+82))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.95e+59) || !(y <= 1.12e+82)) {
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 <= (-1.95d+59)) .or. (.not. (y <= 1.12d+82))) 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 <= -1.95e+59) || !(y <= 1.12e+82)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.95e+59) or not (y <= 1.12e+82): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.95e+59) || !(y <= 1.12e+82)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.95e+59) || ~((y <= 1.12e+82))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.95e+59], N[Not[LessEqual[y, 1.12e+82]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+59} \lor \neg \left(y \leq 1.12 \cdot 10^{+82}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.95000000000000011e59 or 1.11999999999999998e82 < y Initial program 72.8%
Taylor expanded in y around inf 67.7%
mul-1-neg67.7%
Simplified67.7%
if -1.95000000000000011e59 < y < 1.11999999999999998e82Initial program 99.9%
Taylor expanded in y around 0 59.7%
Final simplification62.8%
(FPCore (x y z) :precision binary64 (if (<= x -1.45e-196) x (if (<= x 1.5e-161) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.45e-196) {
tmp = x;
} else if (x <= 1.5e-161) {
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 <= (-1.45d-196)) then
tmp = x
else if (x <= 1.5d-161) 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 <= -1.45e-196) {
tmp = x;
} else if (x <= 1.5e-161) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.45e-196: tmp = x elif x <= 1.5e-161: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.45e-196) tmp = x; elseif (x <= 1.5e-161) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.45e-196) tmp = x; elseif (x <= 1.5e-161) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.45e-196], x, If[LessEqual[x, 1.5e-161], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-196}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-161}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.44999999999999994e-196 or 1.49999999999999994e-161 < x Initial program 90.3%
Taylor expanded in y around 0 45.2%
if -1.44999999999999994e-196 < x < 1.49999999999999994e-161Initial program 84.7%
Taylor expanded in y around 0 45.9%
mul-1-neg45.9%
Simplified45.9%
Taylor expanded in x around 0 46.0%
Taylor expanded in x around 0 36.5%
Final simplification43.5%
(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.2%
Taylor expanded in y around 0 39.2%
Final simplification39.2%
(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 2024024
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:herbie-target
(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))))