2-ancestry mixing, positive discriminant

?

Percentage Accurate: 44.0% → 95.6%
Time: 18.8s
Precision: binary64
Cost: 39488

?

\[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
\[\frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, h\right)}}{\sqrt[3]{a \cdot -2}} \]
(FPCore (g h a)
 :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))))))))
(FPCore (g h a)
 :precision binary64
 (+
  (/ (cbrt (* 0.5 (- (hypot g h) g))) (cbrt a))
  (/ (cbrt (+ g (hypot g h))) (cbrt (* a -2.0)))))
double code(double g, double h, double a) {
	return cbrt(((1.0 / (2.0 * a)) * (-g + sqrt(((g * g) - (h * h)))))) + cbrt(((1.0 / (2.0 * a)) * (-g - sqrt(((g * g) - (h * h))))));
}
double code(double g, double h, double a) {
	return (cbrt((0.5 * (hypot(g, h) - g))) / cbrt(a)) + (cbrt((g + hypot(g, h))) / cbrt((a * -2.0)));
}
public static double code(double g, double h, double a) {
	return Math.cbrt(((1.0 / (2.0 * a)) * (-g + Math.sqrt(((g * g) - (h * h)))))) + Math.cbrt(((1.0 / (2.0 * a)) * (-g - Math.sqrt(((g * g) - (h * h))))));
}
public static double code(double g, double h, double a) {
	return (Math.cbrt((0.5 * (Math.hypot(g, h) - g))) / Math.cbrt(a)) + (Math.cbrt((g + Math.hypot(g, h))) / Math.cbrt((a * -2.0)));
}
function code(g, h, a)
	return Float64(cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(-g) + sqrt(Float64(Float64(g * g) - Float64(h * h)))))) + cbrt(Float64(Float64(1.0 / Float64(2.0 * a)) * Float64(Float64(-g) - sqrt(Float64(Float64(g * g) - Float64(h * h)))))))
end
function code(g, h, a)
	return Float64(Float64(cbrt(Float64(0.5 * Float64(hypot(g, h) - g))) / cbrt(a)) + Float64(cbrt(Float64(g + hypot(g, h))) / cbrt(Float64(a * -2.0))))
