2-ancestry mixing, negative discriminant

Percentage Accurate: 98.5% → 100.0%
Time: 4.2s
Alternatives: 4
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ 2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \end{array} \]
(FPCore (g h)
 :precision binary64
 (* 2.0 (cos (+ (/ (* 2.0 PI) 3.0) (/ (acos (/ (- g) h)) 3.0)))))
double code(double g, double h) {
	return 2.0 * cos((((2.0 * ((double) M_PI)) / 3.0) + (acos((-g / h)) / 3.0)));
}
public static double code(double g, double h) {
	return 2.0 * Math.cos((((2.0 * Math.PI) / 3.0) + (Math.acos((-g / h)) / 3.0)));
}
def code(g, h):
	return 2.0 * math.cos((((2.0 * math.pi) / 3.0) + (math.acos((-g / h)) / 3.0)))
function code(g, h)
	return Float64(2.0 * cos(Float64(Float64(Float64(2.0 * pi) / 3.0) + Float64(acos(Float64(Float64(-g) / h)) / 3.0))))
end
function tmp = code(g, h)
	tmp = 2.0 * cos((((2.0 * pi) / 3.0) + (acos((-g / h)) / 3.0)));
end
code[g_, h_] := N[(2.0 * N[Cos[N[(N[(N[(2.0 * Pi), $MachinePrecision] / 3.0), $MachinePrecision] + N[(N[ArcCos[N[((-g) / h), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)
\end{array}

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.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
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.

Initial Program: 98.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \end{array} \]
(FPCore (g h)
 :precision binary64
 (* 2.0 (cos (+ (/ (* 2.0 PI) 3.0) (/ (acos (/ (- g) h)) 3.0)))))
double code(double g, double h) {
	return 2.0 * cos((((2.0 * ((double) M_PI)) / 3.0) + (acos((-g / h)) / 3.0)));
}
public static double code(double g, double h) {
	return 2.0 * Math.cos((((2.0 * Math.PI) / 3.0) + (Math.acos((-g / h)) / 3.0)));
}
def code(g, h):
	return 2.0 * math.cos((((2.0 * math.pi) / 3.0) + (math.acos((-g / h)) / 3.0)))
function code(g, h)
	return Float64(2.0 * cos(Float64(Float64(Float64(2.0 * pi) / 3.0) + Float64(acos(Float64(Float64(-g) / h)) / 3.0))))
end
function tmp = code(g, h)
	tmp = 2.0 * cos((((2.0 * pi) / 3.0) + (acos((-g / h)) / 3.0)));
end
code[g_, h_] := N[(2.0 * N[Cos[N[(N[(N[(2.0 * Pi), $MachinePrecision] / 3.0), $MachinePrecision] + N[(N[ArcCos[N[((-g) / h), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right)
\end{array}

Alternative 1: 100.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sqrt{3}}{2}\\ t_1 := -0.3333333333333333 \cdot \cos^{-1} \left(\frac{-g}{h}\right)\\ 2 \cdot \frac{\left(\cos t\_1 \cdot \left(0.25 - t\_0 \cdot t\_0\right)\right) \cdot 2 - \left(\cos \left(\mathsf{fma}\left(0.6666666666666666, \pi, t\_1\right)\right) - \cos \left(\mathsf{fma}\left(\pi, 2.5, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot -0.3333333333333333\right)\right)}{2} \end{array} \end{array} \]
(FPCore (g h)
 :precision binary64
 (let* ((t_0 (/ (sqrt 3.0) 2.0))
        (t_1 (* -0.3333333333333333 (acos (/ (- g) h)))))
   (*
    2.0
    (/
     (-
      (* (* (cos t_1) (- 0.25 (* t_0 t_0))) 2.0)
      (-
       (cos (fma 0.6666666666666666 PI t_1))
       (cos (* (fma PI 2.5 (asin (/ g h))) -0.3333333333333333))))
     2.0))))
double code(double g, double h) {
	double t_0 = sqrt(3.0) / 2.0;
	double t_1 = -0.3333333333333333 * acos((-g / h));
	return 2.0 * ((((cos(t_1) * (0.25 - (t_0 * t_0))) * 2.0) - (cos(fma(0.6666666666666666, ((double) M_PI), t_1)) - cos((fma(((double) M_PI), 2.5, asin((g / h))) * -0.3333333333333333)))) / 2.0);
}
function code(g, h)
	t_0 = Float64(sqrt(3.0) / 2.0)
	t_1 = Float64(-0.3333333333333333 * acos(Float64(Float64(-g) / h)))
	return Float64(2.0 * Float64(Float64(Float64(Float64(cos(t_1) * Float64(0.25 - Float64(t_0 * t_0))) * 2.0) - Float64(cos(fma(0.6666666666666666, pi, t_1)) - cos(Float64(fma(pi, 2.5, asin(Float64(g / h))) * -0.3333333333333333)))) / 2.0))
end
code[g_, h_] := Block[{t$95$0 = N[(N[Sqrt[3.0], $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(-0.3333333333333333 * N[ArcCos[N[((-g) / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(N[(N[(N[(N[Cos[t$95$1], $MachinePrecision] * N[(0.25 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] - N[(N[Cos[N[(0.6666666666666666 * Pi + t$95$1), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(N[(Pi * 2.5 + N[ArcSin[N[(g / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sqrt{3}}{2}\\
t_1 := -0.3333333333333333 \cdot \cos^{-1} \left(\frac{-g}{h}\right)\\
2 \cdot \frac{\left(\cos t\_1 \cdot \left(0.25 - t\_0 \cdot t\_0\right)\right) \cdot 2 - \left(\cos \left(\mathsf{fma}\left(0.6666666666666666, \pi, t\_1\right)\right) - \cos \left(\mathsf{fma}\left(\pi, 2.5, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot -0.3333333333333333\right)\right)}{2}
\end{array}
\end{array}
Derivation
  1. Initial program 98.5%

    \[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]
  2. Applied rewrites100.0%

    \[\leadsto 2 \cdot \color{blue}{\frac{\left(\cos \left(-0.3333333333333333 \cdot \cos^{-1} \left(\frac{-g}{h}\right)\right) \cdot \left(0.25 - \frac{\sqrt{3}}{2} \cdot \frac{\sqrt{3}}{2}\right)\right) \cdot 2 - \left(\cos \left(\mathsf{fma}\left(0.6666666666666666, \pi, -0.3333333333333333 \cdot \cos^{-1} \left(\frac{-g}{h}\right)\right)\right) - \cos \left(\mathsf{fma}\left(\pi, 2.5, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot -0.3333333333333333\right)\right)}{2}} \]
  3. Add Preprocessing

Alternative 2: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sin \left(\frac{\left(-0.3333333333333333 \cdot \pi\right) \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right) \cdot 2 \end{array} \]
(FPCore (g h)
 :precision binary64
 (* (sin (/ (- (* (* -0.3333333333333333 PI) 3.0) (asin (/ g h))) 3.0)) 2.0))
double code(double g, double h) {
	return sin(((((-0.3333333333333333 * ((double) M_PI)) * 3.0) - asin((g / h))) / 3.0)) * 2.0;
}
public static double code(double g, double h) {
	return Math.sin(((((-0.3333333333333333 * Math.PI) * 3.0) - Math.asin((g / h))) / 3.0)) * 2.0;
}
def code(g, h):
	return math.sin(((((-0.3333333333333333 * math.pi) * 3.0) - math.asin((g / h))) / 3.0)) * 2.0
function code(g, h)
	return Float64(sin(Float64(Float64(Float64(Float64(-0.3333333333333333 * pi) * 3.0) - asin(Float64(g / h))) / 3.0)) * 2.0)
end
function tmp = code(g, h)
	tmp = sin(((((-0.3333333333333333 * pi) * 3.0) - asin((g / h))) / 3.0)) * 2.0;
end
code[g_, h_] := N[(N[Sin[N[(N[(N[(N[(-0.3333333333333333 * Pi), $MachinePrecision] * 3.0), $MachinePrecision] - N[ArcSin[N[(g / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}

\\
\sin \left(\frac{\left(-0.3333333333333333 \cdot \pi\right) \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right) \cdot 2
\end{array}
Derivation
  1. Initial program 98.5%

    \[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]
  2. Applied rewrites98.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(\pi, 2.5, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot -0.3333333333333333\right) \cdot 2} \]
  3. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    2. sin-+PI/2-revN/A

      \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3} + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot 2 \]
    3. lower-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3} + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot 2 \]
    4. lift-*.f64N/A

      \[\leadsto \sin \left(\color{blue}{\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    5. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\frac{-1}{3} \cdot \mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    6. lift-fma.f64N/A

      \[\leadsto \sin \left(\frac{-1}{3} \cdot \color{blue}{\left(\pi \cdot \frac{5}{2} + \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    7. distribute-lft-inN/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{-1}{3} \cdot \left(\pi \cdot \frac{5}{2}\right) + \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    8. associate-+l+N/A

      \[\leadsto \sin \color{blue}{\left(\frac{-1}{3} \cdot \left(\pi \cdot \frac{5}{2}\right) + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot 2 \]
    9. *-commutativeN/A

      \[\leadsto \sin \left(\frac{-1}{3} \cdot \color{blue}{\left(\frac{5}{2} \cdot \pi\right)} + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    10. associate-*r*N/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{-1}{3} \cdot \frac{5}{2}\right) \cdot \pi} + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    11. metadata-evalN/A

      \[\leadsto \sin \left(\color{blue}{\frac{-5}{6}} \cdot \pi + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    12. metadata-evalN/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{5}{2} \cdot \frac{-1}{3}\right)} \cdot \pi + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    13. lower-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\frac{5}{2} \cdot \frac{-1}{3}, \pi, \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot 2 \]
    14. metadata-evalN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\color{blue}{\frac{-5}{6}}, \pi, \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    15. *-commutativeN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    16. lower-fma.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \color{blue}{\mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot 2 \]
    17. lift-PI.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{\color{blue}{\pi}}{2}\right)\right)\right) \cdot 2 \]
    18. mult-flip-revN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \color{blue}{\pi \cdot \frac{1}{2}}\right)\right)\right) \cdot 2 \]
  4. Applied rewrites98.5%

    \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(-0.8333333333333334, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), -0.3333333333333333, 0.5 \cdot \pi\right)\right)\right)} \cdot 2 \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\frac{-5}{6} \cdot \pi + \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{1}{2} \cdot \pi\right)\right)} \cdot 2 \]
    2. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot \frac{-5}{6}} + \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{1}{2} \cdot \pi\right)\right) \cdot 2 \]
    3. lift-fma.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \color{blue}{\left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \frac{1}{2} \cdot \pi\right)}\right) \cdot 2 \]
    4. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}} + \frac{1}{2} \cdot \pi\right)\right) \cdot 2 \]
    5. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) \cdot 2 \]
    6. *-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) \cdot 2 \]
    7. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \pi \cdot \color{blue}{\frac{1}{2}}\right)\right) \cdot 2 \]
    8. mult-flipN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\frac{\pi}{2}}\right)\right) \cdot 2 \]
    9. lift-PI.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right)\right) \cdot 2 \]
    10. +-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right)}\right) \cdot 2 \]
    11. associate-+r+N/A

      \[\leadsto \sin \color{blue}{\left(\left(\pi \cdot \frac{-5}{6} + \frac{\mathsf{PI}\left(\right)}{2}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    12. lift-PI.f64N/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \frac{\color{blue}{\pi}}{2}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    13. mult-flipN/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \color{blue}{\pi \cdot \frac{1}{2}}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    14. metadata-evalN/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \pi \cdot \color{blue}{\frac{1}{2}}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    15. distribute-lft-outN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot \left(\frac{-5}{6} + \frac{1}{2}\right)} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    16. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \color{blue}{\frac{-1}{3}} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    17. lower-fma.f64100.0

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\pi, -0.3333333333333333, \sin^{-1} \left(\frac{g}{h}\right) \cdot -0.3333333333333333\right)\right)} \cdot 2 \]
    18. lift-*.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, \frac{-1}{3}, \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}}\right)\right) \cdot 2 \]
    19. *-commutativeN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, \frac{-1}{3}, \color{blue}{\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right)\right) \cdot 2 \]
    20. lower-*.f64100.0

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, -0.3333333333333333, \color{blue}{-0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right)\right) \cdot 2 \]
  6. Applied rewrites100.0%

    \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\pi, -0.3333333333333333, -0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)\right)} \cdot 2 \]
  7. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\pi \cdot \frac{-1}{3} + \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)} \cdot 2 \]
    2. add-flipN/A

      \[\leadsto \sin \color{blue}{\left(\pi \cdot \frac{-1}{3} - \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)\right)\right)} \cdot 2 \]
    3. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} - \left(\mathsf{neg}\left(\color{blue}{\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right)\right)\right) \cdot 2 \]
    4. *-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} - \left(\mathsf{neg}\left(\color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}}\right)\right)\right) \cdot 2 \]
    5. distribute-rgt-neg-inN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} - \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \left(\mathsf{neg}\left(\frac{-1}{3}\right)\right)}\right) \cdot 2 \]
    6. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} - \sin^{-1} \left(\frac{g}{h}\right) \cdot \color{blue}{\frac{1}{3}}\right) \cdot 2 \]
    7. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} - \sin^{-1} \left(\frac{g}{h}\right) \cdot \color{blue}{\frac{1}{3}}\right) \cdot 2 \]
    8. mult-flip-revN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} - \color{blue}{\frac{\sin^{-1} \left(\frac{g}{h}\right)}{3}}\right) \cdot 2 \]
    9. sub-to-fractionN/A

      \[\leadsto \sin \color{blue}{\left(\frac{\left(\pi \cdot \frac{-1}{3}\right) \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right)} \cdot 2 \]
    10. lower-/.f64N/A

      \[\leadsto \sin \color{blue}{\left(\frac{\left(\pi \cdot \frac{-1}{3}\right) \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right)} \cdot 2 \]
    11. lower--.f64N/A

      \[\leadsto \sin \left(\frac{\color{blue}{\left(\pi \cdot \frac{-1}{3}\right) \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}}{3}\right) \cdot 2 \]
    12. lower-*.f64N/A

      \[\leadsto \sin \left(\frac{\color{blue}{\left(\pi \cdot \frac{-1}{3}\right) \cdot 3} - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right) \cdot 2 \]
    13. *-commutativeN/A

      \[\leadsto \sin \left(\frac{\color{blue}{\left(\frac{-1}{3} \cdot \pi\right)} \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right) \cdot 2 \]
    14. lower-*.f64100.0

      \[\leadsto \sin \left(\frac{\color{blue}{\left(-0.3333333333333333 \cdot \pi\right)} \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right) \cdot 2 \]
  8. Applied rewrites100.0%

    \[\leadsto \sin \color{blue}{\left(\frac{\left(-0.3333333333333333 \cdot \pi\right) \cdot 3 - \sin^{-1} \left(\frac{g}{h}\right)}{3}\right)} \cdot 2 \]
  9. Add Preprocessing

Alternative 3: 100.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \sin \left(\mathsf{fma}\left(\pi, -0.3333333333333333, -0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot 2 \end{array} \]
(FPCore (g h)
 :precision binary64
 (*
  (sin (fma PI -0.3333333333333333 (* -0.3333333333333333 (asin (/ g h)))))
  2.0))
double code(double g, double h) {
	return sin(fma(((double) M_PI), -0.3333333333333333, (-0.3333333333333333 * asin((g / h))))) * 2.0;
}
function code(g, h)
	return Float64(sin(fma(pi, -0.3333333333333333, Float64(-0.3333333333333333 * asin(Float64(g / h))))) * 2.0)
end
code[g_, h_] := N[(N[Sin[N[(Pi * -0.3333333333333333 + N[(-0.3333333333333333 * N[ArcSin[N[(g / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}

\\
\sin \left(\mathsf{fma}\left(\pi, -0.3333333333333333, -0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)\right) \cdot 2
\end{array}
Derivation
  1. Initial program 98.5%

    \[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]
  2. Applied rewrites98.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(\pi, 2.5, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot -0.3333333333333333\right) \cdot 2} \]
  3. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    2. sin-+PI/2-revN/A

      \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3} + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot 2 \]
    3. lower-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3} + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot 2 \]
    4. lift-*.f64N/A

      \[\leadsto \sin \left(\color{blue}{\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    5. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\frac{-1}{3} \cdot \mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    6. lift-fma.f64N/A

      \[\leadsto \sin \left(\frac{-1}{3} \cdot \color{blue}{\left(\pi \cdot \frac{5}{2} + \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    7. distribute-lft-inN/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{-1}{3} \cdot \left(\pi \cdot \frac{5}{2}\right) + \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    8. associate-+l+N/A

      \[\leadsto \sin \color{blue}{\left(\frac{-1}{3} \cdot \left(\pi \cdot \frac{5}{2}\right) + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot 2 \]
    9. *-commutativeN/A

      \[\leadsto \sin \left(\frac{-1}{3} \cdot \color{blue}{\left(\frac{5}{2} \cdot \pi\right)} + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    10. associate-*r*N/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{-1}{3} \cdot \frac{5}{2}\right) \cdot \pi} + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    11. metadata-evalN/A

      \[\leadsto \sin \left(\color{blue}{\frac{-5}{6}} \cdot \pi + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    12. metadata-evalN/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{5}{2} \cdot \frac{-1}{3}\right)} \cdot \pi + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    13. lower-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\frac{5}{2} \cdot \frac{-1}{3}, \pi, \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot 2 \]
    14. metadata-evalN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\color{blue}{\frac{-5}{6}}, \pi, \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    15. *-commutativeN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    16. lower-fma.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \color{blue}{\mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot 2 \]
    17. lift-PI.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{\color{blue}{\pi}}{2}\right)\right)\right) \cdot 2 \]
    18. mult-flip-revN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \color{blue}{\pi \cdot \frac{1}{2}}\right)\right)\right) \cdot 2 \]
  4. Applied rewrites98.5%

    \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(-0.8333333333333334, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), -0.3333333333333333, 0.5 \cdot \pi\right)\right)\right)} \cdot 2 \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\frac{-5}{6} \cdot \pi + \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{1}{2} \cdot \pi\right)\right)} \cdot 2 \]
    2. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot \frac{-5}{6}} + \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{1}{2} \cdot \pi\right)\right) \cdot 2 \]
    3. lift-fma.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \color{blue}{\left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \frac{1}{2} \cdot \pi\right)}\right) \cdot 2 \]
    4. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}} + \frac{1}{2} \cdot \pi\right)\right) \cdot 2 \]
    5. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) \cdot 2 \]
    6. *-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) \cdot 2 \]
    7. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \pi \cdot \color{blue}{\frac{1}{2}}\right)\right) \cdot 2 \]
    8. mult-flipN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\frac{\pi}{2}}\right)\right) \cdot 2 \]
    9. lift-PI.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right)\right) \cdot 2 \]
    10. +-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right)}\right) \cdot 2 \]
    11. associate-+r+N/A

      \[\leadsto \sin \color{blue}{\left(\left(\pi \cdot \frac{-5}{6} + \frac{\mathsf{PI}\left(\right)}{2}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    12. lift-PI.f64N/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \frac{\color{blue}{\pi}}{2}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    13. mult-flipN/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \color{blue}{\pi \cdot \frac{1}{2}}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    14. metadata-evalN/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \pi \cdot \color{blue}{\frac{1}{2}}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    15. distribute-lft-outN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot \left(\frac{-5}{6} + \frac{1}{2}\right)} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    16. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \color{blue}{\frac{-1}{3}} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    17. lower-fma.f64100.0

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\pi, -0.3333333333333333, \sin^{-1} \left(\frac{g}{h}\right) \cdot -0.3333333333333333\right)\right)} \cdot 2 \]
    18. lift-*.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, \frac{-1}{3}, \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}}\right)\right) \cdot 2 \]
    19. *-commutativeN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, \frac{-1}{3}, \color{blue}{\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right)\right) \cdot 2 \]
    20. lower-*.f64100.0

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, -0.3333333333333333, \color{blue}{-0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right)\right) \cdot 2 \]
  6. Applied rewrites100.0%

    \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\pi, -0.3333333333333333, -0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)\right)} \cdot 2 \]
  7. Add Preprocessing

