
(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.3%
remove-double-neg69.3%
distribute-lft-neg-out69.3%
distribute-frac-neg269.3%
distribute-frac-neg69.3%
neg-mul-169.3%
distribute-lft-neg-out69.3%
*-commutative69.3%
distribute-lft-neg-in69.3%
times-frac69.3%
metadata-eval69.3%
metadata-eval69.3%
associate--l+69.3%
fma-define72.4%
Simplified72.4%
Taylor expanded in x around 0 77.6%
associate--l+77.6%
div-sub79.2%
Simplified79.2%
unpow279.2%
unpow279.2%
difference-of-squares86.7%
Applied egg-rr86.7%
*-commutative86.7%
associate-/l*99.9%
Applied egg-rr99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y 3.8e+62) (and (not (<= y 2.2e+82)) (<= y 1.75e+183))) (* 0.5 (* (+ x z) (/ (- x z) y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 3.8e+62) || (!(y <= 2.2e+82) && (y <= 1.75e+183))) {
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 <= 3.8d+62) .or. (.not. (y <= 2.2d+82)) .and. (y <= 1.75d+183)) 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 <= 3.8e+62) || (!(y <= 2.2e+82) && (y <= 1.75e+183))) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 3.8e+62) or (not (y <= 2.2e+82) and (y <= 1.75e+183)): 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 <= 3.8e+62) || (!(y <= 2.2e+82) && (y <= 1.75e+183))) 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 <= 3.8e+62) || (~((y <= 2.2e+82)) && (y <= 1.75e+183))) tmp = 0.5 * ((x + z) * ((x - z) / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 3.8e+62], And[N[Not[LessEqual[y, 2.2e+82]], $MachinePrecision], LessEqual[y, 1.75e+183]]], 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 3.8 \cdot 10^{+62} \lor \neg \left(y \leq 2.2 \cdot 10^{+82}\right) \land y \leq 1.75 \cdot 10^{+183}:\\
\;\;\;\;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 < 3.79999999999999984e62 or 2.2000000000000001e82 < y < 1.74999999999999994e183Initial program 76.4%
remove-double-neg76.4%
distribute-lft-neg-out76.4%
distribute-frac-neg276.4%
distribute-frac-neg76.4%
neg-mul-176.4%
distribute-lft-neg-out76.4%
*-commutative76.4%
distribute-lft-neg-in76.4%
times-frac76.4%
metadata-eval76.4%
metadata-eval76.4%
associate--l+76.4%
fma-define80.0%
Simplified80.0%
Taylor expanded in x around 0 81.8%
associate--l+81.8%
div-sub83.6%
Simplified83.6%
unpow283.6%
unpow283.6%
difference-of-squares91.8%
Applied egg-rr91.8%
Taylor expanded in y around 0 71.2%
associate-*r/75.9%
+-commutative75.9%
Simplified75.9%
if 3.79999999999999984e62 < y < 2.2000000000000001e82 or 1.74999999999999994e183 < y Initial program 27.3%
Taylor expanded in y around inf 75.6%
*-commutative75.6%
Simplified75.6%
Final simplification75.9%
(FPCore (x y z)
:precision binary64
(if (<= y 3.5e+62)
(* 0.5 (* (- x z) (/ (+ x z) y)))
(if (or (<= y 1.46e+82) (not (<= y 2.1e+183)))
(* 0.5 y)
(* 0.5 (* (+ x z) (/ (- x z) y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+62) {
tmp = 0.5 * ((x - z) * ((x + z) / y));
} else if ((y <= 1.46e+82) || !(y <= 2.1e+183)) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * ((x + 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 (y <= 3.5d+62) then
tmp = 0.5d0 * ((x - z) * ((x + z) / y))
else if ((y <= 1.46d+82) .or. (.not. (y <= 2.1d+183))) then
tmp = 0.5d0 * y
else
tmp = 0.5d0 * ((x + z) * ((x - z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+62) {
tmp = 0.5 * ((x - z) * ((x + z) / y));
} else if ((y <= 1.46e+82) || !(y <= 2.1e+183)) {
tmp = 0.5 * y;
} else {
tmp = 0.5 * ((x + z) * ((x - z) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.5e+62: tmp = 0.5 * ((x - z) * ((x + z) / y)) elif (y <= 1.46e+82) or not (y <= 2.1e+183): tmp = 0.5 * y else: tmp = 0.5 * ((x + z) * ((x - z) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.5e+62) tmp = Float64(0.5 * Float64(Float64(x - z) * Float64(Float64(x + z) / y))); elseif ((y <= 1.46e+82) || !(y <= 2.1e+183)) tmp = Float64(0.5 * y); else tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.5e+62) tmp = 0.5 * ((x - z) * ((x + z) / y)); elseif ((y <= 1.46e+82) || ~((y <= 2.1e+183))) tmp = 0.5 * y; else tmp = 0.5 * ((x + z) * ((x - z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.5e+62], N[(0.5 * N[(N[(x - z), $MachinePrecision] * N[(N[(x + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.46e+82], N[Not[LessEqual[y, 2.1e+183]], $MachinePrecision]], N[(0.5 * y), $MachinePrecision], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+62}:\\
\;\;\;\;0.5 \cdot \left(\left(x - z\right) \cdot \frac{x + z}{y}\right)\\
\mathbf{elif}\;y \leq 1.46 \cdot 10^{+82} \lor \neg \left(y \leq 2.1 \cdot 10^{+183}\right):\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\
\end{array}
\end{array}
if y < 3.49999999999999984e62Initial program 79.0%
remove-double-neg79.0%
distribute-lft-neg-out79.0%
distribute-frac-neg279.0%
distribute-frac-neg79.0%
neg-mul-179.0%
distribute-lft-neg-out79.0%
*-commutative79.0%
distribute-lft-neg-in79.0%
times-frac79.0%
metadata-eval79.0%
metadata-eval79.0%
associate--l+79.0%
fma-define82.6%
Simplified82.6%
Taylor expanded in x around 0 83.0%
associate--l+83.0%
div-sub85.1%
Simplified85.1%
unpow285.1%
unpow285.1%
difference-of-squares93.2%
Applied egg-rr93.2%
Taylor expanded in y around 0 74.6%
*-commutative93.2%
associate-/l*99.9%
Applied egg-rr77.5%
if 3.49999999999999984e62 < y < 1.4599999999999999e82 or 2.1e183 < y Initial program 27.3%
Taylor expanded in y around inf 75.6%
*-commutative75.6%
Simplified75.6%
if 1.4599999999999999e82 < y < 2.1e183Initial program 54.1%
remove-double-neg54.1%
distribute-lft-neg-out54.1%
distribute-frac-neg254.1%
distribute-frac-neg54.1%
neg-mul-154.1%
distribute-lft-neg-out54.1%
*-commutative54.1%
distribute-lft-neg-in54.1%
times-frac54.1%
metadata-eval54.1%
metadata-eval54.1%
associate--l+54.1%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around 0 71.1%
associate--l+71.1%
div-sub71.1%
Simplified71.1%
unpow271.1%
unpow271.1%
difference-of-squares79.8%
Applied egg-rr79.8%
Taylor expanded in y around 0 42.3%
associate-*r/62.3%
+-commutative62.3%
Simplified62.3%
Final simplification75.8%
(FPCore (x y z) :precision binary64 (if (or (<= x 0.0045) (and (not (<= x 7.8e+77)) (<= x 1.75e+110))) (* 0.5 y) (* x (* x (/ 0.5 y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= 0.0045) || (!(x <= 7.8e+77) && (x <= 1.75e+110))) {
tmp = 0.5 * y;
} 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 <= 0.0045d0) .or. (.not. (x <= 7.8d+77)) .and. (x <= 1.75d+110)) then
tmp = 0.5d0 * y
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 <= 0.0045) || (!(x <= 7.8e+77) && (x <= 1.75e+110))) {
tmp = 0.5 * y;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= 0.0045) or (not (x <= 7.8e+77) and (x <= 1.75e+110)): tmp = 0.5 * y else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= 0.0045) || (!(x <= 7.8e+77) && (x <= 1.75e+110))) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= 0.0045) || (~((x <= 7.8e+77)) && (x <= 1.75e+110))) tmp = 0.5 * y; else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, 0.0045], And[N[Not[LessEqual[x, 7.8e+77]], $MachinePrecision], LessEqual[x, 1.75e+110]]], N[(0.5 * y), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0045 \lor \neg \left(x \leq 7.8 \cdot 10^{+77}\right) \land x \leq 1.75 \cdot 10^{+110}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 0.00449999999999999966 or 7.7999999999999995e77 < x < 1.75e110Initial program 69.3%
Taylor expanded in y around inf 38.8%
*-commutative38.8%
Simplified38.8%
if 0.00449999999999999966 < x < 7.7999999999999995e77 or 1.75e110 < x Initial program 69.2%
Taylor expanded in x around inf 63.9%
*-commutative63.9%
associate-*l/63.9%
associate-*r/63.9%
Simplified63.9%
add-sqr-sqrt35.6%
pow235.6%
sqrt-prod35.6%
sqrt-pow138.8%
metadata-eval38.8%
pow138.8%
Applied egg-rr38.8%
unpow238.8%
swap-sqr35.6%
add-sqr-sqrt63.9%
associate-*l*67.1%
Applied egg-rr67.1%
Final simplification45.1%
(FPCore (x y z)
:precision binary64
(if (<= x 8.6e-5)
(* 0.5 y)
(if (<= x 2.1e+77)
(* x (/ (* 0.5 x) y))
(if (<= x 1.35e+110) (* 0.5 y) (* x (* x (/ 0.5 y)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 8.6e-5) {
tmp = 0.5 * y;
} else if (x <= 2.1e+77) {
tmp = x * ((0.5 * x) / y);
} else if (x <= 1.35e+110) {
tmp = 0.5 * y;
} 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.6d-5) then
tmp = 0.5d0 * y
else if (x <= 2.1d+77) then
tmp = x * ((0.5d0 * x) / y)
else if (x <= 1.35d+110) then
tmp = 0.5d0 * y
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.6e-5) {
tmp = 0.5 * y;
} else if (x <= 2.1e+77) {
tmp = x * ((0.5 * x) / y);
} else if (x <= 1.35e+110) {
tmp = 0.5 * y;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 8.6e-5: tmp = 0.5 * y elif x <= 2.1e+77: tmp = x * ((0.5 * x) / y) elif x <= 1.35e+110: tmp = 0.5 * y else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 8.6e-5) tmp = Float64(0.5 * y); elseif (x <= 2.1e+77) tmp = Float64(x * Float64(Float64(0.5 * x) / y)); elseif (x <= 1.35e+110) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 8.6e-5) tmp = 0.5 * y; elseif (x <= 2.1e+77) tmp = x * ((0.5 * x) / y); elseif (x <= 1.35e+110) tmp = 0.5 * y; else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 8.6e-5], N[(0.5 * y), $MachinePrecision], If[LessEqual[x, 2.1e+77], N[(x * N[(N[(0.5 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+110], N[(0.5 * y), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.6 \cdot 10^{-5}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+77}:\\
\;\;\;\;x \cdot \frac{0.5 \cdot x}{y}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+110}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 8.6000000000000003e-5 or 2.0999999999999999e77 < x < 1.35000000000000005e110Initial program 69.3%
Taylor expanded in y around inf 38.8%
*-commutative38.8%
Simplified38.8%
if 8.6000000000000003e-5 < x < 2.0999999999999999e77Initial program 84.4%
Taylor expanded in x around inf 47.8%
*-commutative47.8%
associate-*l/47.8%
associate-*r/47.7%
Simplified47.7%
add-sqr-sqrt26.3%
pow226.3%
sqrt-prod26.3%
sqrt-pow126.3%
metadata-eval26.3%
pow126.3%
Applied egg-rr26.3%
unpow226.3%
swap-sqr26.2%
add-sqr-sqrt47.7%
associate-*l*47.5%
Applied egg-rr47.5%
Taylor expanded in x around 0 47.6%
associate-*r/47.6%
*-commutative47.6%
Simplified47.6%
if 1.35000000000000005e110 < x Initial program 61.6%
Taylor expanded in x around inf 72.0%
*-commutative72.0%
associate-*l/72.0%
associate-*r/72.0%
Simplified72.0%
add-sqr-sqrt40.2%
pow240.2%
sqrt-prod40.2%
sqrt-pow145.1%
metadata-eval45.1%
pow145.1%
Applied egg-rr45.1%
unpow245.1%
swap-sqr40.2%
add-sqr-sqrt72.0%
associate-*l*76.9%
Applied egg-rr76.9%
Final simplification45.1%
(FPCore (x y z)
:precision binary64
(if (<= x 0.0225)
(* 0.5 y)
(if (<= x 4.1e+77)
(/ (* x (* 0.5 x)) y)
(if (<= x 8e+113) (* 0.5 y) (* x (* x (/ 0.5 y)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.0225) {
tmp = 0.5 * y;
} else if (x <= 4.1e+77) {
tmp = (x * (0.5 * x)) / y;
} else if (x <= 8e+113) {
tmp = 0.5 * y;
} 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 <= 0.0225d0) then
tmp = 0.5d0 * y
else if (x <= 4.1d+77) then
tmp = (x * (0.5d0 * x)) / y
else if (x <= 8d+113) then
tmp = 0.5d0 * y
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 <= 0.0225) {
tmp = 0.5 * y;
} else if (x <= 4.1e+77) {
tmp = (x * (0.5 * x)) / y;
} else if (x <= 8e+113) {
tmp = 0.5 * y;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 0.0225: tmp = 0.5 * y elif x <= 4.1e+77: tmp = (x * (0.5 * x)) / y elif x <= 8e+113: tmp = 0.5 * y else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 0.0225) tmp = Float64(0.5 * y); elseif (x <= 4.1e+77) tmp = Float64(Float64(x * Float64(0.5 * x)) / y); elseif (x <= 8e+113) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 0.0225) tmp = 0.5 * y; elseif (x <= 4.1e+77) tmp = (x * (0.5 * x)) / y; elseif (x <= 8e+113) tmp = 0.5 * y; else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 0.0225], N[(0.5 * y), $MachinePrecision], If[LessEqual[x, 4.1e+77], N[(N[(x * N[(0.5 * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 8e+113], N[(0.5 * y), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0225:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+77}:\\
\;\;\;\;\frac{x \cdot \left(0.5 \cdot x\right)}{y}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+113}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 0.022499999999999999 or 4.1000000000000001e77 < x < 8e113Initial program 69.3%
Taylor expanded in y around inf 38.8%
*-commutative38.8%
Simplified38.8%
if 0.022499999999999999 < x < 4.1000000000000001e77Initial program 84.4%
Taylor expanded in x around inf 47.8%
*-commutative47.8%
associate-*l/47.8%
associate-*r/47.7%
Simplified47.7%
add-sqr-sqrt26.3%
pow226.3%
sqrt-prod26.3%
sqrt-pow126.3%
metadata-eval26.3%
pow126.3%
Applied egg-rr26.3%
unpow226.3%
swap-sqr26.2%
add-sqr-sqrt47.7%
associate-*l*47.5%
Applied egg-rr47.5%
*-commutative47.5%
associate-*r/47.6%
associate-*l/47.8%
Applied egg-rr47.8%
if 8e113 < x Initial program 61.6%
Taylor expanded in x around inf 72.0%
*-commutative72.0%
associate-*l/72.0%
associate-*r/72.0%
Simplified72.0%
add-sqr-sqrt40.2%
pow240.2%
sqrt-prod40.2%
sqrt-pow145.1%
metadata-eval45.1%
pow145.1%
Applied egg-rr45.1%
unpow245.1%
swap-sqr40.2%
add-sqr-sqrt72.0%
associate-*l*76.9%
Applied egg-rr76.9%
Final simplification45.1%
(FPCore (x y z)
:precision binary64
(if (<= x 0.00037)
(* 0.5 (+ y (* (- x z) (/ z y))))
(if (<= x 1.06e+77)
(* 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 (x <= 0.00037) {
tmp = 0.5 * (y + ((x - z) * (z / y)));
} else if (x <= 1.06e+77) {
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 (x <= 0.00037d0) then
tmp = 0.5d0 * (y + ((x - z) * (z / y)))
else if (x <= 1.06d+77) 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 (x <= 0.00037) {
tmp = 0.5 * (y + ((x - z) * (z / y)));
} else if (x <= 1.06e+77) {
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 x <= 0.00037: tmp = 0.5 * (y + ((x - z) * (z / y))) elif x <= 1.06e+77: 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 (x <= 0.00037) tmp = Float64(0.5 * Float64(y + Float64(Float64(x - z) * Float64(z / y)))); elseif (x <= 1.06e+77) 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 (x <= 0.00037) tmp = 0.5 * (y + ((x - z) * (z / y))); elseif (x <= 1.06e+77) 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[x, 0.00037], N[(0.5 * N[(y + N[(N[(x - z), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.06e+77], 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}\;x \leq 0.00037:\\
\;\;\;\;0.5 \cdot \left(y + \left(x - z\right) \cdot \frac{z}{y}\right)\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{+77}:\\
\;\;\;\;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 x < 3.6999999999999999e-4Initial program 69.1%
remove-double-neg69.1%
distribute-lft-neg-out69.1%
distribute-frac-neg269.1%
distribute-frac-neg69.1%
neg-mul-169.1%
distribute-lft-neg-out69.1%
*-commutative69.1%
distribute-lft-neg-in69.1%
times-frac69.1%
metadata-eval69.1%
metadata-eval69.1%
associate--l+69.1%
fma-define71.7%
Simplified71.7%
Taylor expanded in x around 0 78.6%
associate--l+78.6%
div-sub79.6%
Simplified79.6%
unpow279.6%
unpow279.6%
difference-of-squares85.9%
Applied egg-rr85.9%
*-commutative85.9%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 75.1%
if 3.6999999999999999e-4 < x < 1.06000000000000003e77Initial program 84.4%
remove-double-neg84.4%
distribute-lft-neg-out84.4%
distribute-frac-neg284.4%
distribute-frac-neg84.4%
neg-mul-184.4%
distribute-lft-neg-out84.4%
*-commutative84.4%
distribute-lft-neg-in84.4%
times-frac84.4%
metadata-eval84.4%
metadata-eval84.4%
associate--l+84.4%
fma-define84.4%
Simplified84.4%
Taylor expanded in x around 0 95.0%
associate--l+95.0%
div-sub95.0%
Simplified95.0%
unpow295.0%
unpow295.0%
difference-of-squares95.0%
Applied egg-rr95.0%
Taylor expanded in y around 0 89.9%
*-commutative95.0%
associate-/l*99.8%
Applied egg-rr94.7%
if 1.06000000000000003e77 < x Initial program 63.0%
remove-double-neg63.0%
distribute-lft-neg-out63.0%
distribute-frac-neg263.0%
distribute-frac-neg63.0%
neg-mul-163.0%
distribute-lft-neg-out63.0%
*-commutative63.0%
distribute-lft-neg-in63.0%
times-frac63.0%
metadata-eval63.0%
metadata-eval63.0%
associate--l+63.0%
fma-define70.2%
Simplified70.2%
Taylor expanded in x around 0 65.3%
associate--l+65.3%
div-sub70.1%
Simplified70.1%
unpow270.1%
unpow270.1%
difference-of-squares86.8%
Applied egg-rr86.8%
*-commutative86.8%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 92.9%
Final simplification79.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.2e-38) (* 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 <= 1.2e-38) {
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 <= 1.2d-38) 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 <= 1.2e-38) {
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 <= 1.2e-38: 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 <= 1.2e-38) 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 <= 1.2e-38) 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, 1.2e-38], 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 1.2 \cdot 10^{-38}:\\
\;\;\;\;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 < 1.20000000000000011e-38Initial program 76.5%
remove-double-neg76.5%
distribute-lft-neg-out76.5%
distribute-frac-neg276.5%
distribute-frac-neg76.5%
neg-mul-176.5%
distribute-lft-neg-out76.5%
*-commutative76.5%
distribute-lft-neg-in76.5%
times-frac76.5%
metadata-eval76.5%
metadata-eval76.5%
associate--l+76.5%
fma-define80.5%
Simplified80.5%
Taylor expanded in x around 0 81.0%
associate--l+81.0%
div-sub83.3%
Simplified83.3%
unpow283.3%
unpow283.3%
difference-of-squares92.4%
Applied egg-rr92.4%
Taylor expanded in y around 0 75.3%
*-commutative92.4%
associate-/l*99.9%
Applied egg-rr78.5%
if 1.20000000000000011e-38 < y Initial program 53.7%
remove-double-neg53.7%
distribute-lft-neg-out53.7%
distribute-frac-neg253.7%
distribute-frac-neg53.7%
neg-mul-153.7%
distribute-lft-neg-out53.7%
*-commutative53.7%
distribute-lft-neg-in53.7%
times-frac53.7%
metadata-eval53.7%
metadata-eval53.7%
associate--l+53.7%
fma-define55.0%
Simplified55.0%
Taylor expanded in x around 0 70.4%
associate--l+70.4%
div-sub70.4%
Simplified70.4%
unpow270.4%
unpow270.4%
difference-of-squares74.3%
Applied egg-rr74.3%
*-commutative74.3%
associate-/l*99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 83.2%
Final simplification80.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.3%
remove-double-neg69.3%
distribute-lft-neg-out69.3%
distribute-frac-neg269.3%
distribute-frac-neg69.3%
neg-mul-169.3%
distribute-lft-neg-out69.3%
*-commutative69.3%
distribute-lft-neg-in69.3%
times-frac69.3%
metadata-eval69.3%
metadata-eval69.3%
associate--l+69.3%
fma-define72.4%
Simplified72.4%
Taylor expanded in x around 0 77.6%
associate--l+77.6%
div-sub79.2%
Simplified79.2%
unpow279.2%
unpow279.2%
difference-of-squares86.7%
Applied egg-rr86.7%
*-commutative86.7%
associate-/l*99.9%
Applied egg-rr99.9%
Final simplification99.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 69.3%
Taylor expanded in y around inf 32.6%
*-commutative32.6%
Simplified32.6%
Final simplification32.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 2024115
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))