
(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 7 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 -1e-291) (not (<= t_0 0.0))) t_0 (* z (- -1.0 (/ x y))))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -1e-291) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * (-1.0 - (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 <= (-1d-291)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = z * ((-1.0d0) - (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 <= -1e-291) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if (t_0 <= -1e-291) or not (t_0 <= 0.0): tmp = t_0 else: tmp = z * (-1.0 - (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 <= -1e-291) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(z * Float64(-1.0 - 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 <= -1e-291) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = z * (-1.0 - (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, -1e-291], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(z * N[(-1.0 - 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 -1 \cdot 10^{-291} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -9.99999999999999962e-292 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 99.9%
if -9.99999999999999962e-292 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 6.1%
Taylor expanded in y around inf 6.1%
neg-mul-16.1%
distribute-neg-frac26.1%
Simplified6.1%
Taylor expanded in x around 0 99.9%
mul-1-neg99.9%
unsub-neg99.9%
mul-1-neg99.9%
*-commutative99.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 99.9%
*-commutative99.9%
associate-*l*99.9%
+-commutative99.9%
distribute-rgt1-in99.9%
*-commutative99.9%
mul-1-neg99.9%
sub-neg99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))))
(if (<= z -1.05e+16)
(+ x y)
(if (<= z -1.6e-20)
(/ y t_0)
(if (<= z -1.15e-128)
(/ x t_0)
(if (<= z 3e+47) (* z (- -1.0 (/ x y))) (+ x y)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double tmp;
if (z <= -1.05e+16) {
tmp = x + y;
} else if (z <= -1.6e-20) {
tmp = y / t_0;
} else if (z <= -1.15e-128) {
tmp = x / t_0;
} else if (z <= 3e+47) {
tmp = z * (-1.0 - (x / y));
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
if (z <= (-1.05d+16)) then
tmp = x + y
else if (z <= (-1.6d-20)) then
tmp = y / t_0
else if (z <= (-1.15d-128)) then
tmp = x / t_0
else if (z <= 3d+47) then
tmp = z * ((-1.0d0) - (x / y))
else
tmp = 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 tmp;
if (z <= -1.05e+16) {
tmp = x + y;
} else if (z <= -1.6e-20) {
tmp = y / t_0;
} else if (z <= -1.15e-128) {
tmp = x / t_0;
} else if (z <= 3e+47) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) tmp = 0 if z <= -1.05e+16: tmp = x + y elif z <= -1.6e-20: tmp = y / t_0 elif z <= -1.15e-128: tmp = x / t_0 elif z <= 3e+47: tmp = z * (-1.0 - (x / y)) else: tmp = x + y return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) tmp = 0.0 if (z <= -1.05e+16) tmp = Float64(x + y); elseif (z <= -1.6e-20) tmp = Float64(y / t_0); elseif (z <= -1.15e-128) tmp = Float64(x / t_0); elseif (z <= 3e+47) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); tmp = 0.0; if (z <= -1.05e+16) tmp = x + y; elseif (z <= -1.6e-20) tmp = y / t_0; elseif (z <= -1.15e-128) tmp = x / t_0; elseif (z <= 3e+47) tmp = z * (-1.0 - (x / y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.05e+16], N[(x + y), $MachinePrecision], If[LessEqual[z, -1.6e-20], N[(y / t$95$0), $MachinePrecision], If[LessEqual[z, -1.15e-128], N[(x / t$95$0), $MachinePrecision], If[LessEqual[z, 3e+47], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
\mathbf{if}\;z \leq -1.05 \cdot 10^{+16}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{-20}:\\
\;\;\;\;\frac{y}{t\_0}\\
\mathbf{elif}\;z \leq -1.15 \cdot 10^{-128}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+47}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1.05e16 or 3.0000000000000001e47 < z Initial program 99.9%
Taylor expanded in z around inf 88.8%
+-commutative88.8%
Simplified88.8%
if -1.05e16 < z < -1.59999999999999985e-20Initial program 99.9%
Taylor expanded in x around 0 99.9%
if -1.59999999999999985e-20 < z < -1.15e-128Initial program 95.3%
Taylor expanded in x around inf 60.8%
if -1.15e-128 < z < 3.0000000000000001e47Initial program 71.7%
Taylor expanded in y around inf 48.0%
neg-mul-148.0%
distribute-neg-frac248.0%
Simplified48.0%
Taylor expanded in x around 0 72.4%
mul-1-neg72.4%
unsub-neg72.4%
mul-1-neg72.4%
*-commutative72.4%
associate-/l*72.2%
Simplified72.2%
Taylor expanded in z around 0 72.2%
*-commutative72.2%
associate-*l*72.2%
+-commutative72.2%
distribute-rgt1-in72.2%
*-commutative72.2%
mul-1-neg72.2%
sub-neg72.2%
Simplified72.2%
Final simplification80.4%
(FPCore (x y z)
:precision binary64
(if (<= z -1.4e+16)
(+ x y)
(if (<= z -5e-24)
(/ y (- 1.0 (/ y z)))
(if (<= z -3.4e-170)
(* x (/ -1.0 (+ (/ y z) -1.0)))
(if (<= z 1.8e+47) (* z (- -1.0 (/ x y))) (+ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e+16) {
tmp = x + y;
} else if (z <= -5e-24) {
tmp = y / (1.0 - (y / z));
} else if (z <= -3.4e-170) {
tmp = x * (-1.0 / ((y / z) + -1.0));
} else if (z <= 1.8e+47) {
tmp = z * (-1.0 - (x / y));
} 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 <= (-1.4d+16)) then
tmp = x + y
else if (z <= (-5d-24)) then
tmp = y / (1.0d0 - (y / z))
else if (z <= (-3.4d-170)) then
tmp = x * ((-1.0d0) / ((y / z) + (-1.0d0)))
else if (z <= 1.8d+47) then
tmp = z * ((-1.0d0) - (x / y))
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e+16) {
tmp = x + y;
} else if (z <= -5e-24) {
tmp = y / (1.0 - (y / z));
} else if (z <= -3.4e-170) {
tmp = x * (-1.0 / ((y / z) + -1.0));
} else if (z <= 1.8e+47) {
tmp = z * (-1.0 - (x / y));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.4e+16: tmp = x + y elif z <= -5e-24: tmp = y / (1.0 - (y / z)) elif z <= -3.4e-170: tmp = x * (-1.0 / ((y / z) + -1.0)) elif z <= 1.8e+47: tmp = z * (-1.0 - (x / y)) else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.4e+16) tmp = Float64(x + y); elseif (z <= -5e-24) tmp = Float64(y / Float64(1.0 - Float64(y / z))); elseif (z <= -3.4e-170) tmp = Float64(x * Float64(-1.0 / Float64(Float64(y / z) + -1.0))); elseif (z <= 1.8e+47) tmp = Float64(z * Float64(-1.0 - Float64(x / y))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.4e+16) tmp = x + y; elseif (z <= -5e-24) tmp = y / (1.0 - (y / z)); elseif (z <= -3.4e-170) tmp = x * (-1.0 / ((y / z) + -1.0)); elseif (z <= 1.8e+47) tmp = z * (-1.0 - (x / y)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.4e+16], N[(x + y), $MachinePrecision], If[LessEqual[z, -5e-24], N[(y / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.4e-170], N[(x * N[(-1.0 / N[(N[(y / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.8e+47], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+16}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq -5 \cdot 10^{-24}:\\
\;\;\;\;\frac{y}{1 - \frac{y}{z}}\\
\mathbf{elif}\;z \leq -3.4 \cdot 10^{-170}:\\
\;\;\;\;x \cdot \frac{-1}{\frac{y}{z} + -1}\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+47}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1.4e16 or 1.80000000000000004e47 < z Initial program 99.9%
Taylor expanded in z around inf 88.8%
+-commutative88.8%
Simplified88.8%
if -1.4e16 < z < -4.9999999999999998e-24Initial program 99.9%
Taylor expanded in x around 0 99.9%
if -4.9999999999999998e-24 < z < -3.40000000000000013e-170Initial program 95.8%
Taylor expanded in x around inf 61.6%
*-un-lft-identity61.6%
associate-*l/61.7%
frac-2neg61.7%
metadata-eval61.7%
sub-neg61.7%
distribute-frac-neg261.7%
distribute-neg-in61.7%
metadata-eval61.7%
distribute-frac-neg261.7%
remove-double-neg61.7%
Applied egg-rr61.7%
if -3.40000000000000013e-170 < z < 1.80000000000000004e47Initial program 70.8%
Taylor expanded in y around inf 47.4%
neg-mul-147.4%
distribute-neg-frac247.4%
Simplified47.4%
Taylor expanded in x around 0 72.5%
mul-1-neg72.5%
unsub-neg72.5%
mul-1-neg72.5%
*-commutative72.5%
associate-/l*72.3%
Simplified72.3%
Taylor expanded in z around 0 72.3%
*-commutative72.3%
associate-*l*72.3%
+-commutative72.3%
distribute-rgt1-in72.3%
*-commutative72.3%
mul-1-neg72.3%
sub-neg72.3%
Simplified72.3%
Final simplification80.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.8e+17) (not (<= z 1.1e+49))) (+ x y) (* z (- -1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e+17) || !(z <= 1.1e+49)) {
tmp = x + y;
} else {
tmp = z * (-1.0 - (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 <= (-4.8d+17)) .or. (.not. (z <= 1.1d+49))) then
tmp = x + y
else
tmp = z * ((-1.0d0) - (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e+17) || !(z <= 1.1e+49)) {
tmp = x + y;
} else {
tmp = z * (-1.0 - (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.8e+17) or not (z <= 1.1e+49): tmp = x + y else: tmp = z * (-1.0 - (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.8e+17) || !(z <= 1.1e+49)) tmp = Float64(x + y); else tmp = Float64(z * Float64(-1.0 - Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.8e+17) || ~((z <= 1.1e+49))) tmp = x + y; else tmp = z * (-1.0 - (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.8e+17], N[Not[LessEqual[z, 1.1e+49]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(z * N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+17} \lor \neg \left(z \leq 1.1 \cdot 10^{+49}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-1 - \frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -4.8e17 or 1.1e49 < z Initial program 99.9%
Taylor expanded in z around inf 88.8%
+-commutative88.8%
Simplified88.8%
if -4.8e17 < z < 1.1e49Initial program 77.9%
Taylor expanded in y around inf 49.5%
neg-mul-149.5%
distribute-neg-frac249.5%
Simplified49.5%
Taylor expanded in x around 0 68.6%
mul-1-neg68.6%
unsub-neg68.6%
mul-1-neg68.6%
*-commutative68.6%
associate-/l*68.4%
Simplified68.4%
Taylor expanded in z around 0 68.4%
*-commutative68.4%
associate-*l*68.4%
+-commutative68.4%
distribute-rgt1-in68.4%
*-commutative68.4%
mul-1-neg68.4%
sub-neg68.4%
Simplified68.4%
Final simplification78.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.5e+153) (not (<= y 3.4e+99))) (- z) (+ x y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.5e+153) || !(y <= 3.4e+99)) {
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 <= (-8.5d+153)) .or. (.not. (y <= 3.4d+99))) 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 <= -8.5e+153) || !(y <= 3.4e+99)) {
tmp = -z;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.5e+153) or not (y <= 3.4e+99): tmp = -z else: tmp = x + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.5e+153) || !(y <= 3.4e+99)) tmp = Float64(-z); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.5e+153) || ~((y <= 3.4e+99))) tmp = -z; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.5e+153], N[Not[LessEqual[y, 3.4e+99]], $MachinePrecision]], (-z), N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+153} \lor \neg \left(y \leq 3.4 \cdot 10^{+99}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if y < -8.49999999999999935e153 or 3.39999999999999984e99 < y Initial program 64.5%
Taylor expanded in y around inf 73.3%
mul-1-neg73.3%
Simplified73.3%
if -8.49999999999999935e153 < y < 3.39999999999999984e99Initial program 96.5%
Taylor expanded in z around inf 71.9%
+-commutative71.9%
Simplified71.9%
Final simplification72.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -350000000.0) (not (<= y 1.9e+19))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -350000000.0) || !(y <= 1.9e+19)) {
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 <= (-350000000.0d0)) .or. (.not. (y <= 1.9d+19))) 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 <= -350000000.0) || !(y <= 1.9e+19)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -350000000.0) or not (y <= 1.9e+19): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -350000000.0) || !(y <= 1.9e+19)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -350000000.0) || ~((y <= 1.9e+19))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -350000000.0], N[Not[LessEqual[y, 1.9e+19]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -350000000 \lor \neg \left(y \leq 1.9 \cdot 10^{+19}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -3.5e8 or 1.9e19 < y Initial program 75.2%
Taylor expanded in y around inf 55.4%
mul-1-neg55.4%
Simplified55.4%
if -3.5e8 < y < 1.9e19Initial program 99.9%
Taylor expanded in y around 0 61.4%
Final simplification58.6%
(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 88.5%
Taylor expanded in y around 0 37.0%
Final simplification37.0%
(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 2024044
(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))))