?

Average Accuracy: 99.8% → 99.8%
Time: 33.4s
Precision: binary64
Cost: 336768

?

\[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
\[\begin{array}{l} t_1 := \mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\\ t_2 := \sin \phi_1 \cdot t_1\\ t_3 := \mathsf{fma}\left(t_2, \mathsf{fma}\left(\sin \phi_1, t_1, \cos delta\right), {\cos delta}^{2}\right)\\ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{{\cos delta}^{3}}{t_3} - \frac{{t_2}^{3}}{t_3}} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (* (sin theta) (sin delta)) (cos phi1))
   (-
    (cos delta)
    (*
     (sin phi1)
     (sin
      (asin
       (+
        (* (sin phi1) (cos delta))
        (* (* (cos phi1) (sin delta)) (cos theta))))))))))
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1
         (fma
          (cos phi1)
          (* (sin delta) (cos theta))
          (* (cos delta) (sin phi1))))
        (t_2 (* (sin phi1) t_1))
        (t_3 (fma t_2 (fma (sin phi1) t_1 (cos delta)) (pow (cos delta) 2.0))))
   (+
    lambda1
    (atan2
     (* (* (sin theta) (sin delta)) (cos phi1))
     (- (/ (pow (cos delta) 3.0) t_3) (/ (pow t_2 3.0) t_3))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
}
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = fma(cos(phi1), (sin(delta) * cos(theta)), (cos(delta) * sin(phi1)));
	double t_2 = sin(phi1) * t_1;
	double t_3 = fma(t_2, fma(sin(phi1), t_1, cos(delta)), pow(cos(delta), 2.0));
	return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), ((pow(cos(delta), 3.0) / t_3) - (pow(t_2, 3.0) / t_3)));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(Float64(cos(phi1) * sin(delta)) * cos(theta)))))))))
end
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = fma(cos(phi1), Float64(sin(delta) * cos(theta)), Float64(cos(delta) * sin(phi1)))
	t_2 = Float64(sin(phi1) * t_1)
	t_3 = fma(t_2, fma(sin(phi1), t_1, cos(delta)), (cos(delta) ^ 2.0))
	return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(Float64((cos(delta) ^ 3.0) / t_3) - Float64((t_2 ^ 3.0) / t_3))))
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(N[Sin[phi1], $MachinePrecision] * t$95$1 + N[Cos[delta], $MachinePrecision]), $MachinePrecision] + N[Power[N[Cos[delta], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Power[N[Cos[delta], $MachinePrecision], 3.0], $MachinePrecision] / t$95$3), $MachinePrecision] - N[(N[Power[t$95$2, 3.0], $MachinePrecision] / t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}
\begin{array}{l}
t_1 := \mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\\
t_2 := \sin \phi_1 \cdot t_1\\
t_3 := \mathsf{fma}\left(t_2, \mathsf{fma}\left(\sin \phi_1, t_1, \cos delta\right), {\cos delta}^{2}\right)\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{{\cos delta}^{3}}{t_3} - \frac{{t_2}^{3}}{t_3}}
\end{array}

Error?

Derivation?

  1. Initial program 99.8%

    \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
  2. Applied egg-rr99.7%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\log \left(1 + \mathsf{expm1}\left(\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right)\right)}} \]
    Proof

    [Start]99.8

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]

    log1p-expm1-u [=>]99.8

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)\right)\right)}} \]

    log1p-udef [=>]99.7

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\log \left(1 + \mathsf{expm1}\left(\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)\right)\right)}} \]

    sin-asin [=>]99.7

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\log \left(1 + \mathsf{expm1}\left(\cos delta - \sin \phi_1 \cdot \color{blue}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}\right)\right)} \]
  3. Applied egg-rr99.8%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{{\cos delta}^{3}}{\mathsf{fma}\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \cos theta \cdot \sin delta, \cos delta \cdot \sin \phi_1\right), \mathsf{fma}\left(\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \cos theta \cdot \sin delta, \cos delta \cdot \sin \phi_1\right), \cos delta\right), {\cos delta}^{2}\right)} - \frac{{\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \cos theta \cdot \sin delta, \cos delta \cdot \sin \phi_1\right)\right)}^{3}}{\mathsf{fma}\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \cos theta \cdot \sin delta, \cos delta \cdot \sin \phi_1\right), \mathsf{fma}\left(\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \cos theta \cdot \sin delta, \cos delta \cdot \sin \phi_1\right), \cos delta\right), {\cos delta}^{2}\right)}}} \]
    Proof

    [Start]99.7

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\log \left(1 + \mathsf{expm1}\left(\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right)\right)} \]

    log1p-def [=>]99.8

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right)\right)}} \]

    log1p-expm1-u [<=]99.8

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)}} \]

    flip3-- [=>]99.8

    \[ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{{\cos delta}^{3} - {\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right)}^{3}}{\cos delta \cdot \cos delta + \left(\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right) \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right) + \cos delta \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right)\right)}}} \]
  4. Final simplification99.8%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{{\cos delta}^{3}}{\mathsf{fma}\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right), \mathsf{fma}\left(\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right), \cos delta\right), {\cos delta}^{2}\right)} - \frac{{\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}^{3}}{\mathsf{fma}\left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right), \mathsf{fma}\left(\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right), \cos delta\right), {\cos delta}^{2}\right)}} \]

