Optimal throwing angle

Percentage Accurate: 67.3% → 99.3%
Time: 2.1s
Alternatives: 7
Speedup: 1.9×

Specification

?
\[\begin{array}{l} \\ \tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \end{array} \]
(FPCore (v H)
 :precision binary64
 (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))
double code(double v, double H) {
	return atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
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(v, h)
use fmin_fmax_functions
    real(8), intent (in) :: v
    real(8), intent (in) :: h
    code = atan((v / sqrt(((v * v) - ((2.0d0 * 9.8d0) * h)))))
end function
public static double code(double v, double H) {
	return Math.atan((v / Math.sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
def code(v, H):
	return math.atan((v / math.sqrt(((v * v) - ((2.0 * 9.8) * H)))))
function code(v, H)
	return atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(Float64(2.0 * 9.8) * H)))))
end
function tmp = code(v, H)
	tmp = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
end
code[v_, H_] := N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 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: 67.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \end{array} \]
(FPCore (v H)
 :precision binary64
 (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))
double code(double v, double H) {
	return atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
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(v, h)
use fmin_fmax_functions
    real(8), intent (in) :: v
    real(8), intent (in) :: h
    code = atan((v / sqrt(((v * v) - ((2.0d0 * 9.8d0) * h)))))
end function
public static double code(double v, double H) {
	return Math.atan((v / Math.sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
def code(v, H):
	return math.atan((v / math.sqrt(((v * v) - ((2.0 * 9.8) * H)))))
function code(v, H)
	return atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(Float64(2.0 * 9.8) * H)))))
end
function tmp = code(v, H)
	tmp = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
end
code[v_, H_] := N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)
\end{array}

Alternative 1: 99.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq -1 \cdot 10^{+156}:\\ \;\;\;\;\tan^{-1} -1\\ \mathbf{elif}\;v \leq 2 \cdot 10^{+97}:\\ \;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \end{array} \]
(FPCore (v H)
 :precision binary64
 (if (<= v -1e+156)
   (atan -1.0)
   (if (<= v 2e+97)
     (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H)))))
     (atan 1.0))))
double code(double v, double H) {
	double tmp;
	if (v <= -1e+156) {
		tmp = atan(-1.0);
	} else if (v <= 2e+97) {
		tmp = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
	} else {
		tmp = atan(1.0);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(v, h)
use fmin_fmax_functions
    real(8), intent (in) :: v
    real(8), intent (in) :: h
    real(8) :: tmp
    if (v <= (-1d+156)) then
        tmp = atan((-1.0d0))
    else if (v <= 2d+97) then
        tmp = atan((v / sqrt(((v * v) - ((2.0d0 * 9.8d0) * h)))))
    else
        tmp = atan(1.0d0)
    end if
    code = tmp
end function
public static double code(double v, double H) {
	double tmp;
	if (v <= -1e+156) {
		tmp = Math.atan(-1.0);
	} else if (v <= 2e+97) {
		tmp = Math.atan((v / Math.sqrt(((v * v) - ((2.0 * 9.8) * H)))));
	} else {
		tmp = Math.atan(1.0);
	}
	return tmp;
}
def code(v, H):
	tmp = 0
	if v <= -1e+156:
		tmp = math.atan(-1.0)
	elif v <= 2e+97:
		tmp = math.atan((v / math.sqrt(((v * v) - ((2.0 * 9.8) * H)))))
	else:
		tmp = math.atan(1.0)
	return tmp
function code(v, H)
	tmp = 0.0
	if (v <= -1e+156)
		tmp = atan(-1.0);
	elseif (v <= 2e+97)
		tmp = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(Float64(2.0 * 9.8) * H)))));
	else
		tmp = atan(1.0);
	end
	return tmp
end
function tmp_2 = code(v, H)
	tmp = 0.0;
	if (v <= -1e+156)
		tmp = atan(-1.0);
	elseif (v <= 2e+97)
		tmp = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
	else
		tmp = atan(1.0);
	end
	tmp_2 = tmp;
end
code[v_, H_] := If[LessEqual[v, -1e+156], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2e+97], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;v \leq -1 \cdot 10^{+156}:\\
\;\;\;\;\tan^{-1} -1\\

