
(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 (* 0.5 (+ y (* (/ (- x z) y) (+ x z)))))
double code(double x, double y, double z) {
return 0.5 * (y + (((x - z) / y) * (x + z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * (y + (((x - z) / y) * (x + z)))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + (((x - z) / y) * (x + z)));
}
def code(x, y, z): return 0.5 * (y + (((x - z) / y) * (x + z)))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(Float64(x - z) / y) * Float64(x + z)))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + (((x - z) / y) * (x + z))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision] * N[(x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \frac{x - z}{y} \cdot \left(x + z\right)\right)
\end{array}
Initial program 69.9%
remove-double-neg69.9%
distribute-lft-neg-out69.9%
distribute-frac-neg269.9%
distribute-frac-neg69.9%
neg-mul-169.9%
distribute-lft-neg-out69.9%
*-commutative69.9%
distribute-lft-neg-in69.9%
times-frac69.9%
metadata-eval69.9%
metadata-eval69.9%
associate--l+69.9%
fma-define70.3%
Simplified70.3%
Taylor expanded in x around 0 81.6%
associate--l+81.6%
div-sub84.7%
Simplified84.7%
clear-num84.7%
inv-pow84.7%
Applied egg-rr84.7%
unpow-184.7%
Simplified84.7%
pow284.7%
clear-num84.7%
unpow284.7%
difference-of-squares87.1%
associate-/l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.46e-161) (* 0.5 (* z (/ (- x z) y))) (if (<= y 1.16e+45) (* 0.5 (/ (* x (- x z)) y)) (* 0.5 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.46e-161) {
tmp = 0.5 * (z * ((x - z) / y));
} else if (y <= 1.16e+45) {
tmp = 0.5 * ((x * (x - z)) / y);
} else {
tmp = 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 (y <= 1.46d-161) then
tmp = 0.5d0 * (z * ((x - z) / y))
else if (y <= 1.16d+45) then
tmp = 0.5d0 * ((x * (x - z)) / y)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.46e-161) {
tmp = 0.5 * (z * ((x - z) / y));
} else if (y <= 1.16e+45) {
tmp = 0.5 * ((x * (x - z)) / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.46e-161: tmp = 0.5 * (z * ((x - z) / y)) elif y <= 1.16e+45: tmp = 0.5 * ((x * (x - z)) / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.46e-161) tmp = Float64(0.5 * Float64(z * Float64(Float64(x - z) / y))); elseif (y <= 1.16e+45) tmp = Float64(0.5 * Float64(Float64(x * Float64(x - z)) / y)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.46e-161) tmp = 0.5 * (z * ((x - z) / y)); elseif (y <= 1.16e+45) tmp = 0.5 * ((x * (x - z)) / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.46e-161], N[(0.5 * N[(z * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.16e+45], N[(0.5 * N[(N[(x * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.46 \cdot 10^{-161}:\\
\;\;\;\;0.5 \cdot \left(z \cdot \frac{x - z}{y}\right)\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{+45}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot \left(x - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.46e-161Initial program 73.0%
remove-double-neg73.0%
distribute-lft-neg-out73.0%
distribute-frac-neg273.0%
distribute-frac-neg73.0%
neg-mul-173.0%
distribute-lft-neg-out73.0%
*-commutative73.0%
distribute-lft-neg-in73.0%
times-frac73.0%
metadata-eval73.0%
metadata-eval73.0%
associate--l+73.0%
fma-define73.0%
Simplified73.0%
Taylor expanded in x around 0 80.4%
associate--l+80.4%
div-sub84.8%
Simplified84.8%
pow284.8%
pow284.8%
difference-of-squares87.2%
Applied egg-rr87.2%
Taylor expanded in y around 0 60.7%
associate-*r/68.3%
+-commutative68.3%
Simplified68.3%
Taylor expanded in z around inf 46.0%
if 1.46e-161 < y < 1.1600000000000001e45Initial program 97.5%
remove-double-neg97.5%
distribute-lft-neg-out97.5%
distribute-frac-neg297.5%
distribute-frac-neg97.5%
neg-mul-197.5%
distribute-lft-neg-out97.5%
*-commutative97.5%
distribute-lft-neg-in97.5%
times-frac97.5%
metadata-eval97.5%
metadata-eval97.5%
associate--l+97.5%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around 0 95.2%
associate--l+95.2%
div-sub97.6%
Simplified97.6%
pow297.6%
pow297.6%
difference-of-squares99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 82.5%
Taylor expanded in y around 0 69.1%
if 1.1600000000000001e45 < y Initial program 36.8%
remove-double-neg36.8%
distribute-lft-neg-out36.8%
distribute-frac-neg236.8%
distribute-frac-neg36.8%
neg-mul-136.8%
distribute-lft-neg-out36.8%
*-commutative36.8%
distribute-lft-neg-in36.8%
times-frac36.8%
metadata-eval36.8%
metadata-eval36.8%
associate--l+36.8%
fma-define36.8%
Simplified36.8%
Taylor expanded in y around inf 58.8%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4000000000000.0) (* 0.5 (+ y (* (- x z) (/ z y)))) (* 0.5 (+ y (* (- x z) (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000000.0) {
tmp = 0.5 * (y + ((x - z) * (z / y)));
} else {
tmp = 0.5 * (y + ((x - z) * (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) <= 4000000000000.0d0) then
tmp = 0.5d0 * (y + ((x - z) * (z / y)))
else
tmp = 0.5d0 * (y + ((x - z) * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000000.0) {
tmp = 0.5 * (y + ((x - z) * (z / y)));
} else {
tmp = 0.5 * (y + ((x - z) * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 4000000000000.0: tmp = 0.5 * (y + ((x - z) * (z / y))) else: tmp = 0.5 * (y + ((x - z) * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 4000000000000.0) tmp = Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(z / y)))); else tmp = Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 4000000000000.0) tmp = 0.5 * (y + ((x - z) * (z / y))); else tmp = 0.5 * (y + ((x - z) * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 4000000000000.0], N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4000000000000:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4e12Initial program 71.5%
remove-double-neg71.5%
distribute-lft-neg-out71.5%
distribute-frac-neg271.5%
distribute-frac-neg71.5%
neg-mul-171.5%
distribute-lft-neg-out71.5%
*-commutative71.5%
distribute-lft-neg-in71.5%
times-frac71.5%
metadata-eval71.5%
metadata-eval71.5%
associate--l+71.5%
fma-define71.6%
Simplified71.6%
Taylor expanded in x around 0 89.0%
associate--l+89.0%
div-sub89.0%
Simplified89.0%
pow289.0%
pow289.0%
difference-of-squares89.0%
Applied egg-rr89.0%
Taylor expanded in x around 0 81.5%
div-inv81.6%
*-commutative81.6%
associate-*l*91.7%
div-inv91.7%
Applied egg-rr91.7%
if 4e12 < (*.f64 x x) Initial program 68.2%
remove-double-neg68.2%
distribute-lft-neg-out68.2%
distribute-frac-neg268.2%
distribute-frac-neg68.2%
neg-mul-168.2%
distribute-lft-neg-out68.2%
*-commutative68.2%
distribute-lft-neg-in68.2%
times-frac68.2%
metadata-eval68.2%
metadata-eval68.2%
associate--l+68.2%
fma-define69.0%
Simplified69.0%
Taylor expanded in x around 0 73.8%
associate--l+73.8%
div-sub80.2%
Simplified80.2%
pow280.2%
pow280.2%
difference-of-squares85.1%
Applied egg-rr85.1%
Taylor expanded in x around inf 77.0%
div-inv77.0%
*-commutative77.0%
associate-*l*88.1%
div-inv88.1%
Applied egg-rr88.1%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4000000000000.0) (* 0.5 (- y (/ (* z z) y))) (* 0.5 (+ y (* (- x z) (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000000.0) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = 0.5 * (y + ((x - z) * (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) <= 4000000000000.0d0) then
tmp = 0.5d0 * (y - ((z * z) / y))
else
tmp = 0.5d0 * (y + ((x - z) * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000000.0) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = 0.5 * (y + ((x - z) * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 4000000000000.0: tmp = 0.5 * (y - ((z * z) / y)) else: tmp = 0.5 * (y + ((x - z) * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 4000000000000.0) tmp = Float64(0.5 * Float64(y - Float64(Float64(z * z) / y))); else tmp = Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 4000000000000.0) tmp = 0.5 * (y - ((z * z) / y)); else tmp = 0.5 * (y + ((x - z) * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 4000000000000.0], N[(0.5 * N[(y - N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4000000000000:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z \cdot z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4e12Initial program 71.5%
remove-double-neg71.5%
distribute-lft-neg-out71.5%
distribute-frac-neg271.5%
distribute-frac-neg71.5%
neg-mul-171.5%
distribute-lft-neg-out71.5%
*-commutative71.5%
distribute-lft-neg-in71.5%
times-frac71.5%
metadata-eval71.5%
metadata-eval71.5%
associate--l+71.5%
fma-define71.6%
Simplified71.6%
Taylor expanded in x around 0 89.0%
associate--l+89.0%
div-sub89.0%
Simplified89.0%
pow289.0%
pow289.0%
difference-of-squares89.0%
Applied egg-rr89.0%
Taylor expanded in x around 0 81.5%
Taylor expanded in x around 0 81.6%
neg-mul-181.6%
Simplified81.6%
if 4e12 < (*.f64 x x) Initial program 68.2%
remove-double-neg68.2%
distribute-lft-neg-out68.2%
distribute-frac-neg268.2%
distribute-frac-neg68.2%
neg-mul-168.2%
distribute-lft-neg-out68.2%
*-commutative68.2%
distribute-lft-neg-in68.2%
times-frac68.2%
metadata-eval68.2%
metadata-eval68.2%
associate--l+68.2%
fma-define69.0%
Simplified69.0%
Taylor expanded in x around 0 73.8%
associate--l+73.8%
div-sub80.2%
Simplified80.2%
pow280.2%
pow280.2%
difference-of-squares85.1%
Applied egg-rr85.1%
Taylor expanded in x around inf 77.0%
div-inv77.0%
*-commutative77.0%
associate-*l*88.1%
div-inv88.1%
Applied egg-rr88.1%
Final simplification84.8%
(FPCore (x y z) :precision binary64 (if (<= y 3.4e-61) (* 0.5 (* z (/ (- x z) y))) (if (<= y 4.2e+45) (* (* x x) (/ 0.5 y)) (* 0.5 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.4e-61) {
tmp = 0.5 * (z * ((x - z) / y));
} else if (y <= 4.2e+45) {
tmp = (x * x) * (0.5 / y);
} else {
tmp = 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 (y <= 3.4d-61) then
tmp = 0.5d0 * (z * ((x - z) / y))
else if (y <= 4.2d+45) then
tmp = (x * x) * (0.5d0 / y)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.4e-61) {
tmp = 0.5 * (z * ((x - z) / y));
} else if (y <= 4.2e+45) {
tmp = (x * x) * (0.5 / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.4e-61: tmp = 0.5 * (z * ((x - z) / y)) elif y <= 4.2e+45: tmp = (x * x) * (0.5 / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.4e-61) tmp = Float64(0.5 * Float64(z * Float64(Float64(x - z) / y))); elseif (y <= 4.2e+45) tmp = Float64(Float64(x * x) * Float64(0.5 / y)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.4e-61) tmp = 0.5 * (z * ((x - z) / y)); elseif (y <= 4.2e+45) tmp = (x * x) * (0.5 / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.4e-61], N[(0.5 * N[(z * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.2e+45], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{-61}:\\
\;\;\;\;0.5 \cdot \left(z \cdot \frac{x - z}{y}\right)\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+45}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 3.3999999999999998e-61Initial program 76.2%
remove-double-neg76.2%
distribute-lft-neg-out76.2%
distribute-frac-neg276.2%
distribute-frac-neg76.2%
neg-mul-176.2%
distribute-lft-neg-out76.2%
*-commutative76.2%
distribute-lft-neg-in76.2%
times-frac76.2%
metadata-eval76.2%
metadata-eval76.2%
associate--l+76.2%
fma-define76.2%
Simplified76.2%
Taylor expanded in x around 0 82.2%
associate--l+82.2%
div-sub86.6%
Simplified86.6%
pow286.6%
pow286.6%
difference-of-squares88.7%
Applied egg-rr88.7%
Taylor expanded in y around 0 64.3%
associate-*r/71.0%
+-commutative71.0%
Simplified71.0%
Taylor expanded in z around inf 45.1%
if 3.3999999999999998e-61 < y < 4.1999999999999999e45Initial program 95.2%
remove-double-neg95.2%
distribute-lft-neg-out95.2%
distribute-frac-neg295.2%
distribute-frac-neg95.2%
neg-mul-195.2%
distribute-lft-neg-out95.2%
*-commutative95.2%
distribute-lft-neg-in95.2%
times-frac95.2%
metadata-eval95.2%
metadata-eval95.2%
associate--l+95.2%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around inf 58.1%
*-commutative58.1%
associate-*l/58.1%
associate-*r/57.9%
Simplified57.9%
pow257.9%
Applied egg-rr57.9%
if 4.1999999999999999e45 < y Initial program 36.8%
remove-double-neg36.8%
distribute-lft-neg-out36.8%
distribute-frac-neg236.8%
distribute-frac-neg36.8%
neg-mul-136.8%
distribute-lft-neg-out36.8%
*-commutative36.8%
distribute-lft-neg-in36.8%
times-frac36.8%
metadata-eval36.8%
metadata-eval36.8%
associate--l+36.8%
fma-define36.8%
Simplified36.8%
Taylor expanded in y around inf 58.8%
(FPCore (x y z) :precision binary64 (if (<= y 2.9e+142) (* 0.5 (* (/ (- x z) y) (+ x z))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.9e+142) {
tmp = 0.5 * (((x - z) / y) * (x + z));
} else {
tmp = 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 (y <= 2.9d+142) then
tmp = 0.5d0 * (((x - z) / y) * (x + z))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.9e+142) {
tmp = 0.5 * (((x - z) / y) * (x + z));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.9e+142: tmp = 0.5 * (((x - z) / y) * (x + z)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.9e+142) tmp = Float64(0.5 * Float64(Float64(Float64(x - z) / y) * Float64(x + z))); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.9e+142) tmp = 0.5 * (((x - z) / y) * (x + z)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.9e+142], N[(0.5 * N[(N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision] * N[(x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{+142}:\\
\;\;\;\;0.5 \cdot \left(\frac{x - z}{y} \cdot \left(x + z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 2.90000000000000013e142Initial program 78.1%
remove-double-neg78.1%
distribute-lft-neg-out78.1%
distribute-frac-neg278.1%
distribute-frac-neg78.1%
neg-mul-178.1%
distribute-lft-neg-out78.1%
*-commutative78.1%
distribute-lft-neg-in78.1%
times-frac78.1%
metadata-eval78.1%
metadata-eval78.1%
associate--l+78.1%
fma-define78.5%
Simplified78.5%
Taylor expanded in x around 0 82.9%
associate--l+82.9%
div-sub86.5%
Simplified86.5%
pow286.5%
pow286.5%
difference-of-squares89.1%
Applied egg-rr89.1%
Taylor expanded in y around 0 64.5%
associate-*r/71.7%
+-commutative71.7%
Simplified71.7%
if 2.90000000000000013e142 < y Initial program 8.6%
remove-double-neg8.6%
distribute-lft-neg-out8.6%
distribute-frac-neg28.6%
distribute-frac-neg8.6%
neg-mul-18.6%
distribute-lft-neg-out8.6%
*-commutative8.6%
distribute-lft-neg-in8.6%
times-frac8.6%
metadata-eval8.6%
metadata-eval8.6%
associate--l+8.6%
fma-define8.6%
Simplified8.6%
Taylor expanded in y around inf 74.7%
Final simplification72.0%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+239) (* 0.5 (- y (/ (* z z) y))) (* (- x z) (/ (* 0.5 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+239) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = (x - z) * ((0.5 * 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) <= 1d+239) then
tmp = 0.5d0 * (y - ((z * z) / y))
else
tmp = (x - z) * ((0.5d0 * x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+239) {
tmp = 0.5 * (y - ((z * z) / y));
} else {
tmp = (x - z) * ((0.5 * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e+239: tmp = 0.5 * (y - ((z * z) / y)) else: tmp = (x - z) * ((0.5 * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+239) tmp = Float64(0.5 * Float64(y - Float64(Float64(z * z) / y))); else tmp = Float64(Float64(x - z) * Float64(Float64(0.5 * x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+239) tmp = 0.5 * (y - ((z * z) / y)); else tmp = (x - z) * ((0.5 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+239], N[(0.5 * N[(y - N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(N[(0.5 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+239}:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z \cdot z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{0.5 \cdot x}{y}\\
\end{array}
\end{array}
if (*.f64 x x) < 9.99999999999999991e238Initial program 71.4%
remove-double-neg71.4%
distribute-lft-neg-out71.4%
distribute-frac-neg271.4%
distribute-frac-neg71.4%
neg-mul-171.4%
distribute-lft-neg-out71.4%
*-commutative71.4%
distribute-lft-neg-in71.4%
times-frac71.4%
metadata-eval71.4%
metadata-eval71.4%
associate--l+71.4%
fma-define71.4%
Simplified71.4%
Taylor expanded in x around 0 89.5%
associate--l+89.5%
div-sub90.6%
Simplified90.6%
pow290.6%
pow290.6%
difference-of-squares90.6%
Applied egg-rr90.6%
Taylor expanded in x around 0 74.7%
Taylor expanded in x around 0 74.7%
neg-mul-174.7%
Simplified74.7%
if 9.99999999999999991e238 < (*.f64 x x) Initial program 66.2%
remove-double-neg66.2%
distribute-lft-neg-out66.2%
distribute-frac-neg266.2%
distribute-frac-neg66.2%
neg-mul-166.2%
distribute-lft-neg-out66.2%
*-commutative66.2%
distribute-lft-neg-in66.2%
times-frac66.2%
metadata-eval66.2%
metadata-eval66.2%
associate--l+66.2%
fma-define67.5%
Simplified67.5%
Taylor expanded in x around 0 61.8%
associate--l+61.8%
div-sub70.0%
Simplified70.0%
pow270.0%
pow270.0%
difference-of-squares78.4%
Applied egg-rr78.4%
Taylor expanded in x around inf 74.3%
Taylor expanded in y around 0 70.4%
*-commutative70.4%
associate-*r/82.3%
*-commutative82.3%
associate-*l*82.3%
*-commutative82.3%
associate-*r/82.3%
Simplified82.3%
Final simplification76.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.06e+42) (* (* x x) (/ 0.5 y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.06e+42) {
tmp = (x * x) * (0.5 / y);
} else {
tmp = 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 (y <= 1.06d+42) then
tmp = (x * x) * (0.5d0 / y)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.06e+42) {
tmp = (x * x) * (0.5 / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.06e+42: tmp = (x * x) * (0.5 / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.06e+42) tmp = Float64(Float64(x * x) * Float64(0.5 / y)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.06e+42) tmp = (x * x) * (0.5 / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.06e+42], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.06 \cdot 10^{+42}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.0599999999999999e42Initial program 78.2%
remove-double-neg78.2%
distribute-lft-neg-out78.2%
distribute-frac-neg278.2%
distribute-frac-neg78.2%
neg-mul-178.2%
distribute-lft-neg-out78.2%
*-commutative78.2%
distribute-lft-neg-in78.2%
times-frac78.2%
metadata-eval78.2%
metadata-eval78.2%
associate--l+78.2%
fma-define78.7%
Simplified78.7%
Taylor expanded in x around inf 34.9%
*-commutative34.9%
associate-*l/34.9%
associate-*r/34.9%
Simplified34.9%
pow234.9%
Applied egg-rr34.9%
if 1.0599999999999999e42 < y Initial program 36.8%
remove-double-neg36.8%
distribute-lft-neg-out36.8%
distribute-frac-neg236.8%
distribute-frac-neg36.8%
neg-mul-136.8%
distribute-lft-neg-out36.8%
*-commutative36.8%
distribute-lft-neg-in36.8%
times-frac36.8%
metadata-eval36.8%
metadata-eval36.8%
associate--l+36.8%
fma-define36.8%
Simplified36.8%
Taylor expanded in y around inf 58.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.12e-94) (* -0.5 (* x (/ z y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.12e-94) {
tmp = -0.5 * (x * (z / y));
} else {
tmp = 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 (y <= 1.12d-94) then
tmp = (-0.5d0) * (x * (z / y))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.12e-94) {
tmp = -0.5 * (x * (z / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.12e-94: tmp = -0.5 * (x * (z / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.12e-94) tmp = Float64(-0.5 * Float64(x * Float64(z / y))); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.12e-94) tmp = -0.5 * (x * (z / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.12e-94], N[(-0.5 * N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{-94}:\\
\;\;\;\;-0.5 \cdot \left(x \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.12e-94Initial program 75.6%
remove-double-neg75.6%
distribute-lft-neg-out75.6%
distribute-frac-neg275.6%
distribute-frac-neg75.6%
neg-mul-175.6%
distribute-lft-neg-out75.6%
*-commutative75.6%
distribute-lft-neg-in75.6%
times-frac75.6%
metadata-eval75.6%
metadata-eval75.6%
associate--l+75.6%
fma-define75.6%
Simplified75.6%
Taylor expanded in x around 0 82.3%
associate--l+82.3%
div-sub86.2%
Simplified86.2%
pow286.2%
pow286.2%
difference-of-squares88.4%
Applied egg-rr88.4%
Taylor expanded in x around inf 62.2%
Taylor expanded in z around inf 12.0%
associate-/l*15.7%
Simplified15.7%
if 1.12e-94 < y Initial program 56.8%
remove-double-neg56.8%
distribute-lft-neg-out56.8%
distribute-frac-neg256.8%
distribute-frac-neg56.8%
neg-mul-156.8%
distribute-lft-neg-out56.8%
*-commutative56.8%
distribute-lft-neg-in56.8%
times-frac56.8%
metadata-eval56.8%
metadata-eval56.8%
associate--l+56.8%
fma-define58.1%
Simplified58.1%
Taylor expanded in y around inf 47.5%
(FPCore (x y z) :precision binary64 (* 0.5 y))
double code(double x, double y, double z) {
return 0.5 * y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
public static double code(double x, double y, double z) {
return 0.5 * y;
}
def code(x, y, z): return 0.5 * y
function code(x, y, z) return Float64(0.5 * y) end
function tmp = code(x, y, z) tmp = 0.5 * y; end
code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot y
\end{array}
Initial program 69.9%
remove-double-neg69.9%
distribute-lft-neg-out69.9%
distribute-frac-neg269.9%
distribute-frac-neg69.9%
neg-mul-169.9%
distribute-lft-neg-out69.9%
*-commutative69.9%
distribute-lft-neg-in69.9%
times-frac69.9%
metadata-eval69.9%
metadata-eval69.9%
associate--l+69.9%
fma-define70.3%
Simplified70.3%
Taylor expanded in y around inf 35.2%
(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 2024139
(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)))