(sqrt (+ (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3))) (* -1/2 (+ -1 (cos (- z3 z2))))))

Percentage Accurate: 57.3% → 96.2%
Time: 14.4s
Alternatives: 17
Speedup: 1.0×

Specification

?
\[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (sqrt
 (+
  (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3)))
  (* -1/2 (+ -1 (cos (- z3 z2)))))))
double code(double z1, double z0, double z2, double z3) {
	return sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + (-0.5 * (-1.0 + cos((z3 - z2))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(((((-0.5d0) * ((-1.0d0) + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + ((-0.5d0) * ((-1.0d0) + cos((z3 - z2))))))
end function
public static double code(double z1, double z0, double z2, double z3) {
	return Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * (Math.cos(z2) * Math.cos(z3))) + (-0.5 * (-1.0 + Math.cos((z3 - z2))))));
}
def code(z1, z0, z2, z3):
	return math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * (math.cos(z2) * math.cos(z3))) + (-0.5 * (-1.0 + math.cos((z3 - z2))))))
function code(z1, z0, z2, z3)
	return sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * Float64(cos(z2) * cos(z3))) + Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2))))))
end
function tmp = code(z1, z0, z2, z3)
	tmp = sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + (-0.5 * (-1.0 + cos((z3 - z2))))));
end
code[z1_, z0_, z2_, z3_] := N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}

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 17 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: 57.3% accurate, 1.0× speedup?

\[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (sqrt
 (+
  (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3)))
  (* -1/2 (+ -1 (cos (- z3 z2)))))))
double code(double z1, double z0, double z2, double z3) {
	return sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + (-0.5 * (-1.0 + cos((z3 - z2))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(((((-0.5d0) * ((-1.0d0) + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + ((-0.5d0) * ((-1.0d0) + cos((z3 - z2))))))
end function
public static double code(double z1, double z0, double z2, double z3) {
	return Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * (Math.cos(z2) * Math.cos(z3))) + (-0.5 * (-1.0 + Math.cos((z3 - z2))))));
}
def code(z1, z0, z2, z3):
	return math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * (math.cos(z2) * math.cos(z3))) + (-0.5 * (-1.0 + math.cos((z3 - z2))))))
function code(z1, z0, z2, z3)
	return sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * Float64(cos(z2) * cos(z3))) + Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2))))))
end
function tmp = code(z1, z0, z2, z3)
	tmp = sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + (-0.5 * (-1.0 + cos((z3 - z2))))));
end
code[z1_, z0_, z2_, z3_] := N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}

Alternative 1: 96.2% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \cos \left(\mathsf{min}\left(z2, z3\right)\right)\\ t_1 := \cos \left(\mathsf{max}\left(z2, z3\right)\right)\\ t_2 := t\_0 \cdot t\_1\\ t_3 := t\_1 \cdot t\_0\\ t_4 := \mathsf{min}\left(z2, z3\right) - \mathsf{max}\left(z2, z3\right)\\ t_5 := \sin t\_4\\ \mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_2 + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{max}\left(z2, z3\right) - \mathsf{min}\left(z2, z3\right)\right)\right)} \leq 0:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_2 + \frac{-1}{2} \cdot \frac{t\_5 \cdot \left(-t\_5\right)}{\cos t\_4 + 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot t\_2 + \frac{-1}{2} \cdot \left(-1 + \left(\sin \left(\mathsf{min}\left(z2, z3\right)\right) \cdot \frac{\sin \left(\mathsf{max}\left(z2, z3\right)\right)}{t\_3} - -1\right) \cdot t\_3\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (cos (fmin z2 z3)))
       (t_1 (cos (fmax z2 z3)))
       (t_2 (* t_0 t_1))
       (t_3 (* t_1 t_0))
       (t_4 (- (fmin z2 z3) (fmax z2 z3)))
       (t_5 (sin t_4)))
  (if (<=
       (sqrt
        (+
         (* (* -1/2 (+ -1 (cos (- z1 z0)))) t_2)
         (* -1/2 (+ -1 (cos (- (fmax z2 z3) (fmin z2 z3)))))))
       0)
    (sqrt
     (+
      (* (* -1/2 (+ -1 (sin (- z1 (- z0 (* PI 1/2)))))) t_2)
      (* -1/2 (/ (* t_5 (- t_5)) (+ (cos t_4) 1)))))
    (sqrt
     (+
      (*
       (* -1/2 (+ (+ -1 (* (cos z1) (cos z0))) (* (sin z0) (sin z1))))
       t_2)
      (*
       -1/2
       (+
        -1
        (*
         (- (* (sin (fmin z2 z3)) (/ (sin (fmax z2 z3)) t_3)) -1)
         t_3))))))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(fmin(z2, z3));
	double t_1 = cos(fmax(z2, z3));
	double t_2 = t_0 * t_1;
	double t_3 = t_1 * t_0;
	double t_4 = fmin(z2, z3) - fmax(z2, z3);
	double t_5 = sin(t_4);
	double tmp;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_2) + (-0.5 * (-1.0 + cos((fmax(z2, z3) - fmin(z2, z3))))))) <= 0.0) {
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (((double) M_PI) * 0.5)))))) * t_2) + (-0.5 * ((t_5 * -t_5) / (cos(t_4) + 1.0)))));
	} else {
		tmp = sqrt((((-0.5 * ((-1.0 + (cos(z1) * cos(z0))) + (sin(z0) * sin(z1)))) * t_2) + (-0.5 * (-1.0 + (((sin(fmin(z2, z3)) * (sin(fmax(z2, z3)) / t_3)) - -1.0) * t_3)))));
	}
	return tmp;
}
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(fmin(z2, z3));
	double t_1 = Math.cos(fmax(z2, z3));
	double t_2 = t_0 * t_1;
	double t_3 = t_1 * t_0;
	double t_4 = fmin(z2, z3) - fmax(z2, z3);
	double t_5 = Math.sin(t_4);
	double tmp;
	if (Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * t_2) + (-0.5 * (-1.0 + Math.cos((fmax(z2, z3) - fmin(z2, z3))))))) <= 0.0) {
		tmp = Math.sqrt((((-0.5 * (-1.0 + Math.sin((z1 - (z0 - (Math.PI * 0.5)))))) * t_2) + (-0.5 * ((t_5 * -t_5) / (Math.cos(t_4) + 1.0)))));
	} else {
		tmp = Math.sqrt((((-0.5 * ((-1.0 + (Math.cos(z1) * Math.cos(z0))) + (Math.sin(z0) * Math.sin(z1)))) * t_2) + (-0.5 * (-1.0 + (((Math.sin(fmin(z2, z3)) * (Math.sin(fmax(z2, z3)) / t_3)) - -1.0) * t_3)))));
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(fmin(z2, z3))
	t_1 = math.cos(fmax(z2, z3))
	t_2 = t_0 * t_1
	t_3 = t_1 * t_0
	t_4 = fmin(z2, z3) - fmax(z2, z3)
	t_5 = math.sin(t_4)
	tmp = 0
	if math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * t_2) + (-0.5 * (-1.0 + math.cos((fmax(z2, z3) - fmin(z2, z3))))))) <= 0.0:
		tmp = math.sqrt((((-0.5 * (-1.0 + math.sin((z1 - (z0 - (math.pi * 0.5)))))) * t_2) + (-0.5 * ((t_5 * -t_5) / (math.cos(t_4) + 1.0)))))
	else:
		tmp = math.sqrt((((-0.5 * ((-1.0 + (math.cos(z1) * math.cos(z0))) + (math.sin(z0) * math.sin(z1)))) * t_2) + (-0.5 * (-1.0 + (((math.sin(fmin(z2, z3)) * (math.sin(fmax(z2, z3)) / t_3)) - -1.0) * t_3)))))
	return tmp