Alternatives

Alternative 1
Accuracy99.8%
Cost71680
\[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)} \]
Alternative 2
Accuracy94.9%
Cost65152
\[\begin{array}{l} t_1 := \sin delta \cdot \cos \phi_1\\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot t_1}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + t_1\right)} \end{array} \]
Alternative 3
Accuracy94.9%
Cost65152
\[\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \sin delta \cdot \cos \phi_1\right)} \]
Alternative 4
Accuracy92.4%
Cost45504
\[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - {\sin \phi_1}^{2}} \]
Alternative 5
Accuracy92.4%
Cost39424
\[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta + \left(\frac{\cos \left(\phi_1 + \phi_1\right)}{2} - 0.5\right)} \]
Alternative 6
Accuracy91.6%
Cost39240
\[\begin{array}{l} t_1 := \sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)\\ \mathbf{if}\;delta \leq -10000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;delta \leq 5 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_1}{{\cos \phi_1}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_1}{\cos delta}\\ \end{array} \]
Alternative 7
Accuracy91.6%
Cost33160
\[\begin{array}{l} t_1 := \sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)\\ \mathbf{if}\;delta \leq -500:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;delta \leq 5 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_1}{\frac{\cos \left(\phi_1 + \phi_1\right) + 1}{2}}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_1}{\cos delta}\\ \end{array} \]
Alternative 8
Accuracy90.9%
Cost32904
\[\begin{array}{l} \mathbf{if}\;delta \leq -500:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta}\\ \mathbf{elif}\;delta \leq 5.1 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot delta\right)}{\cos \phi_1 \cdot \cos \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\cos delta}\\ \end{array} \]
Alternative 9
Accuracy91.6%
Cost32904
\[\begin{array}{l} \mathbf{if}\;delta \leq -560:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;delta \leq 5 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot delta\right)}{\cos \phi_1 \cdot \cos \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\cos delta}\\ \end{array} \]
Alternative 10
Accuracy88.8%
Cost32512
\[\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\cos delta} \]
Alternative 11
Accuracy86.4%
Cost26240
\[\lambda_1 + \tan^{-1}_* \frac{\frac{\sin theta \cdot 2}{\frac{2}{\sin delta}}}{\cos delta} \]
Alternative 12
Accuracy86.4%
Cost25984
\[\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta} \]
Alternative 13
Accuracy76.5%
Cost19849
\[\begin{array}{l} \mathbf{if}\;delta \leq -5.5 \cdot 10^{-77} \lor \neg \left(delta \leq 1.25 \cdot 10^{-52}\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1\\ \end{array} \]
Alternative 14
Accuracy80.4%
Cost19849
\[\begin{array}{l} \mathbf{if}\;delta \leq -115000000000 \lor \neg \left(delta \leq 0.11\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\ \end{array} \]
Alternative 15
Accuracy70.7%
Cost19720
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -1.45 \cdot 10^{-279}:\\ \;\;\;\;\lambda_1\\ \mathbf{elif}\;\lambda_1 \leq 2 \cdot 10^{-262}:\\ \;\;\;\;\tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1\\ \end{array} \]
Alternative 16
Accuracy69.8%
Cost13448
\[\begin{array}{l} \mathbf{if}\;theta \leq -3.2 \cdot 10^{+182}:\\ \;\;\;\;\lambda_1\\ \mathbf{elif}\;theta \leq -7 \cdot 10^{-278}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1\\ \end{array} \]
Alternative 17
Accuracy70.2%
Cost64
\[\lambda_1 \]

Error

Reproduce?

herbie shell --seed 2023152 
(FPCore (lambda1 phi1 phi2 delta theta)
  :name "Destination given bearing on a great circle"
  :precision binary64
  (+ lambda1 (atan2 (* (* (sin theta) (sin delta)) (cos phi1)) (- (cos delta) (* (sin phi1) (sin (asin (+ (* (sin phi1) (cos delta)) (* (* (cos phi1) (sin delta)) (cos theta))))))))))