
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 26 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 82.7%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6492.7
Applied rewrites92.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(t_3 (* (fma (sin (- lambda2)) (cos lambda1) t_0) (cos phi2))))
(if (<= phi2 -4.3e-7)
(atan2 t_3 t_2)
(if (<= phi2 1.4e-29)
(atan2
t_3
(-
t_1
(*
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))
(sin phi1))))
(atan2 (* (cos phi2) (- t_0 (* (cos lambda1) (sin lambda2)))) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)));
double t_3 = fma(sin(-lambda2), cos(lambda1), t_0) * cos(phi2);
double tmp;
if (phi2 <= -4.3e-7) {
tmp = atan2(t_3, t_2);
} else if (phi2 <= 1.4e-29) {
tmp = atan2(t_3, (t_1 - (fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))) * sin(phi1))));
} else {
tmp = atan2((cos(phi2) * (t_0 - (cos(lambda1) * sin(lambda2)))), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2)))) t_3 = Float64(fma(sin(Float64(-lambda2)), cos(lambda1), t_0) * cos(phi2)) tmp = 0.0 if (phi2 <= -4.3e-7) tmp = atan(t_3, t_2); elseif (phi2 <= 1.4e-29) tmp = atan(t_3, Float64(t_1 - Float64(fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))) * sin(phi1)))); else tmp = atan(Float64(cos(phi2) * Float64(t_0 - Float64(cos(lambda1) * sin(lambda2)))), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -4.3e-7], N[ArcTan[t$95$3 / t$95$2], $MachinePrecision], If[LessEqual[phi2, 1.4e-29], N[ArcTan[t$95$3 / N[(t$95$1 - N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t\_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, t\_0\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -4.3 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3}{t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.4 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3}{t\_1 - \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t\_0 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_2}\\
\end{array}
\end{array}
if phi2 < -4.3000000000000001e-7Initial program 80.9%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6493.1
Applied rewrites93.1%
if -4.3000000000000001e-7 < phi2 < 1.4000000000000001e-29Initial program 88.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6492.6
Applied rewrites92.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-sin.f6499.9
Applied rewrites99.9%
if 1.4000000000000001e-29 < phi2 Initial program 75.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.4
Applied rewrites92.4%
Final simplification95.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (- t_0 (* (cos lambda1) (sin lambda2))))
(t_2 (* (cos phi1) (sin phi2)))
(t_3 (* (cos phi2) (sin phi1)))
(t_4 (- t_2 (* t_3 (cos (- lambda1 lambda2))))))
(if (<= phi2 -4.3e-7)
(atan2 (* (fma (sin (- lambda2)) (cos lambda1) t_0) (cos phi2)) t_4)
(if (<= phi2 1.4e-29)
(atan2
t_1
(-
t_2
(*
t_3
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))))
(atan2 (* (cos phi2) t_1) t_4)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = t_0 - (cos(lambda1) * sin(lambda2));
double t_2 = cos(phi1) * sin(phi2);
double t_3 = cos(phi2) * sin(phi1);
double t_4 = t_2 - (t_3 * cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -4.3e-7) {
tmp = atan2((fma(sin(-lambda2), cos(lambda1), t_0) * cos(phi2)), t_4);
} else if (phi2 <= 1.4e-29) {
tmp = atan2(t_1, (t_2 - (t_3 * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
} else {
tmp = atan2((cos(phi2) * t_1), t_4);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(t_0 - Float64(cos(lambda1) * sin(lambda2))) t_2 = Float64(cos(phi1) * sin(phi2)) t_3 = Float64(cos(phi2) * sin(phi1)) t_4 = Float64(t_2 - Float64(t_3 * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi2 <= -4.3e-7) tmp = atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), t_0) * cos(phi2)), t_4); elseif (phi2 <= 1.4e-29) tmp = atan(t_1, Float64(t_2 - Float64(t_3 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))); else tmp = atan(Float64(cos(phi2) * t_1), t_4); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 - N[(t$95$3 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -4.3e-7], N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$4], $MachinePrecision], If[LessEqual[phi2, 1.4e-29], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$3 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$4], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := t\_0 - \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
t_3 := \cos \phi_2 \cdot \sin \phi_1\\
t_4 := t\_2 - t\_3 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.3 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, t\_0\right) \cdot \cos \phi_2}{t\_4}\\
\mathbf{elif}\;\phi_2 \leq 1.4 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_3 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{t\_4}\\
\end{array}
\end{array}
if phi2 < -4.3000000000000001e-7Initial program 80.9%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6493.1
Applied rewrites93.1%
if -4.3000000000000001e-7 < phi2 < 1.4000000000000001e-29Initial program 88.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6492.6
Applied rewrites92.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
sin-negN/A
distribute-lft-neg-outN/A
unsub-negN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6499.9
Applied rewrites99.9%
if 1.4000000000000001e-29 < phi2 Initial program 75.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.4
Applied rewrites92.4%
Final simplification95.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(cos
(* (+ lambda2 lambda1) (/ (- lambda1 lambda2) (+ lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1)))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(Float64(lambda2 + lambda1) * Float64(Float64(lambda1 - lambda2) / Float64(lambda2 + lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(lambda2 + lambda1), $MachinePrecision] * N[(N[(lambda1 - lambda2), $MachinePrecision] / N[(lambda2 + lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\left(\lambda_2 + \lambda_1\right) \cdot \frac{\lambda_1 - \lambda_2}{\lambda_2 + \lambda_1}\right)}
\end{array}
Initial program 82.7%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6492.7
Applied rewrites92.7%
*-rgt-identityN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
inv-powN/A
lift-/.f64N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f6487.0
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6492.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6492.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6492.7
Applied rewrites92.7%
Final simplification92.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2
(atan2
(*
(fma
(sin (- lambda2))
(cos lambda1)
(* (sin lambda1) (cos lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos lambda2))))))
(if (<= lambda2 -2.3e-6)
t_2
(if (<= lambda2 1000000.0)
(atan2
(*
(cos phi2)
(-
(* (sin lambda1) (fma lambda2 (* lambda2 -0.5) 1.0))
(* lambda2 (cos lambda1))))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = atan2((fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
double tmp;
if (lambda2 <= -2.3e-6) {
tmp = t_2;
} else if (lambda2 <= 1000000.0) {
tmp = atan2((cos(phi2) * ((sin(lambda1) * fma(lambda2, (lambda2 * -0.5), 1.0)) - (lambda2 * cos(lambda1)))), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))) tmp = 0.0 if (lambda2 <= -2.3e-6) tmp = t_2; elseif (lambda2 <= 1000000.0) tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * fma(lambda2, Float64(lambda2 * -0.5), 1.0)) - Float64(lambda2 * cos(lambda1)))), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2.3e-6], t$95$2, If[LessEqual[lambda2, 1000000.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[(lambda2 * N[(lambda2 * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(lambda2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -2.3 \cdot 10^{-6}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 1000000:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \mathsf{fma}\left(\lambda_2, \lambda_2 \cdot -0.5, 1\right) - \lambda_2 \cdot \cos \lambda_1\right)}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -2.3e-6 or 1e6 < lambda2 Initial program 65.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6486.0
Applied rewrites86.0%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6486.1
Applied rewrites86.1%
if -2.3e-6 < lambda2 < 1e6Initial program 98.7%
Taylor expanded in lambda2 around 0
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-+r+N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
Applied rewrites98.9%
Final simplification92.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 82.7%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6492.7
Applied rewrites92.7%
Final simplification92.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 82.7%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.7
Applied rewrites92.7%
Final simplification92.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.195)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma (cos phi1) (sin phi2) (* (sin phi1) (* t_1 (- (cos phi2))))))
(if (<= phi1 0.0112)
(atan2
(*
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(-
t_0
(*
t_1
(*
phi1
(* (cos phi2) (fma -0.16666666666666666 (* phi1 phi1) 1.0))))))
(atan2
(*
(cos phi2)
(sin
(* (+ lambda2 lambda1) (/ (- lambda1 lambda2) (+ lambda2 lambda1)))))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.195) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi1), sin(phi2), (sin(phi1) * (t_1 * -cos(phi2)))));
} else if (phi1 <= 0.0112) {
tmp = atan2((fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), (t_0 - (t_1 * (phi1 * (cos(phi2) * fma(-0.16666666666666666, (phi1 * phi1), 1.0))))));
} else {
tmp = atan2((cos(phi2) * sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.195) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi1), sin(phi2), Float64(sin(phi1) * Float64(t_1 * Float64(-cos(phi2)))))); elseif (phi1 <= 0.0112) tmp = atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * Float64(phi1 * Float64(cos(phi2) * fma(-0.16666666666666666, Float64(phi1 * phi1), 1.0)))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(Float64(lambda2 + lambda1) * Float64(Float64(lambda1 - lambda2) / Float64(lambda2 + lambda1))))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.195], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[(t$95$1 * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0112], N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.16666666666666666 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda2 + lambda1), $MachinePrecision] * N[(N[(lambda1 - lambda2), $MachinePrecision] / N[(lambda2 + lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.195:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, \sin \phi_1 \cdot \left(t\_1 \cdot \left(-\cos \phi_2\right)\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 0.0112:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(-0.16666666666666666, \phi_1 \cdot \phi_1, 1\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\left(\lambda_2 + \lambda_1\right) \cdot \frac{\lambda_1 - \lambda_2}{\lambda_2 + \lambda_1}\right)}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -0.19500000000000001Initial program 88.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6488.7
Applied rewrites88.7%
Applied rewrites88.7%
if -0.19500000000000001 < phi1 < 0.0111999999999999999Initial program 79.5%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.4
Applied rewrites98.4%
Taylor expanded in phi1 around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-cos.f6498.3
Applied rewrites98.3%
if 0.0111999999999999999 < phi1 Initial program 83.9%
lift--.f64N/A
flip--N/A
difference-of-squaresN/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6484.2
Applied rewrites84.2%
Final simplification92.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.195)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma (cos phi1) (sin phi2) (* (sin phi1) (* t_1 (- (cos phi2))))))
(if (<= phi1 0.0048)
(atan2
(*
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(- t_0 (* t_1 (* (cos phi2) phi1))))
(atan2
(*
(cos phi2)
(sin
(* (+ lambda2 lambda1) (/ (- lambda1 lambda2) (+ lambda2 lambda1)))))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.195) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi1), sin(phi2), (sin(phi1) * (t_1 * -cos(phi2)))));
} else if (phi1 <= 0.0048) {
tmp = atan2((fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), (t_0 - (t_1 * (cos(phi2) * phi1))));
} else {
tmp = atan2((cos(phi2) * sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.195) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi1), sin(phi2), Float64(sin(phi1) * Float64(t_1 * Float64(-cos(phi2)))))); elseif (phi1 <= 0.0048) tmp = atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * Float64(cos(phi2) * phi1)))); else tmp = atan(Float64(cos(phi2) * sin(Float64(Float64(lambda2 + lambda1) * Float64(Float64(lambda1 - lambda2) / Float64(lambda2 + lambda1))))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.195], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[(t$95$1 * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0048], N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda2 + lambda1), $MachinePrecision] * N[(N[(lambda1 - lambda2), $MachinePrecision] / N[(lambda2 + lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.195:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, \sin \phi_1 \cdot \left(t\_1 \cdot \left(-\cos \phi_2\right)\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 0.0048:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \left(\cos \phi_2 \cdot \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\left(\lambda_2 + \lambda_1\right) \cdot \frac{\lambda_1 - \lambda_2}{\lambda_2 + \lambda_1}\right)}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -0.19500000000000001Initial program 88.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6488.7
Applied rewrites88.7%
Applied rewrites88.7%
if -0.19500000000000001 < phi1 < 0.00479999999999999958Initial program 79.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.4
Applied rewrites98.4%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6498.3
Applied rewrites98.3%
if 0.00479999999999999958 < phi1 Initial program 83.9%
lift--.f64N/A
flip--N/A
difference-of-squaresN/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6484.2
Applied rewrites84.2%
Final simplification92.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -2.4e-15)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(if (<= phi1 0.0048)
(atan2
(*
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(- t_0 (* t_1 (sin phi1))))
(atan2
(*
(cos phi2)
(sin
(* (+ lambda2 lambda1) (/ (- lambda1 lambda2) (+ lambda2 lambda1)))))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.4e-15) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else if (phi1 <= 0.0048) {
tmp = atan2((fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), (t_0 - (t_1 * sin(phi1))));
} else {
tmp = atan2((cos(phi2) * sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -2.4e-15) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); elseif (phi1 <= 0.0048) tmp = atan(Float64(fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * sin(phi1)))); else tmp = atan(Float64(cos(phi2) * sin(Float64(Float64(lambda2 + lambda1) * Float64(Float64(lambda1 - lambda2) / Float64(lambda2 + lambda1))))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.4e-15], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0048], N[ArcTan[N[(N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda2 + lambda1), $MachinePrecision] * N[(N[(lambda1 - lambda2), $MachinePrecision] / N[(lambda2 + lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.4 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 0.0048:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\left(\lambda_2 + \lambda_1\right) \cdot \frac{\lambda_1 - \lambda_2}{\lambda_2 + \lambda_1}\right)}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -2.39999999999999995e-15Initial program 87.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6487.8
Applied rewrites87.8%
if -2.39999999999999995e-15 < phi1 < 0.00479999999999999958Initial program 79.5%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6499.0
Applied rewrites99.0%
Taylor expanded in phi2 around 0
lower-sin.f6499.1
Applied rewrites99.1%
if 0.00479999999999999958 < phi1 Initial program 83.9%
lift--.f64N/A
flip--N/A
difference-of-squaresN/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6484.2
Applied rewrites84.2%
Final simplification91.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (* (+ lambda2 lambda1) (/ (- lambda1 lambda2) (+ lambda2 lambda1))))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(Float64(lambda2 + lambda1) * Float64(Float64(lambda1 - lambda2) / Float64(lambda2 + lambda1))))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1))))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda2 + lambda1), $MachinePrecision] * N[(N[(lambda1 - lambda2), $MachinePrecision] / N[(lambda2 + lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\left(\lambda_2 + \lambda_1\right) \cdot \frac{\lambda_1 - \lambda_2}{\lambda_2 + \lambda_1}\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 82.7%
lift--.f64N/A
flip--N/A
difference-of-squaresN/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f6482.8
Applied rewrites82.8%
Final simplification82.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos phi2) (sin lambda1)))
(t_3 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -5.8e-7)
(atan2
t_2
(fma (cos phi1) (sin phi2) (- (* (cos phi2) (* (sin phi1) t_1)))))
(if (<= lambda1 0.085)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_3 (* t_0 (cos lambda2))))
(atan2 t_2 (- t_3 (* t_0 t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin(lambda1);
double t_3 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -5.8e-7) {
tmp = atan2(t_2, fma(cos(phi1), sin(phi2), -(cos(phi2) * (sin(phi1) * t_1))));
} else if (lambda1 <= 0.085) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_3 - (t_0 * cos(lambda2))));
} else {
tmp = atan2(t_2, (t_3 - (t_0 * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * sin(lambda1)) t_3 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -5.8e-7) tmp = atan(t_2, fma(cos(phi1), sin(phi2), Float64(-Float64(cos(phi2) * Float64(sin(phi1) * t_1))))); elseif (lambda1 <= 0.085) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_3 - Float64(t_0 * cos(lambda2)))); else tmp = atan(t_2, Float64(t_3 - Float64(t_0 * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -5.8e-7], N[ArcTan[t$95$2 / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + (-N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.085], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$3 - N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$3 - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \lambda_1\\
t_3 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -5.8 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, -\cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_1\right)\right)}\\
\mathbf{elif}\;\lambda_1 \leq 0.085:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_3 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_3 - t\_0 \cdot t\_1}\\
\end{array}
\end{array}
if lambda1 < -5.7999999999999995e-7Initial program 72.2%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6472.3
Applied rewrites72.3%
Taylor expanded in lambda2 around 0
Applied rewrites72.7%
if -5.7999999999999995e-7 < lambda1 < 0.0850000000000000061Initial program 99.3%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6499.3
Applied rewrites99.3%
if 0.0850000000000000061 < lambda1 Initial program 59.9%
Taylor expanded in lambda2 around 0
lower-sin.f6462.0
Applied rewrites62.0%
Final simplification83.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1)))))))
(if (<= phi2 -0.015)
t_1
(if (<= phi2 1.45e-11)
(atan2
(sin
(* (+ lambda2 lambda1) (/ (- lambda1 lambda2) (+ lambda2 lambda1))))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
double tmp;
if (phi2 <= -0.015) {
tmp = t_1;
} else if (phi2 <= 1.45e-11) {
tmp = atan2(sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1)))), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
if (phi2 <= (-0.015d0)) then
tmp = t_1
else if (phi2 <= 1.45d-11) then
tmp = atan2(sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1)))), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
double tmp;
if (phi2 <= -0.015) {
tmp = t_1;
} else if (phi2 <= 1.45e-11) {
tmp = Math.atan2(Math.sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1)))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) tmp = 0 if phi2 <= -0.015: tmp = t_1 elif phi2 <= 1.45e-11: tmp = math.atan2(math.sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1)))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))) tmp = 0.0 if (phi2 <= -0.015) tmp = t_1; elseif (phi2 <= 1.45e-11) tmp = atan(sin(Float64(Float64(lambda2 + lambda1) * Float64(Float64(lambda1 - lambda2) / Float64(lambda2 + lambda1)))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); tmp = 0.0; if (phi2 <= -0.015) tmp = t_1; elseif (phi2 <= 1.45e-11) tmp = atan2(sin(((lambda2 + lambda1) * ((lambda1 - lambda2) / (lambda2 + lambda1)))), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.015], t$95$1, If[LessEqual[phi2, 1.45e-11], N[ArcTan[N[Sin[N[(N[(lambda2 + lambda1), $MachinePrecision] * N[(N[(lambda1 - lambda2), $MachinePrecision] / N[(lambda2 + lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\phi_2 \leq -0.015:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1.45 \cdot 10^{-11}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\left(\lambda_2 + \lambda_1\right) \cdot \frac{\lambda_1 - \lambda_2}{\lambda_2 + \lambda_1}\right)}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.014999999999999999 or 1.45e-11 < phi2 Initial program 78.2%
Taylor expanded in lambda2 around 0
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6467.0
Applied rewrites67.0%
if -0.014999999999999999 < phi2 < 1.45e-11Initial program 88.0%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6488.0
Applied rewrites88.0%
Applied rewrites88.2%
Final simplification76.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (cos phi2) (sin lambda1))))
(if (<= lambda1 -5.8e-7)
(atan2
t_1
(fma (cos phi1) (sin phi2) (- (* (cos phi2) (* (sin phi1) t_0)))))
(if (<= lambda1 0.095)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(cos phi1)
(sin phi2)
(- (* (sin phi1) (cos (- lambda2 lambda1))))))
(atan2
t_1
(- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * sin(lambda1);
double tmp;
if (lambda1 <= -5.8e-7) {
tmp = atan2(t_1, fma(cos(phi1), sin(phi2), -(cos(phi2) * (sin(phi1) * t_0))));
} else if (lambda1 <= 0.095) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi1), sin(phi2), -(sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(lambda1)) tmp = 0.0 if (lambda1 <= -5.8e-7) tmp = atan(t_1, fma(cos(phi1), sin(phi2), Float64(-Float64(cos(phi2) * Float64(sin(phi1) * t_0))))); elseif (lambda1 <= 0.095) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi1), sin(phi2), Float64(-Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -5.8e-7], N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + (-N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.095], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + (-N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \lambda_1\\
\mathbf{if}\;\lambda_1 \leq -5.8 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, -\cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_0\right)\right)}\\
\mathbf{elif}\;\lambda_1 \leq 0.095:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, -\sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_0}\\
\end{array}
\end{array}
if lambda1 < -5.7999999999999995e-7Initial program 72.2%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6472.3
Applied rewrites72.3%
Taylor expanded in lambda2 around 0
Applied rewrites72.7%
if -5.7999999999999995e-7 < lambda1 < 0.095000000000000001Initial program 99.3%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6499.3
Applied rewrites99.3%
Taylor expanded in phi2 around 0
Applied rewrites79.1%
if 0.095000000000000001 < lambda1 Initial program 59.9%
Taylor expanded in lambda2 around 0
lower-sin.f6462.0
Applied rewrites62.0%
Final simplification73.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (cos phi2) (sin lambda1))
(fma
(cos phi1)
(sin phi2)
(- (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))))
(if (<= lambda1 -5.8e-7)
t_0
(if (<= lambda1 0.095)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(cos phi1)
(sin phi2)
(- (* (sin phi1) (cos (- lambda2 lambda1))))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((cos(phi2) * sin(lambda1)), fma(cos(phi1), sin(phi2), -(cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
double tmp;
if (lambda1 <= -5.8e-7) {
tmp = t_0;
} else if (lambda1 <= 0.095) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi1), sin(phi2), -(sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(cos(phi2) * sin(lambda1)), fma(cos(phi1), sin(phi2), Float64(-Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))))) tmp = 0.0 if (lambda1 <= -5.8e-7) tmp = t_0; elseif (lambda1 <= 0.095) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi1), sin(phi2), Float64(-Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + (-N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -5.8e-7], t$95$0, If[LessEqual[lambda1, 0.095], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + (-N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, -\cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\\
\mathbf{if}\;\lambda_1 \leq -5.8 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 0.095:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, -\sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -5.7999999999999995e-7 or 0.095000000000000001 < lambda1 Initial program 65.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6465.7
Applied rewrites65.7%
Taylor expanded in lambda2 around 0
Applied rewrites67.0%
if -5.7999999999999995e-7 < lambda1 < 0.095000000000000001Initial program 99.3%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6499.3
Applied rewrites99.3%
Taylor expanded in phi2 around 0
Applied rewrites79.1%
Final simplification73.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos phi1) (sin phi2) (* (sin phi1) (* (cos (- lambda1 lambda2)) (- (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi1), sin(phi2), (sin(phi1) * (cos((lambda1 - lambda2)) * -cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi1), sin(phi2), Float64(sin(phi1) * Float64(cos(Float64(lambda1 - lambda2)) * Float64(-cos(phi2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, \sin \phi_1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\cos \phi_2\right)\right)\right)}
\end{array}
Initial program 82.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6482.7
Applied rewrites82.7%
Applied rewrites82.7%
Final simplification82.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos phi1) (sin phi2) (- (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi1), sin(phi2), -(cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi1), sin(phi2), Float64(-Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + (-N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, -\cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}
\end{array}
Initial program 82.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6482.7
Applied rewrites82.7%
Final simplification82.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (cos phi1) (sin phi2))
(* (cos (- lambda1 lambda2)) (sin phi1))))
(t_1 (atan2 (* (sin (- lambda2)) (cos phi2)) t_0)))
(if (<= lambda2 -1.8e-13)
t_1
(if (<= lambda2 5e-29) (atan2 (* (sin lambda1) (cos phi2)) t_0) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1));
double t_1 = atan2((sin(-lambda2) * cos(phi2)), t_0);
double tmp;
if (lambda2 <= -1.8e-13) {
tmp = t_1;
} else if (lambda2 <= 5e-29) {
tmp = atan2((sin(lambda1) * cos(phi2)), t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))
t_1 = atan2((sin(-lambda2) * cos(phi2)), t_0)
if (lambda2 <= (-1.8d-13)) then
tmp = t_1
else if (lambda2 <= 5d-29) then
tmp = atan2((sin(lambda1) * cos(phi2)), t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1));
double t_1 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), t_0);
double tmp;
if (lambda2 <= -1.8e-13) {
tmp = t_1;
} else if (lambda2 <= 5e-29) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)) t_1 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), t_0) tmp = 0 if lambda2 <= -1.8e-13: tmp = t_1 elif lambda2 <= 5e-29: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), t_0) tmp = 0.0 if (lambda2 <= -1.8e-13) tmp = t_1; elseif (lambda2 <= 5e-29) tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1)); t_1 = atan2((sin(-lambda2) * cos(phi2)), t_0); tmp = 0.0; if (lambda2 <= -1.8e-13) tmp = t_1; elseif (lambda2 <= 5e-29) tmp = atan2((sin(lambda1) * cos(phi2)), t_0); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]}, If[LessEqual[lambda2, -1.8e-13], t$95$1, If[LessEqual[lambda2, 5e-29], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\\
t_1 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0}\\
\mathbf{if}\;\lambda_2 \leq -1.8 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 5 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -1.7999999999999999e-13 or 4.99999999999999986e-29 < lambda2 Initial program 67.0%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6443.6
Applied rewrites43.6%
Taylor expanded in phi2 around 0
lower-sin.f6443.7
Applied rewrites43.7%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-neg.f6450.4
Applied rewrites50.4%
if -1.7999999999999999e-13 < lambda2 < 4.99999999999999986e-29Initial program 99.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6457.8
Applied rewrites57.8%
Taylor expanded in phi2 around 0
lower-sin.f6457.9
Applied rewrites57.9%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6471.5
Applied rewrites71.5%
Final simplification60.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (cos phi1) (sin phi2))
(* (cos (- lambda1 lambda2)) (sin phi1))))
(t_1 (atan2 (* (sin lambda1) (cos phi2)) t_0)))
(if (<= phi2 -7.8e+14)
t_1
(if (<= phi2 0.0025) (atan2 (sin (- lambda1 lambda2)) t_0) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1));
double t_1 = atan2((sin(lambda1) * cos(phi2)), t_0);
double tmp;
if (phi2 <= -7.8e+14) {
tmp = t_1;
} else if (phi2 <= 0.0025) {
tmp = atan2(sin((lambda1 - lambda2)), t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))
t_1 = atan2((sin(lambda1) * cos(phi2)), t_0)
if (phi2 <= (-7.8d+14)) then
tmp = t_1
else if (phi2 <= 0.0025d0) then
tmp = atan2(sin((lambda1 - lambda2)), t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1));
double t_1 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
double tmp;
if (phi2 <= -7.8e+14) {
tmp = t_1;
} else if (phi2 <= 0.0025) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)) t_1 = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) tmp = 0 if phi2 <= -7.8e+14: tmp = t_1 elif phi2 <= 0.0025: tmp = math.atan2(math.sin((lambda1 - lambda2)), t_0) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))) t_1 = atan(Float64(sin(lambda1) * cos(phi2)), t_0) tmp = 0.0 if (phi2 <= -7.8e+14) tmp = t_1; elseif (phi2 <= 0.0025) tmp = atan(sin(Float64(lambda1 - lambda2)), t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1)); t_1 = atan2((sin(lambda1) * cos(phi2)), t_0); tmp = 0.0; if (phi2 <= -7.8e+14) tmp = t_1; elseif (phi2 <= 0.0025) tmp = atan2(sin((lambda1 - lambda2)), t_0); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]}, If[LessEqual[phi2, -7.8e+14], t$95$1, If[LessEqual[phi2, 0.0025], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0}\\
\mathbf{if}\;\phi_2 \leq -7.8 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.0025:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -7.8e14 or 0.00250000000000000005 < phi2 Initial program 77.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6416.5
Applied rewrites16.5%
Taylor expanded in phi2 around 0
lower-sin.f6416.6
Applied rewrites16.6%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6434.0
Applied rewrites34.0%
if -7.8e14 < phi2 < 0.00250000000000000005Initial program 88.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6487.1
Applied rewrites87.1%
Taylor expanded in phi2 around 0
lower-sin.f6487.2
Applied rewrites87.2%
Final simplification59.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos phi1) (sin phi2) (- (* (sin phi1) (cos (- lambda2 lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi1), sin(phi2), -(sin(phi1) * cos((lambda2 - lambda1)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi1), sin(phi2), Float64(-Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + (-N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, -\sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)}
\end{array}
Initial program 82.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
sub-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-neg.f64N/A
lower-sin.f6482.7
Applied rewrites82.7%
Taylor expanded in phi2 around 0
Applied rewrites66.2%
Final simplification66.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(sin lambda1)
(- t_0 (* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= lambda1 -1.02e-9)
t_1
(if (<= lambda1 0.46)
(atan2 (sin (- lambda1 lambda2)) (- t_0 (* (sin phi1) (cos lambda2))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = atan2(sin(lambda1), (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))));
double tmp;
if (lambda1 <= -1.02e-9) {
tmp = t_1;
} else if (lambda1 <= 0.46) {
tmp = atan2(sin((lambda1 - lambda2)), (t_0 - (sin(phi1) * cos(lambda2))));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = atan2(sin(lambda1), (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))))
if (lambda1 <= (-1.02d-9)) then
tmp = t_1
else if (lambda1 <= 0.46d0) then
tmp = atan2(sin((lambda1 - lambda2)), (t_0 - (sin(phi1) * cos(lambda2))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2(Math.sin(lambda1), (t_0 - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
double tmp;
if (lambda1 <= -1.02e-9) {
tmp = t_1;
} else if (lambda1 <= 0.46) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), (t_0 - (Math.sin(phi1) * Math.cos(lambda2))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.atan2(math.sin(lambda1), (t_0 - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) tmp = 0 if lambda1 <= -1.02e-9: tmp = t_1 elif lambda1 <= 0.46: tmp = math.atan2(math.sin((lambda1 - lambda2)), (t_0 - (math.sin(phi1) * math.cos(lambda2)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = atan(sin(lambda1), Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (lambda1 <= -1.02e-9) tmp = t_1; elseif (lambda1 <= 0.46) tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(t_0 - Float64(sin(phi1) * cos(lambda2)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = atan2(sin(lambda1), (t_0 - (cos((lambda1 - lambda2)) * sin(phi1)))); tmp = 0.0; if (lambda1 <= -1.02e-9) tmp = t_1; elseif (lambda1 <= 0.46) tmp = atan2(sin((lambda1 - lambda2)), (t_0 - (sin(phi1) * cos(lambda2)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.02e-9], t$95$1, If[LessEqual[lambda1, 0.46], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1}{t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\lambda_1 \leq -1.02 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 0.46:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \sin \phi_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -1.01999999999999999e-9 or 0.46000000000000002 < lambda1 Initial program 65.9%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6438.8
Applied rewrites38.8%
Taylor expanded in phi2 around 0
lower-sin.f6438.8
Applied rewrites38.8%
Taylor expanded in lambda2 around 0
Applied rewrites40.6%
if -1.01999999999999999e-9 < lambda1 < 0.46000000000000002Initial program 99.5%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6462.1
Applied rewrites62.1%
Taylor expanded in phi2 around 0
lower-sin.f6462.2
Applied rewrites62.2%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6462.2
Applied rewrites62.2%
Final simplification51.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (cos phi1) (sin phi2))
(* (cos (- lambda1 lambda2)) (sin phi1))))
(t_1 (atan2 (sin lambda1) t_0)))
(if (<= lambda1 -48000000.0)
t_1
(if (<= lambda1 1.05e-151) (atan2 (- lambda1 lambda2) t_0) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1));
double t_1 = atan2(sin(lambda1), t_0);
double tmp;
if (lambda1 <= -48000000.0) {
tmp = t_1;
} else if (lambda1 <= 1.05e-151) {
tmp = atan2((lambda1 - lambda2), t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))
t_1 = atan2(sin(lambda1), t_0)
if (lambda1 <= (-48000000.0d0)) then
tmp = t_1
else if (lambda1 <= 1.05d-151) then
tmp = atan2((lambda1 - lambda2), t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1));
double t_1 = Math.atan2(Math.sin(lambda1), t_0);
double tmp;
if (lambda1 <= -48000000.0) {
tmp = t_1;
} else if (lambda1 <= 1.05e-151) {
tmp = Math.atan2((lambda1 - lambda2), t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)) t_1 = math.atan2(math.sin(lambda1), t_0) tmp = 0 if lambda1 <= -48000000.0: tmp = t_1 elif lambda1 <= 1.05e-151: tmp = math.atan2((lambda1 - lambda2), t_0) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))) t_1 = atan(sin(lambda1), t_0) tmp = 0.0 if (lambda1 <= -48000000.0) tmp = t_1; elseif (lambda1 <= 1.05e-151) tmp = atan(Float64(lambda1 - lambda2), t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1)); t_1 = atan2(sin(lambda1), t_0); tmp = 0.0; if (lambda1 <= -48000000.0) tmp = t_1; elseif (lambda1 <= 1.05e-151) tmp = atan2((lambda1 - lambda2), t_0); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[Sin[lambda1], $MachinePrecision] / t$95$0], $MachinePrecision]}, If[LessEqual[lambda1, -48000000.0], t$95$1, If[LessEqual[lambda1, 1.05e-151], N[ArcTan[N[(lambda1 - lambda2), $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1}{t\_0}\\
\mathbf{if}\;\lambda_1 \leq -48000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 1.05 \cdot 10^{-151}:\\
\;\;\;\;\tan^{-1}_* \frac{\lambda_1 - \lambda_2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -4.8e7 or 1.04999999999999995e-151 < lambda1 Initial program 71.5%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6442.1
Applied rewrites42.1%
Taylor expanded in phi2 around 0
lower-sin.f6442.1
Applied rewrites42.1%
Taylor expanded in lambda2 around 0
Applied rewrites39.1%
if -4.8e7 < lambda1 < 1.04999999999999995e-151Initial program 99.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6462.6
Applied rewrites62.6%
Taylor expanded in phi2 around 0
lower-sin.f6462.8
Applied rewrites62.8%
Taylor expanded in lambda1 around 0
Applied rewrites62.8%
Taylor expanded in lambda2 around 0
Applied rewrites46.3%
Final simplification42.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (atan2 (sin lambda1) (- t_0 (* (sin phi1) (cos lambda1))))))
(if (<= lambda1 -48000000.0)
t_1
(if (<= lambda1 2.8e-29)
(atan2
(- lambda1 lambda2)
(- t_0 (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = atan2(sin(lambda1), (t_0 - (sin(phi1) * cos(lambda1))));
double tmp;
if (lambda1 <= -48000000.0) {
tmp = t_1;
} else if (lambda1 <= 2.8e-29) {
tmp = atan2((lambda1 - lambda2), (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = atan2(sin(lambda1), (t_0 - (sin(phi1) * cos(lambda1))))
if (lambda1 <= (-48000000.0d0)) then
tmp = t_1
else if (lambda1 <= 2.8d-29) then
tmp = atan2((lambda1 - lambda2), (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2(Math.sin(lambda1), (t_0 - (Math.sin(phi1) * Math.cos(lambda1))));
double tmp;
if (lambda1 <= -48000000.0) {
tmp = t_1;
} else if (lambda1 <= 2.8e-29) {
tmp = Math.atan2((lambda1 - lambda2), (t_0 - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.atan2(math.sin(lambda1), (t_0 - (math.sin(phi1) * math.cos(lambda1)))) tmp = 0 if lambda1 <= -48000000.0: tmp = t_1 elif lambda1 <= 2.8e-29: tmp = math.atan2((lambda1 - lambda2), (t_0 - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = atan(sin(lambda1), Float64(t_0 - Float64(sin(phi1) * cos(lambda1)))) tmp = 0.0 if (lambda1 <= -48000000.0) tmp = t_1; elseif (lambda1 <= 2.8e-29) tmp = atan(Float64(lambda1 - lambda2), Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = atan2(sin(lambda1), (t_0 - (sin(phi1) * cos(lambda1)))); tmp = 0.0; if (lambda1 <= -48000000.0) tmp = t_1; elseif (lambda1 <= 2.8e-29) tmp = atan2((lambda1 - lambda2), (t_0 - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -48000000.0], t$95$1, If[LessEqual[lambda1, 2.8e-29], N[ArcTan[N[(lambda1 - lambda2), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1}{t\_0 - \sin \phi_1 \cdot \cos \lambda_1}\\
\mathbf{if}\;\lambda_1 \leq -48000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 2.8 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{\lambda_1 - \lambda_2}{t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -4.8e7 or 2.8000000000000002e-29 < lambda1 Initial program 65.9%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6439.2
Applied rewrites39.2%
Taylor expanded in phi2 around 0
lower-sin.f6439.3
Applied rewrites39.3%
Taylor expanded in lambda2 around 0
Applied rewrites39.6%
Taylor expanded in lambda2 around 0
lower-cos.f6439.5
Applied rewrites39.5%
if -4.8e7 < lambda1 < 2.8000000000000002e-29Initial program 99.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6461.5
Applied rewrites61.5%
Taylor expanded in phi2 around 0
lower-sin.f6461.6
Applied rewrites61.6%
Taylor expanded in lambda1 around 0
Applied rewrites61.6%
Taylor expanded in lambda2 around 0
Applied rewrites44.3%
Final simplification41.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (* (cos phi1) (sin phi2)) (* (cos (- lambda1 lambda2)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}
\end{array}
Initial program 82.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6450.4
Applied rewrites50.4%
Taylor expanded in phi2 around 0
lower-sin.f6450.5
Applied rewrites50.5%
Final simplification50.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos lambda1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos(lambda1))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos(lambda1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos(lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos(lambda1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(lambda1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos(lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \lambda_1}
\end{array}
Initial program 82.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6450.4
Applied rewrites50.4%
Taylor expanded in phi2 around 0
lower-sin.f6450.5
Applied rewrites50.5%
Taylor expanded in lambda2 around 0
lower-cos.f6443.6
Applied rewrites43.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (- lambda1 lambda2) (- (* (cos phi1) (sin phi2)) (* (cos (- lambda1 lambda2)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((lambda1 - lambda2), ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((lambda1 - lambda2), ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((lambda1 - lambda2), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((lambda1 - lambda2), ((math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(lambda1 - lambda2), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((lambda1 - lambda2), ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(lambda1 - lambda2), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\lambda_1 - \lambda_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}
\end{array}
Initial program 82.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6450.4
Applied rewrites50.4%
Taylor expanded in phi2 around 0
lower-sin.f6450.5
Applied rewrites50.5%
Taylor expanded in lambda1 around 0
Applied rewrites42.6%
Taylor expanded in lambda2 around 0
Applied rewrites34.2%
Final simplification34.2%
herbie shell --seed 2024226
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Bearing on a great circle"
:precision binary64
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))