Alternative 4: 100.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \sin \left(\left(\sin^{-1} \left(\frac{g}{h}\right) + \pi\right) \cdot -0.3333333333333333\right) \cdot 2 \end{array} \]
(FPCore (g h)
 :precision binary64
 (* (sin (* (+ (asin (/ g h)) PI) -0.3333333333333333)) 2.0))
double code(double g, double h) {
	return sin(((asin((g / h)) + ((double) M_PI)) * -0.3333333333333333)) * 2.0;
}
public static double code(double g, double h) {
	return Math.sin(((Math.asin((g / h)) + Math.PI) * -0.3333333333333333)) * 2.0;
}
def code(g, h):
	return math.sin(((math.asin((g / h)) + math.pi) * -0.3333333333333333)) * 2.0
function code(g, h)
	return Float64(sin(Float64(Float64(asin(Float64(g / h)) + pi) * -0.3333333333333333)) * 2.0)
end
function tmp = code(g, h)
	tmp = sin(((asin((g / h)) + pi) * -0.3333333333333333)) * 2.0;
end
code[g_, h_] := N[(N[Sin[N[(N[(N[ArcSin[N[(g / h), $MachinePrecision]], $MachinePrecision] + Pi), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}

\\
\sin \left(\left(\sin^{-1} \left(\frac{g}{h}\right) + \pi\right) \cdot -0.3333333333333333\right) \cdot 2
\end{array}
Derivation
  1. Initial program 98.5%

    \[2 \cdot \cos \left(\frac{2 \cdot \pi}{3} + \frac{\cos^{-1} \left(\frac{-g}{h}\right)}{3}\right) \]
  2. Applied rewrites98.4%

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(\pi, 2.5, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot -0.3333333333333333\right) \cdot 2} \]
  3. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    2. sin-+PI/2-revN/A

      \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3} + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot 2 \]
    3. lower-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3} + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot 2 \]
    4. lift-*.f64N/A

      \[\leadsto \sin \left(\color{blue}{\mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    5. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\frac{-1}{3} \cdot \mathsf{fma}\left(\pi, \frac{5}{2}, \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    6. lift-fma.f64N/A

      \[\leadsto \sin \left(\frac{-1}{3} \cdot \color{blue}{\left(\pi \cdot \frac{5}{2} + \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    7. distribute-lft-inN/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{-1}{3} \cdot \left(\pi \cdot \frac{5}{2}\right) + \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \cdot 2 \]
    8. associate-+l+N/A

      \[\leadsto \sin \color{blue}{\left(\frac{-1}{3} \cdot \left(\pi \cdot \frac{5}{2}\right) + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot 2 \]
    9. *-commutativeN/A

      \[\leadsto \sin \left(\frac{-1}{3} \cdot \color{blue}{\left(\frac{5}{2} \cdot \pi\right)} + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    10. associate-*r*N/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{-1}{3} \cdot \frac{5}{2}\right) \cdot \pi} + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    11. metadata-evalN/A

      \[\leadsto \sin \left(\color{blue}{\frac{-5}{6}} \cdot \pi + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    12. metadata-evalN/A

      \[\leadsto \sin \left(\color{blue}{\left(\frac{5}{2} \cdot \frac{-1}{3}\right)} \cdot \pi + \left(\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    13. lower-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\frac{5}{2} \cdot \frac{-1}{3}, \pi, \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot 2 \]
    14. metadata-evalN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\color{blue}{\frac{-5}{6}}, \pi, \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    15. *-commutativeN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot 2 \]
    16. lower-fma.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \color{blue}{\mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot 2 \]
    17. lift-PI.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{\color{blue}{\pi}}{2}\right)\right)\right) \cdot 2 \]
    18. mult-flip-revN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\frac{-5}{6}, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \color{blue}{\pi \cdot \frac{1}{2}}\right)\right)\right) \cdot 2 \]
  4. Applied rewrites98.5%

    \[\leadsto \color{blue}{\sin \left(\mathsf{fma}\left(-0.8333333333333334, \pi, \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), -0.3333333333333333, 0.5 \cdot \pi\right)\right)\right)} \cdot 2 \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\frac{-5}{6} \cdot \pi + \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{1}{2} \cdot \pi\right)\right)} \cdot 2 \]
    2. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot \frac{-5}{6}} + \mathsf{fma}\left(\sin^{-1} \left(\frac{g}{h}\right), \frac{-1}{3}, \frac{1}{2} \cdot \pi\right)\right) \cdot 2 \]
    3. lift-fma.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \color{blue}{\left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \frac{1}{2} \cdot \pi\right)}\right) \cdot 2 \]
    4. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}} + \frac{1}{2} \cdot \pi\right)\right) \cdot 2 \]
    5. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) \cdot 2 \]
    6. *-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) \cdot 2 \]
    7. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \pi \cdot \color{blue}{\frac{1}{2}}\right)\right) \cdot 2 \]
    8. mult-flipN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \color{blue}{\frac{\pi}{2}}\right)\right) \cdot 2 \]
    9. lift-PI.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \left(\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3} + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right)\right) \cdot 2 \]
    10. +-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-5}{6} + \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right)}\right) \cdot 2 \]
    11. associate-+r+N/A

      \[\leadsto \sin \color{blue}{\left(\left(\pi \cdot \frac{-5}{6} + \frac{\mathsf{PI}\left(\right)}{2}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    12. lift-PI.f64N/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \frac{\color{blue}{\pi}}{2}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    13. mult-flipN/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \color{blue}{\pi \cdot \frac{1}{2}}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    14. metadata-evalN/A

      \[\leadsto \sin \left(\left(\pi \cdot \frac{-5}{6} + \pi \cdot \color{blue}{\frac{1}{2}}\right) + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    15. distribute-lft-outN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot \left(\frac{-5}{6} + \frac{1}{2}\right)} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    16. metadata-evalN/A

      \[\leadsto \sin \left(\pi \cdot \color{blue}{\frac{-1}{3}} + \sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}\right) \cdot 2 \]
    17. lower-fma.f64100.0

      \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\pi, -0.3333333333333333, \sin^{-1} \left(\frac{g}{h}\right) \cdot -0.3333333333333333\right)\right)} \cdot 2 \]
    18. lift-*.f64N/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, \frac{-1}{3}, \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}}\right)\right) \cdot 2 \]
    19. *-commutativeN/A

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, \frac{-1}{3}, \color{blue}{\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right)\right) \cdot 2 \]
    20. lower-*.f64100.0

      \[\leadsto \sin \left(\mathsf{fma}\left(\pi, -0.3333333333333333, \color{blue}{-0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right)\right) \cdot 2 \]
  6. Applied rewrites100.0%

    \[\leadsto \sin \color{blue}{\left(\mathsf{fma}\left(\pi, -0.3333333333333333, -0.3333333333333333 \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)\right)} \cdot 2 \]
  7. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \sin \color{blue}{\left(\pi \cdot \frac{-1}{3} + \frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)\right)} \cdot 2 \]
    2. lift-*.f64N/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} + \color{blue}{\frac{-1}{3} \cdot \sin^{-1} \left(\frac{g}{h}\right)}\right) \cdot 2 \]
    3. *-commutativeN/A

      \[\leadsto \sin \left(\pi \cdot \frac{-1}{3} + \color{blue}{\sin^{-1} \left(\frac{g}{h}\right) \cdot \frac{-1}{3}}\right) \cdot 2 \]
    4. distribute-rgt-outN/A

      \[\leadsto \sin \color{blue}{\left(\frac{-1}{3} \cdot \left(\pi + \sin^{-1} \left(\frac{g}{h}\right)\right)\right)} \cdot 2 \]
    5. *-commutativeN/A

      \[\leadsto \sin \color{blue}{\left(\left(\pi + \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    6. lower-*.f64N/A

      \[\leadsto \sin \color{blue}{\left(\left(\pi + \sin^{-1} \left(\frac{g}{h}\right)\right) \cdot \frac{-1}{3}\right)} \cdot 2 \]
    7. +-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\left(\sin^{-1} \left(\frac{g}{h}\right) + \pi\right)} \cdot \frac{-1}{3}\right) \cdot 2 \]
    8. lower-+.f64100.0

      \[\leadsto \sin \left(\color{blue}{\left(\sin^{-1} \left(\frac{g}{h}\right) + \pi\right)} \cdot -0.3333333333333333\right) \cdot 2 \]
  8. Applied rewrites100.0%

    \[\leadsto \sin \color{blue}{\left(\left(\sin^{-1} \left(\frac{g}{h}\right) + \pi\right) \cdot -0.3333333333333333\right)} \cdot 2 \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2025150 
(FPCore (g h)
  :name "2-ancestry mixing, negative discriminant"
  :precision binary64
  (* 2.0 (cos (+ (/ (* 2.0 PI) 3.0) (/ (acos (/ (- g) h)) 3.0)))))