
(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}
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (* (fma (/ (- z x) y) (+ z x) (- y)) -0.5))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
return fma(((z - x) / y), (z + x), -y) * -0.5;
}
x = abs(x) z = abs(z) function code(x, y, z) return Float64(fma(Float64(Float64(z - x) / y), Float64(z + x), Float64(-y)) * -0.5) end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := N[(N[(N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision] * N[(z + x), $MachinePrecision] + (-y)), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\mathsf{fma}\left(\frac{z - x}{y}, z + x, -y\right) \cdot -0.5
\end{array}
Initial program 70.2%
sub-neg70.2%
+-commutative70.2%
neg-sub070.2%
associate-+l-70.2%
sub0-neg70.2%
neg-mul-170.2%
*-commutative70.2%
times-frac70.2%
associate--r+70.2%
div-sub70.2%
difference-of-squares74.1%
+-commutative74.1%
associate-*r/80.1%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg99.9%
Applied egg-rr99.9%
Final simplification99.9%
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z)
:precision binary64
(if (<= (* z z) 2e-73)
(* -0.5 (- (- y) (* x (/ x y))))
(if (<= (* z z) 5e+266)
(* -0.5 (* (/ (- z x) y) (+ z x)))
(* -0.5 (- (/ z (/ y z)) y)))))x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-73) {
tmp = -0.5 * (-y - (x * (x / y)));
} else if ((z * z) <= 5e+266) {
tmp = -0.5 * (((z - x) / y) * (z + x));
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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) <= 2d-73) then
tmp = (-0.5d0) * (-y - (x * (x / y)))
else if ((z * z) <= 5d+266) then
tmp = (-0.5d0) * (((z - x) / y) * (z + x))
else
tmp = (-0.5d0) * ((z / (y / z)) - y)
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e-73) {
tmp = -0.5 * (-y - (x * (x / y)));
} else if ((z * z) <= 5e+266) {
tmp = -0.5 * (((z - x) / y) * (z + x));
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if (z * z) <= 2e-73: tmp = -0.5 * (-y - (x * (x / y))) elif (z * z) <= 5e+266: tmp = -0.5 * (((z - x) / y) * (z + x)) else: tmp = -0.5 * ((z / (y / z)) - y) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e-73) tmp = Float64(-0.5 * Float64(Float64(-y) - Float64(x * Float64(x / y)))); elseif (Float64(z * z) <= 5e+266) tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) / y) * Float64(z + x))); else tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 2e-73) tmp = -0.5 * (-y - (x * (x / y))); elseif ((z * z) <= 5e+266) tmp = -0.5 * (((z - x) / y) * (z + x)); else tmp = -0.5 * ((z / (y / z)) - y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e-73], N[(-0.5 * N[((-y) - N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 5e+266], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-73}:\\
\;\;\;\;-0.5 \cdot \left(\left(-y\right) - x \cdot \frac{x}{y}\right)\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+266}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1.99999999999999999e-73Initial program 72.9%
sub-neg72.9%
+-commutative72.9%
neg-sub072.9%
associate-+l-72.9%
sub0-neg72.9%
neg-mul-172.9%
*-commutative72.9%
times-frac72.9%
associate--r+72.9%
div-sub72.9%
difference-of-squares72.9%
+-commutative72.9%
associate-*r/78.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 87.3%
unpow287.3%
associate-*r/87.3%
neg-mul-187.3%
distribute-rgt-neg-in87.3%
Simplified87.3%
distribute-rgt-neg-out87.3%
distribute-frac-neg87.3%
div-inv87.3%
add-sqr-sqrt87.3%
sqrt-unprod78.6%
sqr-neg78.6%
swap-sqr78.6%
sqrt-unprod20.7%
add-sqr-sqrt42.2%
associate-*l*46.4%
add-sqr-sqrt25.7%
sqrt-unprod60.6%
sqr-neg60.6%
sqrt-unprod44.3%
add-sqr-sqrt98.2%
div-inv98.3%
frac-2neg98.3%
Applied egg-rr98.3%
if 1.99999999999999999e-73 < (*.f64 z z) < 4.9999999999999999e266Initial program 79.5%
sub-neg79.5%
+-commutative79.5%
neg-sub079.5%
associate-+l-79.5%
sub0-neg79.5%
neg-mul-179.5%
*-commutative79.5%
times-frac79.5%
associate--r+79.5%
div-sub79.6%
difference-of-squares79.6%
+-commutative79.6%
associate-*r/84.3%
associate-/l*99.8%
*-inverses99.8%
/-rgt-identity99.8%
metadata-eval99.8%
Simplified99.8%
*-commutative99.8%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 72.0%
associate-/l*77.6%
associate-/r/77.7%
+-commutative77.7%
Simplified77.7%
if 4.9999999999999999e266 < (*.f64 z z) Initial program 59.0%
sub-neg59.0%
+-commutative59.0%
neg-sub059.0%
associate-+l-59.0%
sub0-neg59.0%
neg-mul-159.0%
*-commutative59.0%
times-frac59.0%
associate--r+59.0%
div-sub59.0%
difference-of-squares71.8%
+-commutative71.8%
associate-*r/79.3%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 74.1%
unpow274.1%
associate-/l*91.1%
Simplified91.1%
Final simplification91.2%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* x x) 2e-48) (* -0.5 (- (* z (/ z y)) y)) (* -0.5 (- (* (- z x) (/ x y)) y))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e-48) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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-48) then
tmp = (-0.5d0) * ((z * (z / y)) - y)
else
tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e-48) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if (x * x) <= 2e-48: tmp = -0.5 * ((z * (z / y)) - y) else: tmp = -0.5 * (((z - x) * (x / y)) - y) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e-48) tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y)); else tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y)); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e-48) tmp = -0.5 * ((z * (z / y)) - y); else tmp = -0.5 * (((z - x) * (x / y)) - y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e-48], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-48}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.9999999999999999e-48Initial program 75.5%
sub-neg75.5%
+-commutative75.5%
neg-sub075.5%
associate-+l-75.5%
sub0-neg75.5%
neg-mul-175.5%
*-commutative75.5%
times-frac75.5%
associate--r+75.5%
div-sub75.5%
difference-of-squares75.5%
+-commutative75.5%
associate-*r/80.8%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 84.7%
unpow284.7%
associate-/l*91.3%
Simplified91.3%
associate-/r/91.3%
Applied egg-rr91.3%
if 1.9999999999999999e-48 < (*.f64 x x) Initial program 64.7%
sub-neg64.7%
+-commutative64.7%
neg-sub064.7%
associate-+l-64.7%
sub0-neg64.7%
neg-mul-164.7%
*-commutative64.7%
times-frac64.7%
associate--r+64.7%
div-sub64.7%
difference-of-squares72.7%
+-commutative72.7%
associate-*l/79.4%
*-commutative79.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 87.0%
Final simplification89.2%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* x x) 5e+117) (* -0.5 (- (* z (/ z y)) y)) (* -0.5 (- (- y) (* x (/ x y))))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+117) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = -0.5 * (-y - (x * (x / y)));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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+117) then
tmp = (-0.5d0) * ((z * (z / y)) - y)
else
tmp = (-0.5d0) * (-y - (x * (x / y)))
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+117) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = -0.5 * (-y - (x * (x / y)));
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if (x * x) <= 5e+117: tmp = -0.5 * ((z * (z / y)) - y) else: tmp = -0.5 * (-y - (x * (x / y))) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e+117) tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y)); else tmp = Float64(-0.5 * Float64(Float64(-y) - Float64(x * Float64(x / y)))); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e+117) tmp = -0.5 * ((z * (z / y)) - y); else tmp = -0.5 * (-y - (x * (x / y))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+117], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[((-y) - N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+117}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(-y\right) - x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4.99999999999999983e117Initial program 75.0%
sub-neg75.0%
+-commutative75.0%
neg-sub075.0%
associate-+l-75.0%
sub0-neg75.0%
neg-mul-175.0%
*-commutative75.0%
times-frac75.0%
associate--r+75.0%
div-sub75.0%
difference-of-squares75.0%
+-commutative75.0%
associate-*r/79.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 83.8%
unpow283.8%
associate-/l*89.4%
Simplified89.4%
associate-/r/89.4%
Applied egg-rr89.4%
if 4.99999999999999983e117 < (*.f64 x x) Initial program 62.9%
sub-neg62.9%
+-commutative62.9%
neg-sub062.9%
associate-+l-62.9%
sub0-neg62.9%
neg-mul-162.9%
*-commutative62.9%
times-frac62.9%
associate--r+62.9%
div-sub62.9%
difference-of-squares72.8%
+-commutative72.8%
associate-*r/81.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 75.3%
unpow275.4%
associate-*r/75.4%
neg-mul-175.4%
distribute-rgt-neg-in75.4%
Simplified75.4%
distribute-rgt-neg-out75.4%
distribute-frac-neg75.4%
div-inv75.4%
add-sqr-sqrt75.4%
sqrt-unprod60.8%
sqr-neg60.8%
swap-sqr60.8%
sqrt-unprod0.0%
add-sqr-sqrt15.8%
associate-*l*20.7%
add-sqr-sqrt10.8%
sqrt-unprod51.9%
sqr-neg51.9%
sqrt-unprod44.1%
add-sqr-sqrt89.7%
div-inv89.8%
frac-2neg89.8%
Applied egg-rr89.8%
Final simplification89.5%
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z)
:precision binary64
(if (<= x 3.5e-233)
(* y 0.5)
(if (<= x 17500000.0)
(* -0.5 (/ z (/ y z)))
(if (<= x 2.7e+62) (* y 0.5) (* (/ x y) (* x 0.5))))))x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (x <= 3.5e-233) {
tmp = y * 0.5;
} else if (x <= 17500000.0) {
tmp = -0.5 * (z / (y / z));
} else if (x <= 2.7e+62) {
tmp = y * 0.5;
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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 <= 3.5d-233) then
tmp = y * 0.5d0
else if (x <= 17500000.0d0) then
tmp = (-0.5d0) * (z / (y / z))
else if (x <= 2.7d+62) then
tmp = y * 0.5d0
else
tmp = (x / y) * (x * 0.5d0)
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (x <= 3.5e-233) {
tmp = y * 0.5;
} else if (x <= 17500000.0) {
tmp = -0.5 * (z / (y / z));
} else if (x <= 2.7e+62) {
tmp = y * 0.5;
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if x <= 3.5e-233: tmp = y * 0.5 elif x <= 17500000.0: tmp = -0.5 * (z / (y / z)) elif x <= 2.7e+62: tmp = y * 0.5 else: tmp = (x / y) * (x * 0.5) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (x <= 3.5e-233) tmp = Float64(y * 0.5); elseif (x <= 17500000.0) tmp = Float64(-0.5 * Float64(z / Float64(y / z))); elseif (x <= 2.7e+62) tmp = Float64(y * 0.5); else tmp = Float64(Float64(x / y) * Float64(x * 0.5)); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.5e-233) tmp = y * 0.5; elseif (x <= 17500000.0) tmp = -0.5 * (z / (y / z)); elseif (x <= 2.7e+62) tmp = y * 0.5; else tmp = (x / y) * (x * 0.5); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, 3.5e-233], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 17500000.0], N[(-0.5 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.7e+62], N[(y * 0.5), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-233}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 17500000:\\
\;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+62}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\end{array}
\end{array}
if x < 3.49999999999999991e-233 or 1.75e7 < x < 2.7e62Initial program 73.1%
Taylor expanded in y around inf 33.4%
*-commutative33.4%
Simplified33.4%
if 3.49999999999999991e-233 < x < 1.75e7Initial program 74.9%
sub-neg74.9%
+-commutative74.9%
neg-sub074.9%
associate-+l-74.9%
sub0-neg74.9%
neg-mul-174.9%
*-commutative74.9%
times-frac74.9%
associate--r+74.9%
div-sub74.9%
difference-of-squares74.9%
+-commutative74.9%
associate-*r/83.2%
associate-/l*99.8%
*-inverses99.8%
/-rgt-identity99.8%
metadata-eval99.8%
Simplified99.8%
*-commutative99.8%
fma-neg99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 45.4%
unpow245.4%
associate-/l*52.3%
Simplified52.3%
if 2.7e62 < x Initial program 56.3%
Taylor expanded in x around inf 56.3%
unpow256.3%
Simplified56.3%
times-frac68.3%
div-inv68.3%
metadata-eval68.3%
Applied egg-rr68.3%
Final simplification43.6%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+192) (* -0.5 (- (* z (/ z y)) y)) (* (/ x y) (* x 0.5))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+192) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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) <= 1d+192) then
tmp = (-0.5d0) * ((z * (z / y)) - y)
else
tmp = (x / y) * (x * 0.5d0)
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+192) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if (x * x) <= 1e+192: tmp = -0.5 * ((z * (z / y)) - y) else: tmp = (x / y) * (x * 0.5) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+192) tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y)); else tmp = Float64(Float64(x / y) * Float64(x * 0.5)); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+192) tmp = -0.5 * ((z * (z / y)) - y); else tmp = (x / y) * (x * 0.5); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+192], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+192}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000004e192Initial program 73.6%
sub-neg73.6%
+-commutative73.6%
neg-sub073.6%
associate-+l-73.6%
sub0-neg73.6%
neg-mul-173.6%
*-commutative73.6%
times-frac73.6%
associate--r+73.6%
div-sub73.7%
difference-of-squares73.7%
+-commutative73.7%
associate-*r/77.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 82.4%
unpow282.4%
associate-/l*87.6%
Simplified87.6%
associate-/r/87.6%
Applied egg-rr87.6%
if 1.00000000000000004e192 < (*.f64 x x) Initial program 64.0%
Taylor expanded in x around inf 68.4%
unpow268.4%
Simplified68.4%
times-frac77.9%
div-inv77.9%
metadata-eval77.9%
Applied egg-rr77.9%
Final simplification84.1%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (* -0.5 (- (* (/ (- z x) y) (+ z x)) y)))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
return -0.5 * ((((z - x) / y) * (z + x)) - y);
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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) * ((((z - x) / y) * (z + x)) - y)
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
return -0.5 * ((((z - x) / y) * (z + x)) - y);
}
x = abs(x) z = abs(z) def code(x, y, z): return -0.5 * ((((z - x) / y) * (z + x)) - y)
x = abs(x) z = abs(z) function code(x, y, z) return Float64(-0.5 * Float64(Float64(Float64(Float64(z - x) / y) * Float64(z + x)) - y)) end
x = abs(x) z = abs(z) function tmp = code(x, y, z) tmp = -0.5 * ((((z - x) / y) * (z + x)) - y); end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := N[(-0.5 * N[(N[(N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
-0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right) - y\right)
\end{array}
Initial program 70.2%
sub-neg70.2%
+-commutative70.2%
neg-sub070.2%
associate-+l-70.2%
sub0-neg70.2%
neg-mul-170.2%
*-commutative70.2%
times-frac70.2%
associate--r+70.2%
div-sub70.2%
difference-of-squares74.1%
+-commutative74.1%
associate-*r/80.1%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x 2.8e+62) (* y 0.5) (* x (* x (/ 0.5 y)))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (x <= 2.8e+62) {
tmp = y * 0.5;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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.8d+62) then
tmp = y * 0.5d0
else
tmp = x * (x * (0.5d0 / y))
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2.8e+62) {
tmp = y * 0.5;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if x <= 2.8e+62: tmp = y * 0.5 else: tmp = x * (x * (0.5 / y)) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (x <= 2.8e+62) tmp = Float64(y * 0.5); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.8e+62) tmp = y * 0.5; else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, 2.8e+62], N[(y * 0.5), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+62}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 2.80000000000000014e62Initial program 73.5%
Taylor expanded in y around inf 34.3%
*-commutative34.3%
Simplified34.3%
if 2.80000000000000014e62 < x Initial program 56.3%
Taylor expanded in x around inf 56.3%
unpow256.3%
Simplified56.3%
Taylor expanded in x around 0 56.3%
*-commutative56.3%
unpow256.3%
metadata-eval56.3%
times-frac56.3%
associate-*r/56.3%
associate-*r*68.2%
*-commutative68.2%
associate-/r*68.2%
metadata-eval68.2%
Simplified68.2%
Final simplification40.9%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= x 2.9e+62) (* y 0.5) (* (/ x y) (* x 0.5))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (x <= 2.9e+62) {
tmp = y * 0.5;
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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.9d+62) then
tmp = y * 0.5d0
else
tmp = (x / y) * (x * 0.5d0)
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2.9e+62) {
tmp = y * 0.5;
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if x <= 2.9e+62: tmp = y * 0.5 else: tmp = (x / y) * (x * 0.5) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (x <= 2.9e+62) tmp = Float64(y * 0.5); else tmp = Float64(Float64(x / y) * Float64(x * 0.5)); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2.9e+62) tmp = y * 0.5; else tmp = (x / y) * (x * 0.5); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[x, 2.9e+62], N[(y * 0.5), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9 \cdot 10^{+62}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\end{array}
\end{array}
if x < 2.89999999999999984e62Initial program 73.5%
Taylor expanded in y around inf 34.3%
*-commutative34.3%
Simplified34.3%
if 2.89999999999999984e62 < x Initial program 56.3%
Taylor expanded in x around inf 56.3%
unpow256.3%
Simplified56.3%
times-frac68.3%
div-inv68.3%
metadata-eval68.3%
Applied egg-rr68.3%
Final simplification40.9%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (* y 0.5))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
return y * 0.5;
}
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
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
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
return y * 0.5;
}
x = abs(x) z = abs(z) def code(x, y, z): return y * 0.5
x = abs(x) z = abs(z) function code(x, y, z) return Float64(y * 0.5) end
x = abs(x) z = abs(z) function tmp = code(x, y, z) tmp = y * 0.5; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
y \cdot 0.5
\end{array}
Initial program 70.2%
Taylor expanded in y around inf 32.0%
*-commutative32.0%
Simplified32.0%
Final simplification32.0%
(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 2023238
(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)))