function code(z1, z0, z2, z3)
	t_0 = cos(fmin(z2, z3))
	t_1 = cos(fmax(z2, z3))
	t_2 = Float64(t_0 * t_1)
	t_3 = Float64(t_1 * t_0)
	t_4 = Float64(fmin(z2, z3) - fmax(z2, z3))
	t_5 = sin(t_4)
	tmp = 0.0
	if (sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * t_2) + Float64(-0.5 * Float64(-1.0 + cos(Float64(fmax(z2, z3) - fmin(z2, z3))))))) <= 0.0)
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + sin(Float64(z1 - Float64(z0 - Float64(pi * 0.5)))))) * t_2) + Float64(-0.5 * Float64(Float64(t_5 * Float64(-t_5)) / Float64(cos(t_4) + 1.0)))));
	else
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(Float64(-1.0 + Float64(cos(z1) * cos(z0))) + Float64(sin(z0) * sin(z1)))) * t_2) + Float64(-0.5 * Float64(-1.0 + Float64(Float64(Float64(sin(fmin(z2, z3)) * Float64(sin(fmax(z2, z3)) / t_3)) - -1.0) * t_3)))));
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(min(z2, z3));
	t_1 = cos(max(z2, z3));
	t_2 = t_0 * t_1;
	t_3 = t_1 * t_0;
	t_4 = min(z2, z3) - max(z2, z3);
	t_5 = sin(t_4);
	tmp = 0.0;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_2) + (-0.5 * (-1.0 + cos((max(z2, z3) - min(z2, z3))))))) <= 0.0)
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (pi * 0.5)))))) * t_2) + (-0.5 * ((t_5 * -t_5) / (cos(t_4) + 1.0)))));
	else
		tmp = sqrt((((-0.5 * ((-1.0 + (cos(z1) * cos(z0))) + (sin(z0) * sin(z1)))) * t_2) + (-0.5 * (-1.0 + (((sin(min(z2, z3)) * (sin(max(z2, z3)) / t_3)) - -1.0) * t_3)))));
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[Cos[N[Min[z2, z3], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[Max[z2, z3], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$0), $MachinePrecision]}, Block[{t$95$4 = N[(N[Min[z2, z3], $MachinePrecision] - N[Max[z2, z3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[t$95$4], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(N[Max[z2, z3], $MachinePrecision] - N[Min[z2, z3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0], N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Sin[N[(z1 - N[(z0 - N[(Pi * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] + N[(-1/2 * N[(N[(t$95$5 * (-t$95$5)), $MachinePrecision] / N[(N[Cos[t$95$4], $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(-1/2 * N[(N[(-1 + N[(N[Cos[z1], $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] + N[(-1/2 * N[(-1 + N[(N[(N[(N[Sin[N[Min[z2, z3], $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[Max[z2, z3], $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \cos \left(\mathsf{min}\left(z2, z3\right)\right)\\
t_1 := \cos \left(\mathsf{max}\left(z2, z3\right)\right)\\
t_2 := t\_0 \cdot t\_1\\
t_3 := t\_1 \cdot t\_0\\
t_4 := \mathsf{min}\left(z2, z3\right) - \mathsf{max}\left(z2, z3\right)\\
t_5 := \sin t\_4\\
\mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_2 + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{max}\left(z2, z3\right) - \mathsf{min}\left(z2, z3\right)\right)\right)} \leq 0:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_2 + \frac{-1}{2} \cdot \frac{t\_5 \cdot \left(-t\_5\right)}{\cos t\_4 + 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot t\_2 + \frac{-1}{2} \cdot \left(-1 + \left(\sin \left(\mathsf{min}\left(z2, z3\right)\right) \cdot \frac{\sin \left(\mathsf{max}\left(z2, z3\right)\right)}{t\_3} - -1\right) \cdot t\_3\right)}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2)))))) < -0.0

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 - z0\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. associate-+l-N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \color{blue}{\left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-PI.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\pi} \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z3 - z2\right)\right)\right)}\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z3 - z2\right)}\right)\right)\right)} \]
      4. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      6. lift-cos.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z2 - z3\right)}\right)} \]
      7. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z2 - z3\right)\right)}} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) + -1\right)}} \]
      9. add-flip-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(\mathsf{neg}\left(-1\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \left(z2 - z3\right) - \color{blue}{1}\right)} \]
      11. flip--N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      12. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      13. lower-unsound--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      14. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      15. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      16. lower-unsound-+.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\color{blue}{\cos \left(z2 - z3\right) + 1}}} \]
    5. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right)} \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \color{blue}{\cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1}}{\cos \left(z2 - z3\right) + 1}} \]
      7. sub-1-cosN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(\sin \left(z2 - z3\right) \cdot \sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right)} \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}{\cos \left(z2 - z3\right) + 1}} \]
      11. lower-neg.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \color{blue}{\left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      12. lower-sin.f6432.0%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \left(-\color{blue}{\sin \left(z2 - z3\right)}\right)}{\cos \left(z2 - z3\right) + 1}} \]
    7. Applied rewrites32.0%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]

    if -0.0 < (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2))))))

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      10. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right)} \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      14. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2} \cdot \sin z3}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      15. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \color{blue}{\sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      18. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)}\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
      21. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z1 - z0\right)\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z1 - z0\right)\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z1 - z0\right)}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z0 - z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z0 \cdot \cos z1 + \sin z0 \cdot \sin z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z0} \cdot \cos z1 + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\cos z0 \cdot \color{blue}{\cos z1} + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z0 \cdot \cos z1} + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. associate-+r+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z0 \cdot \cos z1\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      11. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z0 \cdot \cos z1\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      12. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\left(-1 + \cos z0 \cdot \cos z1\right)} + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      13. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z0 \cdot \cos z1}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      14. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z1 \cdot \cos z0}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z1 \cdot \cos z0}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      16. lift-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \color{blue}{\sin z1}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \color{blue}{\sin z0 \cdot \sin z1}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      18. lower-sin.f6493.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \color{blue}{\sin z0} \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    5. Applied rewrites93.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} + 1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. add-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \color{blue}{-1}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. lower--.f6493.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z3 \cdot \cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. associate-/l*N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. lower-/.f6493.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    7. Applied rewrites93.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2} - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 96.2% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \cos z2 \cdot \cos z3\\ t_1 := \cos z3 \cdot \cos z2\\ t_2 := \sin \left(z2 - z3\right)\\ \mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq 0:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_2 \cdot \left(-t\_2\right)}{\cos \left(z2 - z3\right) + 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{t\_1}\right) \cdot t\_1\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z2) (cos z3)))
       (t_1 (* (cos z3) (cos z2)))
       (t_2 (sin (- z2 z3))))
  (if (<=
       (sqrt
        (+
         (* (* -1/2 (+ -1 (cos (- z1 z0)))) t_0)
         (* -1/2 (+ -1 (cos (- z3 z2))))))
       0)
    (sqrt
     (+
      (* (* -1/2 (+ -1 (sin (- z1 (- z0 (* PI 1/2)))))) t_0)
      (* -1/2 (/ (* t_2 (- t_2)) (+ (cos (- z2 z3)) 1)))))
    (sqrt
     (+
      (*
       (* -1/2 (+ (+ -1 (* (cos z1) (cos z0))) (* (sin z0) (sin z1))))
       t_0)
      (* -1/2 (+ -1 (* (+ 1 (/ (* (sin z2) (sin z3)) t_1)) t_1))))))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(z2) * cos(z3);
	double t_1 = cos(z3) * cos(z2);
	double t_2 = sin((z2 - z3));
	double tmp;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.0) {
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (((double) M_PI) * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = sqrt((((-0.5 * ((-1.0 + (cos(z1) * cos(z0))) + (sin(z0) * sin(z1)))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((sin(z2) * sin(z3)) / t_1)) * t_1)))));
	}
	return tmp;
}
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(z2) * Math.cos(z3);
	double t_1 = Math.cos(z3) * Math.cos(z2);
	double t_2 = Math.sin((z2 - z3));
	double tmp;
	if (Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + Math.cos((z3 - z2)))))) <= 0.0) {
		tmp = Math.sqrt((((-0.5 * (-1.0 + Math.sin((z1 - (z0 - (Math.PI * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (Math.cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = Math.sqrt((((-0.5 * ((-1.0 + (Math.cos(z1) * Math.cos(z0))) + (Math.sin(z0) * Math.sin(z1)))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((Math.sin(z2) * Math.sin(z3)) / t_1)) * t_1)))));
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(z2) * math.cos(z3)
	t_1 = math.cos(z3) * math.cos(z2)
	t_2 = math.sin((z2 - z3))
	tmp = 0
	if math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + math.cos((z3 - z2)))))) <= 0.0:
		tmp = math.sqrt((((-0.5 * (-1.0 + math.sin((z1 - (z0 - (math.pi * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (math.cos((z2 - z3)) + 1.0)))))
	else:
		tmp = math.sqrt((((-0.5 * ((-1.0 + (math.cos(z1) * math.cos(z0))) + (math.sin(z0) * math.sin(z1)))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((math.sin(z2) * math.sin(z3)) / t_1)) * t_1)))))
	return tmp
function code(z1, z0, z2, z3)
	t_0 = Float64(cos(z2) * cos(z3))
	t_1 = Float64(cos(z3) * cos(z2))
	t_2 = sin(Float64(z2 - z3))
	tmp = 0.0
	if (sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * t_0) + Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2)))))) <= 0.0)
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + sin(Float64(z1 - Float64(z0 - Float64(pi * 0.5)))))) * t_0) + Float64(-0.5 * Float64(Float64(t_2 * Float64(-t_2)) / Float64(cos(Float64(z2 - z3)) + 1.0)))));
	else
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(Float64(-1.0 + Float64(cos(z1) * cos(z0))) + Float64(sin(z0) * sin(z1)))) * t_0) + Float64(-0.5 * Float64(-1.0 + Float64(Float64(1.0 + Float64(Float64(sin(z2) * sin(z3)) / t_1)) * t_1)))));
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(z2) * cos(z3);
	t_1 = cos(z3) * cos(z2);
	t_2 = sin((z2 - z3));
	tmp = 0.0;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.0)
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (pi * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (cos((z2 - z3)) + 1.0)))));
	else
		tmp = sqrt((((-0.5 * ((-1.0 + (cos(z1) * cos(z0))) + (sin(z0) * sin(z1)))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((sin(z2) * sin(z3)) / t_1)) * t_1)))));
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0], N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Sin[N[(z1 - N[(z0 - N[(Pi * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(N[(t$95$2 * (-t$95$2)), $MachinePrecision] / N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(-1/2 * N[(N[(-1 + N[(N[Cos[z1], $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(-1 + N[(N[(1 + N[(N[(N[Sin[z2], $MachinePrecision] * N[Sin[z3], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos z2 \cdot \cos z3\\
t_1 := \cos z3 \cdot \cos z2\\
t_2 := \sin \left(z2 - z3\right)\\
\mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq 0:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_2 \cdot \left(-t\_2\right)}{\cos \left(z2 - z3\right) + 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{t\_1}\right) \cdot t\_1\right)}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2)))))) < -0.0

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 - z0\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. associate-+l-N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \color{blue}{\left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-PI.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\pi} \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z3 - z2\right)\right)\right)}\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z3 - z2\right)}\right)\right)\right)} \]
      4. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      6. lift-cos.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z2 - z3\right)}\right)} \]
      7. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z2 - z3\right)\right)}} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) + -1\right)}} \]
      9. add-flip-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(\mathsf{neg}\left(-1\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \left(z2 - z3\right) - \color{blue}{1}\right)} \]
      11. flip--N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      12. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      13. lower-unsound--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      14. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      15. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      16. lower-unsound-+.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\color{blue}{\cos \left(z2 - z3\right) + 1}}} \]
    5. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right)} \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \color{blue}{\cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1}}{\cos \left(z2 - z3\right) + 1}} \]
      7. sub-1-cosN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(\sin \left(z2 - z3\right) \cdot \sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right)} \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}{\cos \left(z2 - z3\right) + 1}} \]
      11. lower-neg.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \color{blue}{\left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      12. lower-sin.f6432.0%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \left(-\color{blue}{\sin \left(z2 - z3\right)}\right)}{\cos \left(z2 - z3\right) + 1}} \]
    7. Applied rewrites32.0%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]

    if -0.0 < (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2))))))

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      10. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right)} \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      14. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2} \cdot \sin z3}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      15. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \color{blue}{\sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      18. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)}\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
      21. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z1 - z0\right)\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z1 - z0\right)\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z1 - z0\right)}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z0 - z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z0 \cdot \cos z1 + \sin z0 \cdot \sin z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z0} \cdot \cos z1 + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\cos z0 \cdot \color{blue}{\cos z1} + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z0 \cdot \cos z1} + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. associate-+r+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z0 \cdot \cos z1\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      11. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z0 \cdot \cos z1\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      12. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\left(-1 + \cos z0 \cdot \cos z1\right)} + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      13. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z0 \cdot \cos z1}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      14. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z1 \cdot \cos z0}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z1 \cdot \cos z0}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      16. lift-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \color{blue}{\sin z1}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \color{blue}{\sin z0 \cdot \sin z1}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      18. lower-sin.f6493.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \color{blue}{\sin z0} \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    5. Applied rewrites93.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 96.2% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \cos z2 \cdot \cos z3\\ t_1 := \cos z3 \cdot \cos z2\\ t_2 := \sin \left(z2 - z3\right)\\ \mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq 0:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_2 \cdot \left(-t\_2\right)}{\cos \left(z2 - z3\right) + 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\cos z1 \cdot \cos z0 + \left(\sin z0 \cdot \sin z1 - 1\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{t\_1}\right) \cdot t\_1\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z2) (cos z3)))
       (t_1 (* (cos z3) (cos z2)))
       (t_2 (sin (- z2 z3))))
  (if (<=
       (sqrt
        (+
         (* (* -1/2 (+ -1 (cos (- z1 z0)))) t_0)
         (* -1/2 (+ -1 (cos (- z3 z2))))))
       0)
    (sqrt
     (+
      (* (* -1/2 (+ -1 (sin (- z1 (- z0 (* PI 1/2)))))) t_0)
      (* -1/2 (/ (* t_2 (- t_2)) (+ (cos (- z2 z3)) 1)))))
    (sqrt
     (+
      (*
       (* -1/2 (+ (* (cos z1) (cos z0)) (- (* (sin z0) (sin z1)) 1)))
       t_0)
      (* -1/2 (+ -1 (* (+ 1 (/ (* (sin z2) (sin z3)) t_1)) t_1))))))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(z2) * cos(z3);
	double t_1 = cos(z3) * cos(z2);
	double t_2 = sin((z2 - z3));
	double tmp;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.0) {
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (((double) M_PI) * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = sqrt((((-0.5 * ((cos(z1) * cos(z0)) + ((sin(z0) * sin(z1)) - 1.0))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((sin(z2) * sin(z3)) / t_1)) * t_1)))));
	}
	return tmp;
}
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(z2) * Math.cos(z3);
	double t_1 = Math.cos(z3) * Math.cos(z2);
	double t_2 = Math.sin((z2 - z3));
	double tmp;
	if (Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + Math.cos((z3 - z2)))))) <= 0.0) {
		tmp = Math.sqrt((((-0.5 * (-1.0 + Math.sin((z1 - (z0 - (Math.PI * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (Math.cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = Math.sqrt((((-0.5 * ((Math.cos(z1) * Math.cos(z0)) + ((Math.sin(z0) * Math.sin(z1)) - 1.0))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((Math.sin(z2) * Math.sin(z3)) / t_1)) * t_1)))));
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(z2) * math.cos(z3)
	t_1 = math.cos(z3) * math.cos(z2)
	t_2 = math.sin((z2 - z3))
	tmp = 0
	if math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + math.cos((z3 - z2)))))) <= 0.0:
		tmp = math.sqrt((((-0.5 * (-1.0 + math.sin((z1 - (z0 - (math.pi * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (math.cos((z2 - z3)) + 1.0)))))
	else:
		tmp = math.sqrt((((-0.5 * ((math.cos(z1) * math.cos(z0)) + ((math.sin(z0) * math.sin(z1)) - 1.0))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((math.sin(z2) * math.sin(z3)) / t_1)) * t_1)))))
	return tmp
function code(z1, z0, z2, z3)
	t_0 = Float64(cos(z2) * cos(z3))
	t_1 = Float64(cos(z3) * cos(z2))
	t_2 = sin(Float64(z2 - z3))
	tmp = 0.0
	if (sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * t_0) + Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2)))))) <= 0.0)
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + sin(Float64(z1 - Float64(z0 - Float64(pi * 0.5)))))) * t_0) + Float64(-0.5 * Float64(Float64(t_2 * Float64(-t_2)) / Float64(cos(Float64(z2 - z3)) + 1.0)))));
	else
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(Float64(cos(z1) * cos(z0)) + Float64(Float64(sin(z0) * sin(z1)) - 1.0))) * t_0) + Float64(-0.5 * Float64(-1.0 + Float64(Float64(1.0 + Float64(Float64(sin(z2) * sin(z3)) / t_1)) * t_1)))));
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(z2) * cos(z3);
	t_1 = cos(z3) * cos(z2);
	t_2 = sin((z2 - z3));
	tmp = 0.0;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.0)
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (pi * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (cos((z2 - z3)) + 1.0)))));
	else
		tmp = sqrt((((-0.5 * ((cos(z1) * cos(z0)) + ((sin(z0) * sin(z1)) - 1.0))) * t_0) + (-0.5 * (-1.0 + ((1.0 + ((sin(z2) * sin(z3)) / t_1)) * t_1)))));
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0], N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Sin[N[(z1 - N[(z0 - N[(Pi * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(N[(t$95$2 * (-t$95$2)), $MachinePrecision] / N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(-1/2 * N[(N[(N[Cos[z1], $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(-1 + N[(N[(1 + N[(N[(N[Sin[z2], $MachinePrecision] * N[Sin[z3], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos z2 \cdot \cos z3\\
t_1 := \cos z3 \cdot \cos z2\\
t_2 := \sin \left(z2 - z3\right)\\
\mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq 0:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_2 \cdot \left(-t\_2\right)}{\cos \left(z2 - z3\right) + 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\cos z1 \cdot \cos z0 + \left(\sin z0 \cdot \sin z1 - 1\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{t\_1}\right) \cdot t\_1\right)}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2)))))) < -0.0

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 - z0\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. associate-+l-N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \color{blue}{\left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-PI.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\pi} \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z3 - z2\right)\right)\right)}\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z3 - z2\right)}\right)\right)\right)} \]
      4. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      6. lift-cos.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z2 - z3\right)}\right)} \]
      7. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z2 - z3\right)\right)}} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) + -1\right)}} \]
      9. add-flip-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(\mathsf{neg}\left(-1\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \left(z2 - z3\right) - \color{blue}{1}\right)} \]
      11. flip--N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      12. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      13. lower-unsound--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      14. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      15. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      16. lower-unsound-+.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\color{blue}{\cos \left(z2 - z3\right) + 1}}} \]
    5. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right)} \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \color{blue}{\cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1}}{\cos \left(z2 - z3\right) + 1}} \]
      7. sub-1-cosN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(\sin \left(z2 - z3\right) \cdot \sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right)} \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}{\cos \left(z2 - z3\right) + 1}} \]
      11. lower-neg.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \color{blue}{\left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      12. lower-sin.f6432.0%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \left(-\color{blue}{\sin \left(z2 - z3\right)}\right)}{\cos \left(z2 - z3\right) + 1}} \]
    7. Applied rewrites32.0%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]

    if -0.0 < (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2))))))

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      10. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right)} \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      14. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2} \cdot \sin z3}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      15. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \color{blue}{\sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      18. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)}\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
      21. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z1 - z0\right)\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z1 - z0\right) + -1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z1 - z0\right)} + -1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z1 - z0\right)} + -1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\cos \color{blue}{\left(\mathsf{neg}\left(\left(z0 - z1\right)\right)\right)} + -1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\cos \left(\mathsf{neg}\left(\color{blue}{\left(z0 - z1\right)}\right)\right) + -1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z0 - z1\right)} + -1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z0 - z1\right)} + -1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\cos \left(z0 - z1\right) + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. sub-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z0 - z1\right) - 1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      11. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z0 - z1\right)} - 1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      12. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z0 - z1\right)} - 1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      13. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\left(\cos z0 \cdot \cos z1 + \sin z0 \cdot \sin z1\right)} - 1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      14. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z0} \cdot \cos z1 + \sin z0 \cdot \sin z1\right) - 1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      15. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(\cos z0 \cdot \color{blue}{\cos z1} + \sin z0 \cdot \sin z1\right) - 1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z0 \cdot \cos z1} + \sin z0 \cdot \sin z1\right) - 1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      17. associate--l+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\cos z0 \cdot \cos z1 + \left(\sin z0 \cdot \sin z1 - 1\right)\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      18. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\cos z0 \cdot \cos z1 + \left(\sin z0 \cdot \sin z1 - 1\right)\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\cos z0 \cdot \cos z1} + \left(\sin z0 \cdot \sin z1 - 1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\cos z1 \cdot \cos z0} + \left(\sin z0 \cdot \sin z1 - 1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      21. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\cos z1 \cdot \cos z0} + \left(\sin z0 \cdot \sin z1 - 1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      22. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\cos z1 \cdot \cos z0 + \color{blue}{\left(\sin z0 \cdot \sin z1 - 1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    5. Applied rewrites93.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\cos z1 \cdot \cos z0 + \left(\sin z0 \cdot \sin z1 - 1\right)\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 96.2% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \cos z2 \cdot \cos z3\\ t_1 := \sin \left(z2 - z3\right)\\ \mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq 0:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_1 \cdot \left(-t\_1\right)}{\cos \left(z2 - z3\right) + 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \frac{\tan z3}{\cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z2) (cos z3))) (t_1 (sin (- z2 z3))))
  (if (<=
       (sqrt
        (+
         (* (* -1/2 (+ -1 (cos (- z1 z0)))) t_0)
         (* -1/2 (+ -1 (cos (- z3 z2))))))
       0)
    (sqrt
     (+
      (* (* -1/2 (+ -1 (sin (- z1 (- z0 (* PI 1/2)))))) t_0)
      (* -1/2 (/ (* t_1 (- t_1)) (+ (cos (- z2 z3)) 1)))))
    (sqrt
     (+
      (*
       (* -1/2 (+ (+ -1 (* (cos z1) (cos z0))) (* (sin z0) (sin z1))))
       t_0)
      (*
       -1/2
       (+
        -1
        (*
         (- (* (sin z2) (/ (tan z3) (cos z2))) -1)
         (* (cos z3) (cos z2))))))))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(z2) * cos(z3);
	double t_1 = sin((z2 - z3));
	double tmp;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.0) {
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (((double) M_PI) * 0.5)))))) * t_0) + (-0.5 * ((t_1 * -t_1) / (cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = sqrt((((-0.5 * ((-1.0 + (cos(z1) * cos(z0))) + (sin(z0) * sin(z1)))) * t_0) + (-0.5 * (-1.0 + (((sin(z2) * (tan(z3) / cos(z2))) - -1.0) * (cos(z3) * cos(z2)))))));
	}
	return tmp;
}
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(z2) * Math.cos(z3);
	double t_1 = Math.sin((z2 - z3));
	double tmp;
	if (Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + Math.cos((z3 - z2)))))) <= 0.0) {
		tmp = Math.sqrt((((-0.5 * (-1.0 + Math.sin((z1 - (z0 - (Math.PI * 0.5)))))) * t_0) + (-0.5 * ((t_1 * -t_1) / (Math.cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = Math.sqrt((((-0.5 * ((-1.0 + (Math.cos(z1) * Math.cos(z0))) + (Math.sin(z0) * Math.sin(z1)))) * t_0) + (-0.5 * (-1.0 + (((Math.sin(z2) * (Math.tan(z3) / Math.cos(z2))) - -1.0) * (Math.cos(z3) * Math.cos(z2)))))));
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(z2) * math.cos(z3)
	t_1 = math.sin((z2 - z3))
	tmp = 0
	if math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + math.cos((z3 - z2)))))) <= 0.0:
		tmp = math.sqrt((((-0.5 * (-1.0 + math.sin((z1 - (z0 - (math.pi * 0.5)))))) * t_0) + (-0.5 * ((t_1 * -t_1) / (math.cos((z2 - z3)) + 1.0)))))
	else:
		tmp = math.sqrt((((-0.5 * ((-1.0 + (math.cos(z1) * math.cos(z0))) + (math.sin(z0) * math.sin(z1)))) * t_0) + (-0.5 * (-1.0 + (((math.sin(z2) * (math.tan(z3) / math.cos(z2))) - -1.0) * (math.cos(z3) * math.cos(z2)))))))
	return tmp
function code(z1, z0, z2, z3)
	t_0 = Float64(cos(z2) * cos(z3))
	t_1 = sin(Float64(z2 - z3))
	tmp = 0.0
	if (sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * t_0) + Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2)))))) <= 0.0)
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + sin(Float64(z1 - Float64(z0 - Float64(pi * 0.5)))))) * t_0) + Float64(-0.5 * Float64(Float64(t_1 * Float64(-t_1)) / Float64(cos(Float64(z2 - z3)) + 1.0)))));
	else
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(Float64(-1.0 + Float64(cos(z1) * cos(z0))) + Float64(sin(z0) * sin(z1)))) * t_0) + Float64(-0.5 * Float64(-1.0 + Float64(Float64(Float64(sin(z2) * Float64(tan(z3) / cos(z2))) - -1.0) * Float64(cos(z3) * cos(z2)))))));
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(z2) * cos(z3);
	t_1 = sin((z2 - z3));
	tmp = 0.0;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.0)
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (pi * 0.5)))))) * t_0) + (-0.5 * ((t_1 * -t_1) / (cos((z2 - z3)) + 1.0)))));
	else
		tmp = sqrt((((-0.5 * ((-1.0 + (cos(z1) * cos(z0))) + (sin(z0) * sin(z1)))) * t_0) + (-0.5 * (-1.0 + (((sin(z2) * (tan(z3) / cos(z2))) - -1.0) * (cos(z3) * cos(z2)))))));
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0], N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Sin[N[(z1 - N[(z0 - N[(Pi * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(N[(t$95$1 * (-t$95$1)), $MachinePrecision] / N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(N[(-1/2 * N[(N[(-1 + N[(N[Cos[z1], $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[z0], $MachinePrecision] * N[Sin[z1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(-1 + N[(N[(N[(N[Sin[z2], $MachinePrecision] * N[(N[Tan[z3], $MachinePrecision] / N[Cos[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision] * N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos z2 \cdot \cos z3\\
t_1 := \sin \left(z2 - z3\right)\\
\mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq 0:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_1 \cdot \left(-t\_1\right)}{\cos \left(z2 - z3\right) + 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \frac{\tan z3}{\cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2)))))) < -0.0

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 - z0\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. associate-+l-N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \color{blue}{\left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-PI.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\pi} \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z3 - z2\right)\right)\right)}\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z3 - z2\right)}\right)\right)\right)} \]
      4. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      6. lift-cos.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z2 - z3\right)}\right)} \]
      7. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z2 - z3\right)\right)}} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) + -1\right)}} \]
      9. add-flip-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(\mathsf{neg}\left(-1\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \left(z2 - z3\right) - \color{blue}{1}\right)} \]
      11. flip--N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      12. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      13. lower-unsound--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      14. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      15. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      16. lower-unsound-+.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\color{blue}{\cos \left(z2 - z3\right) + 1}}} \]
    5. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right)} \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \color{blue}{\cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1}}{\cos \left(z2 - z3\right) + 1}} \]
      7. sub-1-cosN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(\sin \left(z2 - z3\right) \cdot \sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right)} \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}{\cos \left(z2 - z3\right) + 1}} \]
      11. lower-neg.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \color{blue}{\left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      12. lower-sin.f6432.0%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \left(-\color{blue}{\sin \left(z2 - z3\right)}\right)}{\cos \left(z2 - z3\right) + 1}} \]
    7. Applied rewrites32.0%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]

    if -0.0 < (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2))))))

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      10. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right)} \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      14. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2} \cdot \sin z3}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      15. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \color{blue}{\sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      18. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)}\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
      21. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z1 - z0\right)\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z1 - z0\right)\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z1 - z0\right)}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z0 - z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z0 \cdot \cos z1 + \sin z0 \cdot \sin z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z0} \cdot \cos z1 + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\cos z0 \cdot \color{blue}{\cos z1} + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z0 \cdot \cos z1} + \sin z0 \cdot \sin z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. associate-+r+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z0 \cdot \cos z1\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      11. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z0 \cdot \cos z1\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      12. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\color{blue}{\left(-1 + \cos z0 \cdot \cos z1\right)} + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      13. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z0 \cdot \cos z1}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      14. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z1 \cdot \cos z0}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \color{blue}{\cos z1 \cdot \cos z0}\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      16. lift-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \color{blue}{\sin z1}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \color{blue}{\sin z0 \cdot \sin z1}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      18. lower-sin.f6493.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \color{blue}{\sin z0} \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    5. Applied rewrites93.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)}\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} + 1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. add-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \color{blue}{-1}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. lower--.f6493.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z3 \cdot \cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. associate-/l*N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. lower-/.f6493.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    7. Applied rewrites93.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2} - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    8. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \frac{\sin z3}{\color{blue}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. associate-/r*N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\frac{\frac{\sin z3}{\cos z3}}{\cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. lower-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\frac{\frac{\sin z3}{\cos z3}}{\cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. lift-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \frac{\frac{\color{blue}{\sin z3}}{\cos z3}}{\cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \frac{\frac{\sin z3}{\color{blue}{\cos z3}}}{\cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. quot-tanN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \frac{\color{blue}{\tan z3}}{\cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. lower-tan.f6493.6%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \frac{\color{blue}{\tan z3}}{\cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    9. Applied rewrites93.6%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\frac{\tan z3}{\cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 83.9% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \cos z3 \cdot \cos z2\\ t_1 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(t\_0 + \left(\sin z3 \cdot \sin z2 - 1\right)\right)}\\ \mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\ \;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z3) (cos z2)))
       (t_1
        (sqrt
         (+
          (*
           (*
            -1/2
            (+
             -1
             (+
              (* (sin z1) (cos (+ (- z0) (* PI 1/2))))
              (* (cos z0) (cos z1)))))
           (* (cos z2) (cos z3)))
          (* -1/2 (+ t_0 (- (* (sin z3) (sin z2)) 1)))))))
  (if (<= z3 -8318957063997755/39614081257132168796771975168)
    t_1
    (if (<= z3 3475661731392059/75557863725914323419136)
      (sqrt
       (+
        (304-z0z1z2z3z4
         t_0
         -1/2
         (- (* (cos z1) (cos z0)) 1)
         1/2
         (* (sin z1) (sin z0)))
        (* -1/2 (+ -1 (cos (- z3 z2))))))
      t_1))))
\begin{array}{l}
t_0 := \cos z3 \cdot \cos z2\\
t_1 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(t\_0 + \left(\sin z3 \cdot \sin z2 - 1\right)\right)}\\
\mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\
\;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z3 < -2.0999999999999999e-13 or 4.6000000000000002e-8 < z3

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 - z0\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. sub-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 + \left(\mathsf{neg}\left(z0\right)\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. associate-+l+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 + \left(\left(\mathsf{neg}\left(z0\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. sin-sumN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z1 \cdot \cos \left(\left(\mathsf{neg}\left(z0\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos z1 \cdot \sin \left(\left(\mathsf{neg}\left(z0\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(\mathsf{neg}\left(z0\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos z1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(z0\right)\right)}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(\mathsf{neg}\left(z0\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos z1 \cdot \color{blue}{\cos z0}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z1 \cdot \cos \left(\left(\mathsf{neg}\left(z0\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites57.9%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z3 - z2\right)\right)\right)}\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z3 - z2\right)}\right)\right)\right)} \]
      4. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      6. lift-cos.f6457.9%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z2 - z3\right)}\right)} \]
      7. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z2 - z3\right)\right)}} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) + -1\right)}} \]
      9. add-flip-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(\mathsf{neg}\left(-1\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \left(z2 - z3\right) - \color{blue}{1}\right)} \]
      11. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z2 - z3\right)} - 1\right)} \]
      12. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z2 - z3\right)} - 1\right)} \]
      13. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\left(\cos z2 \cdot \cos z3 + \sin z2 \cdot \sin z3\right)} - 1\right)} \]
      14. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2} \cdot \cos z3 + \sin z2 \cdot \sin z3\right) - 1\right)} \]
      15. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \color{blue}{\cos z3} + \sin z2 \cdot \sin z3\right) - 1\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z2 \cdot \sin z3\right) - 1\right)} \]
      17. lift-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \color{blue}{\sin z2} \cdot \sin z3\right) - 1\right)} \]
      18. lift-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \sin z2 \cdot \color{blue}{\sin z3}\right) - 1\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \color{blue}{\sin z2 \cdot \sin z3}\right) - 1\right)} \]
      20. associate--l+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z2 \cdot \sin z3 - 1\right)\right)}} \]
      21. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z2 \cdot \sin z3 - 1\right)\right)}} \]
    5. Applied rewrites74.3%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(\sin z1 \cdot \cos \left(\left(-z0\right) + \pi \cdot \frac{1}{2}\right) + \cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z3 \cdot \cos z2 + \left(\sin z3 \cdot \sin z2 - 1\right)\right)}} \]

    if -2.0999999999999999e-13 < z3 < 4.6000000000000002e-8

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z1 \cdot \cos z0 + \sin z1 \cdot \sin z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right)} \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0} \cdot \sin z1}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \color{blue}{\sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      14. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0} \cdot \cos z1}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      15. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \color{blue}{\cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      18. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\color{blue}{\cos z0} \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      19. lower-cos.f6472.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \color{blue}{\cos z1}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites72.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Applied rewrites72.7%

      \[\leadsto \sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(\left(\cos z3 \cdot \cos z2\right), \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 83.5% accurate, 0.2× speedup?

\[\begin{array}{l} t_0 := \cos \left(\mathsf{min}\left(z2, z3\right)\right)\\ t_1 := \cos \left(\mathsf{max}\left(z2, z3\right)\right)\\ t_2 := \cos \left(\mathsf{max}\left(z1, z0\right)\right) \cdot \cos \left(\mathsf{min}\left(z1, z0\right)\right)\\ t_3 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin \left(\mathsf{max}\left(z1, z0\right)\right) \cdot \sin \left(\mathsf{min}\left(z1, z0\right)\right)}{t\_2}\right) \cdot t\_2\right)\right) \cdot \left(\left(\cos \left(\mathsf{min}\left(z2, z3\right) - \mathsf{max}\left(z2, z3\right)\right) + \cos \left(\mathsf{max}\left(z2, z3\right) + \mathsf{min}\left(z2, z3\right)\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{max}\left(z2, z3\right) - \mathsf{min}\left(z2, z3\right)\right)\right)}\\ t_4 := t\_1 \cdot t\_0\\ \mathbf{if}\;\mathsf{min}\left(z1, z0\right) \leq \frac{-8106479329266893}{18014398509481984}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;\mathsf{min}\left(z1, z0\right) \leq \frac{7684599350631545}{41538374868278621028243970633760768}:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{min}\left(z1, z0\right) - \mathsf{max}\left(z1, z0\right)\right)\right)\right) \cdot \left(t\_0 \cdot t\_1\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin \left(\mathsf{max}\left(z2, z3\right)\right)}{t\_4} \cdot \sin \left(\mathsf{min}\left(z2, z3\right)\right) - -1\right) \cdot t\_4\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (cos (fmin z2 z3)))
       (t_1 (cos (fmax z2 z3)))
       (t_2 (* (cos (fmax z1 z0)) (cos (fmin z1 z0))))
       (t_3
        (sqrt
         (+
          (*
           (*
            -1/2
            (+
             -1
             (*
              (+ 1 (/ (* (sin (fmax z1 z0)) (sin (fmin z1 z0))) t_2))
              t_2)))
           (*
            (+
             (cos (- (fmin z2 z3) (fmax z2 z3)))
             (cos (+ (fmax z2 z3) (fmin z2 z3))))
            1/2))
          (* -1/2 (+ -1 (cos (- (fmax z2 z3) (fmin z2 z3))))))))
       (t_4 (* t_1 t_0)))
  (if (<= (fmin z1 z0) -8106479329266893/18014398509481984)
    t_3
    (if (<=
         (fmin z1 z0)
         7684599350631545/41538374868278621028243970633760768)
      (sqrt
       (+
        (*
         (* -1/2 (+ -1 (cos (- (fmin z1 z0) (fmax z1 z0)))))
         (* t_0 t_1))
        (*
         -1/2
         (+
          -1
          (*
           (- (* (/ (sin (fmax z2 z3)) t_4) (sin (fmin z2 z3))) -1)
           t_4)))))
      t_3))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(fmin(z2, z3));
	double t_1 = cos(fmax(z2, z3));
	double t_2 = cos(fmax(z1, z0)) * cos(fmin(z1, z0));
	double t_3 = sqrt((((-0.5 * (-1.0 + ((1.0 + ((sin(fmax(z1, z0)) * sin(fmin(z1, z0))) / t_2)) * t_2))) * ((cos((fmin(z2, z3) - fmax(z2, z3))) + cos((fmax(z2, z3) + fmin(z2, z3)))) * 0.5)) + (-0.5 * (-1.0 + cos((fmax(z2, z3) - fmin(z2, z3)))))));
	double t_4 = t_1 * t_0;
	double tmp;
	if (fmin(z1, z0) <= -0.45) {
		tmp = t_3;
	} else if (fmin(z1, z0) <= 1.85e-19) {
		tmp = sqrt((((-0.5 * (-1.0 + cos((fmin(z1, z0) - fmax(z1, z0))))) * (t_0 * t_1)) + (-0.5 * (-1.0 + ((((sin(fmax(z2, z3)) / t_4) * sin(fmin(z2, z3))) - -1.0) * t_4)))));
	} else {
		tmp = t_3;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_0 = cos(fmin(z2, z3))
    t_1 = cos(fmax(z2, z3))
    t_2 = cos(fmax(z1, z0)) * cos(fmin(z1, z0))
    t_3 = sqrt(((((-0.5d0) * ((-1.0d0) + ((1.0d0 + ((sin(fmax(z1, z0)) * sin(fmin(z1, z0))) / t_2)) * t_2))) * ((cos((fmin(z2, z3) - fmax(z2, z3))) + cos((fmax(z2, z3) + fmin(z2, z3)))) * 0.5d0)) + ((-0.5d0) * ((-1.0d0) + cos((fmax(z2, z3) - fmin(z2, z3)))))))
    t_4 = t_1 * t_0
    if (fmin(z1, z0) <= (-0.45d0)) then
        tmp = t_3
    else if (fmin(z1, z0) <= 1.85d-19) then
        tmp = sqrt(((((-0.5d0) * ((-1.0d0) + cos((fmin(z1, z0) - fmax(z1, z0))))) * (t_0 * t_1)) + ((-0.5d0) * ((-1.0d0) + ((((sin(fmax(z2, z3)) / t_4) * sin(fmin(z2, z3))) - (-1.0d0)) * t_4)))))
    else
        tmp = t_3
    end if
    code = tmp
end function
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(fmin(z2, z3));
	double t_1 = Math.cos(fmax(z2, z3));
	double t_2 = Math.cos(fmax(z1, z0)) * Math.cos(fmin(z1, z0));
	double t_3 = Math.sqrt((((-0.5 * (-1.0 + ((1.0 + ((Math.sin(fmax(z1, z0)) * Math.sin(fmin(z1, z0))) / t_2)) * t_2))) * ((Math.cos((fmin(z2, z3) - fmax(z2, z3))) + Math.cos((fmax(z2, z3) + fmin(z2, z3)))) * 0.5)) + (-0.5 * (-1.0 + Math.cos((fmax(z2, z3) - fmin(z2, z3)))))));
	double t_4 = t_1 * t_0;
	double tmp;
	if (fmin(z1, z0) <= -0.45) {
		tmp = t_3;
	} else if (fmin(z1, z0) <= 1.85e-19) {
		tmp = Math.sqrt((((-0.5 * (-1.0 + Math.cos((fmin(z1, z0) - fmax(z1, z0))))) * (t_0 * t_1)) + (-0.5 * (-1.0 + ((((Math.sin(fmax(z2, z3)) / t_4) * Math.sin(fmin(z2, z3))) - -1.0) * t_4)))));
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(fmin(z2, z3))
	t_1 = math.cos(fmax(z2, z3))
	t_2 = math.cos(fmax(z1, z0)) * math.cos(fmin(z1, z0))
	t_3 = math.sqrt((((-0.5 * (-1.0 + ((1.0 + ((math.sin(fmax(z1, z0)) * math.sin(fmin(z1, z0))) / t_2)) * t_2))) * ((math.cos((fmin(z2, z3) - fmax(z2, z3))) + math.cos((fmax(z2, z3) + fmin(z2, z3)))) * 0.5)) + (-0.5 * (-1.0 + math.cos((fmax(z2, z3) - fmin(z2, z3)))))))
	t_4 = t_1 * t_0
	tmp = 0
	if fmin(z1, z0) <= -0.45:
		tmp = t_3
	elif fmin(z1, z0) <= 1.85e-19:
		tmp = math.sqrt((((-0.5 * (-1.0 + math.cos((fmin(z1, z0) - fmax(z1, z0))))) * (t_0 * t_1)) + (-0.5 * (-1.0 + ((((math.sin(fmax(z2, z3)) / t_4) * math.sin(fmin(z2, z3))) - -1.0) * t_4)))))
	else:
		tmp = t_3
	return tmp
function code(z1, z0, z2, z3)
	t_0 = cos(fmin(z2, z3))
	t_1 = cos(fmax(z2, z3))
	t_2 = Float64(cos(fmax(z1, z0)) * cos(fmin(z1, z0)))
	t_3 = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + Float64(Float64(1.0 + Float64(Float64(sin(fmax(z1, z0)) * sin(fmin(z1, z0))) / t_2)) * t_2))) * Float64(Float64(cos(Float64(fmin(z2, z3) - fmax(z2, z3))) + cos(Float64(fmax(z2, z3) + fmin(z2, z3)))) * 0.5)) + Float64(-0.5 * Float64(-1.0 + cos(Float64(fmax(z2, z3) - fmin(z2, z3)))))))
	t_4 = Float64(t_1 * t_0)
	tmp = 0.0
	if (fmin(z1, z0) <= -0.45)
		tmp = t_3;
	elseif (fmin(z1, z0) <= 1.85e-19)
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(fmin(z1, z0) - fmax(z1, z0))))) * Float64(t_0 * t_1)) + Float64(-0.5 * Float64(-1.0 + Float64(Float64(Float64(Float64(sin(fmax(z2, z3)) / t_4) * sin(fmin(z2, z3))) - -1.0) * t_4)))));
	else
		tmp = t_3;
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(min(z2, z3));
	t_1 = cos(max(z2, z3));
	t_2 = cos(max(z1, z0)) * cos(min(z1, z0));
	t_3 = sqrt((((-0.5 * (-1.0 + ((1.0 + ((sin(max(z1, z0)) * sin(min(z1, z0))) / t_2)) * t_2))) * ((cos((min(z2, z3) - max(z2, z3))) + cos((max(z2, z3) + min(z2, z3)))) * 0.5)) + (-0.5 * (-1.0 + cos((max(z2, z3) - min(z2, z3)))))));
	t_4 = t_1 * t_0;
	tmp = 0.0;
	if (min(z1, z0) <= -0.45)
		tmp = t_3;
	elseif (min(z1, z0) <= 1.85e-19)
		tmp = sqrt((((-0.5 * (-1.0 + cos((min(z1, z0) - max(z1, z0))))) * (t_0 * t_1)) + (-0.5 * (-1.0 + ((((sin(max(z2, z3)) / t_4) * sin(min(z2, z3))) - -1.0) * t_4)))));
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[Cos[N[Min[z2, z3], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[Max[z2, z3], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[Max[z1, z0], $MachinePrecision]], $MachinePrecision] * N[Cos[N[Min[z1, z0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[(N[(1 + N[(N[(N[Sin[N[Max[z1, z0], $MachinePrecision]], $MachinePrecision] * N[Sin[N[Min[z1, z0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(N[Min[z2, z3], $MachinePrecision] - N[Max[z2, z3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(N[Max[z2, z3], $MachinePrecision] + N[Min[z2, z3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(N[Max[z2, z3], $MachinePrecision] - N[Min[z2, z3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 * t$95$0), $MachinePrecision]}, If[LessEqual[N[Min[z1, z0], $MachinePrecision], -8106479329266893/18014398509481984], t$95$3, If[LessEqual[N[Min[z1, z0], $MachinePrecision], 7684599350631545/41538374868278621028243970633760768], N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(N[Min[z1, z0], $MachinePrecision] - N[Max[z1, z0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(-1/2 * N[(-1 + N[(N[(N[(N[(N[Sin[N[Max[z2, z3], $MachinePrecision]], $MachinePrecision] / t$95$4), $MachinePrecision] * N[Sin[N[Min[z2, z3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
t_0 := \cos \left(\mathsf{min}\left(z2, z3\right)\right)\\
t_1 := \cos \left(\mathsf{max}\left(z2, z3\right)\right)\\
t_2 := \cos \left(\mathsf{max}\left(z1, z0\right)\right) \cdot \cos \left(\mathsf{min}\left(z1, z0\right)\right)\\
t_3 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin \left(\mathsf{max}\left(z1, z0\right)\right) \cdot \sin \left(\mathsf{min}\left(z1, z0\right)\right)}{t\_2}\right) \cdot t\_2\right)\right) \cdot \left(\left(\cos \left(\mathsf{min}\left(z2, z3\right) - \mathsf{max}\left(z2, z3\right)\right) + \cos \left(\mathsf{max}\left(z2, z3\right) + \mathsf{min}\left(z2, z3\right)\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{max}\left(z2, z3\right) - \mathsf{min}\left(z2, z3\right)\right)\right)}\\
t_4 := t\_1 \cdot t\_0\\
\mathbf{if}\;\mathsf{min}\left(z1, z0\right) \leq \frac{-8106479329266893}{18014398509481984}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;\mathsf{min}\left(z1, z0\right) \leq \frac{7684599350631545}{41538374868278621028243970633760768}:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{min}\left(z1, z0\right) - \mathsf{max}\left(z1, z0\right)\right)\right)\right) \cdot \left(t\_0 \cdot t\_1\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin \left(\mathsf{max}\left(z2, z3\right)\right)}{t\_4} \cdot \sin \left(\mathsf{min}\left(z2, z3\right)\right) - -1\right) \cdot t\_4\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_3\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z1 < -0.45000000000000001 or 1.85e-19 < z1

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z1 \cdot \cos z0 + \sin z1 \cdot \sin z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right)} \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0} \cdot \sin z1}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \color{blue}{\sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      14. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0} \cdot \cos z1}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      15. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \color{blue}{\cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      18. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\color{blue}{\cos z0} \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      19. lower-cos.f6472.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \color{blue}{\cos z1}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites72.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\color{blue}{\cos z2} \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \color{blue}{\cos z3}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. cos-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \color{blue}{\frac{\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)}{2}} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \frac{\cos \color{blue}{\left(z3 + z2\right)} + \cos \left(z2 - z3\right)}{2} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \frac{\cos \color{blue}{\left(z3 + z2\right)} + \cos \left(z2 - z3\right)}{2} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \frac{\color{blue}{\cos \left(z3 + z2\right)} + \cos \left(z2 - z3\right)}{2} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \frac{\cos \left(z3 + z2\right) + \cos \color{blue}{\left(z2 - z3\right)}}{2} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \frac{\cos \left(z3 + z2\right) + \color{blue}{\cos \left(z2 - z3\right)}}{2} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \frac{\color{blue}{\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)}}{2} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      12. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right) \cdot \color{blue}{\frac{1}{2}}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      13. lift-*.f6473.1%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      14. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\color{blue}{\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right)} \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      15. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\color{blue}{\left(\cos \left(z2 - z3\right) + \cos \left(z3 + z2\right)\right)} \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      16. lower-+.f6473.1%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \left(\color{blue}{\left(\cos \left(z2 - z3\right) + \cos \left(z3 + z2\right)\right)} \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    5. Applied rewrites73.1%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z2 - z3\right) + \cos \left(z3 + z2\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]

    if -0.45000000000000001 < z1 < 1.85e-19

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      10. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right)} \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      14. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2} \cdot \sin z3}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      15. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \color{blue}{\sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      18. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)}\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
      21. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} + 1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. add-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \color{blue}{-1}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. lower--.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z3 \cdot \cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. associate-/l*N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z3}{\cos z3 \cdot \cos z2} \cdot \sin z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z3}{\cos z3 \cdot \cos z2} \cdot \sin z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z3 \cdot \cos z2}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      13. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      14. lower-/.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z3}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      15. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z3 \cdot \cos z2}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      17. lift-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z3 \cdot \cos z2}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    5. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z3}{\cos z3 \cdot \cos z2} \cdot \sin z2 - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 83.5% accurate, 0.5× speedup?

\[\begin{array}{l} t_0 := \cos z3 \cdot \cos z2\\ t_1 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{t\_0} \cdot \sin z2 - -1\right) \cdot t\_0\right)}\\ \mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\ \;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z3) (cos z2)))
       (t_1
        (sqrt
         (+
          (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3)))
          (*
           -1/2
           (+ -1 (* (- (* (/ (sin z3) t_0) (sin z2)) -1) t_0)))))))
  (if (<= z3 -8318957063997755/39614081257132168796771975168)
    t_1
    (if (<= z3 3475661731392059/75557863725914323419136)
      (sqrt
       (+
        (304-z0z1z2z3z4
         t_0
         -1/2
         (- (* (cos z1) (cos z0)) 1)
         1/2
         (* (sin z1) (sin z0)))
        (* -1/2 (+ -1 (cos (- z3 z2))))))
      t_1))))
\begin{array}{l}
t_0 := \cos z3 \cdot \cos z2\\
t_1 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{t\_0} \cdot \sin z2 - -1\right) \cdot t\_0\right)}\\
\mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\
\;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z3 < -2.0999999999999999e-13 or 4.6000000000000002e-8 < z3

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      10. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right)} \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      14. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2} \cdot \sin z3}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      15. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \color{blue}{\sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      18. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)}\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
      21. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)}\right)} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} + 1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      3. add-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - \color{blue}{-1}\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      5. lower--.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2} - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      6. lift-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z3 \cdot \cos z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      8. associate-/l*N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \frac{\sin z3}{\cos z3 \cdot \cos z2}} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      9. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z3}{\cos z3 \cdot \cos z2} \cdot \sin z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z3}{\cos z3 \cdot \cos z2} \cdot \sin z2} - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z3 \cdot \cos z2}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      13. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      14. lower-/.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\frac{\sin z3}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      15. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z2 \cdot \cos z3}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z3 \cdot \cos z2}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
      17. lift-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\frac{\sin z3}{\color{blue}{\cos z3 \cdot \cos z2}} \cdot \sin z2 - -1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]
    5. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\frac{\sin z3}{\cos z3 \cdot \cos z2} \cdot \sin z2 - -1\right)} \cdot \left(\cos z3 \cdot \cos z2\right)\right)} \]

    if -2.0999999999999999e-13 < z3 < 4.6000000000000002e-8

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z1 \cdot \cos z0 + \sin z1 \cdot \sin z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right)} \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0} \cdot \sin z1}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \color{blue}{\sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      14. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0} \cdot \cos z1}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      15. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \color{blue}{\cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      18. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\color{blue}{\cos z0} \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      19. lower-cos.f6472.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \color{blue}{\cos z1}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites72.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Applied rewrites72.7%

      \[\leadsto \sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(\left(\cos z3 \cdot \cos z2\right), \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 83.5% accurate, 0.5× speedup?

\[\begin{array}{l} t_0 := \cos z3 \cdot \cos z2\\ t_1 := \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\\ t_2 := \sin z2 \cdot \sin z3\\ \mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\ \;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(t\_0 + \left(t\_2 + -1\right)\right)}\\ \mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\ \;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{t\_2}{t\_0}\right) \cdot t\_0\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z3) (cos z2)))
       (t_1 (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3))))
       (t_2 (* (sin z2) (sin z3))))
  (if (<= z3 -8318957063997755/39614081257132168796771975168)
    (sqrt (+ t_1 (* -1/2 (+ t_0 (+ t_2 -1)))))
    (if (<= z3 3475661731392059/75557863725914323419136)
      (sqrt
       (+
        (304-z0z1z2z3z4
         t_0
         -1/2
         (- (* (cos z1) (cos z0)) 1)
         1/2
         (* (sin z1) (sin z0)))
        (* -1/2 (+ -1 (cos (- z3 z2))))))
      (sqrt (+ t_1 (* -1/2 (+ -1 (* (+ 1 (/ t_2 t_0)) t_0)))))))))
