
(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 10 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
(if (<= (* x x) 2e+151)
(* 0.5 (+ (/ x (/ y x)) (- y (/ z (/ y z)))))
(if (<= (* x x) 2e+297)
(* 0.5 (+ y (/ (- (* x x) (* z z)) y)))
(* (- x z) (/ 1.0 (* y (/ 2.0 (+ x z))))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+151) {
tmp = 0.5 * ((x / (y / x)) + (y - (z / (y / z))));
} else if ((x * x) <= 2e+297) {
tmp = 0.5 * (y + (((x * x) - (z * z)) / y));
} else {
tmp = (x - z) * (1.0 / (y * (2.0 / (x + 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 ((x * x) <= 2d+151) then
tmp = 0.5d0 * ((x / (y / x)) + (y - (z / (y / z))))
else if ((x * x) <= 2d+297) then
tmp = 0.5d0 * (y + (((x * x) - (z * z)) / y))
else
tmp = (x - z) * (1.0d0 / (y * (2.0d0 / (x + z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+151) {
tmp = 0.5 * ((x / (y / x)) + (y - (z / (y / z))));
} else if ((x * x) <= 2e+297) {
tmp = 0.5 * (y + (((x * x) - (z * z)) / y));
} else {
tmp = (x - z) * (1.0 / (y * (2.0 / (x + z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+151: tmp = 0.5 * ((x / (y / x)) + (y - (z / (y / z)))) elif (x * x) <= 2e+297: tmp = 0.5 * (y + (((x * x) - (z * z)) / y)) else: tmp = (x - z) * (1.0 / (y * (2.0 / (x + z)))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+151) tmp = Float64(0.5 * Float64(Float64(x / Float64(y / x)) + Float64(y - Float64(z / Float64(y / z))))); elseif (Float64(x * x) <= 2e+297) tmp = Float64(0.5 * Float64(y + Float64(Float64(Float64(x * x) - Float64(z * z)) / y))); else tmp = Float64(Float64(x - z) * Float64(1.0 / Float64(y * Float64(2.0 / Float64(x + z))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+151) tmp = 0.5 * ((x / (y / x)) + (y - (z / (y / z)))); elseif ((x * x) <= 2e+297) tmp = 0.5 * (y + (((x * x) - (z * z)) / y)); else tmp = (x - z) * (1.0 / (y * (2.0 / (x + z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+151], N[(0.5 * N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] + N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+297], N[(0.5 * N[(y + N[(N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(1.0 / N[(y * N[(2.0 / N[(x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+151}:\\
\;\;\;\;0.5 \cdot \left(\frac{x}{\frac{y}{x}} + \left(y - \frac{z}{\frac{y}{z}}\right)\right)\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+297}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x \cdot x - z \cdot z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{1}{y \cdot \frac{2}{x + z}}\\
\end{array}
\end{array}
if (*.f64 x x) < 2.00000000000000003e151Initial program 79.5%
Taylor expanded in x around inf 94.5%
+-commutative94.5%
distribute-lft-out94.5%
unpow294.5%
associate-/l*95.6%
unpow295.6%
associate-/l*99.9%
Simplified99.9%
if 2.00000000000000003e151 < (*.f64 x x) < 2e297Initial program 68.2%
Taylor expanded in y around 0 96.7%
distribute-lft-out96.7%
unpow296.7%
unpow296.7%
Simplified96.7%
if 2e297 < (*.f64 x x) Initial program 66.2%
Taylor expanded in y around 0 66.2%
unpow266.2%
unpow266.2%
Simplified66.2%
difference-of-squares85.2%
*-commutative85.2%
Applied egg-rr85.2%
associate-/l*96.0%
div-inv95.9%
*-un-lft-identity95.9%
times-frac95.9%
/-rgt-identity95.9%
Applied egg-rr95.9%
Final simplification98.5%
(FPCore (x y z)
:precision binary64
(if (<= (* x x) 5e-180)
(* 0.5 (/ (- y z) (/ y (+ y z))))
(if (<= (* x x) 2e+305)
(* 0.5 (+ y (/ (- (* x x) (* z z)) y)))
(* 0.5 (+ y (* x (/ x y)))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-180) {
tmp = 0.5 * ((y - z) / (y / (y + z)));
} else if ((x * x) <= 2e+305) {
tmp = 0.5 * (y + (((x * x) - (z * z)) / y));
} else {
tmp = 0.5 * (y + (x * (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 ((x * x) <= 5d-180) then
tmp = 0.5d0 * ((y - z) / (y / (y + z)))
else if ((x * x) <= 2d+305) then
tmp = 0.5d0 * (y + (((x * x) - (z * z)) / y))
else
tmp = 0.5d0 * (y + (x * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-180) {
tmp = 0.5 * ((y - z) / (y / (y + z)));
} else if ((x * x) <= 2e+305) {
tmp = 0.5 * (y + (((x * x) - (z * z)) / y));
} else {
tmp = 0.5 * (y + (x * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e-180: tmp = 0.5 * ((y - z) / (y / (y + z))) elif (x * x) <= 2e+305: tmp = 0.5 * (y + (((x * x) - (z * z)) / y)) else: tmp = 0.5 * (y + (x * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e-180) tmp = Float64(0.5 * Float64(Float64(y - z) / Float64(y / Float64(y + z)))); elseif (Float64(x * x) <= 2e+305) tmp = Float64(0.5 * Float64(y + Float64(Float64(Float64(x * x) - Float64(z * z)) / y))); else tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e-180) tmp = 0.5 * ((y - z) / (y / (y + z))); elseif ((x * x) <= 2e+305) tmp = 0.5 * (y + (((x * x) - (z * z)) / y)); else tmp = 0.5 * (y + (x * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-180], N[(0.5 * N[(N[(y - z), $MachinePrecision] / N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+305], N[(0.5 * N[(y + N[(N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-180}:\\
\;\;\;\;0.5 \cdot \frac{y - z}{\frac{y}{y + z}}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+305}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x \cdot x - z \cdot z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 5.0000000000000001e-180Initial program 76.6%
Taylor expanded in x around 0 75.7%
unpow275.7%
unpow275.7%
difference-of-squares75.9%
*-commutative75.9%
associate-/l*96.9%
Simplified96.9%
if 5.0000000000000001e-180 < (*.f64 x x) < 1.9999999999999999e305Initial program 79.1%
Taylor expanded in y around 0 98.0%
distribute-lft-out98.0%
unpow298.0%
unpow298.0%
Simplified98.0%
if 1.9999999999999999e305 < (*.f64 x x) Initial program 65.2%
Taylor expanded in y around 0 65.2%
distribute-lft-out65.2%
unpow265.2%
unpow265.2%
Simplified65.2%
Taylor expanded in x around inf 80.3%
unpow280.3%
associate-*r/95.5%
Simplified95.5%
Final simplification96.9%
(FPCore (x y z)
:precision binary64
(if (<= (* x x) 5e-180)
(* 0.5 (/ (- y z) (/ y (+ y z))))
(if (<= (* x x) 2e+297)
(* 0.5 (+ y (/ (- (* x x) (* z z)) y)))
(* (- x z) (/ 1.0 (* y (/ 2.0 (+ x z))))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-180) {
tmp = 0.5 * ((y - z) / (y / (y + z)));
} else if ((x * x) <= 2e+297) {
tmp = 0.5 * (y + (((x * x) - (z * z)) / y));
} else {
tmp = (x - z) * (1.0 / (y * (2.0 / (x + 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 ((x * x) <= 5d-180) then
tmp = 0.5d0 * ((y - z) / (y / (y + z)))
else if ((x * x) <= 2d+297) then
tmp = 0.5d0 * (y + (((x * x) - (z * z)) / y))
else
tmp = (x - z) * (1.0d0 / (y * (2.0d0 / (x + z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-180) {
tmp = 0.5 * ((y - z) / (y / (y + z)));
} else if ((x * x) <= 2e+297) {
tmp = 0.5 * (y + (((x * x) - (z * z)) / y));
} else {
tmp = (x - z) * (1.0 / (y * (2.0 / (x + z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e-180: tmp = 0.5 * ((y - z) / (y / (y + z))) elif (x * x) <= 2e+297: tmp = 0.5 * (y + (((x * x) - (z * z)) / y)) else: tmp = (x - z) * (1.0 / (y * (2.0 / (x + z)))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e-180) tmp = Float64(0.5 * Float64(Float64(y - z) / Float64(y / Float64(y + z)))); elseif (Float64(x * x) <= 2e+297) tmp = Float64(0.5 * Float64(y + Float64(Float64(Float64(x * x) - Float64(z * z)) / y))); else tmp = Float64(Float64(x - z) * Float64(1.0 / Float64(y * Float64(2.0 / Float64(x + z))))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e-180) tmp = 0.5 * ((y - z) / (y / (y + z))); elseif ((x * x) <= 2e+297) tmp = 0.5 * (y + (((x * x) - (z * z)) / y)); else tmp = (x - z) * (1.0 / (y * (2.0 / (x + z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-180], N[(0.5 * N[(N[(y - z), $MachinePrecision] / N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+297], N[(0.5 * N[(y + N[(N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(1.0 / N[(y * N[(2.0 / N[(x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-180}:\\
\;\;\;\;0.5 \cdot \frac{y - z}{\frac{y}{y + z}}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+297}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x \cdot x - z \cdot z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{1}{y \cdot \frac{2}{x + z}}\\
\end{array}
\end{array}
if (*.f64 x x) < 5.0000000000000001e-180Initial program 76.6%
Taylor expanded in x around 0 75.7%
unpow275.7%
unpow275.7%
difference-of-squares75.9%
*-commutative75.9%
associate-/l*96.9%
Simplified96.9%
if 5.0000000000000001e-180 < (*.f64 x x) < 2e297Initial program 78.7%
Taylor expanded in y around 0 97.9%
distribute-lft-out97.9%
unpow297.9%
unpow297.9%
Simplified97.9%
if 2e297 < (*.f64 x x) Initial program 66.2%
Taylor expanded in y around 0 66.2%
unpow266.2%
unpow266.2%
Simplified66.2%
difference-of-squares85.2%
*-commutative85.2%
Applied egg-rr85.2%
associate-/l*96.0%
div-inv95.9%
*-un-lft-identity95.9%
times-frac95.9%
/-rgt-identity95.9%
Applied egg-rr95.9%
Final simplification97.0%
(FPCore (x y z)
:precision binary64
(if (<= (* x x) 4e-111)
(* 0.5 (/ (- y z) (/ y (+ y z))))
(if (<= (* x x) 5e+263)
(/ (* (- x z) (+ x z)) (* y 2.0))
(* 0.5 (+ y (* x (/ x y)))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4e-111) {
tmp = 0.5 * ((y - z) / (y / (y + z)));
} else if ((x * x) <= 5e+263) {
tmp = ((x - z) * (x + z)) / (y * 2.0);
} else {
tmp = 0.5 * (y + (x * (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 ((x * x) <= 4d-111) then
tmp = 0.5d0 * ((y - z) / (y / (y + z)))
else if ((x * x) <= 5d+263) then
tmp = ((x - z) * (x + z)) / (y * 2.0d0)
else
tmp = 0.5d0 * (y + (x * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4e-111) {
tmp = 0.5 * ((y - z) / (y / (y + z)));
} else if ((x * x) <= 5e+263) {
tmp = ((x - z) * (x + z)) / (y * 2.0);
} else {
tmp = 0.5 * (y + (x * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 4e-111: tmp = 0.5 * ((y - z) / (y / (y + z))) elif (x * x) <= 5e+263: tmp = ((x - z) * (x + z)) / (y * 2.0) else: tmp = 0.5 * (y + (x * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 4e-111) tmp = Float64(0.5 * Float64(Float64(y - z) / Float64(y / Float64(y + z)))); elseif (Float64(x * x) <= 5e+263) tmp = Float64(Float64(Float64(x - z) * Float64(x + z)) / Float64(y * 2.0)); else tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 4e-111) tmp = 0.5 * ((y - z) / (y / (y + z))); elseif ((x * x) <= 5e+263) tmp = ((x - z) * (x + z)) / (y * 2.0); else tmp = 0.5 * (y + (x * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 4e-111], N[(0.5 * N[(N[(y - z), $MachinePrecision] / N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e+263], N[(N[(N[(x - z), $MachinePrecision] * N[(x + z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{-111}:\\
\;\;\;\;0.5 \cdot \frac{y - z}{\frac{y}{y + z}}\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{+263}:\\
\;\;\;\;\frac{\left(x - z\right) \cdot \left(x + z\right)}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4.00000000000000035e-111Initial program 77.5%
Taylor expanded in x around 0 76.6%
unpow276.6%
unpow276.6%
difference-of-squares76.9%
*-commutative76.9%
associate-/l*97.3%
Simplified97.3%
if 4.00000000000000035e-111 < (*.f64 x x) < 5.00000000000000022e263Initial program 81.5%
Taylor expanded in y around 0 78.0%
unpow278.0%
unpow278.0%
Simplified78.0%
difference-of-squares78.0%
*-commutative78.0%
Applied egg-rr78.0%
if 5.00000000000000022e263 < (*.f64 x x) Initial program 64.5%
Taylor expanded in y around 0 70.5%
distribute-lft-out70.5%
unpow270.5%
unpow270.5%
Simplified70.5%
Taylor expanded in x around inf 80.7%
unpow280.7%
associate-*r/93.7%
Simplified93.7%
Final simplification90.7%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 5e+258) (* 0.5 (+ y (* x (/ x y)))) (* z (* (/ z y) -0.5))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+258) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = z * ((z / y) * -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) <= 5d+258) then
tmp = 0.5d0 * (y + (x * (x / y)))
else
tmp = z * ((z / y) * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+258) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 5e+258: tmp = 0.5 * (y + (x * (x / y))) else: tmp = z * ((z / y) * -0.5) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+258) tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); else tmp = Float64(z * Float64(Float64(z / y) * -0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e+258) tmp = 0.5 * (y + (x * (x / y))); else tmp = z * ((z / y) * -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+258], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(z / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+258}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 5e258Initial program 77.7%
Taylor expanded in y around 0 94.0%
distribute-lft-out94.0%
unpow294.0%
unpow294.0%
Simplified94.0%
Taylor expanded in x around inf 77.9%
unpow277.9%
associate-*r/83.8%
Simplified83.8%
if 5e258 < (*.f64 z z) Initial program 68.2%
Taylor expanded in z around inf 71.8%
unpow271.8%
associate-*r/71.8%
Simplified71.8%
Taylor expanded in z around 0 71.8%
unpow271.8%
associate-*r/75.8%
associate-*r*75.8%
*-commutative75.8%
associate-*l*75.8%
Simplified75.8%
Final simplification81.2%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+169) (* 0.5 (- y (* z (/ z y)))) (* 0.5 (+ y (* x (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+169) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = 0.5 * (y + (x * (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 ((x * x) <= 2d+169) then
tmp = 0.5d0 * (y - (z * (z / y)))
else
tmp = 0.5d0 * (y + (x * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+169) {
tmp = 0.5 * (y - (z * (z / y)));
} else {
tmp = 0.5 * (y + (x * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+169: tmp = 0.5 * (y - (z * (z / y))) else: tmp = 0.5 * (y + (x * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+169) tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); else tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+169) tmp = 0.5 * (y - (z * (z / y))); else tmp = 0.5 * (y + (x * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+169], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+169}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.99999999999999987e169Initial program 79.4%
Taylor expanded in x around inf 94.0%
+-commutative94.0%
distribute-lft-out94.0%
unpow294.0%
associate-/l*95.1%
unpow295.1%
associate-/l*99.3%
Simplified99.3%
Taylor expanded in x around 0 84.0%
unpow284.0%
associate-*r/88.2%
Simplified88.2%
if 1.99999999999999987e169 < (*.f64 x x) Initial program 66.5%
Taylor expanded in y around 0 74.4%
distribute-lft-out74.4%
unpow274.4%
unpow274.4%
Simplified74.4%
Taylor expanded in x around inf 79.8%
unpow279.8%
associate-*r/90.5%
Simplified90.5%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+169) (* z (* (/ z y) -0.5)) (* 0.5 (* x (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+169) {
tmp = z * ((z / y) * -0.5);
} else {
tmp = 0.5 * (x * (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 ((x * x) <= 2d+169) then
tmp = z * ((z / y) * (-0.5d0))
else
tmp = 0.5d0 * (x * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+169) {
tmp = z * ((z / y) * -0.5);
} else {
tmp = 0.5 * (x * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+169: tmp = z * ((z / y) * -0.5) else: tmp = 0.5 * (x * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+169) tmp = Float64(z * Float64(Float64(z / y) * -0.5)); else tmp = Float64(0.5 * Float64(x * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+169) tmp = z * ((z / y) * -0.5); else tmp = 0.5 * (x * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+169], N[(z * N[(N[(z / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+169}:\\
\;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.99999999999999987e169Initial program 79.4%
Taylor expanded in z around inf 49.7%
unpow249.7%
associate-*r/49.7%
Simplified49.7%
Taylor expanded in z around 0 49.7%
unpow249.7%
associate-*r/51.2%
associate-*r*51.2%
*-commutative51.2%
associate-*l*51.2%
Simplified51.2%
if 1.99999999999999987e169 < (*.f64 x x) Initial program 66.5%
Taylor expanded in x around inf 65.0%
+-commutative65.0%
distribute-lft-out65.0%
unpow265.0%
associate-/l*74.8%
unpow274.8%
associate-/l*77.8%
Simplified77.8%
Taylor expanded in x around inf 72.3%
unpow272.3%
associate-*r/80.1%
Simplified80.1%
Final simplification62.0%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+169) (/ (* z -0.5) (/ y z)) (* 0.5 (* x (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+169) {
tmp = (z * -0.5) / (y / z);
} else {
tmp = 0.5 * (x * (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 ((x * x) <= 2d+169) then
tmp = (z * (-0.5d0)) / (y / z)
else
tmp = 0.5d0 * (x * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+169) {
tmp = (z * -0.5) / (y / z);
} else {
tmp = 0.5 * (x * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+169: tmp = (z * -0.5) / (y / z) else: tmp = 0.5 * (x * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+169) tmp = Float64(Float64(z * -0.5) / Float64(y / z)); else tmp = Float64(0.5 * Float64(x * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+169) tmp = (z * -0.5) / (y / z); else tmp = 0.5 * (x * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+169], N[(N[(z * -0.5), $MachinePrecision] / N[(y / z), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+169}:\\
\;\;\;\;\frac{z \cdot -0.5}{\frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.99999999999999987e169Initial program 79.4%
Taylor expanded in z around inf 49.7%
unpow249.7%
associate-*r/49.7%
Simplified49.7%
Taylor expanded in z around 0 49.7%
unpow249.7%
associate-*r/51.2%
associate-*r*51.2%
*-commutative51.2%
associate-*l*51.2%
Simplified51.2%
associate-*r*51.2%
clear-num51.2%
un-div-inv51.2%
Applied egg-rr51.2%
if 1.99999999999999987e169 < (*.f64 x x) Initial program 66.5%
Taylor expanded in x around inf 65.0%
+-commutative65.0%
distribute-lft-out65.0%
unpow265.0%
associate-/l*74.8%
unpow274.8%
associate-/l*77.8%
Simplified77.8%
Taylor expanded in x around inf 72.3%
unpow272.3%
associate-*r/80.1%
Simplified80.1%
Final simplification62.0%
(FPCore (x y z) :precision binary64 (if (<= x 2.85e-53) (* 0.5 y) (* 0.5 (* x (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.85e-53) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * (x * (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 (x <= 2.85d-53) then
tmp = 0.5d0 * y
else
tmp = 0.5d0 * (x * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2.85e-53) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * (x * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2.85e-53: tmp = 0.5 * y else: tmp = 0.5 * (x * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2.85e-53) tmp = Float64(0.5 * y); else tmp = Float64(0.5 * Float64(x * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.85e-53) tmp = 0.5 * y; else tmp = 0.5 * (x * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2.85e-53], N[(0.5 * y), $MachinePrecision], N[(0.5 * N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.85 \cdot 10^{-53}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if x < 2.8500000000000001e-53Initial program 73.3%
Taylor expanded in y around inf 33.9%
if 2.8500000000000001e-53 < x Initial program 77.7%
Taylor expanded in x around inf 81.3%
+-commutative81.3%
distribute-lft-out81.3%
unpow281.3%
associate-/l*86.4%
unpow286.4%
associate-/l*89.0%
Simplified89.0%
Taylor expanded in x around inf 62.0%
unpow262.0%
associate-*r/65.8%
Simplified65.8%
Final simplification43.0%
(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 74.6%
Taylor expanded in y around inf 28.5%
Final simplification28.5%
(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 2023268
(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)))