end
code[g_, h_, a_] := N[(N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[((-g) + N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[Power[N[(N[(1.0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision] * N[((-g) - N[Sqrt[N[(N[(g * g), $MachinePrecision] - N[(h * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]
code[g_, h_, a_] := N[(N[(N[Power[N[(0.5 * N[(N[Sqrt[g ^ 2 + h ^ 2], $MachinePrecision] - g), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[a, 1/3], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(g + N[Sqrt[g ^ 2 + h ^ 2], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(a * -2.0), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)}
\frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, h\right)}}{\sqrt[3]{a \cdot -2}}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 5 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 45.1%

    \[\sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]
  2. Simplified45.2%

    \[\leadsto \color{blue}{\sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)} + \sqrt[3]{\frac{g + \sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)}}{\frac{a}{-0.5}}}} \]
    Step-by-step derivation

    [Start]45.1%

    \[ \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]

    associate-/r* [=>]45.1%

    \[ \sqrt[3]{\color{blue}{\frac{\frac{1}{2}}{a}} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]

    metadata-eval [=>]45.1%

    \[ \sqrt[3]{\frac{\color{blue}{0.5}}{a} \cdot \left(\left(-g\right) + \sqrt{g \cdot g - h \cdot h}\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]

    +-commutative [=>]45.1%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \color{blue}{\left(\sqrt{g \cdot g - h \cdot h} + \left(-g\right)\right)}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]

    unsub-neg [=>]45.1%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \color{blue}{\left(\sqrt{g \cdot g - h \cdot h} - g\right)}} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]

    fma-neg [=>]45.1%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(g, g, -h \cdot h\right)}} - g\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \left(\left(-g\right) - \sqrt{g \cdot g - h \cdot h}\right)} \]

    sub-neg [=>]45.1%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \color{blue}{\left(\left(-g\right) + \left(-\sqrt{g \cdot g - h \cdot h}\right)\right)}} \]

    distribute-neg-out [=>]45.1%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \color{blue}{\left(-\left(g + \sqrt{g \cdot g - h \cdot h}\right)\right)}} \]

    neg-mul-1 [=>]45.1%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)} + \sqrt[3]{\frac{1}{2 \cdot a} \cdot \color{blue}{\left(-1 \cdot \left(g + \sqrt{g \cdot g - h \cdot h}\right)\right)}} \]

    associate-*r* [=>]45.1%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)} + \sqrt[3]{\color{blue}{\left(\frac{1}{2 \cdot a} \cdot -1\right) \cdot \left(g + \sqrt{g \cdot g - h \cdot h}\right)}} \]
  3. Applied egg-rr48.3%

    \[\leadsto \color{blue}{\frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}}} + \sqrt[3]{\frac{g + \sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)}}{\frac{a}{-0.5}}} \]
    Step-by-step derivation

    [Start]45.2%

    \[ \sqrt[3]{\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)} + \sqrt[3]{\frac{g + \sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)}}{\frac{a}{-0.5}}} \]

    associate-*l/ [=>]45.1%

    \[ \sqrt[3]{\color{blue}{\frac{0.5 \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)}{a}}} + \sqrt[3]{\frac{g + \sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)}}{\frac{a}{-0.5}}} \]

    cbrt-div [=>]47.8%

    \[ \color{blue}{\frac{\sqrt[3]{0.5 \cdot \left(\sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)} - g\right)}}{\sqrt[3]{a}}} + \sqrt[3]{\frac{g + \sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)}}{\frac{a}{-0.5}}} \]
  4. Applied egg-rr95.2%

    \[\leadsto \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \color{blue}{\frac{\sqrt[3]{g + \mathsf{hypot}\left(g, h\right)}}{\sqrt[3]{a \cdot -2}}} \]
    Step-by-step derivation

    [Start]48.3%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \sqrt[3]{\frac{g + \sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)}}{\frac{a}{-0.5}}} \]

    cbrt-div [=>]48.7%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \color{blue}{\frac{\sqrt[3]{g + \sqrt{\mathsf{fma}\left(g, g, -h \cdot h\right)}}}{\sqrt[3]{\frac{a}{-0.5}}}} \]

    fma-udef [=>]48.7%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \sqrt{\color{blue}{g \cdot g + \left(-h \cdot h\right)}}}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    add-sqr-sqrt [=>]26.0%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \sqrt{g \cdot g + \color{blue}{\sqrt{-h \cdot h} \cdot \sqrt{-h \cdot h}}}}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    hypot-def [=>]43.8%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \color{blue}{\mathsf{hypot}\left(g, \sqrt{-h \cdot h}\right)}}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    add-sqr-sqrt [=>]43.8%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, \sqrt{\color{blue}{\sqrt{-h \cdot h} \cdot \sqrt{-h \cdot h}}}\right)}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    sqrt-unprod [=>]82.1%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, \sqrt{\color{blue}{\sqrt{\left(-h \cdot h\right) \cdot \left(-h \cdot h\right)}}}\right)}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    sqr-neg [=>]82.1%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, \sqrt{\sqrt{\color{blue}{\left(h \cdot h\right) \cdot \left(h \cdot h\right)}}}\right)}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    sqrt-unprod [<=]89.4%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, \sqrt{\color{blue}{\sqrt{h \cdot h} \cdot \sqrt{h \cdot h}}}\right)}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    add-sqr-sqrt [<=]89.4%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, \sqrt{\color{blue}{h \cdot h}}\right)}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    sqrt-prod [=>]44.2%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, \color{blue}{\sqrt{h} \cdot \sqrt{h}}\right)}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    add-sqr-sqrt [<=]95.2%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, \color{blue}{h}\right)}}{\sqrt[3]{\frac{a}{-0.5}}} \]

    div-inv [=>]95.2%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, h\right)}}{\sqrt[3]{\color{blue}{a \cdot \frac{1}{-0.5}}}} \]

    metadata-eval [=>]95.2%

    \[ \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, h\right)}}{\sqrt[3]{a \cdot \color{blue}{-2}}} \]
  5. Final simplification95.2%

    \[\leadsto \frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, h\right)}}{\sqrt[3]{a \cdot -2}} \]

Alternatives

Alternative 1
Accuracy95.6%
Cost39488
\[\frac{\sqrt[3]{0.5 \cdot \left(\mathsf{hypot}\left(g, h\right) - g\right)}}{\sqrt[3]{a}} + \frac{\sqrt[3]{g + \mathsf{hypot}\left(g, h\right)}}{\sqrt[3]{a \cdot -2}} \]
Alternative 2
Accuracy95.7%
Cost19968
\[\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \frac{\sqrt[3]{g}}{\sqrt[3]{-a}} \]
Alternative 3
Accuracy73.3%
Cost13760
\[\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{-0.5}{a} \cdot \left(g + g\right)} \]
Alternative 4
Accuracy73.3%
Cost13568
\[\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{-g}{a}} \]
Alternative 5
Accuracy1.4%
Cost13504
\[\sqrt[3]{\left(g - g\right) \cdot \frac{-0.5}{a}} + \sqrt[3]{\frac{g}{a}} \]

Reproduce?

herbie shell --seed 2023166 
(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))))))))