\begin{array}{l}
t_0 := \cos z3 \cdot \cos z2\\
t_1 := \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\\
t_2 := \sin z2 \cdot \sin z3\\
\mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\
\;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(t\_0 + \left(t\_2 + -1\right)\right)}\\

\mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\
\;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{t\_2}{t\_0}\right) \cdot t\_0\right)}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z3 < -2.0999999999999999e-13

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z3 - z2\right) + -1\right)}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z3 - z2\right)} + -1\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z3 - z2\right)} + -1\right)} \]
      5. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)} + -1\right)} \]
      6. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      10. associate-+l+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z3 \cdot \sin z2 + -1\right)\right)}} \]
      11. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z3 \cdot \sin z2 + -1\right)\right)}} \]
      12. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z2 \cdot \cos z3} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      13. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z3 \cdot \cos z2} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z3 \cdot \cos z2} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      15. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \color{blue}{\left(\sin z3 \cdot \sin z2 + -1\right)}\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2 \cdot \sin z3} + -1\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2 \cdot \sin z3} + -1\right)\right)} \]
      18. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2} \cdot \sin z3 + -1\right)\right)} \]
      19. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\sin z2 \cdot \color{blue}{\sin z3} + -1\right)\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z3 \cdot \cos z2 + \left(\sin z2 \cdot \sin z3 + -1\right)\right)}} \]

    if -2.0999999999999999e-13 < z3 < 4.6000000000000002e-8

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z1 \cdot \cos z0 + \sin z1 \cdot \sin z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right)} \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0} \cdot \sin z1}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \color{blue}{\sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      14. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0} \cdot \cos z1}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      15. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \color{blue}{\cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      18. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\color{blue}{\cos z0} \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      19. lower-cos.f6472.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \color{blue}{\cos z1}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites72.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Applied rewrites72.7%

      \[\leadsto \sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(\left(\cos z3 \cdot \cos z2\right), \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]

    if 4.6000000000000002e-8 < z3

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)}\right)} \]
      10. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}\right)} \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z3 \cdot \sin z2}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2 \cdot \sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      14. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z2} \cdot \sin z3}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      15. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \color{blue}{\sin z3}}{\cos z2 \cdot \cos z3}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z2 \cdot \cos z3}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      18. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\color{blue}{\cos z3 \cdot \cos z2}}\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)}\right)} \]
      20. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
      21. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \color{blue}{\left(\cos z3 \cdot \cos z2\right)}\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z2 \cdot \sin z3}{\cos z3 \cdot \cos z2}\right) \cdot \left(\cos z3 \cdot \cos z2\right)}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 83.5% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \cos z3 \cdot \cos z2\\ t_1 := \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\\ t_2 := \sin z2 \cdot \sin z3\\ \mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\ \;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(t\_0 + \left(t\_2 + -1\right)\right)}\\ \mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\ \;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(-1 + \left(t\_2 + t\_0\right)\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z3) (cos z2)))
       (t_1 (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3))))
       (t_2 (* (sin z2) (sin z3))))
  (if (<= z3 -8318957063997755/39614081257132168796771975168)
    (sqrt (+ t_1 (* -1/2 (+ t_0 (+ t_2 -1)))))
    (if (<= z3 3475661731392059/75557863725914323419136)
      (sqrt
       (+
        (304-z0z1z2z3z4
         t_0
         -1/2
         (- (* (cos z1) (cos z0)) 1)
         1/2
         (* (sin z1) (sin z0)))
        (* -1/2 (+ -1 (cos (- z3 z2))))))
      (sqrt (+ t_1 (* -1/2 (+ -1 (+ t_2 t_0)))))))))