\mathbf{elif}\;v \leq 2 \cdot 10^{+97}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if v < -9.9999999999999998e155

    1. Initial program 3.1%

      \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
    2. Taylor expanded in v around -inf

      \[\leadsto \tan^{-1} \color{blue}{-1} \]
    3. Step-by-step derivation
      1. Applied rewrites100.0%

        \[\leadsto \tan^{-1} \color{blue}{-1} \]

      if -9.9999999999999998e155 < v < 2.0000000000000001e97

      1. Initial program 99.3%

        \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]

      if 2.0000000000000001e97 < v

      1. Initial program 29.4%

        \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
      2. Taylor expanded in v around inf

        \[\leadsto \tan^{-1} \color{blue}{1} \]
      3. Step-by-step derivation
        1. Applied rewrites98.6%

          \[\leadsto \tan^{-1} \color{blue}{1} \]
      4. Recombined 3 regimes into one program.
      5. Add Preprocessing

      Alternative 2: 99.3% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq -1 \cdot 10^{+156}:\\ \;\;\;\;\tan^{-1} -1\\ \mathbf{elif}\;v \leq 2 \cdot 10^{+97}:\\ \;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \end{array} \]
      (FPCore (v H)
       :precision binary64
       (if (<= v -1e+156)
         (atan -1.0)
         (if (<= v 2e+97) (atan (/ v (sqrt (fma H -19.6 (* v v))))) (atan 1.0))))
      double code(double v, double H) {
      	double tmp;
      	if (v <= -1e+156) {
      		tmp = atan(-1.0);
      	} else if (v <= 2e+97) {
      		tmp = atan((v / sqrt(fma(H, -19.6, (v * v)))));
      	} else {
      		tmp = atan(1.0);
      	}
      	return tmp;
      }
      
      function code(v, H)
      	tmp = 0.0
      	if (v <= -1e+156)
      		tmp = atan(-1.0);
      	elseif (v <= 2e+97)
      		tmp = atan(Float64(v / sqrt(fma(H, -19.6, Float64(v * v)))));
      	else
      		tmp = atan(1.0);
      	end
      	return tmp
      end
      
      code[v_, H_] := If[LessEqual[v, -1e+156], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2e+97], N[ArcTan[N[(v / N[Sqrt[N[(H * -19.6 + N[(v * v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;v \leq -1 \cdot 10^{+156}:\\
      \;\;\;\;\tan^{-1} -1\\
      
      \mathbf{elif}\;v \leq 2 \cdot 10^{+97}:\\
      \;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\tan^{-1} 1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if v < -9.9999999999999998e155

        1. Initial program 3.1%

          \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
        2. Taylor expanded in v around -inf

          \[\leadsto \tan^{-1} \color{blue}{-1} \]
        3. Step-by-step derivation
          1. Applied rewrites100.0%

            \[\leadsto \tan^{-1} \color{blue}{-1} \]

          if -9.9999999999999998e155 < v < 2.0000000000000001e97

          1. Initial program 99.3%

            \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
          2. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{v \cdot v} - \left(2 \cdot \frac{49}{5}\right) \cdot H}}\right) \]
            2. lift--.f64N/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{v \cdot v - \left(2 \cdot \frac{49}{5}\right) \cdot H}}}\right) \]
            3. pow2N/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{{v}^{2}} - \left(2 \cdot \frac{49}{5}\right) \cdot H}}\right) \]
            4. lift-*.f64N/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} - \color{blue}{\left(2 \cdot \frac{49}{5}\right)} \cdot H}}\right) \]
            5. lift-*.f64N/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} - \color{blue}{\left(2 \cdot \frac{49}{5}\right) \cdot H}}}\right) \]
            6. fp-cancel-sub-sign-invN/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{{v}^{2} + \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) \cdot H}}}\right) \]
            7. metadata-evalN/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} + \left(\mathsf{neg}\left(\color{blue}{\frac{98}{5}}\right)\right) \cdot H}}\right) \]
            8. metadata-evalN/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} + \color{blue}{\frac{-98}{5}} \cdot H}}\right) \]
            9. +-commutativeN/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\frac{-98}{5} \cdot H + {v}^{2}}}}\right) \]
            10. *-commutativeN/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{H \cdot \frac{-98}{5}} + {v}^{2}}}\right) \]
            11. lower-fma.f64N/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\mathsf{fma}\left(H, \frac{-98}{5}, {v}^{2}\right)}}}\right) \]
            12. pow2N/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, \frac{-98}{5}, \color{blue}{v \cdot v}\right)}}\right) \]
            13. lift-*.f6499.3

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, -19.6, \color{blue}{v \cdot v}\right)}}\right) \]
          3. Applied rewrites99.3%

            \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}}\right) \]

          if 2.0000000000000001e97 < v

          1. Initial program 29.4%

            \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
          2. Taylor expanded in v around inf

            \[\leadsto \tan^{-1} \color{blue}{1} \]
          3. Step-by-step derivation
            1. Applied rewrites98.6%

              \[\leadsto \tan^{-1} \color{blue}{1} \]
          4. Recombined 3 regimes into one program.
          5. Add Preprocessing

          Alternative 3: 89.5% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq -3.5 \cdot 10^{-66}:\\ \;\;\;\;\tan^{-1} -1\\ \mathbf{elif}\;v \leq 2.4 \cdot 10^{-54}:\\ \;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\frac{H}{v}, -9.8, v\right)}\right)\\ \end{array} \end{array} \]
          (FPCore (v H)
           :precision binary64
           (if (<= v -3.5e-66)
             (atan -1.0)
             (if (<= v 2.4e-54)
               (atan (/ v (sqrt (* -19.6 H))))
               (atan (/ v (fma (/ H v) -9.8 v))))))
          double code(double v, double H) {
          	double tmp;
          	if (v <= -3.5e-66) {
          		tmp = atan(-1.0);
          	} else if (v <= 2.4e-54) {
          		tmp = atan((v / sqrt((-19.6 * H))));
          	} else {
          		tmp = atan((v / fma((H / v), -9.8, v)));
          	}
          	return tmp;
          }
          
          function code(v, H)
          	tmp = 0.0
          	if (v <= -3.5e-66)
          		tmp = atan(-1.0);
          	elseif (v <= 2.4e-54)
          		tmp = atan(Float64(v / sqrt(Float64(-19.6 * H))));
          	else
          		tmp = atan(Float64(v / fma(Float64(H / v), -9.8, v)));
          	end
          	return tmp
          end
          
          code[v_, H_] := If[LessEqual[v, -3.5e-66], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2.4e-54], N[ArcTan[N[(v / N[Sqrt[N[(-19.6 * H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(N[(H / v), $MachinePrecision] * -9.8 + v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;v \leq -3.5 \cdot 10^{-66}:\\
          \;\;\;\;\tan^{-1} -1\\
          
          \mathbf{elif}\;v \leq 2.4 \cdot 10^{-54}:\\
          \;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\frac{H}{v}, -9.8, v\right)}\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if v < -3.5e-66

            1. Initial program 54.0%

              \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
            2. Taylor expanded in v around -inf

              \[\leadsto \tan^{-1} \color{blue}{-1} \]
            3. Step-by-step derivation
              1. Applied rewrites88.5%

                \[\leadsto \tan^{-1} \color{blue}{-1} \]

              if -3.5e-66 < v < 2.40000000000000013e-54

              1. Initial program 99.5%

                \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
              2. Taylor expanded in v around 0

                \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\frac{-98}{5} \cdot H}}}\right) \]
              3. Step-by-step derivation
                1. lower-*.f6489.1

                  \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot \color{blue}{H}}}\right) \]
              4. Applied rewrites89.1%

                \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{-19.6 \cdot H}}}\right) \]

              if 2.40000000000000013e-54 < v

              1. Initial program 54.9%

                \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
              2. Taylor expanded in H around 0

                \[\leadsto \tan^{-1} \left(\frac{v}{\color{blue}{v + \frac{-49}{5} \cdot \frac{H}{v}}}\right) \]
              3. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto \tan^{-1} \left(\frac{v}{\frac{-49}{5} \cdot \frac{H}{v} + \color{blue}{v}}\right) \]
                2. *-commutativeN/A

                  \[\leadsto \tan^{-1} \left(\frac{v}{\frac{H}{v} \cdot \frac{-49}{5} + v}\right) \]
                3. lower-fma.f64N/A

                  \[\leadsto \tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\frac{H}{v}, \color{blue}{\frac{-49}{5}}, v\right)}\right) \]
                4. lower-/.f6490.8

                  \[\leadsto \tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\frac{H}{v}, -9.8, v\right)}\right) \]
              4. Applied rewrites90.8%

                \[\leadsto \tan^{-1} \left(\frac{v}{\color{blue}{\mathsf{fma}\left(\frac{H}{v}, -9.8, v\right)}}\right) \]
            4. Recombined 3 regimes into one program.
            5. Add Preprocessing

            Alternative 4: 89.3% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq -3.5 \cdot 10^{-66}:\\ \;\;\;\;\tan^{-1} -1\\ \mathbf{elif}\;v \leq 2.4 \cdot 10^{-54}:\\ \;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \end{array} \]
            (FPCore (v H)
             :precision binary64
             (if (<= v -3.5e-66)
               (atan -1.0)
               (if (<= v 2.4e-54) (atan (/ v (sqrt (* -19.6 H)))) (atan 1.0))))
            double code(double v, double H) {
            	double tmp;
            	if (v <= -3.5e-66) {
            		tmp = atan(-1.0);
            	} else if (v <= 2.4e-54) {
            		tmp = atan((v / sqrt((-19.6 * H))));
            	} else {
            		tmp = atan(1.0);
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(v, h)
            use fmin_fmax_functions
                real(8), intent (in) :: v
                real(8), intent (in) :: h
                real(8) :: tmp
                if (v <= (-3.5d-66)) then
                    tmp = atan((-1.0d0))
                else if (v <= 2.4d-54) then
                    tmp = atan((v / sqrt(((-19.6d0) * h))))
                else
                    tmp = atan(1.0d0)
                end if
                code = tmp
            end function
            
            public static double code(double v, double H) {
            	double tmp;
            	if (v <= -3.5e-66) {
            		tmp = Math.atan(-1.0);
            	} else if (v <= 2.4e-54) {
            		tmp = Math.atan((v / Math.sqrt((-19.6 * H))));
            	} else {
            		tmp = Math.atan(1.0);
            	}
            	return tmp;
            }
            
            def code(v, H):
            	tmp = 0
            	if v <= -3.5e-66:
            		tmp = math.atan(-1.0)
            	elif v <= 2.4e-54:
            		tmp = math.atan((v / math.sqrt((-19.6 * H))))
            	else:
            		tmp = math.atan(1.0)
            	return tmp
            
            function code(v, H)
            	tmp = 0.0
            	if (v <= -3.5e-66)
            		tmp = atan(-1.0);
            	elseif (v <= 2.4e-54)
            		tmp = atan(Float64(v / sqrt(Float64(-19.6 * H))));
            	else
            		tmp = atan(1.0);
            	end
            	return tmp
            end
            
            function tmp_2 = code(v, H)
            	tmp = 0.0;
            	if (v <= -3.5e-66)
            		tmp = atan(-1.0);
            	elseif (v <= 2.4e-54)
            		tmp = atan((v / sqrt((-19.6 * H))));
            	else
            		tmp = atan(1.0);
            	end
            	tmp_2 = tmp;
            end
            
            code[v_, H_] := If[LessEqual[v, -3.5e-66], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2.4e-54], N[ArcTan[N[(v / N[Sqrt[N[(-19.6 * H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;v \leq -3.5 \cdot 10^{-66}:\\
            \;\;\;\;\tan^{-1} -1\\
            
            \mathbf{elif}\;v \leq 2.4 \cdot 10^{-54}:\\
            \;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\tan^{-1} 1\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if v < -3.5e-66

              1. Initial program 54.0%

                \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
              2. Taylor expanded in v around -inf

                \[\leadsto \tan^{-1} \color{blue}{-1} \]
              3. Step-by-step derivation
                1. Applied rewrites88.5%

                  \[\leadsto \tan^{-1} \color{blue}{-1} \]

                if -3.5e-66 < v < 2.40000000000000013e-54

                1. Initial program 99.5%

                  \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                2. Taylor expanded in v around 0

                  \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\frac{-98}{5} \cdot H}}}\right) \]
                3. Step-by-step derivation
                  1. lower-*.f6489.1

                    \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot \color{blue}{H}}}\right) \]
                4. Applied rewrites89.1%

                  \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{-19.6 \cdot H}}}\right) \]

                if 2.40000000000000013e-54 < v

                1. Initial program 54.9%

                  \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                2. Taylor expanded in v around inf

                  \[\leadsto \tan^{-1} \color{blue}{1} \]
                3. Step-by-step derivation
                  1. Applied rewrites90.3%

                    \[\leadsto \tan^{-1} \color{blue}{1} \]
                4. Recombined 3 regimes into one program.
                5. Add Preprocessing

                Alternative 5: 89.3% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq -3.5 \cdot 10^{-66}:\\ \;\;\;\;\tan^{-1} -1\\ \mathbf{elif}\;v \leq 2.4 \cdot 10^{-54}:\\ \;\;\;\;\tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot v\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \end{array} \]
                (FPCore (v H)
                 :precision binary64
                 (if (<= v -3.5e-66)
                   (atan -1.0)
                   (if (<= v 2.4e-54)
                     (atan (* (sqrt (/ -0.05102040816326531 H)) v))
                     (atan 1.0))))
                double code(double v, double H) {
                	double tmp;
                	if (v <= -3.5e-66) {
                		tmp = atan(-1.0);
                	} else if (v <= 2.4e-54) {
                		tmp = atan((sqrt((-0.05102040816326531 / H)) * v));
                	} else {
                		tmp = atan(1.0);
                	}
                	return tmp;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(v, h)
                use fmin_fmax_functions
                    real(8), intent (in) :: v
                    real(8), intent (in) :: h
                    real(8) :: tmp
                    if (v <= (-3.5d-66)) then
                        tmp = atan((-1.0d0))
                    else if (v <= 2.4d-54) then
                        tmp = atan((sqrt(((-0.05102040816326531d0) / h)) * v))
                    else
                        tmp = atan(1.0d0)
                    end if
                    code = tmp
                end function
                
                public static double code(double v, double H) {
                	double tmp;
                	if (v <= -3.5e-66) {
                		tmp = Math.atan(-1.0);
                	} else if (v <= 2.4e-54) {
                		tmp = Math.atan((Math.sqrt((-0.05102040816326531 / H)) * v));
                	} else {
                		tmp = Math.atan(1.0);
                	}
                	return tmp;
                }
                
                def code(v, H):
                	tmp = 0
                	if v <= -3.5e-66:
                		tmp = math.atan(-1.0)
                	elif v <= 2.4e-54:
                		tmp = math.atan((math.sqrt((-0.05102040816326531 / H)) * v))
                	else:
                		tmp = math.atan(1.0)
                	return tmp
                
                function code(v, H)
                	tmp = 0.0
                	if (v <= -3.5e-66)
                		tmp = atan(-1.0);
                	elseif (v <= 2.4e-54)
                		tmp = atan(Float64(sqrt(Float64(-0.05102040816326531 / H)) * v));
                	else
                		tmp = atan(1.0);
                	end
                	return tmp
                end
                
                function tmp_2 = code(v, H)
                	tmp = 0.0;
                	if (v <= -3.5e-66)
                		tmp = atan(-1.0);
                	elseif (v <= 2.4e-54)
                		tmp = atan((sqrt((-0.05102040816326531 / H)) * v));
                	else
                		tmp = atan(1.0);
                	end
                	tmp_2 = tmp;
                end
                
                code[v_, H_] := If[LessEqual[v, -3.5e-66], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2.4e-54], N[ArcTan[N[(N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;v \leq -3.5 \cdot 10^{-66}:\\
                \;\;\;\;\tan^{-1} -1\\
                
                \mathbf{elif}\;v \leq 2.4 \cdot 10^{-54}:\\
                \;\;\;\;\tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot v\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\tan^{-1} 1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if v < -3.5e-66

                  1. Initial program 54.0%

                    \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                  2. Taylor expanded in v around -inf

                    \[\leadsto \tan^{-1} \color{blue}{-1} \]
                  3. Step-by-step derivation
                    1. Applied rewrites88.5%

                      \[\leadsto \tan^{-1} \color{blue}{-1} \]

                    if -3.5e-66 < v < 2.40000000000000013e-54

                    1. Initial program 99.5%

                      \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                    2. Step-by-step derivation
                      1. lift-*.f64N/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{v \cdot v} - \left(2 \cdot \frac{49}{5}\right) \cdot H}}\right) \]
                      2. lift--.f64N/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{v \cdot v - \left(2 \cdot \frac{49}{5}\right) \cdot H}}}\right) \]
                      3. pow2N/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{{v}^{2}} - \left(2 \cdot \frac{49}{5}\right) \cdot H}}\right) \]
                      4. lift-*.f64N/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} - \color{blue}{\left(2 \cdot \frac{49}{5}\right)} \cdot H}}\right) \]
                      5. lift-*.f64N/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} - \color{blue}{\left(2 \cdot \frac{49}{5}\right) \cdot H}}}\right) \]
                      6. fp-cancel-sub-sign-invN/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{{v}^{2} + \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) \cdot H}}}\right) \]
                      7. metadata-evalN/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} + \left(\mathsf{neg}\left(\color{blue}{\frac{98}{5}}\right)\right) \cdot H}}\right) \]
                      8. metadata-evalN/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{{v}^{2} + \color{blue}{\frac{-98}{5}} \cdot H}}\right) \]
                      9. +-commutativeN/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\frac{-98}{5} \cdot H + {v}^{2}}}}\right) \]
                      10. *-commutativeN/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{H \cdot \frac{-98}{5}} + {v}^{2}}}\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\mathsf{fma}\left(H, \frac{-98}{5}, {v}^{2}\right)}}}\right) \]
                      12. pow2N/A

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, \frac{-98}{5}, \color{blue}{v \cdot v}\right)}}\right) \]
                      13. lift-*.f6499.5

                        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, -19.6, \color{blue}{v \cdot v}\right)}}\right) \]
                    3. Applied rewrites99.5%

                      \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}}\right) \]
                    4. Taylor expanded in v around 0

                      \[\leadsto \color{blue}{\tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right)} \]
                    5. Step-by-step derivation
                      1. pow2N/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      2. +-commutativeN/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      3. *-commutativeN/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      4. fp-cancel-sign-sub-invN/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      5. metadata-evalN/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      6. metadata-evalN/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      7. pow2N/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      8. lower-atan.f64N/A

                        \[\leadsto \tan^{-1} \left(v \cdot \sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}}\right) \]
                      9. *-commutativeN/A

                        \[\leadsto \tan^{-1} \left(\sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}} \cdot v\right) \]
                      10. lower-*.f64N/A

                        \[\leadsto \tan^{-1} \left(\sqrt{\frac{1}{\frac{-98}{5} \cdot H + {v}^{2}}} \cdot v\right) \]
                    6. Applied rewrites99.5%

                      \[\leadsto \color{blue}{\tan^{-1} \left(\sqrt{\frac{1}{\mathsf{fma}\left(-19.6, H, v \cdot v\right)}} \cdot v\right)} \]
                    7. Taylor expanded in v around 0

                      \[\leadsto \tan^{-1} \left(\sqrt{\frac{\frac{-5}{98}}{H}} \cdot v\right) \]
                    8. Step-by-step derivation
                      1. lower-/.f6489.3

                        \[\leadsto \tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot v\right) \]
                    9. Applied rewrites89.3%

                      \[\leadsto \tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot v\right) \]

                    if 2.40000000000000013e-54 < v

                    1. Initial program 54.9%

                      \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                    2. Taylor expanded in v around inf

                      \[\leadsto \tan^{-1} \color{blue}{1} \]
                    3. Step-by-step derivation
                      1. Applied rewrites90.3%

                        \[\leadsto \tan^{-1} \color{blue}{1} \]
                    4. Recombined 3 regimes into one program.
                    5. Add Preprocessing

                    Alternative 6: 68.1% accurate, 1.9× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 8.2 \cdot 10^{-307}:\\ \;\;\;\;\tan^{-1} -1\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \end{array} \]
                    (FPCore (v H) :precision binary64 (if (<= v 8.2e-307) (atan -1.0) (atan 1.0)))
                    double code(double v, double H) {
                    	double tmp;
                    	if (v <= 8.2e-307) {
                    		tmp = atan(-1.0);
                    	} else {
                    		tmp = atan(1.0);
                    	}
                    	return tmp;
                    }
                    
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(v, h)
                    use fmin_fmax_functions
                        real(8), intent (in) :: v
                        real(8), intent (in) :: h
                        real(8) :: tmp
                        if (v <= 8.2d-307) then
                            tmp = atan((-1.0d0))
                        else
                            tmp = atan(1.0d0)
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double v, double H) {
                    	double tmp;
                    	if (v <= 8.2e-307) {
                    		tmp = Math.atan(-1.0);
                    	} else {
                    		tmp = Math.atan(1.0);
                    	}
                    	return tmp;
                    }
                    
                    def code(v, H):
                    	tmp = 0
                    	if v <= 8.2e-307:
                    		tmp = math.atan(-1.0)
                    	else:
                    		tmp = math.atan(1.0)
                    	return tmp
                    
                    function code(v, H)
                    	tmp = 0.0
                    	if (v <= 8.2e-307)
                    		tmp = atan(-1.0);
                    	else
                    		tmp = atan(1.0);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(v, H)
                    	tmp = 0.0;
                    	if (v <= 8.2e-307)
                    		tmp = atan(-1.0);
                    	else
                    		tmp = atan(1.0);
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[v_, H_] := If[LessEqual[v, 8.2e-307], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;v \leq 8.2 \cdot 10^{-307}:\\
                    \;\;\;\;\tan^{-1} -1\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\tan^{-1} 1\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if v < 8.20000000000000064e-307

                      1. Initial program 66.6%

                        \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                      2. Taylor expanded in v around -inf

                        \[\leadsto \tan^{-1} \color{blue}{-1} \]
                      3. Step-by-step derivation
                        1. Applied rewrites67.8%

                          \[\leadsto \tan^{-1} \color{blue}{-1} \]

                        if 8.20000000000000064e-307 < v

                        1. Initial program 67.9%

                          \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                        2. Taylor expanded in v around inf

                          \[\leadsto \tan^{-1} \color{blue}{1} \]
                        3. Step-by-step derivation
                          1. Applied rewrites68.5%

                            \[\leadsto \tan^{-1} \color{blue}{1} \]
                        4. Recombined 2 regimes into one program.
                        5. Add Preprocessing

                        Alternative 7: 35.5% accurate, 2.6× speedup?

                        \[\begin{array}{l} \\ \tan^{-1} -1 \end{array} \]
                        (FPCore (v H) :precision binary64 (atan -1.0))
                        double code(double v, double H) {
                        	return atan(-1.0);
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(v, h)
                        use fmin_fmax_functions
                            real(8), intent (in) :: v
                            real(8), intent (in) :: h
                            code = atan((-1.0d0))
                        end function
                        
                        public static double code(double v, double H) {
                        	return Math.atan(-1.0);
                        }
                        
                        def code(v, H):
                        	return math.atan(-1.0)
                        
                        function code(v, H)
                        	return atan(-1.0)
                        end
                        
                        function tmp = code(v, H)
                        	tmp = atan(-1.0);
                        end
                        
                        code[v_, H_] := N[ArcTan[-1.0], $MachinePrecision]
                        
                        \begin{array}{l}
                        
                        \\
                        \tan^{-1} -1
                        \end{array}
                        
                        Derivation
                        1. Initial program 67.3%

                          \[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
                        2. Taylor expanded in v around -inf

                          \[\leadsto \tan^{-1} \color{blue}{-1} \]
                        3. Step-by-step derivation
                          1. Applied rewrites35.5%

                            \[\leadsto \tan^{-1} \color{blue}{-1} \]
                          2. Add Preprocessing

                          Reproduce

                          ?
                          herbie shell --seed 2025112 
                          (FPCore (v H)
                            :name "Optimal throwing angle"
                            :precision binary64
                            (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))