
(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 9 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 67.4%
remove-double-neg67.4%
distribute-lft-neg-out67.4%
distribute-frac-neg267.4%
distribute-frac-neg67.4%
neg-mul-167.4%
distribute-lft-neg-out67.4%
*-commutative67.4%
distribute-lft-neg-in67.4%
times-frac67.4%
metadata-eval67.4%
metadata-eval67.4%
associate--l+67.4%
fma-define70.1%
Simplified70.1%
Taylor expanded in x around 0 78.8%
associate--l+78.8%
div-sub83.8%
Simplified83.8%
pow283.8%
pow283.8%
difference-of-squares89.1%
Applied egg-rr89.1%
associate-/l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
(FPCore (x y z) :precision binary64 (if (<= z 1e+29) (* 0.5 (+ y (* (+ x z) (/ x y)))) (* 0.5 (+ y (* z (/ (- x z) y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e+29) {
tmp = 0.5 * (y + ((x + z) * (x / y)));
} else {
tmp = 0.5 * (y + (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 <= 1d+29) then
tmp = 0.5d0 * (y + ((x + z) * (x / y)))
else
tmp = 0.5d0 * (y + (z * ((x - z) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1e+29) {
tmp = 0.5 * (y + ((x + z) * (x / y)));
} else {
tmp = 0.5 * (y + (z * ((x - z) / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1e+29: tmp = 0.5 * (y + ((x + z) * (x / y))) else: tmp = 0.5 * (y + (z * ((x - z) / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1e+29) tmp = Float64(0.5 * Float64(y + Float64(Float64(x + z) * Float64(x / y)))); else tmp = Float64(0.5 * Float64(y + Float64(z * Float64(Float64(x - z) / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1e+29) tmp = 0.5 * (y + ((x + z) * (x / y))); else tmp = 0.5 * (y + (z * ((x - z) / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1e+29], N[(0.5 * N[(y + N[(N[(x + z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(z * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+29}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x + z\right) \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot \frac{x - z}{y}\right)\\
\end{array}
\end{array}
if z < 9.99999999999999914e28Initial program 69.0%
remove-double-neg69.0%
distribute-lft-neg-out69.0%
distribute-frac-neg269.0%
distribute-frac-neg69.0%
neg-mul-169.0%
distribute-lft-neg-out69.0%
*-commutative69.0%
distribute-lft-neg-in69.0%
times-frac69.0%
metadata-eval69.0%
metadata-eval69.0%
associate--l+69.0%
fma-define71.0%
Simplified71.0%
Taylor expanded in x around 0 83.1%
associate--l+83.1%
div-sub87.0%
Simplified87.0%
pow287.0%
pow287.0%
difference-of-squares91.0%
Applied egg-rr91.0%
associate-/l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 79.3%
if 9.99999999999999914e28 < z Initial program 60.7%
remove-double-neg60.7%
distribute-lft-neg-out60.7%
distribute-frac-neg260.7%
distribute-frac-neg60.7%
neg-mul-160.7%
distribute-lft-neg-out60.7%
*-commutative60.7%
distribute-lft-neg-in60.7%
times-frac60.7%
metadata-eval60.7%
metadata-eval60.7%
associate--l+60.7%
fma-define66.7%
Simplified66.7%
Taylor expanded in x around 0 60.9%
associate--l+60.9%
div-sub70.9%
Simplified70.9%
pow270.9%
pow270.9%
difference-of-squares81.3%
Applied egg-rr81.3%
associate-/l*99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 88.5%
Final simplification81.1%
(FPCore (x y z) :precision binary64 (if (<= y 2.2e+88) (* 0.5 (* (+ x z) (/ (- x z) y))) (* 0.5 (+ y (* (+ x z) (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.2e+88) {
tmp = 0.5 * ((x + z) * ((x - 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 (y <= 2.2d+88) then
tmp = 0.5d0 * ((x + z) * ((x - 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 (y <= 2.2e+88) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else {
tmp = 0.5 * (y + ((x + z) * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.2e+88: tmp = 0.5 * ((x + z) * ((x - z) / y)) else: tmp = 0.5 * (y + ((x + z) * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.2e+88) 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(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.2e+88) tmp = 0.5 * ((x + z) * ((x - z) / y)); else tmp = 0.5 * (y + ((x + z) * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.2e+88], 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[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.2 \cdot 10^{+88}:\\
\;\;\;\;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{x}{y}\right)\\
\end{array}
\end{array}
if y < 2.20000000000000009e88Initial program 78.0%
remove-double-neg78.0%
distribute-lft-neg-out78.0%
distribute-frac-neg278.0%
distribute-frac-neg78.0%
neg-mul-178.0%
distribute-lft-neg-out78.0%
*-commutative78.0%
distribute-lft-neg-in78.0%
times-frac78.0%
metadata-eval78.0%
metadata-eval78.0%
associate--l+78.0%
fma-define81.4%
Simplified81.4%
Taylor expanded in x around 0 81.1%
associate--l+81.1%
div-sub87.4%
Simplified87.4%
pow287.4%
pow287.4%
difference-of-squares93.4%
Applied egg-rr93.4%
Taylor expanded in y around 0 70.3%
associate-*r/75.2%
+-commutative75.2%
Simplified75.2%
if 2.20000000000000009e88 < y Initial program 23.6%
remove-double-neg23.6%
distribute-lft-neg-out23.6%
distribute-frac-neg223.6%
distribute-frac-neg23.6%
neg-mul-123.6%
distribute-lft-neg-out23.6%
*-commutative23.6%
distribute-lft-neg-in23.6%
times-frac23.6%
metadata-eval23.6%
metadata-eval23.6%
associate--l+23.6%
fma-define23.6%
Simplified23.6%
Taylor expanded in x around 0 69.0%
associate--l+69.0%
div-sub69.0%
Simplified69.0%
pow269.0%
pow269.0%
difference-of-squares71.3%
Applied egg-rr71.3%
associate-/l*100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 86.7%
Final simplification77.4%
(FPCore (x y z) :precision binary64 (if (<= y 2.7e+117) (* 0.5 (* (+ x z) (/ (- x z) y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.7e+117) {
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.7d+117) 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.7e+117) {
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.7e+117: 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.7e+117) 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.7e+117) 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.7e+117], 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.7 \cdot 10^{+117}:\\
\;\;\;\;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.7000000000000002e117Initial 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-define81.4%
Simplified81.4%
Taylor expanded in x around 0 81.1%
associate--l+81.1%
div-sub87.3%
Simplified87.3%
pow287.3%
pow287.3%
difference-of-squares93.1%
Applied egg-rr93.1%
Taylor expanded in y around 0 69.6%
associate-*r/74.8%
+-commutative74.8%
Simplified74.8%
if 2.7000000000000002e117 < y Initial program 17.2%
remove-double-neg17.2%
distribute-lft-neg-out17.2%
distribute-frac-neg217.2%
distribute-frac-neg17.2%
neg-mul-117.2%
distribute-lft-neg-out17.2%
*-commutative17.2%
distribute-lft-neg-in17.2%
times-frac17.2%
metadata-eval17.2%
metadata-eval17.2%
associate--l+17.2%
fma-define17.2%
Simplified17.2%
Taylor expanded in y around inf 76.9%
Final simplification75.2%
(FPCore (x y z) :precision binary64 (if (<= y 9.5e+90) (* 0.5 (* z (/ (- x z) y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 9.5e+90) {
tmp = 0.5 * (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 <= 9.5d+90) then
tmp = 0.5d0 * (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 <= 9.5e+90) {
tmp = 0.5 * (z * ((x - z) / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 9.5e+90: tmp = 0.5 * (z * ((x - z) / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 9.5e+90) tmp = Float64(0.5 * Float64(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 <= 9.5e+90) tmp = 0.5 * (z * ((x - z) / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 9.5e+90], N[(0.5 * N[(z * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.5 \cdot 10^{+90}:\\
\;\;\;\;0.5 \cdot \left(z \cdot \frac{x - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 9.4999999999999994e90Initial program 78.0%
remove-double-neg78.0%
distribute-lft-neg-out78.0%
distribute-frac-neg278.0%
distribute-frac-neg78.0%
neg-mul-178.0%
distribute-lft-neg-out78.0%
*-commutative78.0%
distribute-lft-neg-in78.0%
times-frac78.0%
metadata-eval78.0%
metadata-eval78.0%
associate--l+78.0%
fma-define81.4%
Simplified81.4%
Taylor expanded in x around 0 81.1%
associate--l+81.1%
div-sub87.4%
Simplified87.4%
pow287.4%
pow287.4%
difference-of-squares93.4%
Applied egg-rr93.4%
Taylor expanded in y around 0 70.3%
associate-*r/75.2%
+-commutative75.2%
Simplified75.2%
Taylor expanded in z around inf 44.9%
if 9.4999999999999994e90 < y Initial program 23.6%
remove-double-neg23.6%
distribute-lft-neg-out23.6%
distribute-frac-neg223.6%
distribute-frac-neg23.6%
neg-mul-123.6%
distribute-lft-neg-out23.6%
*-commutative23.6%
distribute-lft-neg-in23.6%
times-frac23.6%
metadata-eval23.6%
metadata-eval23.6%
associate--l+23.6%
fma-define23.6%
Simplified23.6%
Taylor expanded in y around inf 73.5%
(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 67.4%
remove-double-neg67.4%
distribute-lft-neg-out67.4%
distribute-frac-neg267.4%
distribute-frac-neg67.4%
neg-mul-167.4%
distribute-lft-neg-out67.4%
*-commutative67.4%
distribute-lft-neg-in67.4%
times-frac67.4%
metadata-eval67.4%
metadata-eval67.4%
associate--l+67.4%
fma-define70.1%
Simplified70.1%
Taylor expanded in x around 0 78.8%
associate--l+78.8%
div-sub83.8%
Simplified83.8%
pow283.8%
pow283.8%
difference-of-squares89.1%
Applied egg-rr89.1%
associate-/l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 1.8e+64) (* 0.5 y) (* x (/ x (* y 2.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.8e+64) {
tmp = 0.5 * y;
} else {
tmp = x * (x / (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 <= 1.8d+64) then
tmp = 0.5d0 * y
else
tmp = x * (x / (y * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.8e+64) {
tmp = 0.5 * y;
} else {
tmp = x * (x / (y * 2.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.8e+64: tmp = 0.5 * y else: tmp = x * (x / (y * 2.0)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.8e+64) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(x / Float64(y * 2.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.8e+64) tmp = 0.5 * y; else tmp = x * (x / (y * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.8e+64], N[(0.5 * y), $MachinePrecision], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{+64}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\end{array}
\end{array}
if x < 1.80000000000000007e64Initial program 70.1%
remove-double-neg70.1%
distribute-lft-neg-out70.1%
distribute-frac-neg270.1%
distribute-frac-neg70.1%
neg-mul-170.1%
distribute-lft-neg-out70.1%
*-commutative70.1%
distribute-lft-neg-in70.1%
times-frac70.1%
metadata-eval70.1%
metadata-eval70.1%
associate--l+70.1%
fma-define73.0%
Simplified73.0%
Taylor expanded in y around inf 38.4%
if 1.80000000000000007e64 < x Initial program 55.8%
remove-double-neg55.8%
distribute-lft-neg-out55.8%
distribute-frac-neg255.8%
distribute-frac-neg55.8%
neg-mul-155.8%
distribute-lft-neg-out55.8%
*-commutative55.8%
distribute-lft-neg-in55.8%
times-frac55.8%
metadata-eval55.8%
metadata-eval55.8%
associate--l+55.8%
fma-define57.9%
Simplified57.9%
Taylor expanded in x around inf 54.5%
*-commutative54.5%
associate-*l/54.5%
associate-*r/54.4%
Simplified54.4%
associate-*r/54.5%
clear-num54.4%
*-commutative54.4%
Applied egg-rr54.4%
clear-num54.5%
associate-*l/54.4%
pow254.4%
associate-*r*69.0%
*-commutative69.0%
clear-num69.0%
un-div-inv69.1%
div-inv69.1%
metadata-eval69.1%
Applied egg-rr69.1%
Final simplification44.1%
(FPCore (x y z) :precision binary64 (if (<= y 4.8e+112) (* (* x x) (/ 0.5 y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e+112) {
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 <= 4.8d+112) 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 <= 4.8e+112) {
tmp = (x * x) * (0.5 / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.8e+112: tmp = (x * x) * (0.5 / y) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.8e+112) 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 <= 4.8e+112) tmp = (x * x) * (0.5 / y); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.8e+112], 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 4.8 \cdot 10^{+112}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 4.8e112Initial 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-define81.4%
Simplified81.4%
Taylor expanded in x around inf 36.7%
*-commutative36.7%
associate-*l/36.7%
associate-*r/36.6%
Simplified36.6%
pow236.6%
Applied egg-rr36.6%
if 4.8e112 < y Initial program 17.2%
remove-double-neg17.2%
distribute-lft-neg-out17.2%
distribute-frac-neg217.2%
distribute-frac-neg17.2%
neg-mul-117.2%
distribute-lft-neg-out17.2%
*-commutative17.2%
distribute-lft-neg-in17.2%
times-frac17.2%
metadata-eval17.2%
metadata-eval17.2%
associate--l+17.2%
fma-define17.2%
Simplified17.2%
Taylor expanded in y around inf 76.9%
(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 67.4%
remove-double-neg67.4%
distribute-lft-neg-out67.4%
distribute-frac-neg267.4%
distribute-frac-neg67.4%
neg-mul-167.4%
distribute-lft-neg-out67.4%
*-commutative67.4%
distribute-lft-neg-in67.4%
times-frac67.4%
metadata-eval67.4%
metadata-eval67.4%
associate--l+67.4%
fma-define70.1%
Simplified70.1%
Taylor expanded in y around inf 35.6%
(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 2024165
(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)))