\begin{array}{l}
t_0 := \cos z3 \cdot \cos z2\\
t_1 := \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\\
t_2 := \sin z2 \cdot \sin z3\\
\mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\
\;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(t\_0 + \left(t\_2 + -1\right)\right)}\\

\mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\
\;\;\;\;\sqrt{\mathsf{304\_z0z1z2z3z4}\left(t\_0, \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(-1 + \left(t\_2 + t\_0\right)\right)}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z3 < -2.0999999999999999e-13

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z3 - z2\right) + -1\right)}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z3 - z2\right)} + -1\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z3 - z2\right)} + -1\right)} \]
      5. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)} + -1\right)} \]
      6. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      10. associate-+l+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z3 \cdot \sin z2 + -1\right)\right)}} \]
      11. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z3 \cdot \sin z2 + -1\right)\right)}} \]
      12. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z2 \cdot \cos z3} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      13. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z3 \cdot \cos z2} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z3 \cdot \cos z2} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      15. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \color{blue}{\left(\sin z3 \cdot \sin z2 + -1\right)}\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2 \cdot \sin z3} + -1\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2 \cdot \sin z3} + -1\right)\right)} \]
      18. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2} \cdot \sin z3 + -1\right)\right)} \]
      19. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\sin z2 \cdot \color{blue}{\sin z3} + -1\right)\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z3 \cdot \cos z2 + \left(\sin z2 \cdot \sin z3 + -1\right)\right)}} \]

    if -2.0999999999999999e-13 < z3 < 4.6000000000000002e-8

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z1 \cdot \cos z0 + \sin z1 \cdot \sin z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. sum-to-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower-unsound-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}\right)} \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \color{blue}{\frac{\sin z1 \cdot \sin z0}{\cos z1 \cdot \cos z0}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0 \cdot \sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\color{blue}{\sin z0} \cdot \sin z1}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \color{blue}{\sin z1}}{\cos z1 \cdot \cos z0}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0 \cdot \cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      14. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\color{blue}{\cos z0} \cdot \cos z1}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      15. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \color{blue}{\cos z1}}\right) \cdot \left(\cos z1 \cdot \cos z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \color{blue}{\left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      18. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\color{blue}{\cos z0} \cdot \cos z1\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      19. lower-cos.f6472.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \color{blue}{\cos z1}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites72.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(1 + \frac{\sin z0 \cdot \sin z1}{\cos z0 \cdot \cos z1}\right) \cdot \left(\cos z0 \cdot \cos z1\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Applied rewrites72.7%

      \[\leadsto \sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(\left(\cos z3 \cdot \cos z2\right), \frac{-1}{2}, \left(\cos z1 \cdot \cos z0 - 1\right), \frac{1}{2}, \left(\sin z1 \cdot \sin z0\right)\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]

    if 4.6000000000000002e-8 < z3

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z3 \cdot \sin z2 + \cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z3 \cdot \sin z2 + \cos z2 \cdot \cos z3\right)}\right)} \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      12. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2} \cdot \sin z3 + \cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z2 \cdot \cos z3}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z3 \cdot \cos z2}\right)\right)} \]
      16. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z3 \cdot \cos z2}\right)\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z2 \cdot \sin z3 + \cos z3 \cdot \cos z2\right)}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 83.5% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \cos z3 \cdot \cos z2\\ t_1 := \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\\ t_2 := \sin z2 \cdot \sin z3\\ \mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\ \;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(t\_0 + \left(t\_2 + -1\right)\right)}\\ \mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\ \;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right) \cdot \cos z2\right) \cdot \cos z3\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(-1 + \left(t\_2 + t\_0\right)\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z3) (cos z2)))
       (t_1 (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3))))
       (t_2 (* (sin z2) (sin z3))))
  (if (<= z3 -8318957063997755/39614081257132168796771975168)
    (sqrt (+ t_1 (* -1/2 (+ t_0 (+ t_2 -1)))))
    (if (<= z3 3475661731392059/75557863725914323419136)
      (sqrt
       (*
        -1/2
        (+
         (- (cos (- z2 z3)) 1)
         (*
          (*
           (+ (- (* (cos z1) (cos z0)) 1) (* (sin z1) (sin z0)))
           (cos z2))
          (cos z3)))))
      (sqrt (+ t_1 (* -1/2 (+ -1 (+ t_2 t_0)))))))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(z3) * cos(z2);
	double t_1 = (-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3));
	double t_2 = sin(z2) * sin(z3);
	double tmp;
	if (z3 <= -2.1e-13) {
		tmp = sqrt((t_1 + (-0.5 * (t_0 + (t_2 + -1.0)))));
	} else if (z3 <= 4.6e-8) {
		tmp = sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + (((((cos(z1) * cos(z0)) - 1.0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	} else {
		tmp = sqrt((t_1 + (-0.5 * (-1.0 + (t_2 + t_0)))));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = cos(z3) * cos(z2)
    t_1 = ((-0.5d0) * ((-1.0d0) + cos((z1 - z0)))) * (cos(z2) * cos(z3))
    t_2 = sin(z2) * sin(z3)
    if (z3 <= (-2.1d-13)) then
        tmp = sqrt((t_1 + ((-0.5d0) * (t_0 + (t_2 + (-1.0d0))))))
    else if (z3 <= 4.6d-8) then
        tmp = sqrt(((-0.5d0) * ((cos((z2 - z3)) - 1.0d0) + (((((cos(z1) * cos(z0)) - 1.0d0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))))
    else
        tmp = sqrt((t_1 + ((-0.5d0) * ((-1.0d0) + (t_2 + t_0)))))
    end if
    code = tmp
end function
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(z3) * Math.cos(z2);
	double t_1 = (-0.5 * (-1.0 + Math.cos((z1 - z0)))) * (Math.cos(z2) * Math.cos(z3));
	double t_2 = Math.sin(z2) * Math.sin(z3);
	double tmp;
	if (z3 <= -2.1e-13) {
		tmp = Math.sqrt((t_1 + (-0.5 * (t_0 + (t_2 + -1.0)))));
	} else if (z3 <= 4.6e-8) {
		tmp = Math.sqrt((-0.5 * ((Math.cos((z2 - z3)) - 1.0) + (((((Math.cos(z1) * Math.cos(z0)) - 1.0) + (Math.sin(z1) * Math.sin(z0))) * Math.cos(z2)) * Math.cos(z3)))));
	} else {
		tmp = Math.sqrt((t_1 + (-0.5 * (-1.0 + (t_2 + t_0)))));
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(z3) * math.cos(z2)
	t_1 = (-0.5 * (-1.0 + math.cos((z1 - z0)))) * (math.cos(z2) * math.cos(z3))
	t_2 = math.sin(z2) * math.sin(z3)
	tmp = 0
	if z3 <= -2.1e-13:
		tmp = math.sqrt((t_1 + (-0.5 * (t_0 + (t_2 + -1.0)))))
	elif z3 <= 4.6e-8:
		tmp = math.sqrt((-0.5 * ((math.cos((z2 - z3)) - 1.0) + (((((math.cos(z1) * math.cos(z0)) - 1.0) + (math.sin(z1) * math.sin(z0))) * math.cos(z2)) * math.cos(z3)))))
	else:
		tmp = math.sqrt((t_1 + (-0.5 * (-1.0 + (t_2 + t_0)))))
	return tmp
function code(z1, z0, z2, z3)
	t_0 = Float64(cos(z3) * cos(z2))
	t_1 = Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * Float64(cos(z2) * cos(z3)))
	t_2 = Float64(sin(z2) * sin(z3))
	tmp = 0.0
	if (z3 <= -2.1e-13)
		tmp = sqrt(Float64(t_1 + Float64(-0.5 * Float64(t_0 + Float64(t_2 + -1.0)))));
	elseif (z3 <= 4.6e-8)
		tmp = sqrt(Float64(-0.5 * Float64(Float64(cos(Float64(z2 - z3)) - 1.0) + Float64(Float64(Float64(Float64(Float64(cos(z1) * cos(z0)) - 1.0) + Float64(sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	else
		tmp = sqrt(Float64(t_1 + Float64(-0.5 * Float64(-1.0 + Float64(t_2 + t_0)))));
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(z3) * cos(z2);
	t_1 = (-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3));
	t_2 = sin(z2) * sin(z3);
	tmp = 0.0;
	if (z3 <= -2.1e-13)
		tmp = sqrt((t_1 + (-0.5 * (t_0 + (t_2 + -1.0)))));
	elseif (z3 <= 4.6e-8)
		tmp = sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + (((((cos(z1) * cos(z0)) - 1.0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	else
		tmp = sqrt((t_1 + (-0.5 * (-1.0 + (t_2 + t_0)))));
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[z2], $MachinePrecision] * N[Sin[z3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z3, -8318957063997755/39614081257132168796771975168], N[Sqrt[N[(t$95$1 + N[(-1/2 * N[(t$95$0 + N[(t$95$2 + -1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z3, 3475661731392059/75557863725914323419136], N[Sqrt[N[(-1/2 * N[(N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision] + N[(N[(N[(N[(N[(N[Cos[z1], $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision] + N[(N[Sin[z1], $MachinePrecision] * N[Sin[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(t$95$1 + N[(-1/2 * N[(-1 + N[(t$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos z3 \cdot \cos z2\\
t_1 := \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\\
t_2 := \sin z2 \cdot \sin z3\\
\mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\
\;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(t\_0 + \left(t\_2 + -1\right)\right)}\\

\mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\
\;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right) \cdot \cos z2\right) \cdot \cos z3\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1 + \frac{-1}{2} \cdot \left(-1 + \left(t\_2 + t\_0\right)\right)}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z3 < -2.0999999999999999e-13

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z3 - z2\right) + -1\right)}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z3 - z2\right)} + -1\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z3 - z2\right)} + -1\right)} \]
      5. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)} + -1\right)} \]
      6. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      8. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right) + -1\right)} \]
      10. associate-+l+N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z3 \cdot \sin z2 + -1\right)\right)}} \]
      11. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z3 \cdot \sin z2 + -1\right)\right)}} \]
      12. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z2 \cdot \cos z3} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      13. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z3 \cdot \cos z2} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\color{blue}{\cos z3 \cdot \cos z2} + \left(\sin z3 \cdot \sin z2 + -1\right)\right)} \]
      15. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \color{blue}{\left(\sin z3 \cdot \sin z2 + -1\right)}\right)} \]
      16. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2 \cdot \sin z3} + -1\right)\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2 \cdot \sin z3} + -1\right)\right)} \]
      18. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\color{blue}{\sin z2} \cdot \sin z3 + -1\right)\right)} \]
      19. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos z3 \cdot \cos z2 + \left(\sin z2 \cdot \color{blue}{\sin z3} + -1\right)\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos z3 \cdot \cos z2 + \left(\sin z2 \cdot \sin z3 + -1\right)\right)}} \]

    if -2.0999999999999999e-13 < z3 < 4.6000000000000002e-8

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right)} \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      7. distribute-lft-outN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    3. Applied rewrites57.3%

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)}\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z3 \cdot \cos z2\right)} \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)} \]
      3. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\cos z3 \cdot \left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}\right)} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right) \cdot \cos z3}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right) \cdot \cos z3}\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right)} \cdot \cos z3\right)} \]
      7. lower-*.f6457.3%

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right)} \cdot \cos z3\right)} \]
    5. Applied rewrites57.3%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right) \cdot \cos z3}\right)} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\cos \left(z0 - z1\right) - 1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      2. sub-flipN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\cos \left(z0 - z1\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      3. metadata-evalN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\cos \left(z0 - z1\right) + \color{blue}{-1}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      4. +-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(-1 + \cos \left(z0 - z1\right)\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \color{blue}{\cos \left(z0 - z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      6. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \cos \color{blue}{\left(z0 - z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      7. cos-diffN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \color{blue}{\left(\cos z0 \cdot \cos z1 + \sin z0 \cdot \sin z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z0} \cdot \cos z1 + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      9. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z0 \cdot \color{blue}{\cos z1} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z1 \cdot \cos z0} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z1 \cdot \cos z0} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      12. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \color{blue}{\sin z0} \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      13. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \sin z0 \cdot \color{blue}{\sin z1}\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \color{blue}{\sin z0 \cdot \sin z1}\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      15. associate-+l+N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      16. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\color{blue}{\left(-1 + \cos z1 \cdot \cos z0\right)} + \sin z0 \cdot \sin z1\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      17. lift-+.f6472.7%

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
    7. Applied rewrites72.7%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]

    if 4.6000000000000002e-8 < z3

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z3 \cdot \sin z2 + \cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z3 \cdot \sin z2 + \cos z2 \cdot \cos z3\right)}\right)} \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      12. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2} \cdot \sin z3 + \cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z2 \cdot \cos z3}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z3 \cdot \cos z2}\right)\right)} \]
      16. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z3 \cdot \cos z2}\right)\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z2 \cdot \sin z3 + \cos z3 \cdot \cos z2\right)}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 83.5% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \cos z3 \cdot \cos z2\right)\right)}\\ \mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\ \;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right) \cdot \cos z2\right) \cdot \cos z3\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0
        (sqrt
         (+
          (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3)))
          (*
           -1/2
           (+ -1 (+ (* (sin z2) (sin z3)) (* (cos z3) (cos z2)))))))))
  (if (<= z3 -8318957063997755/39614081257132168796771975168)
    t_0
    (if (<= z3 3475661731392059/75557863725914323419136)
      (sqrt
       (*
        -1/2
        (+
         (- (cos (- z2 z3)) 1)
         (*
          (*
           (+ (- (* (cos z1) (cos z0)) 1) (* (sin z1) (sin z0)))
           (cos z2))
          (cos z3)))))
      t_0))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + (-0.5 * (-1.0 + ((sin(z2) * sin(z3)) + (cos(z3) * cos(z2)))))));
	double tmp;
	if (z3 <= -2.1e-13) {
		tmp = t_0;
	} else if (z3 <= 4.6e-8) {
		tmp = sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + (((((cos(z1) * cos(z0)) - 1.0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt(((((-0.5d0) * ((-1.0d0) + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + ((-0.5d0) * ((-1.0d0) + ((sin(z2) * sin(z3)) + (cos(z3) * cos(z2)))))))
    if (z3 <= (-2.1d-13)) then
        tmp = t_0
    else if (z3 <= 4.6d-8) then
        tmp = sqrt(((-0.5d0) * ((cos((z2 - z3)) - 1.0d0) + (((((cos(z1) * cos(z0)) - 1.0d0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * (Math.cos(z2) * Math.cos(z3))) + (-0.5 * (-1.0 + ((Math.sin(z2) * Math.sin(z3)) + (Math.cos(z3) * Math.cos(z2)))))));
	double tmp;
	if (z3 <= -2.1e-13) {
		tmp = t_0;
	} else if (z3 <= 4.6e-8) {
		tmp = Math.sqrt((-0.5 * ((Math.cos((z2 - z3)) - 1.0) + (((((Math.cos(z1) * Math.cos(z0)) - 1.0) + (Math.sin(z1) * Math.sin(z0))) * Math.cos(z2)) * Math.cos(z3)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * (math.cos(z2) * math.cos(z3))) + (-0.5 * (-1.0 + ((math.sin(z2) * math.sin(z3)) + (math.cos(z3) * math.cos(z2)))))))
	tmp = 0
	if z3 <= -2.1e-13:
		tmp = t_0
	elif z3 <= 4.6e-8:
		tmp = math.sqrt((-0.5 * ((math.cos((z2 - z3)) - 1.0) + (((((math.cos(z1) * math.cos(z0)) - 1.0) + (math.sin(z1) * math.sin(z0))) * math.cos(z2)) * math.cos(z3)))))
	else:
		tmp = t_0
	return tmp
function code(z1, z0, z2, z3)
	t_0 = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * Float64(cos(z2) * cos(z3))) + Float64(-0.5 * Float64(-1.0 + Float64(Float64(sin(z2) * sin(z3)) + Float64(cos(z3) * cos(z2)))))))
	tmp = 0.0
	if (z3 <= -2.1e-13)
		tmp = t_0;
	elseif (z3 <= 4.6e-8)
		tmp = sqrt(Float64(-0.5 * Float64(Float64(cos(Float64(z2 - z3)) - 1.0) + Float64(Float64(Float64(Float64(Float64(cos(z1) * cos(z0)) - 1.0) + Float64(sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * (cos(z2) * cos(z3))) + (-0.5 * (-1.0 + ((sin(z2) * sin(z3)) + (cos(z3) * cos(z2)))))));
	tmp = 0.0;
	if (z3 <= -2.1e-13)
		tmp = t_0;
	elseif (z3 <= 4.6e-8)
		tmp = sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + (((((cos(z1) * cos(z0)) - 1.0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1/2 * N[(-1 + N[(N[(N[Sin[z2], $MachinePrecision] * N[Sin[z3], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z3, -8318957063997755/39614081257132168796771975168], t$95$0, If[LessEqual[z3, 3475661731392059/75557863725914323419136], N[Sqrt[N[(-1/2 * N[(N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision] + N[(N[(N[(N[(N[(N[Cos[z1], $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision] + N[(N[Sin[z1], $MachinePrecision] * N[Sin[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \cos z3 \cdot \cos z2\right)\right)}\\
\mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\
\;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right) \cdot \cos z2\right) \cdot \cos z3\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z3 < -2.0999999999999999e-13 or 4.6000000000000002e-8 < z3

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z3 - z2\right)}\right)} \]
      3. cos-diffN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\cos z3 \cdot \cos z2 + \sin z3 \cdot \sin z2\right)}\right)} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z3} \cdot \cos z2 + \sin z3 \cdot \sin z2\right)\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\cos z3 \cdot \color{blue}{\cos z2} + \sin z3 \cdot \sin z2\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z3 \cdot \sin z2\right)\right)} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z3 \cdot \sin z2 + \cos z2 \cdot \cos z3\right)}\right)} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z3 \cdot \sin z2 + \cos z2 \cdot \cos z3\right)}\right)} \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2 \cdot \sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      12. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\color{blue}{\sin z2} \cdot \sin z3 + \cos z2 \cdot \cos z3\right)\right)} \]
      13. lower-sin.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \color{blue}{\sin z3} + \cos z2 \cdot \cos z3\right)\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z2 \cdot \cos z3}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z3 \cdot \cos z2}\right)\right)} \]
      16. lower-*.f6473.5%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \left(\sin z2 \cdot \sin z3 + \color{blue}{\cos z3 \cdot \cos z2}\right)\right)} \]
    3. Applied rewrites73.5%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\left(\sin z2 \cdot \sin z3 + \cos z3 \cdot \cos z2\right)}\right)} \]

    if -2.0999999999999999e-13 < z3 < 4.6000000000000002e-8

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right)} \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      7. distribute-lft-outN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    3. Applied rewrites57.3%

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)}\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z3 \cdot \cos z2\right)} \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)} \]
      3. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\cos z3 \cdot \left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}\right)} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right) \cdot \cos z3}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right) \cdot \cos z3}\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right)} \cdot \cos z3\right)} \]
      7. lower-*.f6457.3%

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right)} \cdot \cos z3\right)} \]
    5. Applied rewrites57.3%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right) \cdot \cos z3}\right)} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\cos \left(z0 - z1\right) - 1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      2. sub-flipN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\cos \left(z0 - z1\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      3. metadata-evalN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\cos \left(z0 - z1\right) + \color{blue}{-1}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      4. +-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(-1 + \cos \left(z0 - z1\right)\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \color{blue}{\cos \left(z0 - z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      6. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \cos \color{blue}{\left(z0 - z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      7. cos-diffN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \color{blue}{\left(\cos z0 \cdot \cos z1 + \sin z0 \cdot \sin z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z0} \cdot \cos z1 + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      9. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z0 \cdot \color{blue}{\cos z1} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z1 \cdot \cos z0} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z1 \cdot \cos z0} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      12. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \color{blue}{\sin z0} \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      13. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \sin z0 \cdot \color{blue}{\sin z1}\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \color{blue}{\sin z0 \cdot \sin z1}\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      15. associate-+l+N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      16. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\color{blue}{\left(-1 + \cos z1 \cdot \cos z0\right)} + \sin z0 \cdot \sin z1\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      17. lift-+.f6472.7%

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
    7. Applied rewrites72.7%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 83.2% accurate, 0.6× speedup?

\[\begin{array}{l} t_0 := \cos z3 \cdot \cos z2\\ t_1 := \sqrt{\frac{-1}{2} \cdot \left(t\_0 + \left(\sin z3 \cdot \sin z2 - \left(1 - \left(\cos \left(z0 - z1\right) - 1\right) \cdot t\_0\right)\right)\right)}\\ \mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\ \;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right) \cdot \cos z2\right) \cdot \cos z3\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z3) (cos z2)))
       (t_1
        (sqrt
         (*
          -1/2
          (+
           t_0
           (-
            (* (sin z3) (sin z2))
            (- 1 (* (- (cos (- z0 z1)) 1) t_0))))))))
  (if (<= z3 -8318957063997755/39614081257132168796771975168)
    t_1
    (if (<= z3 3475661731392059/75557863725914323419136)
      (sqrt
       (*
        -1/2
        (+
         (- (cos (- z2 z3)) 1)
         (*
          (*
           (+ (- (* (cos z1) (cos z0)) 1) (* (sin z1) (sin z0)))
           (cos z2))
          (cos z3)))))
      t_1))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(z3) * cos(z2);
	double t_1 = sqrt((-0.5 * (t_0 + ((sin(z3) * sin(z2)) - (1.0 - ((cos((z0 - z1)) - 1.0) * t_0))))));
	double tmp;
	if (z3 <= -2.1e-13) {
		tmp = t_1;
	} else if (z3 <= 4.6e-8) {
		tmp = sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + (((((cos(z1) * cos(z0)) - 1.0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos(z3) * cos(z2)
    t_1 = sqrt(((-0.5d0) * (t_0 + ((sin(z3) * sin(z2)) - (1.0d0 - ((cos((z0 - z1)) - 1.0d0) * t_0))))))
    if (z3 <= (-2.1d-13)) then
        tmp = t_1
    else if (z3 <= 4.6d-8) then
        tmp = sqrt(((-0.5d0) * ((cos((z2 - z3)) - 1.0d0) + (((((cos(z1) * cos(z0)) - 1.0d0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(z3) * Math.cos(z2);
	double t_1 = Math.sqrt((-0.5 * (t_0 + ((Math.sin(z3) * Math.sin(z2)) - (1.0 - ((Math.cos((z0 - z1)) - 1.0) * t_0))))));
	double tmp;
	if (z3 <= -2.1e-13) {
		tmp = t_1;
	} else if (z3 <= 4.6e-8) {
		tmp = Math.sqrt((-0.5 * ((Math.cos((z2 - z3)) - 1.0) + (((((Math.cos(z1) * Math.cos(z0)) - 1.0) + (Math.sin(z1) * Math.sin(z0))) * Math.cos(z2)) * Math.cos(z3)))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(z3) * math.cos(z2)
	t_1 = math.sqrt((-0.5 * (t_0 + ((math.sin(z3) * math.sin(z2)) - (1.0 - ((math.cos((z0 - z1)) - 1.0) * t_0))))))
	tmp = 0
	if z3 <= -2.1e-13:
		tmp = t_1
	elif z3 <= 4.6e-8:
		tmp = math.sqrt((-0.5 * ((math.cos((z2 - z3)) - 1.0) + (((((math.cos(z1) * math.cos(z0)) - 1.0) + (math.sin(z1) * math.sin(z0))) * math.cos(z2)) * math.cos(z3)))))
	else:
		tmp = t_1
	return tmp
function code(z1, z0, z2, z3)
	t_0 = Float64(cos(z3) * cos(z2))
	t_1 = sqrt(Float64(-0.5 * Float64(t_0 + Float64(Float64(sin(z3) * sin(z2)) - Float64(1.0 - Float64(Float64(cos(Float64(z0 - z1)) - 1.0) * t_0))))))
	tmp = 0.0
	if (z3 <= -2.1e-13)
		tmp = t_1;
	elseif (z3 <= 4.6e-8)
		tmp = sqrt(Float64(-0.5 * Float64(Float64(cos(Float64(z2 - z3)) - 1.0) + Float64(Float64(Float64(Float64(Float64(cos(z1) * cos(z0)) - 1.0) + Float64(sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(z3) * cos(z2);
	t_1 = sqrt((-0.5 * (t_0 + ((sin(z3) * sin(z2)) - (1.0 - ((cos((z0 - z1)) - 1.0) * t_0))))));
	tmp = 0.0;
	if (z3 <= -2.1e-13)
		tmp = t_1;
	elseif (z3 <= 4.6e-8)
		tmp = sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + (((((cos(z1) * cos(z0)) - 1.0) + (sin(z1) * sin(z0))) * cos(z2)) * cos(z3)))));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(-1/2 * N[(t$95$0 + N[(N[(N[Sin[z3], $MachinePrecision] * N[Sin[z2], $MachinePrecision]), $MachinePrecision] - N[(1 - N[(N[(N[Cos[N[(z0 - z1), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z3, -8318957063997755/39614081257132168796771975168], t$95$1, If[LessEqual[z3, 3475661731392059/75557863725914323419136], N[Sqrt[N[(-1/2 * N[(N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision] + N[(N[(N[(N[(N[(N[Cos[z1], $MachinePrecision] * N[Cos[z0], $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision] + N[(N[Sin[z1], $MachinePrecision] * N[Sin[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \cos z3 \cdot \cos z2\\
t_1 := \sqrt{\frac{-1}{2} \cdot \left(t\_0 + \left(\sin z3 \cdot \sin z2 - \left(1 - \left(\cos \left(z0 - z1\right) - 1\right) \cdot t\_0\right)\right)\right)}\\
\mathbf{if}\;z3 \leq \frac{-8318957063997755}{39614081257132168796771975168}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z3 \leq \frac{3475661731392059}{75557863725914323419136}:\\
\;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right) \cdot \cos z2\right) \cdot \cos z3\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z3 < -2.0999999999999999e-13 or 4.6000000000000002e-8 < z3

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right)} \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      7. distribute-lft-outN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    3. Applied rewrites57.3%

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\color{blue}{\left(\cos \left(z2 - z3\right) - 1\right)} + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)} \]
      3. associate-+l-N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z2 - z3\right)} - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z2 - z3\right)} - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      6. cos-diffN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\color{blue}{\left(\cos z2 \cdot \cos z3 + \sin z2 \cdot \sin z3\right)} - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2} \cdot \cos z3 + \sin z2 \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \color{blue}{\cos z3} + \sin z2 \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z2 \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      10. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \color{blue}{\sin z2} \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      11. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \sin z2 \cdot \color{blue}{\sin z3}\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      12. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \color{blue}{\sin z2 \cdot \sin z3}\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      13. associate--l+N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z2 \cdot \sin z3 - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)\right)}} \]
      14. lower-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z2 \cdot \sin z3 - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)\right)}} \]
    5. Applied rewrites73.4%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos z3 \cdot \cos z2 + \left(\sin z3 \cdot \sin z2 - \left(1 - \left(\cos \left(z0 - z1\right) - 1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)\right)\right)}} \]

    if -2.0999999999999999e-13 < z3 < 4.6000000000000002e-8

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right)} \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      7. distribute-lft-outN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    3. Applied rewrites57.3%

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)}\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z3 \cdot \cos z2\right)} \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)} \]
      3. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\cos z3 \cdot \left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}\right)} \]
      4. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right) \cdot \cos z3}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\cos z2 \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right) \cdot \cos z3}\right)} \]
      6. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right)} \cdot \cos z3\right)} \]
      7. lower-*.f6457.3%

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right)} \cdot \cos z3\right)} \]
    5. Applied rewrites57.3%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \color{blue}{\left(\left(\cos \left(z0 - z1\right) - 1\right) \cdot \cos z2\right) \cdot \cos z3}\right)} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\cos \left(z0 - z1\right) - 1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      2. sub-flipN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\cos \left(z0 - z1\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      3. metadata-evalN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\cos \left(z0 - z1\right) + \color{blue}{-1}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      4. +-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(-1 + \cos \left(z0 - z1\right)\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      5. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \color{blue}{\cos \left(z0 - z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      6. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \cos \color{blue}{\left(z0 - z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      7. cos-diffN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \color{blue}{\left(\cos z0 \cdot \cos z1 + \sin z0 \cdot \sin z1\right)}\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z0} \cdot \cos z1 + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      9. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z0 \cdot \color{blue}{\cos z1} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      10. *-commutativeN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z1 \cdot \cos z0} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\color{blue}{\cos z1 \cdot \cos z0} + \sin z0 \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      12. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \color{blue}{\sin z0} \cdot \sin z1\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      13. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \sin z0 \cdot \color{blue}{\sin z1}\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(-1 + \left(\cos z1 \cdot \cos z0 + \color{blue}{\sin z0 \cdot \sin z1}\right)\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      15. associate-+l+N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
      16. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\left(\color{blue}{\left(-1 + \cos z1 \cdot \cos z0\right)} + \sin z0 \cdot \sin z1\right) \cdot \cos z2\right) \cdot \cos z3\right)} \]
      17. lift-+.f6472.7%

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(-1 + \cos z1 \cdot \cos z0\right) + \sin z0 \cdot \sin z1\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
    7. Applied rewrites72.7%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\color{blue}{\left(\left(\cos z1 \cdot \cos z0 - 1\right) + \sin z1 \cdot \sin z0\right)} \cdot \cos z2\right) \cdot \cos z3\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 74.9% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \cos z2 \cdot \cos z3\\ t_1 := \cos z3 \cdot \cos z2\\ t_2 := \sin \left(z2 - z3\right)\\ \mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq \frac{7854277750134145}{72057594037927936}:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_2 \cdot \left(-t\_2\right)}{\cos \left(z2 - z3\right) + 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(t\_1 + \left(\sin z3 \cdot \sin z2 - \left(1 - \left(\cos \left(z0 - z1\right) - 1\right) \cdot t\_1\right)\right)\right)}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z2) (cos z3)))
       (t_1 (* (cos z3) (cos z2)))
       (t_2 (sin (- z2 z3))))
  (if (<=
       (sqrt
        (+
         (* (* -1/2 (+ -1 (cos (- z1 z0)))) t_0)
         (* -1/2 (+ -1 (cos (- z3 z2))))))
       7854277750134145/72057594037927936)
    (sqrt
     (+
      (* (* -1/2 (+ -1 (sin (- z1 (- z0 (* PI 1/2)))))) t_0)
      (* -1/2 (/ (* t_2 (- t_2)) (+ (cos (- z2 z3)) 1)))))
    (sqrt
     (*
      -1/2
      (+
       t_1
       (-
        (* (sin z3) (sin z2))
        (- 1 (* (- (cos (- z0 z1)) 1) t_1)))))))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(z2) * cos(z3);
	double t_1 = cos(z3) * cos(z2);
	double t_2 = sin((z2 - z3));
	double tmp;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.109) {
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (((double) M_PI) * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = sqrt((-0.5 * (t_1 + ((sin(z3) * sin(z2)) - (1.0 - ((cos((z0 - z1)) - 1.0) * t_1))))));
	}
	return tmp;
}
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(z2) * Math.cos(z3);
	double t_1 = Math.cos(z3) * Math.cos(z2);
	double t_2 = Math.sin((z2 - z3));
	double tmp;
	if (Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + Math.cos((z3 - z2)))))) <= 0.109) {
		tmp = Math.sqrt((((-0.5 * (-1.0 + Math.sin((z1 - (z0 - (Math.PI * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (Math.cos((z2 - z3)) + 1.0)))));
	} else {
		tmp = Math.sqrt((-0.5 * (t_1 + ((Math.sin(z3) * Math.sin(z2)) - (1.0 - ((Math.cos((z0 - z1)) - 1.0) * t_1))))));
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(z2) * math.cos(z3)
	t_1 = math.cos(z3) * math.cos(z2)
	t_2 = math.sin((z2 - z3))
	tmp = 0
	if math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + math.cos((z3 - z2)))))) <= 0.109:
		tmp = math.sqrt((((-0.5 * (-1.0 + math.sin((z1 - (z0 - (math.pi * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (math.cos((z2 - z3)) + 1.0)))))
	else:
		tmp = math.sqrt((-0.5 * (t_1 + ((math.sin(z3) * math.sin(z2)) - (1.0 - ((math.cos((z0 - z1)) - 1.0) * t_1))))))
	return tmp
function code(z1, z0, z2, z3)
	t_0 = Float64(cos(z2) * cos(z3))
	t_1 = Float64(cos(z3) * cos(z2))
	t_2 = sin(Float64(z2 - z3))
	tmp = 0.0
	if (sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * t_0) + Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2)))))) <= 0.109)
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + sin(Float64(z1 - Float64(z0 - Float64(pi * 0.5)))))) * t_0) + Float64(-0.5 * Float64(Float64(t_2 * Float64(-t_2)) / Float64(cos(Float64(z2 - z3)) + 1.0)))));
	else
		tmp = sqrt(Float64(-0.5 * Float64(t_1 + Float64(Float64(sin(z3) * sin(z2)) - Float64(1.0 - Float64(Float64(cos(Float64(z0 - z1)) - 1.0) * t_1))))));
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(z2) * cos(z3);
	t_1 = cos(z3) * cos(z2);
	t_2 = sin((z2 - z3));
	tmp = 0.0;
	if (sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * t_0) + (-0.5 * (-1.0 + cos((z3 - z2)))))) <= 0.109)
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (pi * 0.5)))))) * t_0) + (-0.5 * ((t_2 * -t_2) / (cos((z2 - z3)) + 1.0)))));
	else
		tmp = sqrt((-0.5 * (t_1 + ((sin(z3) * sin(z2)) - (1.0 - ((cos((z0 - z1)) - 1.0) * t_1))))));
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 7854277750134145/72057594037927936], N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Sin[N[(z1 - N[(z0 - N[(Pi * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(N[(t$95$2 * (-t$95$2)), $MachinePrecision] / N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(-1/2 * N[(t$95$1 + N[(N[(N[Sin[z3], $MachinePrecision] * N[Sin[z2], $MachinePrecision]), $MachinePrecision] - N[(1 - N[(N[(N[Cos[N[(z0 - z1), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos z2 \cdot \cos z3\\
t_1 := \cos z3 \cdot \cos z2\\
t_2 := \sin \left(z2 - z3\right)\\
\mathbf{if}\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \leq \frac{7854277750134145}{72057594037927936}:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_2 \cdot \left(-t\_2\right)}{\cos \left(z2 - z3\right) + 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-1}{2} \cdot \left(t\_1 + \left(\sin z3 \cdot \sin z2 - \left(1 - \left(\cos \left(z0 - z1\right) - 1\right) \cdot t\_1\right)\right)\right)}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2)))))) < 0.109

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 - z0\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. associate-+l-N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \color{blue}{\left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-PI.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\pi} \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z3 - z2\right)\right)\right)}\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z3 - z2\right)}\right)\right)\right)} \]
      4. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      6. lift-cos.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z2 - z3\right)}\right)} \]
      7. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z2 - z3\right)\right)}} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) + -1\right)}} \]
      9. add-flip-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(\mathsf{neg}\left(-1\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \left(z2 - z3\right) - \color{blue}{1}\right)} \]
      11. flip--N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      12. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      13. lower-unsound--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      14. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      15. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      16. lower-unsound-+.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\color{blue}{\cos \left(z2 - z3\right) + 1}}} \]
    5. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right)} \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \color{blue}{\cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1}}{\cos \left(z2 - z3\right) + 1}} \]
      7. sub-1-cosN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(\sin \left(z2 - z3\right) \cdot \sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right)} \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}{\cos \left(z2 - z3\right) + 1}} \]
      11. lower-neg.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \color{blue}{\left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      12. lower-sin.f6432.0%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \left(-\color{blue}{\sin \left(z2 - z3\right)}\right)}{\cos \left(z2 - z3\right) + 1}} \]
    7. Applied rewrites32.0%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]

    if 0.109 < (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2))))))

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right)} \cdot \left(\cos z2 \cdot \cos z3\right)} \]
      6. associate-*l*N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      7. distribute-lft-outN/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      8. lower-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
      9. lower-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    3. Applied rewrites57.3%

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
    4. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
      2. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\color{blue}{\left(\cos \left(z2 - z3\right) - 1\right)} + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)} \]
      3. associate-+l-N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\color{blue}{\cos \left(z2 - z3\right)} - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\cos \color{blue}{\left(z2 - z3\right)} - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      6. cos-diffN/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\color{blue}{\left(\cos z2 \cdot \cos z3 + \sin z2 \cdot \sin z3\right)} - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      7. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2} \cdot \cos z3 + \sin z2 \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      8. lift-cos.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \color{blue}{\cos z3} + \sin z2 \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\color{blue}{\cos z2 \cdot \cos z3} + \sin z2 \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      10. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \color{blue}{\sin z2} \cdot \sin z3\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      11. lift-sin.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \sin z2 \cdot \color{blue}{\sin z3}\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      12. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(\left(\cos z2 \cdot \cos z3 + \color{blue}{\sin z2 \cdot \sin z3}\right) - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)} \]
      13. associate--l+N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z2 \cdot \sin z3 - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)\right)}} \]
      14. lower-+.f64N/A

        \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos z2 \cdot \cos z3 + \left(\sin z2 \cdot \sin z3 - \left(1 - \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right)\right)}} \]
    5. Applied rewrites73.4%

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\cos z3 \cdot \cos z2 + \left(\sin z3 \cdot \sin z2 - \left(1 - \left(\cos \left(z0 - z1\right) - 1\right) \cdot \left(\cos z3 \cdot \cos z2\right)\right)\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 14: 60.3% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \cos z2 \cdot \cos z3\\ t_1 := \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)\\ t_2 := \cos \left(z2 - z3\right)\\ t_3 := \frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\\ t_4 := \sin \left(z2 - z3\right)\\ \mathbf{if}\;\sqrt{t\_3 \cdot t\_0 + t\_1} \leq 0:\\ \;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_4 \cdot \left(-t\_4\right)}{t\_2 + 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{t\_3 \cdot \left(\left(\cos \left(z3 + z2\right) + t\_2\right) \cdot \frac{1}{2}\right) + t\_1}\\ \end{array} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (let* ((t_0 (* (cos z2) (cos z3)))
       (t_1 (* -1/2 (+ -1 (cos (- z3 z2)))))
       (t_2 (cos (- z2 z3)))
       (t_3 (* -1/2 (+ -1 (cos (- z1 z0)))))
       (t_4 (sin (- z2 z3))))
  (if (<= (sqrt (+ (* t_3 t_0) t_1)) 0)
    (sqrt
     (+
      (* (* -1/2 (+ -1 (sin (- z1 (- z0 (* PI 1/2)))))) t_0)
      (* -1/2 (/ (* t_4 (- t_4)) (+ t_2 1)))))
    (sqrt (+ (* t_3 (* (+ (cos (+ z3 z2)) t_2) 1/2)) t_1)))))
