Average Error: 0.1 → 0.1
Time: 23.8s
Precision: binary64
\[\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 := \sin \sin^{-1} \left(\mathsf{fma}\left(\cos delta, \sin \phi_1, \left(\sin delta \cdot \cos \phi_1\right) \cdot \cos theta\right)\right)\\ t_2 := \sin \phi_1 \cdot t_1\\ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\cos delta - t_2\right) + \mathsf{fma}\left(-t_1, \sin \phi_1, t_2\right)} \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
         (sin
          (asin
           (fma
            (cos delta)
            (sin phi1)
            (* (* (sin delta) (cos phi1)) (cos theta))))))
        (t_2 (* (sin phi1) t_1)))
   (+
    lambda1
    (atan2
     (* (* (sin theta) (sin delta)) (cos phi1))
     (+ (- (cos delta) t_2) (fma (- t_1) (sin phi1) t_2))))))
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 = sin(asin(fma(cos(delta), sin(phi1), ((sin(delta) * cos(phi1)) * cos(theta)))));
	double t_2 = sin(phi1) * t_1;
	return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), ((cos(delta) - t_2) + fma(-t_1, sin(phi1), t_2)));
}
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 = sin(asin(fma(cos(delta), sin(phi1), Float64(Float64(sin(delta) * cos(phi1)) * cos(theta)))))
	t_2 = Float64(sin(phi1) * t_1)
	return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(Float64(cos(delta) - t_2) + fma(Float64(-t_1), sin(phi1), t_2))))
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[Sin[N[ArcSin[N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[delta], $MachinePrecision] - t$95$2), $MachinePrecision] + N[((-t$95$1) * N[Sin[phi1], $MachinePrecision] + t$95$2), $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 := \sin \sin^{-1} \left(\mathsf{fma}\left(\cos delta, \sin \phi_1, \left(\sin delta \cdot \cos \phi_1\right) \cdot \cos theta\right)\right)\\
t_2 := \sin \phi_1 \cdot t_1\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\cos delta - t_2\right) + \mathsf{fma}\left(-t_1, \sin \phi_1, t_2\right)}
\end{array}

Error

Bits error versus lambda1

Bits error versus phi1

Bits error versus phi2

Bits error versus delta

Bits error versus theta

Derivation

  1. Initial program 0.1

    \[\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. Simplified0.1

    \[\leadsto \color{blue}{\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(\mathsf{fma}\left(\cos delta, \sin \phi_1, \left(\sin delta \cdot \cos \phi_1\right) \cdot \cos theta\right)\right)}} \]
  3. Applied *-un-lft-identity_binary640.1

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

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

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

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

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

Reproduce

herbie shell --seed 2022137 
(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))))))))))