(sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3))

Percentage Accurate: 59.6% → 85.5%
Time: 23.4s
Alternatives: 8
Speedup: 1.2×

Specification

?
\[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3)))
double code(double z0, double z1, double z2, double z3) {
	return sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
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(z0, z1, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(((((-2.0d0) * z0) * (((((z0 - z1) / z2) * z3) - (-2.0d0)) / z2)) * z3))
end function
public static double code(double z0, double z1, double z2, double z3) {
	return Math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
def code(z0, z1, z2, z3):
	return math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3))
function code(z0, z1, z2, z3)
	return sqrt(Float64(Float64(Float64(-2.0 * z0) * Float64(Float64(Float64(Float64(Float64(z0 - z1) / z2) * z3) - -2.0) / z2)) * z3))
end
function tmp = code(z0, z1, z2, z3)
	tmp = sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
end
code[z0_, z1_, z2_, z3_] := N[Sqrt[N[(N[(N[(-2 * z0), $MachinePrecision] * N[(N[(N[(N[(N[(z0 - z1), $MachinePrecision] / z2), $MachinePrecision] * z3), $MachinePrecision] - -2), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}

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

\[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3)))
double code(double z0, double z1, double z2, double z3) {
	return sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
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(z0, z1, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(((((-2.0d0) * z0) * (((((z0 - z1) / z2) * z3) - (-2.0d0)) / z2)) * z3))
end function
public static double code(double z0, double z1, double z2, double z3) {
	return Math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
}
def code(z0, z1, z2, z3):
	return math.sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3))
function code(z0, z1, z2, z3)
	return sqrt(Float64(Float64(Float64(-2.0 * z0) * Float64(Float64(Float64(Float64(Float64(z0 - z1) / z2) * z3) - -2.0) / z2)) * z3))
end
function tmp = code(z0, z1, z2, z3)
	tmp = sqrt((((-2.0 * z0) * (((((z0 - z1) / z2) * z3) - -2.0) / z2)) * z3));
end
code[z0_, z1_, z2_, z3_] := N[Sqrt[N[(N[(N[(-2 * z0), $MachinePrecision] * N[(N[(N[(N[(N[(z0 - z1), $MachinePrecision] / z2), $MachinePrecision] * z3), $MachinePrecision] - -2), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision]
\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}

Alternative 1: 85.5% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}\\ \mathbf{if}\;t\_0 \leq \frac{6183260036827613}{123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568}:\\ \;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(\left(z3 \cdot -2\right), \left(z2 + z2\right), z0, \left(\left(z1 - z0\right) \cdot z3\right), z0\right)}}{\left|z2\right|}\\ \mathbf{elif}\;t\_0 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\ \end{array} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (let* ((t_0
        (sqrt
         (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3))))
  (if (<=
       t_0
       6183260036827613/123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568)
    (/
     (sqrt
      (304-z0z1z2z3z4 (* z3 -2) (+ z2 z2) z0 (* (- z1 z0) z3) z0))
     (fabs z2))
    (if (<=
         t_0
         200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048)
      t_0
      (/
       (sqrt (* (304-z0z1z2z3z4 z0 (- z0 z1) z3 z2 -2) (* z3 -2)))
       (fabs z2))))))
\begin{array}{l}
t_0 := \sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}\\
\mathbf{if}\;t\_0 \leq \frac{6183260036827613}{123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568}:\\
\;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(\left(z3 \cdot -2\right), \left(z2 + z2\right), z0, \left(\left(z1 - z0\right) \cdot z3\right), z0\right)}}{\left|z2\right|}\\

\mathbf{elif}\;t\_0 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\


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

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z3 \cdot -2\right) \cdot \left(z0 \cdot \left(\left(z2 + z2\right) - \color{blue}{\left(z1 - z0\right) \cdot z3}\right)\right)}}{\left|z2\right|} \]
      18. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

    if 4.9999999999999997e-158 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3)) < 2.0000000000000001e140

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]

    if 2.0000000000000001e140 < (sqrt.f64 (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) z0) (/.f64 (-.f64 (*.f64 (/.f64 (-.f64 z0 z1) z2) z3) #s(literal -2 binary64)) z2)) z3))

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

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

        \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(z3 \cdot \left(z0 - z1\right)\right) \cdot 1} - z2 \cdot -2\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      3. *-rgt-identityN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z3 \cdot \left(z0 - z1\right) - \color{blue}{-2 \cdot z2}\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      6. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right)} \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      10. lift-+.f6465.5%

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}}{\left|z2\right|} \]
    4. Applied rewrites64.6%

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z2 + z2\right) - \color{blue}{\left(z1 - z0\right) \cdot z3}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(z2 + z2\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      16. count-2N/A

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot z2\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      18. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{z2 \cdot \left(\mathsf{neg}\left(-2\right)\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      19. distribute-rgt-neg-outN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - z2 \cdot \color{blue}{-2}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      22. lower-304-z0z1z2z3z466.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right)} \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
    6. Applied rewrites66.0%

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

Alternative 2: 84.5% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\ t_1 := \sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}\\ \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (let* ((t_0
        (/
         (sqrt (* (304-z0z1z2z3z4 z0 (- z0 z1) z3 z2 -2) (* z3 -2)))
         (fabs z2)))
       (t_1
        (sqrt
         (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3))))
  (if (<= t_1 0)
    t_0
    (if (<=
         t_1
         200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048)
      t_1
      t_0))))
