
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z) :precision binary64 (* 0.5 (+ y (/ (+ z x) (/ y (- x z))))))
double code(double x, double y, double z) {
return 0.5 * (y + ((z + x) / (y / (x - z))));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * (y + ((z + x) / (y / (x - z))))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + ((z + x) / (y / (x - z))));
}
def code(x, y, z): return 0.5 * (y + ((z + x) / (y / (x - z))))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(z + x) / Float64(y / Float64(x - z))))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + ((z + x) / (y / (x - z)))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(z + x), $MachinePrecision] / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \frac{z + x}{\frac{y}{x - z}}\right)
\end{array}
Initial program 69.6%
Taylor expanded in y around 0 84.7%
distribute-lft-out84.7%
unpow284.7%
unpow284.7%
difference-of-squares89.8%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* z (/ -0.5 y)))))
(if (<= x 5e-293)
t_0
(if (<= x 7.2e-219)
(* 0.5 y)
(if (<= x 4e-176)
t_0
(if (<= x 7.2e+41)
(* 0.5 y)
(if (<= x 1.9e+109) t_0 (* 0.5 (/ x (/ y x))))))))))
double code(double x, double y, double z) {
double t_0 = z * (z * (-0.5 / y));
double tmp;
if (x <= 5e-293) {
tmp = t_0;
} else if (x <= 7.2e-219) {
tmp = 0.5 * y;
} else if (x <= 4e-176) {
tmp = t_0;
} else if (x <= 7.2e+41) {
tmp = 0.5 * y;
} else if (x <= 1.9e+109) {
tmp = t_0;
} else {
tmp = 0.5 * (x / (y / 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) :: t_0
real(8) :: tmp
t_0 = z * (z * ((-0.5d0) / y))
if (x <= 5d-293) then
tmp = t_0
else if (x <= 7.2d-219) then
tmp = 0.5d0 * y
else if (x <= 4d-176) then
tmp = t_0
else if (x <= 7.2d+41) then
tmp = 0.5d0 * y
else if (x <= 1.9d+109) then
tmp = t_0
else
tmp = 0.5d0 * (x / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (z * (-0.5 / y));
double tmp;
if (x <= 5e-293) {
tmp = t_0;
} else if (x <= 7.2e-219) {
tmp = 0.5 * y;
} else if (x <= 4e-176) {
tmp = t_0;
} else if (x <= 7.2e+41) {
tmp = 0.5 * y;
} else if (x <= 1.9e+109) {
tmp = t_0;
} else {
tmp = 0.5 * (x / (y / x));
}
return tmp;
}
def code(x, y, z): t_0 = z * (z * (-0.5 / y)) tmp = 0 if x <= 5e-293: tmp = t_0 elif x <= 7.2e-219: tmp = 0.5 * y elif x <= 4e-176: tmp = t_0 elif x <= 7.2e+41: tmp = 0.5 * y elif x <= 1.9e+109: tmp = t_0 else: tmp = 0.5 * (x / (y / x)) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(z * Float64(-0.5 / y))) tmp = 0.0 if (x <= 5e-293) tmp = t_0; elseif (x <= 7.2e-219) tmp = Float64(0.5 * y); elseif (x <= 4e-176) tmp = t_0; elseif (x <= 7.2e+41) tmp = Float64(0.5 * y); elseif (x <= 1.9e+109) tmp = t_0; else tmp = Float64(0.5 * Float64(x / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (z * (-0.5 / y)); tmp = 0.0; if (x <= 5e-293) tmp = t_0; elseif (x <= 7.2e-219) tmp = 0.5 * y; elseif (x <= 4e-176) tmp = t_0; elseif (x <= 7.2e+41) tmp = 0.5 * y; elseif (x <= 1.9e+109) tmp = t_0; else tmp = 0.5 * (x / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5e-293], t$95$0, If[LessEqual[x, 7.2e-219], N[(0.5 * y), $MachinePrecision], If[LessEqual[x, 4e-176], t$95$0, If[LessEqual[x, 7.2e+41], N[(0.5 * y), $MachinePrecision], If[LessEqual[x, 1.9e+109], t$95$0, N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{if}\;x \leq 5 \cdot 10^{-293}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-219}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-176}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+41}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+109}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\end{array}
\end{array}
if x < 5.0000000000000003e-293 or 7.19999999999999947e-219 < x < 4e-176 or 7.20000000000000051e41 < x < 1.90000000000000019e109Initial program 70.7%
Taylor expanded in z around inf 33.3%
*-commutative33.3%
unpow233.3%
associate-/l*37.1%
Simplified37.1%
Taylor expanded in z around 0 33.3%
unpow233.3%
associate-*r/37.1%
*-commutative37.1%
associate-*r*37.1%
associate-*l/37.1%
*-commutative37.1%
associate-/l*37.1%
associate-/r/37.1%
Simplified37.1%
if 5.0000000000000003e-293 < x < 7.19999999999999947e-219 or 4e-176 < x < 7.20000000000000051e41Initial program 68.2%
Taylor expanded in y around inf 50.4%
if 1.90000000000000019e109 < x Initial program 68.1%
Taylor expanded in x around inf 76.4%
unpow276.4%
associate-/l*78.2%
Simplified78.2%
Final simplification48.2%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+82) (* 0.5 y) (if (<= (* x x) 5e+218) (* (/ z (/ y z)) -0.5) (* 0.5 (/ x (/ y x))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+82) {
tmp = 0.5 * y;
} else if ((x * x) <= 5e+218) {
tmp = (z / (y / z)) * -0.5;
} else {
tmp = 0.5 * (x / (y / 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 * x) <= 2d+82) then
tmp = 0.5d0 * y
else if ((x * x) <= 5d+218) then
tmp = (z / (y / z)) * (-0.5d0)
else
tmp = 0.5d0 * (x / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+82) {
tmp = 0.5 * y;
} else if ((x * x) <= 5e+218) {
tmp = (z / (y / z)) * -0.5;
} else {
tmp = 0.5 * (x / (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+82: tmp = 0.5 * y elif (x * x) <= 5e+218: tmp = (z / (y / z)) * -0.5 else: tmp = 0.5 * (x / (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+82) tmp = Float64(0.5 * y); elseif (Float64(x * x) <= 5e+218) tmp = Float64(Float64(z / Float64(y / z)) * -0.5); else tmp = Float64(0.5 * Float64(x / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+82) tmp = 0.5 * y; elseif ((x * x) <= 5e+218) tmp = (z / (y / z)) * -0.5; else tmp = 0.5 * (x / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+82], N[(0.5 * y), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e+218], N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+82}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+218}:\\
\;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\end{array}
\end{array}
if (*.f64 x x) < 1.9999999999999999e82Initial program 68.9%
Taylor expanded in y around inf 50.9%
if 1.9999999999999999e82 < (*.f64 x x) < 4.99999999999999983e218Initial program 80.2%
Taylor expanded in z around inf 53.6%
*-commutative53.6%
unpow253.6%
associate-/l*58.5%
Simplified58.5%
if 4.99999999999999983e218 < (*.f64 x x) Initial program 68.5%
Taylor expanded in x around inf 74.8%
unpow274.8%
associate-/l*80.7%
Simplified80.7%
Final simplification60.8%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 1e+250) (* 0.5 (+ y (/ x (/ y x)))) (* (/ z (/ y z)) -0.5)))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+250) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = (z / (y / z)) * -0.5;
}
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 * z) <= 1d+250) then
tmp = 0.5d0 * (y + (x / (y / x)))
else
tmp = (z / (y / z)) * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+250) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = (z / (y / z)) * -0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 1e+250: tmp = 0.5 * (y + (x / (y / x))) else: tmp = (z / (y / z)) * -0.5 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+250) tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x)))); else tmp = Float64(Float64(z / Float64(y / z)) * -0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 1e+250) tmp = 0.5 * (y + (x / (y / x))); else tmp = (z / (y / z)) * -0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+250], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+250}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\
\end{array}
\end{array}
if (*.f64 z z) < 9.9999999999999992e249Initial program 74.3%
Taylor expanded in y around 0 93.5%
distribute-lft-out93.5%
unpow293.5%
unpow293.5%
difference-of-squares93.5%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 83.5%
unpow283.5%
associate-/l*88.6%
Simplified88.6%
if 9.9999999999999992e249 < (*.f64 z z) Initial program 58.9%
Taylor expanded in z around inf 69.3%
*-commutative69.3%
unpow269.3%
associate-/l*74.1%
Simplified74.1%
Final simplification84.3%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+67) (* 0.5 (+ y (/ x (/ y x)))) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+67) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = 0.5 * (y - (z * (z / 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 * z) <= 4d+67) then
tmp = 0.5d0 * (y + (x / (y / x)))
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+67) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 4e+67: tmp = 0.5 * (y + (x / (y / x))) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+67) tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x)))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 4e+67) tmp = 0.5 * (y + (x / (y / x))); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+67], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+67}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 3.99999999999999993e67Initial program 73.7%
Taylor expanded in y around 0 92.9%
distribute-lft-out92.9%
unpow292.9%
unpow292.9%
difference-of-squares92.9%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 87.5%
unpow287.5%
associate-/l*93.0%
Simplified93.0%
if 3.99999999999999993e67 < (*.f64 z z) Initial program 63.8%
Taylor expanded in y around 0 73.1%
distribute-lft-out73.1%
unpow273.1%
unpow273.1%
difference-of-squares85.4%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 70.3%
mul-1-neg70.3%
unpow270.3%
associate-*r/82.3%
unsub-neg82.3%
Simplified82.3%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+67) (* 0.5 (+ y (/ x (/ y x)))) (* 0.5 (- y (/ z (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+67) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = 0.5 * (y - (z / (y / 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) :: tmp
if ((z * z) <= 4d+67) then
tmp = 0.5d0 * (y + (x / (y / x)))
else
tmp = 0.5d0 * (y - (z / (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+67) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = 0.5 * (y - (z / (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 4e+67: tmp = 0.5 * (y + (x / (y / x))) else: tmp = 0.5 * (y - (z / (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+67) tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x)))); else tmp = Float64(0.5 * Float64(y - Float64(z / Float64(y / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 4e+67) tmp = 0.5 * (y + (x / (y / x))); else tmp = 0.5 * (y - (z / (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+67], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+67}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 3.99999999999999993e67Initial program 73.7%
Taylor expanded in y around 0 92.9%
distribute-lft-out92.9%
unpow292.9%
unpow292.9%
difference-of-squares92.9%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 87.5%
unpow287.5%
associate-/l*93.0%
Simplified93.0%
if 3.99999999999999993e67 < (*.f64 z z) Initial program 63.8%
Taylor expanded in y around 0 73.1%
distribute-lft-out73.1%
unpow273.1%
unpow273.1%
difference-of-squares85.4%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 70.3%
mul-1-neg70.3%
unpow270.3%
associate-*r/82.3%
unsub-neg82.3%
Simplified82.3%
clear-num82.3%
un-div-inv82.3%
Applied egg-rr82.3%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (<= x 6.8e+99) (* 0.5 y) (* 0.5 (/ x (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 6.8e+99) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * (x / (y / 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 <= 6.8d+99) then
tmp = 0.5d0 * y
else
tmp = 0.5d0 * (x / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 6.8e+99) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * (x / (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 6.8e+99: tmp = 0.5 * y else: tmp = 0.5 * (x / (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 6.8e+99) tmp = Float64(0.5 * y); else tmp = Float64(0.5 * Float64(x / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 6.8e+99) tmp = 0.5 * y; else tmp = 0.5 * (x / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 6.8e+99], N[(0.5 * y), $MachinePrecision], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{+99}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\end{array}
\end{array}
if x < 6.79999999999999968e99Initial program 69.5%
Taylor expanded in y around inf 42.7%
if 6.79999999999999968e99 < x Initial program 70.0%
Taylor expanded in x around inf 75.8%
unpow275.8%
associate-/l*77.6%
Simplified77.6%
Final simplification49.8%
(FPCore (x y z) :precision binary64 (* 0.5 y))
double code(double x, double y, double z) {
return 0.5 * y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
public static double code(double x, double y, double z) {
return 0.5 * y;
}
def code(x, y, z): return 0.5 * y
function code(x, y, z) return Float64(0.5 * y) end
function tmp = code(x, y, z) tmp = 0.5 * y; end
code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot y
\end{array}
Initial program 69.6%
Taylor expanded in y around inf 36.3%
Final simplification36.3%
(FPCore (x y z) :precision binary64 (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x))))
double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * 0.5d0) - (((0.5d0 / y) * (z + x)) * (z - x))
end function
public static double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
def code(x, y, z): return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x))
function code(x, y, z) return Float64(Float64(y * 0.5) - Float64(Float64(Float64(0.5 / y) * Float64(z + x)) * Float64(z - x))) end
function tmp = code(x, y, z) tmp = (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x)); end
code[x_, y_, z_] := N[(N[(y * 0.5), $MachinePrecision] - N[(N[(N[(0.5 / y), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)
\end{array}
herbie shell --seed 2023271
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:herbie-target
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))