
(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(x + z) / Float64(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[(x + z), $MachinePrecision] / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \frac{x + z}{\frac{y}{x - z}}\right)
\end{array}
Initial program 69.8%
remove-double-neg69.8%
distribute-lft-neg-out69.8%
distribute-frac-neg269.8%
distribute-frac-neg69.8%
neg-mul-169.8%
distribute-lft-neg-out69.8%
*-commutative69.8%
distribute-lft-neg-in69.8%
times-frac69.8%
metadata-eval69.8%
metadata-eval69.8%
associate--l+69.8%
fma-define72.1%
Simplified72.1%
Taylor expanded in x around 0 81.2%
associate--l+81.2%
div-sub86.3%
Simplified86.3%
pow286.3%
unpow286.3%
difference-of-squares90.7%
Applied egg-rr90.7%
div-inv90.6%
*-commutative90.6%
associate-*l*99.9%
Applied egg-rr99.9%
*-commutative99.9%
associate-*l*99.9%
associate-/r/99.8%
un-div-inv99.9%
Applied egg-rr99.9%
(FPCore (x y z)
:precision binary64
(if (<= z 8.2e-140)
(* 0.5 y)
(if (<= z 5.8e-35)
(* x (* x (/ 0.5 y)))
(if (<= z 2.9e-19) (* 0.5 y) (* 0.5 (/ (* z (- x z)) y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 8.2e-140) {
tmp = 0.5 * y;
} else if (z <= 5.8e-35) {
tmp = x * (x * (0.5 / y));
} else if (z <= 2.9e-19) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * ((z * (x - z)) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 8.2d-140) then
tmp = 0.5d0 * y
else if (z <= 5.8d-35) then
tmp = x * (x * (0.5d0 / y))
else if (z <= 2.9d-19) then
tmp = 0.5d0 * y
else
tmp = 0.5d0 * ((z * (x - z)) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 8.2e-140) {
tmp = 0.5 * y;
} else if (z <= 5.8e-35) {
tmp = x * (x * (0.5 / y));
} else if (z <= 2.9e-19) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * ((z * (x - z)) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 8.2e-140: tmp = 0.5 * y elif z <= 5.8e-35: tmp = x * (x * (0.5 / y)) elif z <= 2.9e-19: tmp = 0.5 * y else: tmp = 0.5 * ((z * (x - z)) / y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 8.2e-140) tmp = Float64(0.5 * y); elseif (z <= 5.8e-35) tmp = Float64(x * Float64(x * Float64(0.5 / y))); elseif (z <= 2.9e-19) tmp = Float64(0.5 * y); else tmp = Float64(0.5 * Float64(Float64(z * Float64(x - z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 8.2e-140) tmp = 0.5 * y; elseif (z <= 5.8e-35) tmp = x * (x * (0.5 / y)); elseif (z <= 2.9e-19) tmp = 0.5 * y; else tmp = 0.5 * ((z * (x - z)) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 8.2e-140], N[(0.5 * y), $MachinePrecision], If[LessEqual[z, 5.8e-35], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.9e-19], N[(0.5 * y), $MachinePrecision], N[(0.5 * N[(N[(z * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.2 \cdot 10^{-140}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-19}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{z \cdot \left(x - z\right)}{y}\\
\end{array}
\end{array}
if z < 8.2000000000000003e-140 or 5.8000000000000004e-35 < z < 2.9e-19Initial program 69.4%
remove-double-neg69.4%
distribute-lft-neg-out69.4%
distribute-frac-neg269.4%
distribute-frac-neg69.4%
neg-mul-169.4%
distribute-lft-neg-out69.4%
*-commutative69.4%
distribute-lft-neg-in69.4%
times-frac69.4%
metadata-eval69.4%
metadata-eval69.4%
associate--l+69.4%
fma-define70.5%
Simplified70.5%
Taylor expanded in y around inf 39.7%
if 8.2000000000000003e-140 < z < 5.8000000000000004e-35Initial program 92.7%
remove-double-neg92.7%
distribute-lft-neg-out92.7%
distribute-frac-neg292.7%
distribute-frac-neg92.7%
neg-mul-192.7%
distribute-lft-neg-out92.7%
*-commutative92.7%
distribute-lft-neg-in92.7%
times-frac92.7%
metadata-eval92.7%
metadata-eval92.7%
associate--l+92.7%
fma-define92.7%
Simplified92.7%
Taylor expanded in x around inf 77.6%
*-commutative77.6%
associate-*l/77.6%
associate-*r/77.4%
Simplified77.4%
add-sqr-sqrt23.5%
pow223.5%
sqrt-prod23.4%
sqrt-pow123.4%
metadata-eval23.4%
pow123.4%
Applied egg-rr23.4%
unpow223.4%
swap-sqr23.4%
add-sqr-sqrt77.4%
associate-*l*77.6%
*-commutative77.6%
Applied egg-rr77.6%
if 2.9e-19 < z 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-define72.3%
Simplified72.3%
Taylor expanded in x around 0 74.8%
associate--l+74.8%
div-sub80.9%
Simplified80.9%
pow280.9%
unpow280.9%
difference-of-squares87.1%
Applied egg-rr87.1%
Taylor expanded in y around 0 72.2%
Taylor expanded in x around 0 66.1%
Final simplification48.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.96e-25) (* 0.5 (* (- x z) (/ (+ x z) y))) (* 0.5 (+ y (* (- x z) (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.96e-25) {
tmp = 0.5 * ((x - z) * ((x + z) / y));
} else {
tmp = 0.5 * (y + ((x - z) * (z / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.96d-25) then
tmp = 0.5d0 * ((x - z) * ((x + z) / y))
else
tmp = 0.5d0 * (y + ((x - z) * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.96e-25) {
tmp = 0.5 * ((x - z) * ((x + z) / y));
} else {
tmp = 0.5 * (y + ((x - z) * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.96e-25: tmp = 0.5 * ((x - z) * ((x + z) / y)) else: tmp = 0.5 * (y + ((x - z) * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.96e-25) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(Float64(x + z) / y))); else tmp = Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.96e-25) tmp = 0.5 * ((x - z) * ((x + z) / y)); else tmp = 0.5 * (y + ((x - z) * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.96e-25], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.96 \cdot 10^{-25}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x + z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if y < 1.96e-25Initial 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-define79.0%
Simplified79.0%
Taylor expanded in x around 0 80.5%
associate--l+80.5%
div-sub87.8%
Simplified87.8%
pow287.8%
unpow287.8%
difference-of-squares91.8%
Applied egg-rr91.8%
Taylor expanded in y around 0 69.2%
*-commutative69.2%
associate-*r/74.1%
+-commutative74.1%
Simplified74.1%
if 1.96e-25 < y Initial program 55.4%
remove-double-neg55.4%
distribute-lft-neg-out55.4%
distribute-frac-neg255.4%
distribute-frac-neg55.4%
neg-mul-155.4%
distribute-lft-neg-out55.4%
*-commutative55.4%
distribute-lft-neg-in55.4%
times-frac55.4%
metadata-eval55.4%
metadata-eval55.4%
associate--l+55.4%
fma-define56.7%
Simplified56.7%
Taylor expanded in x around 0 82.8%
associate--l+82.8%
div-sub82.8%
Simplified82.8%
pow282.8%
unpow282.8%
difference-of-squares88.1%
Applied egg-rr88.1%
div-inv88.1%
*-commutative88.1%
associate-*l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 83.2%
Final simplification76.9%
(FPCore (x y z) :precision binary64 (if (<= y 2.05e+167) (* 0.5 (* (- x z) (/ (+ x z) y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.05e+167) {
tmp = 0.5 * ((x - z) * ((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 <= 2.05d+167) then
tmp = 0.5d0 * ((x - z) * ((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 <= 2.05e+167) {
tmp = 0.5 * ((x - z) * ((x + z) / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.05e+167: tmp = 0.5 * ((x - z) * ((x + z) / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.05e+167) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(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 <= 2.05e+167) tmp = 0.5 * ((x - z) * ((x + z) / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.05e+167], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.05 \cdot 10^{+167}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x + z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 2.05e167Initial program 77.2%
remove-double-neg77.2%
distribute-lft-neg-out77.2%
distribute-frac-neg277.2%
distribute-frac-neg77.2%
neg-mul-177.2%
distribute-lft-neg-out77.2%
*-commutative77.2%
distribute-lft-neg-in77.2%
times-frac77.2%
metadata-eval77.2%
metadata-eval77.2%
associate--l+77.2%
fma-define79.9%
Simplified79.9%
Taylor expanded in x around 0 81.9%
associate--l+81.9%
div-sub87.6%
Simplified87.6%
pow287.6%
unpow287.6%
difference-of-squares92.0%
Applied egg-rr92.0%
Taylor expanded in y around 0 66.7%
*-commutative66.7%
associate-*r/72.1%
+-commutative72.1%
Simplified72.1%
if 2.05e167 < y Initial program 9.2%
remove-double-neg9.2%
distribute-lft-neg-out9.2%
distribute-frac-neg29.2%
distribute-frac-neg9.2%
neg-mul-19.2%
distribute-lft-neg-out9.2%
*-commutative9.2%
distribute-lft-neg-in9.2%
times-frac9.2%
metadata-eval9.2%
metadata-eval9.2%
associate--l+9.2%
fma-define9.2%
Simplified9.2%
Taylor expanded in y around inf 79.3%
Final simplification72.9%
(FPCore (x y z) :precision binary64 (if (<= y 6e-5) (* 0.5 (/ (* x (- x z)) y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6e-5) {
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 <= 6d-5) 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 <= 6e-5) {
tmp = 0.5 * ((x * (x - z)) / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6e-5: tmp = 0.5 * ((x * (x - z)) / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6e-5) 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 <= 6e-5) tmp = 0.5 * ((x * (x - z)) / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6e-5], 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 6 \cdot 10^{-5}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot \left(x - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 6.00000000000000015e-5Initial program 76.6%
remove-double-neg76.6%
distribute-lft-neg-out76.6%
distribute-frac-neg276.6%
distribute-frac-neg76.6%
neg-mul-176.6%
distribute-lft-neg-out76.6%
*-commutative76.6%
distribute-lft-neg-in76.6%
times-frac76.6%
metadata-eval76.6%
metadata-eval76.6%
associate--l+76.6%
fma-define79.4%
Simplified79.4%
Taylor expanded in x around 0 80.8%
associate--l+80.8%
div-sub88.0%
Simplified88.0%
pow288.0%
unpow288.0%
difference-of-squares92.0%
Applied egg-rr92.0%
Taylor expanded in y around 0 68.7%
Taylor expanded in x around inf 36.0%
if 6.00000000000000015e-5 < y Initial program 53.6%
remove-double-neg53.6%
distribute-lft-neg-out53.6%
distribute-frac-neg253.6%
distribute-frac-neg53.6%
neg-mul-153.6%
distribute-lft-neg-out53.6%
*-commutative53.6%
distribute-lft-neg-in53.6%
times-frac53.6%
metadata-eval53.6%
metadata-eval53.6%
associate--l+53.6%
fma-define55.0%
Simplified55.0%
Taylor expanded in y around inf 51.0%
(FPCore (x y z) :precision binary64 (* 0.5 (+ y (* (+ x z) (/ (- x z) y)))))
double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) * ((x - z) / 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 + ((x + z) * ((x - z) / y)))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) * ((x - z) / y)));
}
def code(x, y, z): return 0.5 * (y + ((x + z) * ((x - z) / y)))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(x + z) * Float64(Float64(x - z) / y)))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + ((x + z) * ((x - z) / y))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \left(x + z\right) \cdot \frac{x - z}{y}\right)
\end{array}
Initial program 69.8%
remove-double-neg69.8%
distribute-lft-neg-out69.8%
distribute-frac-neg269.8%
distribute-frac-neg69.8%
neg-mul-169.8%
distribute-lft-neg-out69.8%
*-commutative69.8%
distribute-lft-neg-in69.8%
times-frac69.8%
metadata-eval69.8%
metadata-eval69.8%
associate--l+69.8%
fma-define72.1%
Simplified72.1%
Taylor expanded in x around 0 81.2%
associate--l+81.2%
div-sub86.3%
Simplified86.3%
pow286.3%
unpow286.3%
difference-of-squares90.7%
Applied egg-rr90.7%
associate-/l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.55e-11) (* x (/ (* 0.5 x) y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.55e-11) {
tmp = x * ((0.5 * x) / 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.55d-11) then
tmp = x * ((0.5d0 * x) / 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.55e-11) {
tmp = x * ((0.5 * x) / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.55e-11: tmp = x * ((0.5 * x) / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.55e-11) tmp = Float64(x * Float64(Float64(0.5 * x) / y)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.55e-11) tmp = x * ((0.5 * x) / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.55e-11], N[(x * N[(N[(0.5 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.55000000000000014e-11Initial program 76.6%
remove-double-neg76.6%
distribute-lft-neg-out76.6%
distribute-frac-neg276.6%
distribute-frac-neg76.6%
neg-mul-176.6%
distribute-lft-neg-out76.6%
*-commutative76.6%
distribute-lft-neg-in76.6%
times-frac76.6%
metadata-eval76.6%
metadata-eval76.6%
associate--l+76.6%
fma-define79.4%
Simplified79.4%
Taylor expanded in x around inf 28.7%
*-commutative28.7%
associate-*l/28.7%
associate-*r/28.6%
Simplified28.6%
add-sqr-sqrt10.3%
pow210.3%
sqrt-prod9.8%
sqrt-pow110.3%
metadata-eval10.3%
pow110.3%
Applied egg-rr10.3%
unpow210.3%
swap-sqr9.8%
add-sqr-sqrt28.6%
associate-*l*30.1%
*-commutative30.1%
Applied egg-rr30.1%
associate-*r/30.1%
Applied egg-rr30.1%
if 1.55000000000000014e-11 < y Initial program 53.6%
remove-double-neg53.6%
distribute-lft-neg-out53.6%
distribute-frac-neg253.6%
distribute-frac-neg53.6%
neg-mul-153.6%
distribute-lft-neg-out53.6%
*-commutative53.6%
distribute-lft-neg-in53.6%
times-frac53.6%
metadata-eval53.6%
metadata-eval53.6%
associate--l+53.6%
fma-define55.0%
Simplified55.0%
Taylor expanded in y around inf 51.0%
Final simplification36.3%
(FPCore (x y z) :precision binary64 (if (<= y 5.9e-5) (* x (* x (/ 0.5 y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.9e-5) {
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 <= 5.9d-5) 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 <= 5.9e-5) {
tmp = x * (x * (0.5 / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.9e-5: tmp = x * (x * (0.5 / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.9e-5) tmp = Float64(x * Float64(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 <= 5.9e-5) tmp = x * (x * (0.5 / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.9e-5], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.9 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 5.8999999999999998e-5Initial program 76.6%
remove-double-neg76.6%
distribute-lft-neg-out76.6%
distribute-frac-neg276.6%
distribute-frac-neg76.6%
neg-mul-176.6%
distribute-lft-neg-out76.6%
*-commutative76.6%
distribute-lft-neg-in76.6%
times-frac76.6%
metadata-eval76.6%
metadata-eval76.6%
associate--l+76.6%
fma-define79.4%
Simplified79.4%
Taylor expanded in x around inf 28.7%
*-commutative28.7%
associate-*l/28.7%
associate-*r/28.6%
Simplified28.6%
add-sqr-sqrt10.3%
pow210.3%
sqrt-prod9.8%
sqrt-pow110.3%
metadata-eval10.3%
pow110.3%
Applied egg-rr10.3%
unpow210.3%
swap-sqr9.8%
add-sqr-sqrt28.6%
associate-*l*30.1%
*-commutative30.1%
Applied egg-rr30.1%
if 5.8999999999999998e-5 < y Initial program 53.6%
remove-double-neg53.6%
distribute-lft-neg-out53.6%
distribute-frac-neg253.6%
distribute-frac-neg53.6%
neg-mul-153.6%
distribute-lft-neg-out53.6%
*-commutative53.6%
distribute-lft-neg-in53.6%
times-frac53.6%
metadata-eval53.6%
metadata-eval53.6%
associate--l+53.6%
fma-define55.0%
Simplified55.0%
Taylor expanded in y around inf 51.0%
Final simplification36.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.24e-14) (* (/ 0.5 y) (* x x)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.24e-14) {
tmp = (0.5 / y) * (x * x);
} 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.24d-14) then
tmp = (0.5d0 / y) * (x * x)
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.24e-14) {
tmp = (0.5 / y) * (x * x);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.24e-14: tmp = (0.5 / y) * (x * x) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.24e-14) tmp = Float64(Float64(0.5 / y) * Float64(x * x)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.24e-14) tmp = (0.5 / y) * (x * x); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.24e-14], N[(N[(0.5 / y), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.24 \cdot 10^{-14}:\\
\;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.24e-14Initial program 76.6%
remove-double-neg76.6%
distribute-lft-neg-out76.6%
distribute-frac-neg276.6%
distribute-frac-neg76.6%
neg-mul-176.6%
distribute-lft-neg-out76.6%
*-commutative76.6%
distribute-lft-neg-in76.6%
times-frac76.6%
metadata-eval76.6%
metadata-eval76.6%
associate--l+76.6%
fma-define79.4%
Simplified79.4%
Taylor expanded in x around inf 28.7%
*-commutative28.7%
associate-*l/28.7%
associate-*r/28.6%
Simplified28.6%
pow228.6%
Applied egg-rr28.6%
if 1.24e-14 < y Initial program 53.6%
remove-double-neg53.6%
distribute-lft-neg-out53.6%
distribute-frac-neg253.6%
distribute-frac-neg53.6%
neg-mul-153.6%
distribute-lft-neg-out53.6%
*-commutative53.6%
distribute-lft-neg-in53.6%
times-frac53.6%
metadata-eval53.6%
metadata-eval53.6%
associate--l+53.6%
fma-define55.0%
Simplified55.0%
Taylor expanded in y around inf 51.0%
Final simplification35.3%
(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.8%
remove-double-neg69.8%
distribute-lft-neg-out69.8%
distribute-frac-neg269.8%
distribute-frac-neg69.8%
neg-mul-169.8%
distribute-lft-neg-out69.8%
*-commutative69.8%
distribute-lft-neg-in69.8%
times-frac69.8%
metadata-eval69.8%
metadata-eval69.8%
associate--l+69.8%
fma-define72.1%
Simplified72.1%
Taylor expanded in y around inf 34.8%
(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 2024123
(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)))