\begin{array}{l}
t_0 := \frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\
t_1 := \sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

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

        \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(z3 \cdot \left(z0 - z1\right)\right) \cdot 1} - z2 \cdot -2\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      3. *-rgt-identityN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z3 \cdot \left(z0 - z1\right) - \color{blue}{-2 \cdot z2}\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      6. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right)} \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      10. lift-+.f6465.5%

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}}{\left|z2\right|} \]
    4. Applied rewrites64.6%

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z2 + z2\right) - \color{blue}{\left(z1 - z0\right) \cdot z3}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(z2 + z2\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      16. count-2N/A

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot z2\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      18. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{z2 \cdot \left(\mathsf{neg}\left(-2\right)\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      19. distribute-rgt-neg-outN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - z2 \cdot \color{blue}{-2}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      22. lower-304-z0z1z2z3z466.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right)} \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
    6. Applied rewrites66.0%

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

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

    1. Initial program 59.6%

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

Alternative 3: 80.3% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_2 \leq 200000000000000011856760248162974007412724977534090657729700148965999155656947961304046593016036249138303584474586765896459394327029164802048:\\
\;\;\;\;\sqrt{\left(2 \cdot \left(-2 - z3 \cdot t\_1\right)\right) \cdot \frac{z3 \cdot z0}{z2}}\\

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


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

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

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

        \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(z3 \cdot \left(z0 - z1\right)\right) \cdot 1} - z2 \cdot -2\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      3. *-rgt-identityN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z3 \cdot \left(z0 - z1\right) - \color{blue}{-2 \cdot z2}\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      6. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right)} \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      10. lift-+.f6465.5%

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}}{\left|z2\right|} \]
    4. Applied rewrites64.6%

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z2 + z2\right) - \color{blue}{\left(z1 - z0\right) \cdot z3}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(z2 + z2\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      16. count-2N/A

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot z2\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      18. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{z2 \cdot \left(\mathsf{neg}\left(-2\right)\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      19. distribute-rgt-neg-outN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - z2 \cdot \color{blue}{-2}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      22. lower-304-z0z1z2z3z466.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right)} \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
    6. Applied rewrites66.0%

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

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

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{\left(2 \cdot \left(z2 \cdot -2 - z3 \cdot \left(z0 - z1\right)\right)\right) \cdot \left(z0 \cdot z3\right)}{\color{blue}{z2 \cdot z2}}} \]
      7. times-fracN/A

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

        \[\leadsto \sqrt{\color{blue}{\frac{2 \cdot \left(z2 \cdot -2 - z3 \cdot \left(z0 - z1\right)\right)}{z2} \cdot \frac{z0 \cdot z3}{z2}}} \]
    5. Applied rewrites61.0%

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

Alternative 4: 70.2% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\ \mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\ \;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\ \mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\ \;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\ \end{array} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (let* ((t_0 (- (- (* (- z1 z0) z3) z2) z2)))
  (if (<= z0 -49999999999999999661047433718081398823085422097203200)
    (/ (sqrt (* t_0 (* (+ z0 z0) z3))) (fabs z2))
    (if (<=
         z0
         5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
      (/
       (sqrt (* (304-z0z1z2z3z4 z0 (- z0 z1) z3 z2 -2) (* z3 -2)))
       (fabs z2))
      (/ (sqrt (* (+ z0 z0) (* z3 t_0))) (fabs z2))))))