double code(double z1, double z0, double z2, double z3) {
	double t_0 = cos(z2) * cos(z3);
	double t_1 = -0.5 * (-1.0 + cos((z3 - z2)));
	double t_2 = cos((z2 - z3));
	double t_3 = -0.5 * (-1.0 + cos((z1 - z0)));
	double t_4 = sin((z2 - z3));
	double tmp;
	if (sqrt(((t_3 * t_0) + t_1)) <= 0.0) {
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (((double) M_PI) * 0.5)))))) * t_0) + (-0.5 * ((t_4 * -t_4) / (t_2 + 1.0)))));
	} else {
		tmp = sqrt(((t_3 * ((cos((z3 + z2)) + t_2) * 0.5)) + t_1));
	}
	return tmp;
}
public static double code(double z1, double z0, double z2, double z3) {
	double t_0 = Math.cos(z2) * Math.cos(z3);
	double t_1 = -0.5 * (-1.0 + Math.cos((z3 - z2)));
	double t_2 = Math.cos((z2 - z3));
	double t_3 = -0.5 * (-1.0 + Math.cos((z1 - z0)));
	double t_4 = Math.sin((z2 - z3));
	double tmp;
	if (Math.sqrt(((t_3 * t_0) + t_1)) <= 0.0) {
		tmp = Math.sqrt((((-0.5 * (-1.0 + Math.sin((z1 - (z0 - (Math.PI * 0.5)))))) * t_0) + (-0.5 * ((t_4 * -t_4) / (t_2 + 1.0)))));
	} else {
		tmp = Math.sqrt(((t_3 * ((Math.cos((z3 + z2)) + t_2) * 0.5)) + t_1));
	}
	return tmp;
}
def code(z1, z0, z2, z3):
	t_0 = math.cos(z2) * math.cos(z3)
	t_1 = -0.5 * (-1.0 + math.cos((z3 - z2)))
	t_2 = math.cos((z2 - z3))
	t_3 = -0.5 * (-1.0 + math.cos((z1 - z0)))
	t_4 = math.sin((z2 - z3))
	tmp = 0
	if math.sqrt(((t_3 * t_0) + t_1)) <= 0.0:
		tmp = math.sqrt((((-0.5 * (-1.0 + math.sin((z1 - (z0 - (math.pi * 0.5)))))) * t_0) + (-0.5 * ((t_4 * -t_4) / (t_2 + 1.0)))))
	else:
		tmp = math.sqrt(((t_3 * ((math.cos((z3 + z2)) + t_2) * 0.5)) + t_1))
	return tmp
