
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t\_0 \cdot \left(\left(-g\right) + t\_1\right)} + \sqrt[3]{t\_0 \cdot \left(\left(-g\right) - t\_1\right)}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (g h a) :precision binary64 (let* ((t_0 (/ 1.0 (* 2.0 a))) (t_1 (sqrt (- (* g g) (* h h))))) (+ (cbrt (* t_0 (+ (- g) t_1))) (cbrt (* t_0 (- (- g) t_1))))))
double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = sqrt(((g * g) - (h * h)));
return cbrt((t_0 * (-g + t_1))) + cbrt((t_0 * (-g - t_1)));
}
public static double code(double g, double h, double a) {
double t_0 = 1.0 / (2.0 * a);
double t_1 = Math.sqrt(((g * g) - (h * h)));
return Math.cbrt((t_0 * (-g + t_1))) + Math.cbrt((t_0 * (-g - t_1)));
}
function code(g, h, a) t_0 = Float64(1.0 / Float64(2.0 * a)) t_1 = sqrt(Float64(Float64(g * g) - Float64(h * h))) return Float64(cbrt(Float64(t_0 * Float64(Float64(-g) + t_1))) + cbrt(Float64(t_0 * Float64(Float64(-g) - t_1)))) end
code[g_, h_, a_] := Block[{t$95$0 = N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(t$95$0 * N[((-g) + t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(t$95$0 * N[((-g) - t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{2 \cdot a}\\
t_1 := \sqrt{g \cdot g - h \cdot h}\\
\sqrt[3]{t\_0 \cdot \left(\left(-g\right) + t\_1\right)} + \sqrt[3]{t\_0 \cdot \left(\left(-g\right) - t\_1\right)}
\end{array}
\end{array}
(FPCore (g h a) :precision binary64 (- (cbrt (* (- g g) (/ -0.5 a))) (/ (cbrt g) (cbrt a))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) - (cbrt(g) / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) - (Math.cbrt(g) / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) - Float64(cbrt(g) / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - N[(N[Power[g, 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} - \frac{\sqrt[3]{g}}{\sqrt[3]{a}}
\end{array}
Initial program 37.8%
Simplified37.8%
Taylor expanded in g around -inf 24.0%
*-commutative24.0%
Simplified24.0%
Taylor expanded in g around -inf 69.8%
neg-mul-169.8%
Simplified69.8%
associate-*l/69.8%
cbrt-div95.7%
*-commutative95.7%
associate-*r*96.0%
metadata-eval96.0%
neg-mul-196.0%
add-cube-cbrt95.8%
unpow295.8%
distribute-rgt-neg-in95.8%
unpow295.8%
sqr-neg95.8%
add-cbrt-cube96.0%
add-sqr-sqrt45.9%
sqrt-unprod46.6%
sqr-neg46.6%
sqrt-prod0.7%
add-sqr-sqrt1.3%
frac-2neg1.3%
Applied egg-rr96.0%
Final simplification96.0%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (- g g) (/ -0.5 a)))))
(if (<= a -5.2e-81)
(+ t_0 (cbrt (* (/ 0.5 a) (* g -2.0))))
(if (<= a 2.3e-50)
(+ (cbrt -1.0) (/ (cbrt (- g)) (cbrt a)))
(+ t_0 (cbrt (/ g (- a))))))))
double code(double g, double h, double a) {
double t_0 = cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -5.2e-81) {
tmp = t_0 + cbrt(((0.5 / a) * (g * -2.0)));
} else if (a <= 2.3e-50) {
tmp = cbrt(-1.0) + (cbrt(-g) / cbrt(a));
} else {
tmp = t_0 + cbrt((g / -a));
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((g - g) * (-0.5 / a)));
double tmp;
if (a <= -5.2e-81) {
tmp = t_0 + Math.cbrt(((0.5 / a) * (g * -2.0)));
} else if (a <= 2.3e-50) {
tmp = Math.cbrt(-1.0) + (Math.cbrt(-g) / Math.cbrt(a));
} else {
tmp = t_0 + Math.cbrt((g / -a));
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) tmp = 0.0 if (a <= -5.2e-81) tmp = Float64(t_0 + cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0)))); elseif (a <= 2.3e-50) tmp = Float64(cbrt(-1.0) + Float64(cbrt(Float64(-g)) / cbrt(a))); else tmp = Float64(t_0 + cbrt(Float64(g / Float64(-a)))); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[a, -5.2e-81], N[(t$95$0 + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.3e-50], N[(N[Power[-1.0, 1/3], $MachinePrecision] + N[(N[Power[(-g), 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}}\\
\mathbf{if}\;a \leq -5.2 \cdot 10^{-81}:\\
\;\;\;\;t\_0 + \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\
\mathbf{elif}\;a \leq 2.3 \cdot 10^{-50}:\\
\;\;\;\;\sqrt[3]{-1} + \frac{\sqrt[3]{-g}}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \sqrt[3]{\frac{g}{-a}}\\
\end{array}
\end{array}
if a < -5.1999999999999998e-81Initial program 44.4%
Simplified44.4%
Taylor expanded in g around -inf 27.6%
*-commutative27.6%
Simplified27.6%
Taylor expanded in g around -inf 90.5%
neg-mul-190.5%
Simplified90.5%
if -5.1999999999999998e-81 < a < 2.3000000000000002e-50Initial program 31.4%
Simplified31.4%
Taylor expanded in g around -inf 19.6%
*-commutative19.6%
Simplified19.6%
Taylor expanded in g around inf 10.5%
add-sqr-sqrt5.9%
sqrt-unprod4.2%
swap-sqr4.3%
frac-times4.3%
metadata-eval4.3%
metadata-eval4.3%
frac-times4.3%
*-commutative4.3%
*-commutative4.3%
swap-sqr4.3%
metadata-eval4.3%
metadata-eval4.3%
swap-sqr4.3%
count-24.3%
count-24.3%
swap-sqr4.2%
*-commutative4.2%
*-commutative4.2%
sqrt-unprod5.9%
add-sqr-sqrt10.5%
expm1-log1p-u6.2%
Applied egg-rr0.0%
Simplified39.2%
add-sqr-sqrt23.9%
sqrt-unprod12.0%
*-commutative12.0%
*-commutative12.0%
swap-sqr4.8%
frac-times4.8%
metadata-eval4.8%
metadata-eval4.8%
frac-times4.8%
count-24.8%
count-24.8%
swap-sqr4.8%
metadata-eval4.8%
metadata-eval4.8%
swap-sqr4.8%
*-commutative4.8%
*-commutative4.8%
swap-sqr12.0%
Applied egg-rr91.7%
if 2.3000000000000002e-50 < a Initial program 40.1%
Simplified40.1%
Taylor expanded in g around -inf 26.8%
*-commutative26.8%
Simplified26.8%
Taylor expanded in g around -inf 90.2%
neg-mul-190.2%
Simplified90.2%
associate-*l/90.3%
*-commutative90.3%
associate-*r*90.3%
metadata-eval90.3%
neg-mul-190.3%
Applied egg-rr90.3%
Final simplification91.0%
(FPCore (g h a)
:precision binary64
(let* ((t_0 (cbrt (* (/ 0.5 a) (* g -2.0)))))
(if (or (<= g -21500000000000.0) (not (<= g 7.5e+21)))
(+ t_0 (/ -1.0 (cbrt a)))
(- t_0 (cbrt g)))))
double code(double g, double h, double a) {
double t_0 = cbrt(((0.5 / a) * (g * -2.0)));
double tmp;
if ((g <= -21500000000000.0) || !(g <= 7.5e+21)) {
tmp = t_0 + (-1.0 / cbrt(a));
} else {
tmp = t_0 - cbrt(g);
}
return tmp;
}
public static double code(double g, double h, double a) {
double t_0 = Math.cbrt(((0.5 / a) * (g * -2.0)));
double tmp;
if ((g <= -21500000000000.0) || !(g <= 7.5e+21)) {
tmp = t_0 + (-1.0 / Math.cbrt(a));
} else {
tmp = t_0 - Math.cbrt(g);
}
return tmp;
}
function code(g, h, a) t_0 = cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0))) tmp = 0.0 if ((g <= -21500000000000.0) || !(g <= 7.5e+21)) tmp = Float64(t_0 + Float64(-1.0 / cbrt(a))); else tmp = Float64(t_0 - cbrt(g)); end return tmp end
code[g_, h_, a_] := Block[{t$95$0 = N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[Or[LessEqual[g, -21500000000000.0], N[Not[LessEqual[g, 7.5e+21]], $MachinePrecision]], N[(t$95$0 + N[(-1.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[Power[g, 1/3], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}\\
\mathbf{if}\;g \leq -21500000000000 \lor \neg \left(g \leq 7.5 \cdot 10^{+21}\right):\\
\;\;\;\;t\_0 + \frac{-1}{\sqrt[3]{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \sqrt[3]{g}\\
\end{array}
\end{array}
if g < -2.15e13 or 7.5e21 < g Initial program 26.9%
Simplified26.9%
Taylor expanded in g around -inf 15.6%
*-commutative15.6%
Simplified15.6%
Taylor expanded in g around inf 13.8%
*-un-lft-identity13.8%
*-commutative13.8%
Applied egg-rr0.0%
Simplified63.5%
if -2.15e13 < g < 7.5e21Initial program 71.2%
Simplified71.2%
Taylor expanded in g around -inf 49.8%
*-commutative49.8%
Simplified49.8%
Taylor expanded in g around inf 16.9%
Taylor expanded in g around 0 16.9%
Simplified51.0%
Final simplification60.4%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (* (/ 0.5 a) (* g -2.0)))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) + cbrt(((0.5 / a) * (g * -2.0)));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt(((0.5 / a) * (g * -2.0)));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(Float64(0.5 / a) * Float64(g * -2.0)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(0.5 / a), $MachinePrecision] * N[(g * -2.0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{0.5}{a} \cdot \left(g \cdot -2\right)}
\end{array}
Initial program 37.8%
Simplified37.8%
Taylor expanded in g around -inf 24.0%
*-commutative24.0%
Simplified24.0%
Taylor expanded in g around -inf 69.8%
neg-mul-169.8%
Simplified69.8%
Final simplification69.8%
(FPCore (g h a) :precision binary64 (+ (cbrt (* (- g g) (/ -0.5 a))) (cbrt (/ g (- a)))))
double code(double g, double h, double a) {
return cbrt(((g - g) * (-0.5 / a))) + cbrt((g / -a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(((g - g) * (-0.5 / a))) + Math.cbrt((g / -a));
}
function code(g, h, a) return Float64(cbrt(Float64(Float64(g - g) * Float64(-0.5 / a))) + cbrt(Float64(g / Float64(-a)))) end
code[g_, h_, a_] := N[(N[Power[N[(N[(g - g), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{g}{-a}}
\end{array}
Initial program 37.8%
Simplified37.8%
Taylor expanded in g around -inf 24.0%
*-commutative24.0%
Simplified24.0%
Taylor expanded in g around -inf 69.8%
neg-mul-169.8%
Simplified69.8%
associate-*l/69.8%
*-commutative69.8%
associate-*r*69.8%
metadata-eval69.8%
neg-mul-169.8%
Applied egg-rr69.8%
Final simplification69.8%
(FPCore (g h a) :precision binary64 (+ (cbrt -1.0) (cbrt (/ g (- a)))))
double code(double g, double h, double a) {
return cbrt(-1.0) + cbrt((g / -a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-1.0) + Math.cbrt((g / -a));
}
function code(g, h, a) return Float64(cbrt(-1.0) + cbrt(Float64(g / Float64(-a)))) end
code[g_, h_, a_] := N[(N[Power[-1.0, 1/3], $MachinePrecision] + N[Power[N[(g / (-a)), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-1} + \sqrt[3]{\frac{g}{-a}}
\end{array}
Initial program 37.8%
Simplified37.8%
Taylor expanded in g around -inf 24.0%
*-commutative24.0%
Simplified24.0%
Taylor expanded in g around inf 14.6%
add-sqr-sqrt8.0%
sqrt-unprod13.0%
swap-sqr13.3%
frac-times13.4%
metadata-eval13.4%
metadata-eval13.4%
frac-times13.3%
*-commutative13.3%
*-commutative13.3%
swap-sqr13.3%
metadata-eval13.3%
metadata-eval13.3%
swap-sqr13.3%
count-213.3%
count-213.3%
swap-sqr13.0%
*-commutative13.0%
*-commutative13.0%
sqrt-unprod8.0%
add-sqr-sqrt14.6%
expm1-log1p-u10.4%
Applied egg-rr0.0%
Simplified42.6%
Taylor expanded in g around 0 42.6%
mul-1-neg42.6%
distribute-neg-frac242.6%
Simplified42.6%
(FPCore (g h a) :precision binary64 (+ (cbrt -1.0) (/ -1.0 (cbrt a))))
double code(double g, double h, double a) {
return cbrt(-1.0) + (-1.0 / cbrt(a));
}
public static double code(double g, double h, double a) {
return Math.cbrt(-1.0) + (-1.0 / Math.cbrt(a));
}
function code(g, h, a) return Float64(cbrt(-1.0) + Float64(-1.0 / cbrt(a))) end
code[g_, h_, a_] := N[(N[Power[-1.0, 1/3], $MachinePrecision] + N[(-1.0 / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{-1} + \frac{-1}{\sqrt[3]{a}}
\end{array}
Initial program 37.8%
Simplified37.8%
Taylor expanded in g around -inf 24.0%
*-commutative24.0%
Simplified24.0%
Taylor expanded in g around inf 14.6%
add-sqr-sqrt8.0%
sqrt-unprod13.0%
swap-sqr13.3%
frac-times13.4%
metadata-eval13.4%
metadata-eval13.4%
frac-times13.3%
*-commutative13.3%
*-commutative13.3%
swap-sqr13.3%
metadata-eval13.3%
metadata-eval13.3%
swap-sqr13.3%
count-213.3%
count-213.3%
swap-sqr13.0%
*-commutative13.0%
*-commutative13.0%
sqrt-unprod8.0%
add-sqr-sqrt14.6%
expm1-log1p-u10.4%
Applied egg-rr0.0%
Simplified42.6%
*-un-lft-identity14.6%
*-commutative14.6%
Applied egg-rr0.0%
Simplified4.9%
(FPCore (g h a) :precision binary64 1.0)
double code(double g, double h, double a) {
return 1.0;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = 1.0d0
end function
public static double code(double g, double h, double a) {
return 1.0;
}
def code(g, h, a): return 1.0
function code(g, h, a) return 1.0 end
function tmp = code(g, h, a) tmp = 1.0; end
code[g_, h_, a_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 37.8%
Simplified37.8%
Taylor expanded in g around -inf 24.0%
*-commutative24.0%
Simplified24.0%
Taylor expanded in g around inf 14.6%
add-sqr-sqrt8.0%
sqrt-unprod13.0%
swap-sqr13.3%
frac-times13.4%
metadata-eval13.4%
metadata-eval13.4%
frac-times13.3%
*-commutative13.3%
*-commutative13.3%
swap-sqr13.3%
metadata-eval13.3%
metadata-eval13.3%
swap-sqr13.3%
count-213.3%
count-213.3%
swap-sqr13.0%
*-commutative13.0%
*-commutative13.0%
sqrt-unprod8.0%
add-sqr-sqrt14.6%
expm1-log1p-u10.4%
Applied egg-rr0.0%
Simplified42.6%
Applied egg-rr4.7%
(FPCore (g h a) :precision binary64 -1.0)
double code(double g, double h, double a) {
return -1.0;
}
real(8) function code(g, h, a)
real(8), intent (in) :: g
real(8), intent (in) :: h
real(8), intent (in) :: a
code = -1.0d0
end function
public static double code(double g, double h, double a) {
return -1.0;
}
def code(g, h, a): return -1.0
function code(g, h, a) return -1.0 end
function tmp = code(g, h, a) tmp = -1.0; end
code[g_, h_, a_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 37.8%
Simplified37.8%
Taylor expanded in g around -inf 24.0%
*-commutative24.0%
Simplified24.0%
Taylor expanded in g around inf 14.6%
add-sqr-sqrt8.0%
sqrt-unprod13.0%
swap-sqr13.3%
frac-times13.4%
metadata-eval13.4%
metadata-eval13.4%
frac-times13.3%
*-commutative13.3%
*-commutative13.3%
swap-sqr13.3%
metadata-eval13.3%
metadata-eval13.3%
swap-sqr13.3%
count-213.3%
count-213.3%
swap-sqr13.0%
*-commutative13.0%
*-commutative13.0%
sqrt-unprod8.0%
add-sqr-sqrt14.6%
expm1-log1p-u10.4%
Applied egg-rr0.0%
Simplified42.6%
Applied egg-rr4.3%
herbie shell --seed 2024114
(FPCore (g h a)
:name "2-ancestry mixing, positive discriminant"
:precision binary64
(+ (cbrt (* (/ 1.0 (* 2.0 a)) (+ (- g) (sqrt (- (* g g) (* h h)))))) (cbrt (* (/ 1.0 (* 2.0 a)) (- (- g) (sqrt (- (* g g) (* h h))))))))