\begin{array}{l}
t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\

\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z0 < -5e52

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(2 \cdot z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
      2. count-2-revN/A

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(z0 + z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
      3. lower-+.f6465.6%

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(z0 + z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
    6. Applied rewrites65.6%

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

    if -5e52 < z0 < 5.0000000000000005e105

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

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

        \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(z3 \cdot \left(z0 - z1\right)\right) \cdot 1} - z2 \cdot -2\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      3. *-rgt-identityN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z3 \cdot \left(z0 - z1\right) - \color{blue}{-2 \cdot z2}\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      6. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right)} \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      10. lift-+.f6465.5%

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}}{\left|z2\right|} \]
    4. Applied rewrites64.6%

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z2 + z2\right) - \color{blue}{\left(z1 - z0\right) \cdot z3}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      5. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(z2 + z2\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      16. count-2N/A

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot z2\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      18. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - \left(\mathsf{neg}\left(\color{blue}{z2 \cdot \left(\mathsf{neg}\left(-2\right)\right)}\right)\right)\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      19. distribute-rgt-neg-outN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z0 \cdot \left(\left(z0 - z1\right) \cdot z3 - z2 \cdot \color{blue}{-2}\right)\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
      22. lower-304-z0z1z2z3z466.0%

        \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{304\_z0z1z2z3z4}\left(z0, \left(z0 - z1\right), z3, z2, -2\right)} \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|} \]
    6. Applied rewrites66.0%

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

    if 5.0000000000000005e105 < z0

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      7. count-2-revN/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(z0 + z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      9. lower-*.f6462.7%

        \[\leadsto \frac{\sqrt{\left(z0 + z0\right) \cdot \color{blue}{\left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}}{\left|z2\right|} \]
    6. Applied rewrites62.7%

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

Alternative 5: 68.9% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \left(z1 - z0\right) \cdot z3\\ t_1 := \left(t\_0 - z2\right) - z2\\ \mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\ \;\;\;\;\frac{\sqrt{t\_1 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\ \mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\ \;\;\;\;\frac{\sqrt{\left(\left(\left(z2 + z2\right) - t\_0\right) \cdot z0\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_1\right)}}{\left|z2\right|}\\ \end{array} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (let* ((t_0 (* (- z1 z0) z3)) (t_1 (- (- t_0 z2) z2)))
  (if (<= z0 -49999999999999999661047433718081398823085422097203200)
    (/ (sqrt (* t_1 (* (+ z0 z0) z3))) (fabs z2))
    (if (<=
         z0
         5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
      (/ (sqrt (* (* (- (+ z2 z2) t_0) z0) (* z3 -2))) (fabs z2))
      (/ (sqrt (* (+ z0 z0) (* z3 t_1))) (fabs z2))))))
double code(double z0, double z1, double z2, double z3) {
	double t_0 = (z1 - z0) * z3;
	double t_1 = (t_0 - z2) - z2;
	double tmp;
	if (z0 <= -5e+52) {
		tmp = sqrt((t_1 * ((z0 + z0) * z3))) / fabs(z2);
	} else if (z0 <= 5e+105) {
		tmp = sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / fabs(z2);
	} else {
		tmp = sqrt(((z0 + z0) * (z3 * t_1))) / fabs(z2);
	}
	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(z0, z1, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (z1 - z0) * z3
    t_1 = (t_0 - z2) - z2
    if (z0 <= (-5d+52)) then
        tmp = sqrt((t_1 * ((z0 + z0) * z3))) / abs(z2)
    else if (z0 <= 5d+105) then
        tmp = sqrt(((((z2 + z2) - t_0) * z0) * (z3 * (-2.0d0)))) / abs(z2)
    else
        tmp = sqrt(((z0 + z0) * (z3 * t_1))) / abs(z2)
    end if
    code = tmp
end function
public static double code(double z0, double z1, double z2, double z3) {
	double t_0 = (z1 - z0) * z3;
	double t_1 = (t_0 - z2) - z2;
	double tmp;
	if (z0 <= -5e+52) {
		tmp = Math.sqrt((t_1 * ((z0 + z0) * z3))) / Math.abs(z2);
	} else if (z0 <= 5e+105) {
		tmp = Math.sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / Math.abs(z2);
	} else {
		tmp = Math.sqrt(((z0 + z0) * (z3 * t_1))) / Math.abs(z2);
	}
	return tmp;
}
def code(z0, z1, z2, z3):
	t_0 = (z1 - z0) * z3
	t_1 = (t_0 - z2) - z2
	tmp = 0
	if z0 <= -5e+52:
		tmp = math.sqrt((t_1 * ((z0 + z0) * z3))) / math.fabs(z2)
	elif z0 <= 5e+105:
		tmp = math.sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / math.fabs(z2)
	else:
		tmp = math.sqrt(((z0 + z0) * (z3 * t_1))) / math.fabs(z2)
	return tmp
function code(z0, z1, z2, z3)
	t_0 = Float64(Float64(z1 - z0) * z3)
	t_1 = Float64(Float64(t_0 - z2) - z2)
	tmp = 0.0
	if (z0 <= -5e+52)
		tmp = Float64(sqrt(Float64(t_1 * Float64(Float64(z0 + z0) * z3))) / abs(z2));
	elseif (z0 <= 5e+105)
		tmp = Float64(sqrt(Float64(Float64(Float64(Float64(z2 + z2) - t_0) * z0) * Float64(z3 * -2.0))) / abs(z2));
	else
		tmp = Float64(sqrt(Float64(Float64(z0 + z0) * Float64(z3 * t_1))) / abs(z2));
	end
	return tmp
end
function tmp_2 = code(z0, z1, z2, z3)
	t_0 = (z1 - z0) * z3;
	t_1 = (t_0 - z2) - z2;
	tmp = 0.0;
	if (z0 <= -5e+52)
		tmp = sqrt((t_1 * ((z0 + z0) * z3))) / abs(z2);
	elseif (z0 <= 5e+105)
		tmp = sqrt(((((z2 + z2) - t_0) * z0) * (z3 * -2.0))) / abs(z2);
	else
		tmp = sqrt(((z0 + z0) * (z3 * t_1))) / abs(z2);
	end
	tmp_2 = tmp;
end
code[z0_, z1_, z2_, z3_] := Block[{t$95$0 = N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - z2), $MachinePrecision] - z2), $MachinePrecision]}, If[LessEqual[z0, -49999999999999999661047433718081398823085422097203200], N[(N[Sqrt[N[(t$95$1 * N[(N[(z0 + z0), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], If[LessEqual[z0, 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176], N[(N[Sqrt[N[(N[(N[(N[(z2 + z2), $MachinePrecision] - t$95$0), $MachinePrecision] * z0), $MachinePrecision] * N[(z3 * -2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(z0 + z0), $MachinePrecision] * N[(z3 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left(z1 - z0\right) \cdot z3\\
t_1 := \left(t\_0 - z2\right) - z2\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;\frac{\sqrt{t\_1 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\

\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\left(\left(\left(z2 + z2\right) - t\_0\right) \cdot z0\right) \cdot \left(z3 \cdot -2\right)}}{\left|z2\right|}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_1\right)}}{\left|z2\right|}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z0 < -5e52

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(2 \cdot z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
      2. count-2-revN/A

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(z0 + z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
      3. lower-+.f6465.6%

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(z0 + z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
    6. Applied rewrites65.6%

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

    if -5e52 < z0 < 5.0000000000000005e105

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

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

        \[\leadsto \frac{\sqrt{\left(\color{blue}{\left(z3 \cdot \left(z0 - z1\right)\right) \cdot 1} - z2 \cdot -2\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      3. *-rgt-identityN/A

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

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

        \[\leadsto \frac{\sqrt{\left(z3 \cdot \left(z0 - z1\right) - \color{blue}{-2 \cdot z2}\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      6. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right)} \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}{\left|z2\right|} \]
      10. lift-+.f6465.5%

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z2 + z3 \cdot \left(z0 - z1\right)\right) \cdot \left(\left(z3 \cdot -2\right) \cdot z0\right)}}}{\left|z2\right|} \]
    4. Applied rewrites64.6%

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

    if 5.0000000000000005e105 < z0

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      7. count-2-revN/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(z0 + z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      9. lower-*.f6462.7%

        \[\leadsto \frac{\sqrt{\left(z0 + z0\right) \cdot \color{blue}{\left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}}{\left|z2\right|} \]
    6. Applied rewrites62.7%

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

Alternative 6: 68.8% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\ \mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\ \;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\ \mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\ \;\;\;\;\frac{\sqrt{\left(t\_0 \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\ \end{array} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (let* ((t_0 (- (- (* (- z1 z0) z3) z2) z2)))
  (if (<= z0 -49999999999999999661047433718081398823085422097203200)
    (/ (sqrt (* t_0 (* (+ z0 z0) z3))) (fabs z2))
    (if (<=
         z0
         5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
      (/ (sqrt (* (* t_0 (+ z0 z0)) z3)) (fabs z2))
      (/ (sqrt (* (+ z0 z0) (* z3 t_0))) (fabs z2))))))
double code(double z0, double z1, double z2, double z3) {
	double t_0 = (((z1 - z0) * z3) - z2) - z2;
	double tmp;
	if (z0 <= -5e+52) {
		tmp = sqrt((t_0 * ((z0 + z0) * z3))) / fabs(z2);
	} else if (z0 <= 5e+105) {
		tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / fabs(z2);
	} else {
		tmp = sqrt(((z0 + z0) * (z3 * t_0))) / fabs(z2);
	}
	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(z0, z1, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((z1 - z0) * z3) - z2) - z2
    if (z0 <= (-5d+52)) then
        tmp = sqrt((t_0 * ((z0 + z0) * z3))) / abs(z2)
    else if (z0 <= 5d+105) then
        tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2)
    else
        tmp = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2)
    end if
    code = tmp
end function
public static double code(double z0, double z1, double z2, double z3) {
	double t_0 = (((z1 - z0) * z3) - z2) - z2;
	double tmp;
	if (z0 <= -5e+52) {
		tmp = Math.sqrt((t_0 * ((z0 + z0) * z3))) / Math.abs(z2);
	} else if (z0 <= 5e+105) {
		tmp = Math.sqrt(((t_0 * (z0 + z0)) * z3)) / Math.abs(z2);
	} else {
		tmp = Math.sqrt(((z0 + z0) * (z3 * t_0))) / Math.abs(z2);
	}
	return tmp;
}
def code(z0, z1, z2, z3):
	t_0 = (((z1 - z0) * z3) - z2) - z2
	tmp = 0
	if z0 <= -5e+52:
		tmp = math.sqrt((t_0 * ((z0 + z0) * z3))) / math.fabs(z2)
	elif z0 <= 5e+105:
		tmp = math.sqrt(((t_0 * (z0 + z0)) * z3)) / math.fabs(z2)
	else:
		tmp = math.sqrt(((z0 + z0) * (z3 * t_0))) / math.fabs(z2)
	return tmp
function code(z0, z1, z2, z3)
	t_0 = Float64(Float64(Float64(Float64(z1 - z0) * z3) - z2) - z2)
	tmp = 0.0
	if (z0 <= -5e+52)
		tmp = Float64(sqrt(Float64(t_0 * Float64(Float64(z0 + z0) * z3))) / abs(z2));
	elseif (z0 <= 5e+105)
		tmp = Float64(sqrt(Float64(Float64(t_0 * Float64(z0 + z0)) * z3)) / abs(z2));
	else
		tmp = Float64(sqrt(Float64(Float64(z0 + z0) * Float64(z3 * t_0))) / abs(z2));
	end
	return tmp
end
function tmp_2 = code(z0, z1, z2, z3)
	t_0 = (((z1 - z0) * z3) - z2) - z2;
	tmp = 0.0;
	if (z0 <= -5e+52)
		tmp = sqrt((t_0 * ((z0 + z0) * z3))) / abs(z2);
	elseif (z0 <= 5e+105)
		tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2);
	else
		tmp = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2);
	end
	tmp_2 = tmp;
end
code[z0_, z1_, z2_, z3_] := Block[{t$95$0 = N[(N[(N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision] - z2), $MachinePrecision] - z2), $MachinePrecision]}, If[LessEqual[z0, -49999999999999999661047433718081398823085422097203200], N[(N[Sqrt[N[(t$95$0 * N[(N[(z0 + z0), $MachinePrecision] * z3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], If[LessEqual[z0, 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176], N[(N[Sqrt[N[(N[(t$95$0 * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(z0 + z0), $MachinePrecision] * N[(z3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(\left(z0 + z0\right) \cdot z3\right)}}{\left|z2\right|}\\

\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z0 < -5e52

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(2 \cdot z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
      2. count-2-revN/A

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(z0 + z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
      3. lower-+.f6465.6%

        \[\leadsto \frac{\sqrt{\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(\color{blue}{\left(z0 + z0\right)} \cdot z3\right)}}{\left|z2\right|} \]
    6. Applied rewrites65.6%

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

    if -5e52 < z0 < 5.0000000000000005e105

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(2 \cdot z0\right)\right) \cdot z3}}}{\left|z2\right|} \]
      5. lower-*.f6464.6%

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

        \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(2 \cdot z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
      7. count-2-revN/A

        \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(z0 + z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
      8. lower-+.f6464.6%

        \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(z0 + z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
    6. Applied rewrites64.6%

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

    if 5.0000000000000005e105 < z0

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      7. count-2-revN/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(z0 + z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      9. lower-*.f6462.7%

        \[\leadsto \frac{\sqrt{\left(z0 + z0\right) \cdot \color{blue}{\left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}}{\left|z2\right|} \]
    6. Applied rewrites62.7%

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

Alternative 7: 68.4% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\ t_1 := \frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\ \mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\ \;\;\;\;\frac{\sqrt{\left(t\_0 \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (let* ((t_0 (- (- (* (- z1 z0) z3) z2) z2))
       (t_1 (/ (sqrt (* (+ z0 z0) (* z3 t_0))) (fabs z2))))
  (if (<= z0 -49999999999999999661047433718081398823085422097203200)
    t_1
    (if (<=
         z0
         5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176)
      (/ (sqrt (* (* t_0 (+ z0 z0)) z3)) (fabs z2))
      t_1))))
double code(double z0, double z1, double z2, double z3) {
	double t_0 = (((z1 - z0) * z3) - z2) - z2;
	double t_1 = sqrt(((z0 + z0) * (z3 * t_0))) / fabs(z2);
	double tmp;
	if (z0 <= -5e+52) {
		tmp = t_1;
	} else if (z0 <= 5e+105) {
		tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / fabs(z2);
	} 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(z0, z1, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (((z1 - z0) * z3) - z2) - z2
    t_1 = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2)
    if (z0 <= (-5d+52)) then
        tmp = t_1
    else if (z0 <= 5d+105) then
        tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double z0, double z1, double z2, double z3) {
	double t_0 = (((z1 - z0) * z3) - z2) - z2;
	double t_1 = Math.sqrt(((z0 + z0) * (z3 * t_0))) / Math.abs(z2);
	double tmp;
	if (z0 <= -5e+52) {
		tmp = t_1;
	} else if (z0 <= 5e+105) {
		tmp = Math.sqrt(((t_0 * (z0 + z0)) * z3)) / Math.abs(z2);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(z0, z1, z2, z3):
	t_0 = (((z1 - z0) * z3) - z2) - z2
	t_1 = math.sqrt(((z0 + z0) * (z3 * t_0))) / math.fabs(z2)
	tmp = 0
	if z0 <= -5e+52:
		tmp = t_1
	elif z0 <= 5e+105:
		tmp = math.sqrt(((t_0 * (z0 + z0)) * z3)) / math.fabs(z2)
	else:
		tmp = t_1
	return tmp
function code(z0, z1, z2, z3)
	t_0 = Float64(Float64(Float64(Float64(z1 - z0) * z3) - z2) - z2)
	t_1 = Float64(sqrt(Float64(Float64(z0 + z0) * Float64(z3 * t_0))) / abs(z2))
	tmp = 0.0
	if (z0 <= -5e+52)
		tmp = t_1;
	elseif (z0 <= 5e+105)
		tmp = Float64(sqrt(Float64(Float64(t_0 * Float64(z0 + z0)) * z3)) / abs(z2));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(z0, z1, z2, z3)
	t_0 = (((z1 - z0) * z3) - z2) - z2;
	t_1 = sqrt(((z0 + z0) * (z3 * t_0))) / abs(z2);
	tmp = 0.0;
	if (z0 <= -5e+52)
		tmp = t_1;
	elseif (z0 <= 5e+105)
		tmp = sqrt(((t_0 * (z0 + z0)) * z3)) / abs(z2);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[z0_, z1_, z2_, z3_] := Block[{t$95$0 = N[(N[(N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision] - z2), $MachinePrecision] - z2), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[(z0 + z0), $MachinePrecision] * N[(z3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z0, -49999999999999999661047433718081398823085422097203200], t$95$1, If[LessEqual[z0, 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176], N[(N[Sqrt[N[(N[(t$95$0 * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\\
t_1 := \frac{\sqrt{\left(z0 + z0\right) \cdot \left(z3 \cdot t\_0\right)}}{\left|z2\right|}\\
\mathbf{if}\;z0 \leq -49999999999999999661047433718081398823085422097203200:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z0 \leq 5000000000000000455179995251842175052302269975877432785772728687420451447675667076077090048770806095282176:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -5e52 or 5.0000000000000005e105 < z0

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(2 \cdot z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      7. count-2-revN/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(z0 + z0\right)} \cdot \left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}{\left|z2\right|} \]
      9. lower-*.f6462.7%

        \[\leadsto \frac{\sqrt{\left(z0 + z0\right) \cdot \color{blue}{\left(z3 \cdot \left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right)\right)}}}{\left|z2\right|} \]
    6. Applied rewrites62.7%

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

    if -5e52 < z0 < 5.0000000000000005e105

    1. Initial program 59.6%

      \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
    2. Applied rewrites65.5%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
    4. Applied rewrites65.6%

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

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(2 \cdot z0\right)\right) \cdot z3}}}{\left|z2\right|} \]
      5. lower-*.f6464.6%

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

        \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(2 \cdot z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
      7. count-2-revN/A

        \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(z0 + z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
      8. lower-+.f6464.6%

        \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(z0 + z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
    6. Applied rewrites64.6%

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

Alternative 8: 64.6% accurate, 1.2× speedup?

\[\frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|} \]
(FPCore (z0 z1 z2 z3)
  :precision binary64
  (/
 (sqrt (* (* (- (- (* (- z1 z0) z3) z2) z2) (+ z0 z0)) z3))
 (fabs z2)))
double code(double z0, double z1, double z2, double z3) {
	return sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / fabs(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(z0, z1, z2, z3)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8), intent (in) :: z2
    real(8), intent (in) :: z3
    code = sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / abs(z2)
end function
public static double code(double z0, double z1, double z2, double z3) {
	return Math.sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / Math.abs(z2);
}
def code(z0, z1, z2, z3):
	return math.sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / math.fabs(z2)
function code(z0, z1, z2, z3)
	return Float64(sqrt(Float64(Float64(Float64(Float64(Float64(Float64(z1 - z0) * z3) - z2) - z2) * Float64(z0 + z0)) * z3)) / abs(z2))
end
function tmp = code(z0, z1, z2, z3)
	tmp = sqrt(((((((z1 - z0) * z3) - z2) - z2) * (z0 + z0)) * z3)) / abs(z2);
end
code[z0_, z1_, z2_, z3_] := N[(N[Sqrt[N[(N[(N[(N[(N[(N[(z1 - z0), $MachinePrecision] * z3), $MachinePrecision] - z2), $MachinePrecision] - z2), $MachinePrecision] * N[(z0 + z0), $MachinePrecision]), $MachinePrecision] * z3), $MachinePrecision]], $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(z0 + z0\right)\right) \cdot z3}}{\left|z2\right|}
Derivation
  1. Initial program 59.6%

    \[\sqrt{\left(\left(-2 \cdot z0\right) \cdot \frac{\frac{z0 - z1}{z2} \cdot z3 - -2}{z2}\right) \cdot z3} \]
  2. Applied rewrites65.5%

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

    \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(z2 + z2\right) - \left(z1 - z0\right) \cdot z3\right) \cdot z3\right) \cdot \left(z0 \cdot -2\right)}}}{\left|z2\right|} \]
  4. Applied rewrites65.6%

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

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(2 \cdot z0\right)\right) \cdot z3}}}{\left|z2\right|} \]
    5. lower-*.f6464.6%

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

      \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(2 \cdot z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
    7. count-2-revN/A

      \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(z0 + z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
    8. lower-+.f6464.6%

      \[\leadsto \frac{\sqrt{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \color{blue}{\left(z0 + z0\right)}\right) \cdot z3}}{\left|z2\right|} \]
  6. Applied rewrites64.6%

    \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(\left(\left(z1 - z0\right) \cdot z3 - z2\right) - z2\right) \cdot \left(z0 + z0\right)\right) \cdot z3}}}{\left|z2\right|} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2025277 -o generate:taylor -o generate:evaluate
(FPCore (z0 z1 z2 z3)
  :name "(sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3))"
  :precision binary64
  (sqrt (* (* (* -2 z0) (/ (- (* (/ (- z0 z1) z2) z3) -2) z2)) z3)))