function code(z1, z0, z2, z3)
	t_0 = Float64(cos(z2) * cos(z3))
	t_1 = Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2))))
	t_2 = cos(Float64(z2 - z3))
	t_3 = Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0))))
	t_4 = sin(Float64(z2 - z3))
	tmp = 0.0
	if (sqrt(Float64(Float64(t_3 * t_0) + t_1)) <= 0.0)
		tmp = sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + sin(Float64(z1 - Float64(z0 - Float64(pi * 0.5)))))) * t_0) + Float64(-0.5 * Float64(Float64(t_4 * Float64(-t_4)) / Float64(t_2 + 1.0)))));
	else
		tmp = sqrt(Float64(Float64(t_3 * Float64(Float64(cos(Float64(z3 + z2)) + t_2) * 0.5)) + t_1));
	end
	return tmp
end
function tmp_2 = code(z1, z0, z2, z3)
	t_0 = cos(z2) * cos(z3);
	t_1 = -0.5 * (-1.0 + cos((z3 - z2)));
	t_2 = cos((z2 - z3));
	t_3 = -0.5 * (-1.0 + cos((z1 - z0)));
	t_4 = sin((z2 - z3));
	tmp = 0.0;
	if (sqrt(((t_3 * t_0) + t_1)) <= 0.0)
		tmp = sqrt((((-0.5 * (-1.0 + sin((z1 - (z0 - (pi * 0.5)))))) * t_0) + (-0.5 * ((t_4 * -t_4) / (t_2 + 1.0)))));
	else
		tmp = sqrt(((t_3 * ((cos((z3 + z2)) + t_2) * 0.5)) + t_1));
	end
	tmp_2 = tmp;
