
(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 13 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 (/ (fma (+ x z) (/ (- x z) y) y) 2.0))
double code(double x, double y, double z) {
return fma((x + z), ((x - z) / y), y) / 2.0;
}
function code(x, y, z) return Float64(fma(Float64(x + z), Float64(Float64(x - z) / y), y) / 2.0) end
code[x_, y_, z_] := N[(N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision] + y), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x + z, \frac{x - z}{y}, y\right)}{2}
\end{array}
Initial program 70.5%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified84.2%
+-commutativeN/A
difference-of-squaresN/A
associate-/l*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
(FPCore (x y z)
:precision binary64
(if (<= (* x x) 2e+73)
(/ (* (+ z y) (/ (- y z) y)) 2.0)
(if (<= (* x x) 2e+307)
(* (- (* x x) (* z z)) (/ 0.5 y))
(/ (+ y (/ x (/ y x))) 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+73) {
tmp = ((z + y) * ((y - z) / y)) / 2.0;
} else if ((x * x) <= 2e+307) {
tmp = ((x * x) - (z * z)) * (0.5 / y);
} else {
tmp = (y + (x / (y / x))) / 2.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) :: tmp
if ((x * x) <= 2d+73) then
tmp = ((z + y) * ((y - z) / y)) / 2.0d0
else if ((x * x) <= 2d+307) then
tmp = ((x * x) - (z * z)) * (0.5d0 / y)
else
tmp = (y + (x / (y / x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+73) {
tmp = ((z + y) * ((y - z) / y)) / 2.0;
} else if ((x * x) <= 2e+307) {
tmp = ((x * x) - (z * z)) * (0.5 / y);
} else {
tmp = (y + (x / (y / x))) / 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+73: tmp = ((z + y) * ((y - z) / y)) / 2.0 elif (x * x) <= 2e+307: tmp = ((x * x) - (z * z)) * (0.5 / y) else: tmp = (y + (x / (y / x))) / 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+73) tmp = Float64(Float64(Float64(z + y) * Float64(Float64(y - z) / y)) / 2.0); elseif (Float64(x * x) <= 2e+307) tmp = Float64(Float64(Float64(x * x) - Float64(z * z)) * Float64(0.5 / y)); else tmp = Float64(Float64(y + Float64(x / Float64(y / x))) / 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+73) tmp = ((z + y) * ((y - z) / y)) / 2.0; elseif ((x * x) <= 2e+307) tmp = ((x * x) - (z * z)) * (0.5 / y); else tmp = (y + (x / (y / x))) / 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+73], N[(N[(N[(z + y), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+307], N[(N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision], N[(N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{\left(z + y\right) \cdot \frac{y - z}{y}}{2}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\left(x \cdot x - z \cdot z\right) \cdot \frac{0.5}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 1.99999999999999997e73Initial program 66.8%
Taylor expanded in x around 0
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6458.6%
Simplified58.6%
associate-/r*N/A
/-lowering-/.f64N/A
difference-of-squaresN/A
associate-/l*N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6490.9%
Applied egg-rr90.9%
if 1.99999999999999997e73 < (*.f64 x x) < 1.99999999999999997e307Initial program 90.6%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified99.8%
Taylor expanded in y around 0
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6487.3%
Simplified87.3%
if 1.99999999999999997e307 < (*.f64 x x) Initial program 66.8%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified66.8%
+-commutativeN/A
difference-of-squaresN/A
associate-/l*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
+-lowering-+.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6478.5%
Simplified78.5%
associate-*l/N/A
associate-/r/N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6494.2%
Applied egg-rr94.2%
Final simplification91.2%
(FPCore (x y z)
:precision binary64
(if (<= (* x x) 2e+73)
(/ (- y (* z (/ z y))) 2.0)
(if (<= (* x x) 2e+307)
(* (- (* x x) (* z z)) (/ 0.5 y))
(/ (+ y (/ x (/ y x))) 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+73) {
tmp = (y - (z * (z / y))) / 2.0;
} else if ((x * x) <= 2e+307) {
tmp = ((x * x) - (z * z)) * (0.5 / y);
} else {
tmp = (y + (x / (y / x))) / 2.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) :: tmp
if ((x * x) <= 2d+73) then
tmp = (y - (z * (z / y))) / 2.0d0
else if ((x * x) <= 2d+307) then
tmp = ((x * x) - (z * z)) * (0.5d0 / y)
else
tmp = (y + (x / (y / x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+73) {
tmp = (y - (z * (z / y))) / 2.0;
} else if ((x * x) <= 2e+307) {
tmp = ((x * x) - (z * z)) * (0.5 / y);
} else {
tmp = (y + (x / (y / x))) / 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+73: tmp = (y - (z * (z / y))) / 2.0 elif (x * x) <= 2e+307: tmp = ((x * x) - (z * z)) * (0.5 / y) else: tmp = (y + (x / (y / x))) / 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+73) tmp = Float64(Float64(y - Float64(z * Float64(z / y))) / 2.0); elseif (Float64(x * x) <= 2e+307) tmp = Float64(Float64(Float64(x * x) - Float64(z * z)) * Float64(0.5 / y)); else tmp = Float64(Float64(y + Float64(x / Float64(y / x))) / 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+73) tmp = (y - (z * (z / y))) / 2.0; elseif ((x * x) <= 2e+307) tmp = ((x * x) - (z * z)) * (0.5 / y); else tmp = (y + (x / (y / x))) / 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+73], N[(N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+307], N[(N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision], N[(N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{y - z \cdot \frac{z}{y}}{2}\\
\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\left(x \cdot x - z \cdot z\right) \cdot \frac{0.5}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 1.99999999999999997e73Initial program 66.8%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified88.2%
Taylor expanded in x around 0
--lowering--.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6480.1%
Simplified80.1%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6490.9%
Applied egg-rr90.9%
if 1.99999999999999997e73 < (*.f64 x x) < 1.99999999999999997e307Initial program 90.6%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified99.8%
Taylor expanded in y around 0
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6487.3%
Simplified87.3%
if 1.99999999999999997e307 < (*.f64 x x) Initial program 66.8%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified66.8%
+-commutativeN/A
difference-of-squaresN/A
associate-/l*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
+-lowering-+.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6478.5%
Simplified78.5%
associate-*l/N/A
associate-/r/N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6494.2%
Applied egg-rr94.2%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+73) (/ (* (+ z y) (/ (- y z) y)) 2.0) (/ (* (- x z) (/ (+ x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+73) {
tmp = ((z + y) * ((y - z) / y)) / 2.0;
} else {
tmp = ((x - z) * ((x + z) / y)) / 2.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) :: tmp
if ((x * x) <= 2d+73) then
tmp = ((z + y) * ((y - z) / y)) / 2.0d0
else
tmp = ((x - z) * ((x + z) / y)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+73) {
tmp = ((z + y) * ((y - z) / y)) / 2.0;
} else {
tmp = ((x - z) * ((x + z) / y)) / 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+73: tmp = ((z + y) * ((y - z) / y)) / 2.0 else: tmp = ((x - z) * ((x + z) / y)) / 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+73) tmp = Float64(Float64(Float64(z + y) * Float64(Float64(y - z) / y)) / 2.0); else tmp = Float64(Float64(Float64(x - z) * Float64(Float64(x + z) / y)) / 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+73) tmp = ((z + y) * ((y - z) / y)) / 2.0; else tmp = ((x - z) * ((x + z) / y)) / 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+73], N[(N[(N[(z + y), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{\left(z + y\right) \cdot \frac{y - z}{y}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - z\right) \cdot \frac{x + z}{y}}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 1.99999999999999997e73Initial program 66.8%
Taylor expanded in x around 0
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6458.6%
Simplified58.6%
associate-/r*N/A
/-lowering-/.f64N/A
difference-of-squaresN/A
associate-/l*N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6490.9%
Applied egg-rr90.9%
if 1.99999999999999997e73 < (*.f64 x x) Initial program 75.5%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified78.8%
+-commutativeN/A
difference-of-squaresN/A
associate-/l*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
Taylor expanded in y around 0
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6494.0%
Simplified94.0%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+153) (/ (- y (* z (/ z y))) 2.0) (/ (+ y (/ x (/ y x))) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+153) {
tmp = (y - (z * (z / y))) / 2.0;
} else {
tmp = (y + (x / (y / x))) / 2.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) :: tmp
if ((x * x) <= 1d+153) then
tmp = (y - (z * (z / y))) / 2.0d0
else
tmp = (y + (x / (y / x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+153) {
tmp = (y - (z * (z / y))) / 2.0;
} else {
tmp = (y + (x / (y / x))) / 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e+153: tmp = (y - (z * (z / y))) / 2.0 else: tmp = (y + (x / (y / x))) / 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+153) tmp = Float64(Float64(y - Float64(z * Float64(z / y))) / 2.0); else tmp = Float64(Float64(y + Float64(x / Float64(y / x))) / 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+153) tmp = (y - (z * (z / y))) / 2.0; else tmp = (y + (x / (y / x))) / 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+153], N[(N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+153}:\\
\;\;\;\;\frac{y - z \cdot \frac{z}{y}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 1e153Initial program 69.2%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified89.3%
Taylor expanded in x around 0
--lowering--.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6478.3%
Simplified78.3%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6488.1%
Applied egg-rr88.1%
if 1e153 < (*.f64 x x) Initial program 72.7%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified75.5%
+-commutativeN/A
difference-of-squaresN/A
associate-/l*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
+-lowering-+.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6477.8%
Simplified77.8%
associate-*l/N/A
associate-/r/N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6489.4%
Applied egg-rr89.4%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (<= z 1.75e+113) (/ (+ y (/ x (/ y x))) 2.0) (* (/ z (/ y z)) -0.5)))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.75e+113) {
tmp = (y + (x / (y / x))) / 2.0;
} 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 <= 1.75d+113) then
tmp = (y + (x / (y / x))) / 2.0d0
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 <= 1.75e+113) {
tmp = (y + (x / (y / x))) / 2.0;
} else {
tmp = (z / (y / z)) * -0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.75e+113: tmp = (y + (x / (y / x))) / 2.0 else: tmp = (z / (y / z)) * -0.5 return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.75e+113) tmp = Float64(Float64(y + Float64(x / Float64(y / x))) / 2.0); 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 <= 1.75e+113) tmp = (y + (x / (y / x))) / 2.0; else tmp = (z / (y / z)) * -0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.75e+113], N[(N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.75 \cdot 10^{+113}:\\
\;\;\;\;\frac{y + \frac{x}{\frac{y}{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\
\end{array}
\end{array}
if z < 1.75e113Initial program 73.0%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified87.4%
+-commutativeN/A
difference-of-squaresN/A
associate-/l*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
+-lowering-+.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6469.1%
Simplified69.1%
associate-*l/N/A
associate-/r/N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6473.9%
Applied egg-rr73.9%
if 1.75e113 < z Initial program 50.6%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified58.0%
Taylor expanded in z around inf
*-commutativeN/A
unpow2N/A
associate-/l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6463.4%
Simplified63.4%
associate-*r*N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6463.5%
Applied egg-rr63.5%
Final simplification72.8%
(FPCore (x y z) :precision binary64 (if (<= z 2.55e+113) (/ (+ y (/ (* x x) y)) 2.0) (* (/ z (/ y z)) -0.5)))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.55e+113) {
tmp = (y + ((x * x) / y)) / 2.0;
} 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 <= 2.55d+113) then
tmp = (y + ((x * x) / y)) / 2.0d0
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 <= 2.55e+113) {
tmp = (y + ((x * x) / y)) / 2.0;
} else {
tmp = (z / (y / z)) * -0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.55e+113: tmp = (y + ((x * x) / y)) / 2.0 else: tmp = (z / (y / z)) * -0.5 return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.55e+113) tmp = Float64(Float64(y + Float64(Float64(x * x) / y)) / 2.0); 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 <= 2.55e+113) tmp = (y + ((x * x) / y)) / 2.0; else tmp = (z / (y / z)) * -0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.55e+113], N[(N[(y + N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.55 \cdot 10^{+113}:\\
\;\;\;\;\frac{y + \frac{x \cdot x}{y}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\
\end{array}
\end{array}
if z < 2.54999999999999997e113Initial program 73.0%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified87.4%
Taylor expanded in z around 0
+-lowering-+.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6469.1%
Simplified69.1%
if 2.54999999999999997e113 < z Initial program 50.6%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified58.0%
Taylor expanded in z around inf
*-commutativeN/A
unpow2N/A
associate-/l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6463.4%
Simplified63.4%
associate-*r*N/A
*-lowering-*.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6463.5%
Applied egg-rr63.5%
(FPCore (x y z) :precision binary64 (/ (+ y (* (+ x z) (/ (- x z) y))) 2.0))
double code(double x, double y, double z) {
return (y + ((x + z) * ((x - 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 = (y + ((x + z) * ((x - z) / y))) / 2.0d0
end function
public static double code(double x, double y, double z) {
return (y + ((x + z) * ((x - z) / y))) / 2.0;
}
def code(x, y, z): return (y + ((x + z) * ((x - z) / y))) / 2.0
function code(x, y, z) return Float64(Float64(y + Float64(Float64(x + z) * Float64(Float64(x - z) / y))) / 2.0) end
function tmp = code(x, y, z) tmp = (y + ((x + z) * ((x - z) / y))) / 2.0; end
code[x_, y_, z_] := N[(N[(y + N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{y + \left(x + z\right) \cdot \frac{x - z}{y}}{2}
\end{array}
Initial program 70.5%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified84.2%
difference-of-squaresN/A
associate-/l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
(FPCore (x y z) :precision binary64 (if (<= x 9.5e+37) (/ y 2.0) (/ (/ x (/ y x)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (x <= 9.5e+37) {
tmp = y / 2.0;
} else {
tmp = (x / (y / x)) / 2.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) :: tmp
if (x <= 9.5d+37) then
tmp = y / 2.0d0
else
tmp = (x / (y / x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 9.5e+37) {
tmp = y / 2.0;
} else {
tmp = (x / (y / x)) / 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 9.5e+37: tmp = y / 2.0 else: tmp = (x / (y / x)) / 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= 9.5e+37) tmp = Float64(y / 2.0); else tmp = Float64(Float64(x / Float64(y / x)) / 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 9.5e+37) tmp = y / 2.0; else tmp = (x / (y / x)) / 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 9.5e+37], N[(y / 2.0), $MachinePrecision], N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.5 \cdot 10^{+37}:\\
\;\;\;\;\frac{y}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{x}}}{2}\\
\end{array}
\end{array}
if x < 9.4999999999999995e37Initial program 68.4%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified85.0%
Taylor expanded in y around inf
Simplified38.8%
if 9.4999999999999995e37 < x Initial program 79.1%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified80.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6465.0%
Simplified65.0%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6471.4%
Applied egg-rr71.4%
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6471.4%
Applied egg-rr71.4%
(FPCore (x y z) :precision binary64 (if (<= x 1.4e+38) (/ y 2.0) (/ x (/ 2.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.4e+38) {
tmp = y / 2.0;
} else {
tmp = x / (2.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 (x <= 1.4d+38) then
tmp = y / 2.0d0
else
tmp = x / (2.0d0 / (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.4e+38) {
tmp = y / 2.0;
} else {
tmp = x / (2.0 / (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.4e+38: tmp = y / 2.0 else: tmp = x / (2.0 / (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.4e+38) tmp = Float64(y / 2.0); else tmp = Float64(x / Float64(2.0 / Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.4e+38) tmp = y / 2.0; else tmp = x / (2.0 / (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.4e+38], N[(y / 2.0), $MachinePrecision], N[(x / N[(2.0 / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4 \cdot 10^{+38}:\\
\;\;\;\;\frac{y}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{2}{\frac{x}{y}}}\\
\end{array}
\end{array}
if x < 1.4e38Initial program 68.4%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified85.0%
Taylor expanded in y around inf
Simplified38.8%
if 1.4e38 < x Initial program 79.1%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified80.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6465.0%
Simplified65.0%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6471.4%
Applied egg-rr71.4%
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6471.4%
Applied egg-rr71.4%
associate-/l/N/A
/-lowering-/.f64N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6471.4%
Applied egg-rr71.4%
(FPCore (x y z) :precision binary64 (if (<= x 8.8e+39) (/ y 2.0) (* (* x x) (/ 0.5 y))))
double code(double x, double y, double z) {
double tmp;
if (x <= 8.8e+39) {
tmp = y / 2.0;
} else {
tmp = (x * x) * (0.5 / 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 <= 8.8d+39) then
tmp = y / 2.0d0
else
tmp = (x * x) * (0.5d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 8.8e+39) {
tmp = y / 2.0;
} else {
tmp = (x * x) * (0.5 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 8.8e+39: tmp = y / 2.0 else: tmp = (x * x) * (0.5 / y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 8.8e+39) tmp = Float64(y / 2.0); else tmp = Float64(Float64(x * x) * Float64(0.5 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 8.8e+39) tmp = y / 2.0; else tmp = (x * x) * (0.5 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 8.8e+39], N[(y / 2.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.8 \cdot 10^{+39}:\\
\;\;\;\;\frac{y}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\
\end{array}
\end{array}
if x < 8.8000000000000006e39Initial program 68.4%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified85.0%
Taylor expanded in y around inf
Simplified38.8%
if 8.8000000000000006e39 < x Initial program 79.1%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified80.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6465.0%
Simplified65.0%
associate-/r*N/A
div-invN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-eval65.0%
Applied egg-rr65.0%
(FPCore (x y z) :precision binary64 (if (<= z 1.1e+82) (/ y 2.0) (* z (* (/ z y) -0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.1e+82) {
tmp = y / 2.0;
} 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 <= 1.1d+82) then
tmp = y / 2.0d0
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 <= 1.1e+82) {
tmp = y / 2.0;
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.1e+82: tmp = y / 2.0 else: tmp = z * ((z / y) * -0.5) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.1e+82) tmp = Float64(y / 2.0); 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 <= 1.1e+82) tmp = y / 2.0; else tmp = z * ((z / y) * -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.1e+82], N[(y / 2.0), $MachinePrecision], N[(z * N[(N[(z / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.1 \cdot 10^{+82}:\\
\;\;\;\;\frac{y}{2}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\
\end{array}
\end{array}
if z < 1.1000000000000001e82Initial program 72.5%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified87.0%
Taylor expanded in y around inf
Simplified34.7%
if 1.1000000000000001e82 < z Initial program 57.9%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified66.4%
Taylor expanded in z around inf
*-commutativeN/A
unpow2N/A
associate-/l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f6456.4%
Simplified56.4%
(FPCore (x y z) :precision binary64 (/ y 2.0))
double code(double x, double y, double z) {
return 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 = y / 2.0d0
end function
public static double code(double x, double y, double z) {
return y / 2.0;
}
def code(x, y, z): return y / 2.0
function code(x, y, z) return Float64(y / 2.0) end
function tmp = code(x, y, z) tmp = y / 2.0; end
code[x_, y_, z_] := N[(y / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{2}
\end{array}
Initial program 70.5%
associate-/r*N/A
/-lowering-/.f64N/A
Simplified84.2%
Taylor expanded in y around inf
Simplified32.4%
(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 2024138
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))