Optimal throwing angle

Percentage Accurate: 68.0% → 99.8%
Time: 3.7s
Alternatives: 5
Speedup: 0.7×

Specification

?
\[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
(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]
\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

\[\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right) \]
(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]
\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)

Alternative 1: 99.8% accurate, 0.5× speedup?

\[\mathsf{copysign}\left(1, v\right) \cdot \begin{array}{l} \mathbf{if}\;\left|v\right| \leq 2 \cdot 10^{+150}:\\ \;\;\;\;\tan^{-1} \left({\left(\mathsf{fma}\left(H, -19.6, \left|v\right| \cdot \left|v\right|\right)\right)}^{-0.5} \cdot \left|v\right|\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \]
(FPCore (v H)
 :precision binary64
 (*
  (copysign 1.0 v)
  (if (<= (fabs v) 2e+150)
    (atan (* (pow (fma H -19.6 (* (fabs v) (fabs v))) -0.5) (fabs v)))
    (atan 1.0))))
double code(double v, double H) {
	double tmp;
	if (fabs(v) <= 2e+150) {
		tmp = atan((pow(fma(H, -19.6, (fabs(v) * fabs(v))), -0.5) * fabs(v)));
	} else {
		tmp = atan(1.0);
	}
	return copysign(1.0, v) * tmp;
}
function code(v, H)
	tmp = 0.0
	if (abs(v) <= 2e+150)
		tmp = atan(Float64((fma(H, -19.6, Float64(abs(v) * abs(v))) ^ -0.5) * abs(v)));
	else
		tmp = atan(1.0);
	end
	return Float64(copysign(1.0, v) * tmp)
end
code[v_, H_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[v], $MachinePrecision], 2e+150], N[ArcTan[N[(N[Power[N[(H * -19.6 + N[(N[Abs[v], $MachinePrecision] * N[Abs[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision] * N[Abs[v], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, v\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|v\right| \leq 2 \cdot 10^{+150}:\\
\;\;\;\;\tan^{-1} \left({\left(\mathsf{fma}\left(H, -19.6, \left|v\right| \cdot \left|v\right|\right)\right)}^{-0.5} \cdot \left|v\right|\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < 1.99999999999999996e150

    1. Initial program 68.0%

      \[\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{v \cdot v - \color{blue}{\left(2 \cdot \frac{49}{5}\right) \cdot H}}}\right) \]
      3. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right)} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|v\right|\right)\right)\right)\right) \cdot \left|v\right|}}\right) \]
      10. distribute-lft-neg-outN/A

        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|v\right|\right)\right) \cdot \left|v\right|\right)\right)}}}\right) \]
      11. distribute-rgt-neg-outN/A

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

        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) + \color{blue}{\left|v\right| \cdot \left|v\right|}}}\right) \]
      13. sqr-abs-revN/A

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

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

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

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

        \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, \mathsf{neg}\left(\color{blue}{\frac{98}{5}}\right), v \cdot v\right)}}\right) \]
      18. metadata-eval68.0%

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

      \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}}\right) \]
    4. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1} \left(\frac{v}{{\left(\color{blue}{v \cdot v} - \left(2 \cdot \frac{49}{5}\right) \cdot H\right)}^{\frac{1}{2}}}\right) \]
    5. Applied rewrites68.0%

      \[\leadsto \tan^{-1} \color{blue}{\left(\frac{1}{\sqrt{\mathsf{fma}\left(-19.6, H, v \cdot v\right)}} \cdot v\right)} \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

        \[\leadsto \tan^{-1} \left({\left(\mathsf{fma}\left(\frac{-98}{5}, H, v \cdot v\right)\right)}^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}} \cdot v\right) \]
      7. lower-pow.f64N/A

        \[\leadsto \tan^{-1} \left(\color{blue}{{\left(\mathsf{fma}\left(\frac{-98}{5}, H, v \cdot v\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}} \cdot v\right) \]
      8. lift-fma.f64N/A

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

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

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

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

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

        \[\leadsto \tan^{-1} \left({\left(\color{blue}{H \cdot \frac{-98}{5}} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(v\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(v\right)\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot v\right) \]
      14. distribute-lft-neg-inN/A

        \[\leadsto \tan^{-1} \left({\left(H \cdot \frac{-98}{5} + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(v\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(v\right)\right)\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot v\right) \]
      15. distribute-lft-neg-inN/A

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

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

        \[\leadsto \tan^{-1} \left({\left(H \cdot \frac{-98}{5} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{v \cdot v}\right)\right)\right)\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot v\right) \]
      18. remove-double-negN/A

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

        \[\leadsto \tan^{-1} \left({\color{blue}{\left(\mathsf{fma}\left(H, \frac{-98}{5}, v \cdot v\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot v\right) \]
      20. metadata-eval68.0%

        \[\leadsto \tan^{-1} \left({\left(\mathsf{fma}\left(H, -19.6, v \cdot v\right)\right)}^{\color{blue}{-0.5}} \cdot v\right) \]
    7. Applied rewrites68.0%

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

    if 1.99999999999999996e150 < v

    1. Initial program 68.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 rewrites34.6%

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

    Alternative 2: 99.8% accurate, 0.7× speedup?

    \[\mathsf{copysign}\left(1, v\right) \cdot \begin{array}{l} \mathbf{if}\;\left|v\right| \leq 2 \cdot 10^{+150}:\\ \;\;\;\;\tan^{-1} \left(\frac{\left|v\right|}{\sqrt{\mathsf{fma}\left(H, -19.6, \left|v\right| \cdot \left|v\right|\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \]
    (FPCore (v H)
     :precision binary64
     (*
      (copysign 1.0 v)
      (if (<= (fabs v) 2e+150)
        (atan (/ (fabs v) (sqrt (fma H -19.6 (* (fabs v) (fabs v))))))
        (atan 1.0))))
    double code(double v, double H) {
    	double tmp;
    	if (fabs(v) <= 2e+150) {
    		tmp = atan((fabs(v) / sqrt(fma(H, -19.6, (fabs(v) * fabs(v))))));
    	} else {
    		tmp = atan(1.0);
    	}
    	return copysign(1.0, v) * tmp;
    }
    
    function code(v, H)
    	tmp = 0.0
    	if (abs(v) <= 2e+150)
    		tmp = atan(Float64(abs(v) / sqrt(fma(H, -19.6, Float64(abs(v) * abs(v))))));
    	else
    		tmp = atan(1.0);
    	end
    	return Float64(copysign(1.0, v) * tmp)
    end
    
    code[v_, H_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[v], $MachinePrecision], 2e+150], N[ArcTan[N[(N[Abs[v], $MachinePrecision] / N[Sqrt[N[(H * -19.6 + N[(N[Abs[v], $MachinePrecision] * N[Abs[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]), $MachinePrecision]
    
    \mathsf{copysign}\left(1, v\right) \cdot \begin{array}{l}
    \mathbf{if}\;\left|v\right| \leq 2 \cdot 10^{+150}:\\
    \;\;\;\;\tan^{-1} \left(\frac{\left|v\right|}{\sqrt{\mathsf{fma}\left(H, -19.6, \left|v\right| \cdot \left|v\right|\right)}}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\tan^{-1} 1\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if v < 1.99999999999999996e150

      1. Initial program 68.0%

        \[\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{v \cdot v - \color{blue}{\left(2 \cdot \frac{49}{5}\right) \cdot H}}}\right) \]
        3. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

          \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right)} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|v\right|\right)\right)\right)\right) \cdot \left|v\right|}}\right) \]
        10. distribute-lft-neg-outN/A

          \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|v\right|\right)\right) \cdot \left|v\right|\right)\right)}}}\right) \]
        11. distribute-rgt-neg-outN/A

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

          \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) + \color{blue}{\left|v\right| \cdot \left|v\right|}}}\right) \]
        13. sqr-abs-revN/A

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

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

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

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

          \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, \mathsf{neg}\left(\color{blue}{\frac{98}{5}}\right), v \cdot v\right)}}\right) \]
        18. metadata-eval68.0%

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

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

      if 1.99999999999999996e150 < v

      1. Initial program 68.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 rewrites34.6%

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

      Alternative 3: 95.9% accurate, 0.3× speedup?

      \[\begin{array}{l} t_0 := \tan^{-1} \left(\frac{\left|v\right|}{\sqrt{\left|v\right| \cdot \left|v\right| - \left(2 \cdot 9.8\right) \cdot H}}\right)\\ \mathsf{copysign}\left(1, v\right) \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\tan^{-1} 1\\ \mathbf{elif}\;t\_0 \leq 0.1:\\ \;\;\;\;\tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot \left|v\right|\right)\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1} 1\\ \end{array} \end{array} \]
      (FPCore (v H)
       :precision binary64
       (let* ((t_0
               (atan
                (/ (fabs v) (sqrt (- (* (fabs v) (fabs v)) (* (* 2.0 9.8) H)))))))
         (*
          (copysign 1.0 v)
          (if (<= t_0 0.0)
            (atan 1.0)
            (if (<= t_0 0.1)
              (atan (* (sqrt (/ -0.05102040816326531 H)) (fabs v)))
              (atan 1.0))))))
      double code(double v, double H) {
      	double t_0 = atan((fabs(v) / sqrt(((fabs(v) * fabs(v)) - ((2.0 * 9.8) * H)))));
      	double tmp;
      	if (t_0 <= 0.0) {
      		tmp = atan(1.0);
      	} else if (t_0 <= 0.1) {
      		tmp = atan((sqrt((-0.05102040816326531 / H)) * fabs(v)));
      	} else {
      		tmp = atan(1.0);
      	}
      	return copysign(1.0, v) * tmp;
      }
      
      public static double code(double v, double H) {
      	double t_0 = Math.atan((Math.abs(v) / Math.sqrt(((Math.abs(v) * Math.abs(v)) - ((2.0 * 9.8) * H)))));
      	double tmp;
      	if (t_0 <= 0.0) {
      		tmp = Math.atan(1.0);
      	} else if (t_0 <= 0.1) {
      		tmp = Math.atan((Math.sqrt((-0.05102040816326531 / H)) * Math.abs(v)));
      	} else {
      		tmp = Math.atan(1.0);
      	}
      	return Math.copySign(1.0, v) * tmp;
      }
      
      def code(v, H):
      	t_0 = math.atan((math.fabs(v) / math.sqrt(((math.fabs(v) * math.fabs(v)) - ((2.0 * 9.8) * H)))))
      	tmp = 0
      	if t_0 <= 0.0:
      		tmp = math.atan(1.0)
      	elif t_0 <= 0.1:
      		tmp = math.atan((math.sqrt((-0.05102040816326531 / H)) * math.fabs(v)))
      	else:
      		tmp = math.atan(1.0)
      	return math.copysign(1.0, v) * tmp
      
      function code(v, H)
      	t_0 = atan(Float64(abs(v) / sqrt(Float64(Float64(abs(v) * abs(v)) - Float64(Float64(2.0 * 9.8) * H)))))
      	tmp = 0.0
      	if (t_0 <= 0.0)
      		tmp = atan(1.0);
      	elseif (t_0 <= 0.1)
      		tmp = atan(Float64(sqrt(Float64(-0.05102040816326531 / H)) * abs(v)));
      	else
      		tmp = atan(1.0);
      	end
      	return Float64(copysign(1.0, v) * tmp)
      end
      
      function tmp_2 = code(v, H)
      	t_0 = atan((abs(v) / sqrt(((abs(v) * abs(v)) - ((2.0 * 9.8) * H)))));
      	tmp = 0.0;
      	if (t_0 <= 0.0)
      		tmp = atan(1.0);
      	elseif (t_0 <= 0.1)
      		tmp = atan((sqrt((-0.05102040816326531 / H)) * abs(v)));
      	else
      		tmp = atan(1.0);
      	end
      	tmp_2 = (sign(v) * abs(1.0)) * tmp;
      end
      
      code[v_, H_] := Block[{t$95$0 = N[ArcTan[N[(N[Abs[v], $MachinePrecision] / N[Sqrt[N[(N[(N[Abs[v], $MachinePrecision] * N[Abs[v], $MachinePrecision]), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$0, 0.0], N[ArcTan[1.0], $MachinePrecision], If[LessEqual[t$95$0, 0.1], N[ArcTan[N[(N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision] * N[Abs[v], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]), $MachinePrecision]]
      
      \begin{array}{l}
      t_0 := \tan^{-1} \left(\frac{\left|v\right|}{\sqrt{\left|v\right| \cdot \left|v\right| - \left(2 \cdot 9.8\right) \cdot H}}\right)\\
      \mathsf{copysign}\left(1, v\right) \cdot \begin{array}{l}
      \mathbf{if}\;t\_0 \leq 0:\\
      \;\;\;\;\tan^{-1} 1\\
      
      \mathbf{elif}\;t\_0 \leq 0.1:\\
      \;\;\;\;\tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot \left|v\right|\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\tan^{-1} 1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) < 0.0 or 0.10000000000000001 < (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H)))))

        1. Initial program 68.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 rewrites34.6%

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

          if 0.0 < (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) < 0.10000000000000001

          1. Initial program 68.0%

            \[\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{v \cdot v - \color{blue}{\left(2 \cdot \frac{49}{5}\right) \cdot H}}}\right) \]
            3. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right)} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|v\right|\right)\right)\right)\right) \cdot \left|v\right|}}\right) \]
            10. distribute-lft-neg-outN/A

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|v\right|\right)\right) \cdot \left|v\right|\right)\right)}}}\right) \]
            11. distribute-rgt-neg-outN/A

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

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{H \cdot \left(\mathsf{neg}\left(2 \cdot \frac{49}{5}\right)\right) + \color{blue}{\left|v\right| \cdot \left|v\right|}}}\right) \]
            13. sqr-abs-revN/A

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

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

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

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

              \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, \mathsf{neg}\left(\color{blue}{\frac{98}{5}}\right), v \cdot v\right)}}\right) \]
            18. metadata-eval68.0%

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

            \[\leadsto \tan^{-1} \left(\frac{v}{\sqrt{\color{blue}{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}}\right) \]
          4. Step-by-step derivation
            1. lift-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \tan^{-1} \left(\frac{v}{{\left(\color{blue}{v \cdot v} - \left(2 \cdot \frac{49}{5}\right) \cdot H\right)}^{\frac{1}{2}}}\right) \]
          5. Applied rewrites68.0%

            \[\leadsto \tan^{-1} \color{blue}{\left(\frac{1}{\sqrt{\mathsf{fma}\left(-19.6, H, v \cdot v\right)}} \cdot v\right)} \]
          6. Step-by-step derivation
            1. lift-/.f64N/A

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

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

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

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

              \[\leadsto \tan^{-1} \left(\color{blue}{\sqrt{\frac{1}{\mathsf{fma}\left(\frac{-98}{5}, H, v \cdot v\right)}}} \cdot v\right) \]
            6. lower-/.f6468.0%

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

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

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

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

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

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

              \[\leadsto \tan^{-1} \left(\sqrt{\frac{1}{\color{blue}{H \cdot \frac{-98}{5}} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(v\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(v\right)\right)}} \cdot v\right) \]
            13. distribute-lft-neg-inN/A

              \[\leadsto \tan^{-1} \left(\sqrt{\frac{1}{H \cdot \frac{-98}{5} + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(v\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(v\right)\right)\right)\right)}}} \cdot v\right) \]
            14. distribute-lft-neg-inN/A

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

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

              \[\leadsto \tan^{-1} \left(\sqrt{\frac{1}{H \cdot \frac{-98}{5} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{v \cdot v}\right)\right)\right)\right)}} \cdot v\right) \]
            17. remove-double-negN/A

              \[\leadsto \tan^{-1} \left(\sqrt{\frac{1}{H \cdot \frac{-98}{5} + \color{blue}{v \cdot v}}} \cdot v\right) \]
            18. lower-fma.f6468.0%

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

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

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

              \[\leadsto \tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{\color{blue}{H}}} \cdot v\right) \]
          10. Applied rewrites39.8%

            \[\leadsto \tan^{-1} \left(\sqrt{\color{blue}{\frac{-0.05102040816326531}{H}}} \cdot v\right) \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 4: 67.1% accurate, 1.7× speedup?

        \[\mathsf{copysign}\left(1, v\right) \cdot \tan^{-1} 1 \]
        (FPCore (v H) :precision binary64 (* (copysign 1.0 v) (atan 1.0)))
        double code(double v, double H) {
        	return copysign(1.0, v) * atan(1.0);
        }
        
        public static double code(double v, double H) {
        	return Math.copySign(1.0, v) * Math.atan(1.0);
        }
        
        def code(v, H):
        	return math.copysign(1.0, v) * math.atan(1.0)
        
        function code(v, H)
        	return Float64(copysign(1.0, v) * atan(1.0))
        end
        
        function tmp = code(v, H)
        	tmp = (sign(v) * abs(1.0)) * atan(1.0);
        end
        
        code[v_, H_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[v]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[ArcTan[1.0], $MachinePrecision]), $MachinePrecision]
        
        \mathsf{copysign}\left(1, v\right) \cdot \tan^{-1} 1
        
        Derivation
        1. Initial program 68.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 rewrites34.6%

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

          Alternative 5: 34.3% accurate, 2.6× speedup?

          \[\tan^{-1} -1 \]
          (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]
          
          \tan^{-1} -1
          
          Derivation
          1. Initial program 68.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 rewrites34.3%

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

            Reproduce

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