end
code[z1_, z0_, z2_, z3_] := Block[{t$95$0 = N[(N[Cos[z2], $MachinePrecision] * N[Cos[z3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[(t$95$3 * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision], 0], N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Sin[N[(z1 - N[(z0 - N[(Pi * 1/2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(-1/2 * N[(N[(t$95$4 * (-t$95$4)), $MachinePrecision] / N[(t$95$2 + 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(t$95$3 * N[(N[(N[Cos[N[(z3 + z2), $MachinePrecision]], $MachinePrecision] + t$95$2), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \cos z2 \cdot \cos z3\\
t_1 := \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)\\
t_2 := \cos \left(z2 - z3\right)\\
t_3 := \frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\\
t_4 := \sin \left(z2 - z3\right)\\
\mathbf{if}\;\sqrt{t\_3 \cdot t\_0 + t\_1} \leq 0:\\
\;\;\;\;\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot t\_0 + \frac{-1}{2} \cdot \frac{t\_4 \cdot \left(-t\_4\right)}{t\_2 + 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{t\_3 \cdot \left(\left(\cos \left(z3 + z2\right) + t\_2\right) \cdot \frac{1}{2}\right) + t\_1}\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2)))))) < -0.0

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z1 - z0\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(\left(z1 - z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(\color{blue}{\left(z1 - z0\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. associate-+l-N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \color{blue}{\left(z1 - \left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \color{blue}{\left(z0 - \frac{\mathsf{PI}\left(\right)}{2}\right)}\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lower-PI.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \color{blue}{\pi} \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \color{blue}{\sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)}\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z3 - z2\right)}\right)} \]
      2. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z3 - z2\right)\right)\right)}\right)} \]
      3. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(\mathsf{neg}\left(\color{blue}{\left(z3 - z2\right)}\right)\right)\right)} \]
      4. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      5. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \color{blue}{\left(z2 - z3\right)}\right)} \]
      6. lift-cos.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \color{blue}{\cos \left(z2 - z3\right)}\right)} \]
      7. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(-1 + \cos \left(z2 - z3\right)\right)}} \]
      8. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) + -1\right)}} \]
      9. add-flip-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\left(\cos \left(z2 - z3\right) - \left(\mathsf{neg}\left(-1\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(\cos \left(z2 - z3\right) - \color{blue}{1}\right)} \]
      11. flip--N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      12. lower-unsound-/.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
      13. lower-unsound--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      14. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      15. lower-unsound-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      16. lower-unsound-+.f6429.4%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\color{blue}{\cos \left(z2 - z3\right) + 1}}} \]
    5. Applied rewrites29.4%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \color{blue}{\frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}}} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\cos \left(z2 - z3\right)} \cdot \cos \left(z2 - z3\right) - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      4. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \color{blue}{\cos \left(z2 - z3\right)} - 1 \cdot 1}{\cos \left(z2 - z3\right) + 1}} \]
      5. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1 \cdot 1}}{\cos \left(z2 - z3\right) + 1}} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\cos \left(z2 - z3\right) \cdot \cos \left(z2 - z3\right) - \color{blue}{1}}{\cos \left(z2 - z3\right) + 1}} \]
      7. sub-1-cosN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\mathsf{neg}\left(\sin \left(z2 - z3\right) \cdot \sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      9. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      10. lower-sin.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right)} \cdot \left(\mathsf{neg}\left(\sin \left(z2 - z3\right)\right)\right)}{\cos \left(z2 - z3\right) + 1}} \]
      11. lower-neg.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \color{blue}{\left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]
      12. lower-sin.f6432.0%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\sin \left(z2 - z3\right) \cdot \left(-\color{blue}{\sin \left(z2 - z3\right)}\right)}{\cos \left(z2 - z3\right) + 1}} \]
    7. Applied rewrites32.0%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \sin \left(z1 - \left(z0 - \pi \cdot \frac{1}{2}\right)\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \frac{\color{blue}{\sin \left(z2 - z3\right) \cdot \left(-\sin \left(z2 - z3\right)\right)}}{\cos \left(z2 - z3\right) + 1}} \]

    if -0.0 < (sqrt.f64 (+.f64 (*.f64 (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z1 z0)))) (*.f64 (cos.f64 z2) (cos.f64 z3))) (*.f64 #s(literal -1/2 binary64) (+.f64 #s(literal -1 binary64) (cos.f64 (-.f64 z3 z2))))))

    1. Initial program 57.3%

      \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      2. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\color{blue}{\cos z2} \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      3. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \color{blue}{\cos z3}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      4. cos-multN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\frac{\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)}{2}} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      5. mult-flipN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      6. metadata-evalN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)\right) \cdot \color{blue}{\frac{1}{2}}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      8. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z2 - z3\right)\right)\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      9. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \cos \color{blue}{\left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      10. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \cos \color{blue}{\left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      11. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \color{blue}{\cos \left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      12. lower-+.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\color{blue}{\left(\cos \left(z2 + z3\right) + \cos \left(z3 - z2\right)\right)} \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      13. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\color{blue}{\cos \left(z2 + z3\right)} + \cos \left(z3 - z2\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      14. +-commutativeN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \color{blue}{\left(z3 + z2\right)} + \cos \left(z3 - z2\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      15. lower-+.f6457.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \color{blue}{\left(z3 + z2\right)} + \cos \left(z3 - z2\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      16. lift-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \color{blue}{\cos \left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      17. lift--.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \color{blue}{\left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      18. sub-negate-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \color{blue}{\left(\mathsf{neg}\left(\left(z2 - z3\right)\right)\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      19. cos-neg-revN/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \color{blue}{\cos \left(z2 - z3\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      20. lower-cos.f64N/A

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \color{blue}{\cos \left(z2 - z3\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
      21. lower--.f6457.7%

        \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \color{blue}{\left(z2 - z3\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. Applied rewrites57.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 15: 57.7% accurate, 1.0× speedup?

\[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (sqrt
 (+
  (*
   (* -1/2 (+ -1 (cos (- z1 z0))))
   (* (+ (cos (+ z3 z2)) (cos (- z2 z3))) 1/2))
  (* -1/2 (+ -1 (cos (- z3 z2)))))))
double code(double z1, double z0, double z2, double z3) {
	return sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * ((cos((z3 + z2)) + cos((z2 - z3))) * 0.5)) + (-0.5 * (-1.0 + cos((z3 - z2))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(((((-0.5d0) * ((-1.0d0) + cos((z1 - z0)))) * ((cos((z3 + z2)) + cos((z2 - z3))) * 0.5d0)) + ((-0.5d0) * ((-1.0d0) + cos((z3 - z2))))))
end function
public static double code(double z1, double z0, double z2, double z3) {
	return Math.sqrt((((-0.5 * (-1.0 + Math.cos((z1 - z0)))) * ((Math.cos((z3 + z2)) + Math.cos((z2 - z3))) * 0.5)) + (-0.5 * (-1.0 + Math.cos((z3 - z2))))));
}
def code(z1, z0, z2, z3):
	return math.sqrt((((-0.5 * (-1.0 + math.cos((z1 - z0)))) * ((math.cos((z3 + z2)) + math.cos((z2 - z3))) * 0.5)) + (-0.5 * (-1.0 + math.cos((z3 - z2))))))
function code(z1, z0, z2, z3)
	return sqrt(Float64(Float64(Float64(-0.5 * Float64(-1.0 + cos(Float64(z1 - z0)))) * Float64(Float64(cos(Float64(z3 + z2)) + cos(Float64(z2 - z3))) * 0.5)) + Float64(-0.5 * Float64(-1.0 + cos(Float64(z3 - z2))))))
end
function tmp = code(z1, z0, z2, z3)
	tmp = sqrt((((-0.5 * (-1.0 + cos((z1 - z0)))) * ((cos((z3 + z2)) + cos((z2 - z3))) * 0.5)) + (-0.5 * (-1.0 + cos((z3 - z2))))));
end
code[z1_, z0_, z2_, z3_] := N[Sqrt[N[(N[(N[(-1/2 * N[(-1 + N[Cos[N[(z1 - z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(z3 + z2), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] + N[(-1/2 * N[(-1 + N[Cos[N[(z3 - z2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}
Derivation
  1. Initial program 57.3%

    \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\cos z2 \cdot \cos z3\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    2. lift-cos.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\color{blue}{\cos z2} \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    3. lift-cos.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \color{blue}{\cos z3}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    4. cos-multN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\frac{\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)}{2}} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    5. mult-flipN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    6. metadata-evalN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)\right) \cdot \color{blue}{\frac{1}{2}}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z2 + z3\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    8. cos-neg-revN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \color{blue}{\cos \left(\mathsf{neg}\left(\left(z2 - z3\right)\right)\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    9. sub-negate-revN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \cos \color{blue}{\left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    10. lift--.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \cos \color{blue}{\left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    11. lift-cos.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z2 + z3\right) + \color{blue}{\cos \left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    12. lower-+.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\color{blue}{\left(\cos \left(z2 + z3\right) + \cos \left(z3 - z2\right)\right)} \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    13. lower-cos.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\color{blue}{\cos \left(z2 + z3\right)} + \cos \left(z3 - z2\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    14. +-commutativeN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \color{blue}{\left(z3 + z2\right)} + \cos \left(z3 - z2\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    15. lower-+.f6457.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \color{blue}{\left(z3 + z2\right)} + \cos \left(z3 - z2\right)\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    16. lift-cos.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \color{blue}{\cos \left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    17. lift--.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \color{blue}{\left(z3 - z2\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    18. sub-negate-revN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \color{blue}{\left(\mathsf{neg}\left(\left(z2 - z3\right)\right)\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    19. cos-neg-revN/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \color{blue}{\cos \left(z2 - z3\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    20. lower-cos.f64N/A

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \color{blue}{\cos \left(z2 - z3\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
    21. lower--.f6457.7%

      \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\left(\cos \left(z3 + z2\right) + \cos \color{blue}{\left(z2 - z3\right)}\right) \cdot \frac{1}{2}\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  3. Applied rewrites57.7%

    \[\leadsto \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \color{blue}{\left(\left(\cos \left(z3 + z2\right) + \cos \left(z2 - z3\right)\right) \cdot \frac{1}{2}\right)} + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  4. Add Preprocessing

Alternative 16: 57.7% accurate, 1.0× speedup?

\[\sqrt{\left|\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right|} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (sqrt
 (fabs
  (*
   -1/2
   (+
    (- (cos (- z2 z3)) 1)
    (* (* (cos z3) (cos z2)) (- (cos (- z0 z1)) 1)))))))
double code(double z1, double z0, double z2, double z3) {
	return sqrt(fabs((-0.5 * ((cos((z2 - z3)) - 1.0) + ((cos(z3) * cos(z2)) * (cos((z0 - z1)) - 1.0))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(abs(((-0.5d0) * ((cos((z2 - z3)) - 1.0d0) + ((cos(z3) * cos(z2)) * (cos((z0 - z1)) - 1.0d0))))))
end function
public static double code(double z1, double z0, double z2, double z3) {
	return Math.sqrt(Math.abs((-0.5 * ((Math.cos((z2 - z3)) - 1.0) + ((Math.cos(z3) * Math.cos(z2)) * (Math.cos((z0 - z1)) - 1.0))))));
}
def code(z1, z0, z2, z3):
	return math.sqrt(math.fabs((-0.5 * ((math.cos((z2 - z3)) - 1.0) + ((math.cos(z3) * math.cos(z2)) * (math.cos((z0 - z1)) - 1.0))))))
function code(z1, z0, z2, z3)
	return sqrt(abs(Float64(-0.5 * Float64(Float64(cos(Float64(z2 - z3)) - 1.0) + Float64(Float64(cos(z3) * cos(z2)) * Float64(cos(Float64(z0 - z1)) - 1.0))))))
end
function tmp = code(z1, z0, z2, z3)
	tmp = sqrt(abs((-0.5 * ((cos((z2 - z3)) - 1.0) + ((cos(z3) * cos(z2)) * (cos((z0 - z1)) - 1.0))))));
end
code[z1_, z0_, z2_, z3_] := N[Sqrt[N[Abs[N[(-1/2 * N[(N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision] + N[(N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(z0 - z1), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\sqrt{\left|\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right|}
Derivation
  1. Initial program 57.3%

    \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  2. Step-by-step derivation
    1. rem-square-sqrtN/A

      \[\leadsto \sqrt{\color{blue}{\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \cdot \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}}} \]
    2. lift-sqrt.f64N/A

      \[\leadsto \sqrt{\color{blue}{\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \cdot \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \]
    3. lift-sqrt.f64N/A

      \[\leadsto \sqrt{\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \cdot \color{blue}{\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}}} \]
    4. sqr-abs-revN/A

      \[\leadsto \sqrt{\color{blue}{\left|\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\right| \cdot \left|\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\right|}} \]
    5. mul-fabsN/A

      \[\leadsto \sqrt{\color{blue}{\left|\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \cdot \sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}\right|}} \]
  3. Applied rewrites57.7%

    \[\leadsto \sqrt{\color{blue}{\left|\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)\right|}} \]
  4. Add Preprocessing

Alternative 17: 57.3% accurate, 1.0× speedup?

\[\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)} \]
(FPCore (z1 z0 z2 z3)
  :precision binary64
  (sqrt
 (*
  -1/2
  (+
   (- (cos (- z2 z3)) 1)
   (* (* (cos z3) (cos z2)) (- (cos (- z0 z1)) 1))))))
double code(double z1, double z0, double z2, double z3) {
	return sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + ((cos(z3) * cos(z2)) * (cos((z0 - z1)) - 1.0)))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z1, z0, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z1
    real(8), intent (in) :: z0
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(((-0.5d0) * ((cos((z2 - z3)) - 1.0d0) + ((cos(z3) * cos(z2)) * (cos((z0 - z1)) - 1.0d0)))))
end function
public static double code(double z1, double z0, double z2, double z3) {
	return Math.sqrt((-0.5 * ((Math.cos((z2 - z3)) - 1.0) + ((Math.cos(z3) * Math.cos(z2)) * (Math.cos((z0 - z1)) - 1.0)))));
}
def code(z1, z0, z2, z3):
	return math.sqrt((-0.5 * ((math.cos((z2 - z3)) - 1.0) + ((math.cos(z3) * math.cos(z2)) * (math.cos((z0 - z1)) - 1.0)))))
function code(z1, z0, z2, z3)
	return sqrt(Float64(-0.5 * Float64(Float64(cos(Float64(z2 - z3)) - 1.0) + Float64(Float64(cos(z3) * cos(z2)) * Float64(cos(Float64(z0 - z1)) - 1.0)))))
end
function tmp = code(z1, z0, z2, z3)
	tmp = sqrt((-0.5 * ((cos((z2 - z3)) - 1.0) + ((cos(z3) * cos(z2)) * (cos((z0 - z1)) - 1.0)))));
end
code[z1_, z0_, z2_, z3_] := N[Sqrt[N[(-1/2 * N[(N[(N[Cos[N[(z2 - z3), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision] + N[(N[(N[Cos[z3], $MachinePrecision] * N[Cos[z2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(z0 - z1), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}
Derivation
  1. Initial program 57.3%

    \[\sqrt{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \sqrt{\color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right) + \frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)}} \]
    2. +-commutativeN/A

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
    3. lift-*.f64N/A

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right)} + \left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)} \]
    4. lift-*.f64N/A

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)}} \]
    5. lift-*.f64N/A

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\left(\frac{-1}{2} \cdot \left(-1 + \cos \left(z1 - z0\right)\right)\right)} \cdot \left(\cos z2 \cdot \cos z3\right)} \]
    6. associate-*l*N/A

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \left(-1 + \cos \left(z3 - z2\right)\right) + \color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    7. distribute-lft-outN/A

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    8. lower-*.f64N/A

      \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
    9. lower-+.f64N/A

      \[\leadsto \sqrt{\frac{-1}{2} \cdot \color{blue}{\left(\left(-1 + \cos \left(z3 - z2\right)\right) + \left(-1 + \cos \left(z1 - z0\right)\right) \cdot \left(\cos z2 \cdot \cos z3\right)\right)}} \]
  3. Applied rewrites57.3%

    \[\leadsto \sqrt{\color{blue}{\frac{-1}{2} \cdot \left(\left(\cos \left(z2 - z3\right) - 1\right) + \left(\cos z3 \cdot \cos z2\right) \cdot \left(\cos \left(z0 - z1\right) - 1\right)\right)}} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2025277 -o generate:taylor -o generate:evaluate
(FPCore (z1 z0 z2 z3)
  :name "(sqrt (+ (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3))) (* -1/2 (+ -1 (cos (- z3 z2))))))"
  :precision binary64
  (sqrt (+ (* (* -1/2 (+ -1 (cos (- z1 z0)))) (* (cos z2) (cos z3))) (* -1/2 (+ -1 (cos (- z3 z2)))))))