
(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 23 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
(*
(cos phi2)
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2)))))
(-
(* (sin phi2) (cos phi1))
(*
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1)))
(* (sin phi1) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2)))), ((sin(phi2) * cos(phi1)) - (fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1))) * (sin(phi1) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2))))), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1))) * Float64(sin(phi1) * cos(phi2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)}{\sin \phi_2 \cdot \cos \phi_1 - \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}
\end{array}
Initial program 80.3%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6488.7
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (- (cos lambda1)) (sin lambda2) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(fma
(- (cos phi2))
(*
(fma (sin lambda1) (sin lambda2) (* (cos lambda1) (cos lambda2)))
(sin phi1))
(* (sin phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(-cos(lambda1), sin(lambda2), (cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(-cos(phi2), (fma(sin(lambda1), sin(lambda2), (cos(lambda1) * cos(lambda2))) * sin(phi1)), (sin(phi2) * cos(phi1))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(Float64(-cos(lambda1)), sin(lambda2), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(Float64(-cos(phi2)), Float64(fma(sin(lambda1), sin(lambda2), Float64(cos(lambda1) * cos(lambda2))) * sin(phi1)), Float64(sin(phi2) * cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(-\cos \lambda_1, \sin \lambda_2, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\cos \phi_2, \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right) \cdot \sin \phi_1, \sin \phi_2 \cdot \cos \phi_1\right)}
\end{array}
Initial program 80.3%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6488.7
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-sin.f6449.6
Applied rewrites49.6%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (- t_0 (* (cos (- lambda1 lambda2)) t_1)))
(t_3 (* (cos lambda2) (sin lambda1))))
(if (<= phi2 -145000.0)
(atan2
(*
(cos phi2)
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2)))))
t_2)
(if (<= phi2 1.5e-6)
(atan2
(fma (- (cos lambda1)) (sin lambda2) t_3)
(-
t_0
(*
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1)))
t_1)))
(atan2 (* (- t_3 (* (cos lambda1) (sin lambda2))) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = sin(phi1) * cos(phi2);
double t_2 = t_0 - (cos((lambda1 - lambda2)) * t_1);
double t_3 = cos(lambda2) * sin(lambda1);
double tmp;
if (phi2 <= -145000.0) {
tmp = atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2)))), t_2);
} else if (phi2 <= 1.5e-6) {
tmp = atan2(fma(-cos(lambda1), sin(lambda2), t_3), (t_0 - (fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1))) * t_1)));
} else {
tmp = atan2(((t_3 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) * t_1)) t_3 = Float64(cos(lambda2) * sin(lambda1)) tmp = 0.0 if (phi2 <= -145000.0) tmp = atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2))))), t_2); elseif (phi2 <= 1.5e-6) tmp = atan(fma(Float64(-cos(lambda1)), sin(lambda2), t_3), Float64(t_0 - Float64(fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1))) * t_1))); else tmp = atan(Float64(Float64(t_3 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -145000.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 1.5e-6], N[ArcTan[N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision] + t$95$3), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$3 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_1\\
t_3 := \cos \lambda_2 \cdot \sin \lambda_1\\
\mathbf{if}\;\phi_2 \leq -145000:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)}{t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.5 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-\cos \lambda_1, \sin \lambda_2, t\_3\right)}{t\_0 - \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_3 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi2 < -145000Initial program 79.2%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6490.9
Applied rewrites90.9%
if -145000 < phi2 < 1.5e-6Initial program 83.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6486.9
Applied rewrites86.9%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
if 1.5e-6 < phi2 Initial program 76.2%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6489.7
Applied rewrites89.7%
Final simplification94.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1
(*
(cos phi2)
(fma
(sin lambda1)
(cos lambda2)
(* (cos lambda1) (- (sin lambda2))))))
(t_2 (* (sin phi1) (cos phi2)))
(t_3 (atan2 t_1 (- t_0 (* (cos lambda1) t_2)))))
(if (<= lambda1 -0.000105)
t_3
(if (<= lambda1 9e-6) (atan2 t_1 (- t_0 (* (cos lambda2) t_2))) t_3))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2)));
double t_2 = sin(phi1) * cos(phi2);
double t_3 = atan2(t_1, (t_0 - (cos(lambda1) * t_2)));
double tmp;
if (lambda1 <= -0.000105) {
tmp = t_3;
} else if (lambda1 <= 9e-6) {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)));
} else {
tmp = t_3;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2))))) t_2 = Float64(sin(phi1) * cos(phi2)) t_3 = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * t_2))) tmp = 0.0 if (lambda1 <= -0.000105) tmp = t_3; elseif (lambda1 <= 9e-6) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * t_2))); else tmp = t_3; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.000105], t$95$3, If[LessEqual[lambda1, 9e-6], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
t_3 := \tan^{-1}_* \frac{t\_1}{t\_0 - \cos \lambda_1 \cdot t\_2}\\
\mathbf{if}\;\lambda_1 \leq -0.000105:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \lambda_2 \cdot t\_2}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if lambda1 < -1.05e-4 or 9.00000000000000023e-6 < lambda1 Initial program 62.1%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6478.5
Applied rewrites78.5%
Taylor expanded in lambda2 around 0
lower-cos.f6478.6
Applied rewrites78.6%
if -1.05e-4 < lambda1 < 9.00000000000000023e-6Initial program 99.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6499.5
Applied rewrites99.5%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6499.5
Applied rewrites99.5%
Final simplification88.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin lambda2)))
(t_1 (* (sin phi2) (cos phi1)))
(t_2 (* (sin phi1) (cos phi2)))
(t_3
(atan2
(*
(cos phi2)
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) t_0)))
(- t_1 (* (cos lambda1) t_2)))))
(if (<= lambda1 -1.45e-5)
t_3
(if (<= lambda1 9e-6)
(atan2
(* (fma (cos lambda2) lambda1 t_0) (cos phi2))
(- t_1 (* (cos (- lambda1 lambda2)) t_2)))
t_3))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -sin(lambda2);
double t_1 = sin(phi2) * cos(phi1);
double t_2 = sin(phi1) * cos(phi2);
double t_3 = atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * t_0))), (t_1 - (cos(lambda1) * t_2)));
double tmp;
if (lambda1 <= -1.45e-5) {
tmp = t_3;
} else if (lambda1 <= 9e-6) {
tmp = atan2((fma(cos(lambda2), lambda1, t_0) * cos(phi2)), (t_1 - (cos((lambda1 - lambda2)) * t_2)));
} else {
tmp = t_3;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-sin(lambda2)) t_1 = Float64(sin(phi2) * cos(phi1)) t_2 = Float64(sin(phi1) * cos(phi2)) t_3 = atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * t_0))), Float64(t_1 - Float64(cos(lambda1) * t_2))) tmp = 0.0 if (lambda1 <= -1.45e-5) tmp = t_3; elseif (lambda1 <= 9e-6) tmp = atan(Float64(fma(cos(lambda2), lambda1, t_0) * cos(phi2)), Float64(t_1 - Float64(cos(Float64(lambda1 - lambda2)) * t_2))); else tmp = t_3; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Sin[lambda2], $MachinePrecision])}, Block[{t$95$1 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.45e-5], t$95$3, If[LessEqual[lambda1, 9e-6], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * lambda1 + t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin \lambda_2\\
t_1 := \sin \phi_2 \cdot \cos \phi_1\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
t_3 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot t\_0\right)}{t\_1 - \cos \lambda_1 \cdot t\_2}\\
\mathbf{if}\;\lambda_1 \leq -1.45 \cdot 10^{-5}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \lambda_1, t\_0\right) \cdot \cos \phi_2}{t\_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_2}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if lambda1 < -1.45e-5 or 9.00000000000000023e-6 < lambda1 Initial program 62.1%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6478.5
Applied rewrites78.5%
Taylor expanded in lambda2 around 0
lower-cos.f6478.6
Applied rewrites78.6%
if -1.45e-5 < lambda1 < 9.00000000000000023e-6Initial program 99.4%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Final simplification88.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2))))) (- (* (sin phi2) (cos phi1)) (* (cos (- lambda1 lambda2)) (* (sin phi1) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2)))), ((sin(phi2) * cos(phi1)) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2))))), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * Float64(sin(phi1) * cos(phi2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)}{\sin \phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}
\end{array}
Initial program 80.3%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6488.7
Applied rewrites88.7%
Final simplification88.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (sin phi2) (cos phi1)) (* (cos (- lambda1 lambda2)) (* (sin phi1) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))));
}
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(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.sin(phi2) * Math.cos(phi1)) - (Math.cos((lambda1 - lambda2)) * (Math.sin(phi1) * Math.cos(phi2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - (math.cos((lambda1 - lambda2)) * (math.sin(phi1) * math.cos(phi2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * Float64(sin(phi1) * cos(phi2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}
\end{array}
Initial program 80.3%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6488.7
Applied rewrites88.7%
Final simplification88.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (sin phi2) (cos phi1)) (* (* t_0 (sin phi1)) (cos phi2))))))
(if (<= phi1 -7.5e+17)
t_1
(if (<= phi1 1.65)
(atan2
(*
(cos phi2)
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2)))))
(- (sin phi2) (* t_0 (* (sin phi1) (cos phi2)))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((t_0 * sin(phi1)) * cos(phi2))));
double tmp;
if (phi1 <= -7.5e+17) {
tmp = t_1;
} else if (phi1 <= 1.65) {
tmp = atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2)))), (sin(phi2) - (t_0 * (sin(phi1) * cos(phi2)))));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (phi1 <= -7.5e+17) tmp = t_1; elseif (phi1 <= 1.65) tmp = atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2))))), Float64(sin(phi2) - Float64(t_0 * Float64(sin(phi1) * cos(phi2))))); else tmp = t_1; 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[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7.5e+17], t$95$1, If[LessEqual[phi1, 1.65], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\phi_1 \leq -7.5 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 1.65:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)}{\sin \phi_2 - t\_0 \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -7.5e17 or 1.6499999999999999 < phi1 Initial program 77.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6477.4
Applied rewrites77.4%
if -7.5e17 < phi1 < 1.6499999999999999Initial program 83.3%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in phi1 around 0
lower-sin.f6497.8
Applied rewrites97.8%
Final simplification87.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_2 (* (sin phi2) (cos phi1))))
(if (<= lambda1 -0.000205)
(atan2 (* (sin lambda1) (cos phi2)) (- t_2 (* t_0 (cos lambda1))))
(if (<= lambda1 9e-6)
(atan2 t_1 (- t_2 (* (cos lambda2) t_0)))
(atan2 t_1 (- t_2 (* (* (cos phi2) (cos lambda1)) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double t_2 = sin(phi2) * cos(phi1);
double tmp;
if (lambda1 <= -0.000205) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos(lambda1))));
} else if (lambda1 <= 9e-6) {
tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0)));
} else {
tmp = atan2(t_1, (t_2 - ((cos(phi2) * cos(lambda1)) * sin(phi1))));
}
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) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
t_2 = sin(phi2) * cos(phi1)
if (lambda1 <= (-0.000205d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos(lambda1))))
else if (lambda1 <= 9d-6) then
tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0)))
else
tmp = atan2(t_1, (t_2 - ((cos(phi2) * cos(lambda1)) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double t_2 = Math.sin(phi2) * Math.cos(phi1);
double tmp;
if (lambda1 <= -0.000205) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_2 - (t_0 * Math.cos(lambda1))));
} else if (lambda1 <= 9e-6) {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(lambda2) * t_0)));
} else {
tmp = Math.atan2(t_1, (t_2 - ((Math.cos(phi2) * Math.cos(lambda1)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_2 = math.sin(phi2) * math.cos(phi1) tmp = 0 if lambda1 <= -0.000205: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_2 - (t_0 * math.cos(lambda1)))) elif lambda1 <= 9e-6: tmp = math.atan2(t_1, (t_2 - (math.cos(lambda2) * t_0))) else: tmp = math.atan2(t_1, (t_2 - ((math.cos(phi2) * math.cos(lambda1)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_2 = Float64(sin(phi2) * cos(phi1)) tmp = 0.0 if (lambda1 <= -0.000205) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_2 - Float64(t_0 * cos(lambda1)))); elseif (lambda1 <= 9e-6) tmp = atan(t_1, Float64(t_2 - Float64(cos(lambda2) * t_0))); else tmp = atan(t_1, Float64(t_2 - Float64(Float64(cos(phi2) * cos(lambda1)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); t_2 = sin(phi2) * cos(phi1); tmp = 0.0; if (lambda1 <= -0.000205) tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos(lambda1)))); elseif (lambda1 <= 9e-6) tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0))); else tmp = atan2(t_1, (t_2 - ((cos(phi2) * cos(lambda1)) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.000205], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 9e-6], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_2 \cdot \cos \phi_1\\
\mathbf{if}\;\lambda_1 \leq -0.000205:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - \cos \lambda_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - \left(\cos \phi_2 \cdot \cos \lambda_1\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -2.05e-4Initial program 64.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6481.1
Applied rewrites81.1%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-sin.f6466.9
Applied rewrites66.9%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6466.7
Applied rewrites66.7%
if -2.05e-4 < lambda1 < 9.00000000000000023e-6Initial program 99.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6499.4
Applied rewrites99.4%
if 9.00000000000000023e-6 < lambda1 Initial program 60.4%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6460.9
Applied rewrites60.9%
Taylor expanded in lambda2 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-sin.f6460.5
Applied rewrites60.5%
Final simplification81.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (cos lambda2) (* (sin phi1) (cos phi2)))))))
(if (<= lambda2 -1.2e+17)
t_1
(if (<= lambda2 2.4e+55)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos phi2) (cos lambda1)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(lambda2) * (sin(phi1) * cos(phi2)))));
double tmp;
if (lambda2 <= -1.2e+17) {
tmp = t_1;
} else if (lambda2 <= 2.4e+55) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(phi2) * cos(lambda1)) * 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 = sin(phi2) * cos(phi1)
t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(lambda2) * (sin(phi1) * cos(phi2)))))
if (lambda2 <= (-1.2d+17)) then
tmp = t_1
else if (lambda2 <= 2.4d+55) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(phi2) * cos(lambda1)) * 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.sin(phi2) * Math.cos(phi1);
double t_1 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (Math.cos(lambda2) * (Math.sin(phi1) * Math.cos(phi2)))));
double tmp;
if (lambda2 <= -1.2e+17) {
tmp = t_1;
} else if (lambda2 <= 2.4e+55) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(phi2) * Math.cos(lambda1)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) * math.cos(phi1) t_1 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (math.cos(lambda2) * (math.sin(phi1) * math.cos(phi2))))) tmp = 0 if lambda2 <= -1.2e+17: tmp = t_1 elif lambda2 <= 2.4e+55: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(phi2) * math.cos(lambda1)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(lambda2) * Float64(sin(phi1) * cos(phi2))))) tmp = 0.0 if (lambda2 <= -1.2e+17) tmp = t_1; elseif (lambda2 <= 2.4e+55) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * cos(lambda1)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) * cos(phi1); t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(lambda2) * (sin(phi1) * cos(phi2))))); tmp = 0.0; if (lambda2 <= -1.2e+17) tmp = t_1; elseif (lambda2 <= 2.4e+55) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(phi2) * cos(lambda1)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1.2e+17], t$95$1, If[LessEqual[lambda2, 2.4e+55], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \lambda_2 \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}\\
\mathbf{if}\;\lambda_2 \leq -1.2 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 2.4 \cdot 10^{+55}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \phi_2 \cdot \cos \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -1.2e17 or 2.3999999999999999e55 < lambda2 Initial program 61.8%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6460.3
Applied rewrites60.3%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6460.3
Applied rewrites60.3%
if -1.2e17 < lambda2 < 2.3999999999999999e55Initial program 94.0%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6494.1
Applied rewrites94.1%
Taylor expanded in lambda2 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-sin.f6493.5
Applied rewrites93.5%
Final simplification79.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1 (* (sin lambda1) (cos phi2)))
(t_2 (* (sin phi2) (cos phi1))))
(if (<= lambda1 -7.2e-18)
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))
(if (<= lambda1 1.45e-8)
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_2 (* (cos lambda2) t_0)))
(atan2 t_1 (- t_2 (* (cos (- lambda1 lambda2)) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = sin(lambda1) * cos(phi2);
double t_2 = sin(phi2) * cos(phi1);
double tmp;
if (lambda1 <= -7.2e-18) {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
} else if (lambda1 <= 1.45e-8) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_2 - (cos(lambda2) * t_0)));
} else {
tmp = atan2(t_1, (t_2 - (cos((lambda1 - lambda2)) * t_0)));
}
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) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin(lambda1) * cos(phi2)
t_2 = sin(phi2) * cos(phi1)
if (lambda1 <= (-7.2d-18)) then
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
else if (lambda1 <= 1.45d-8) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_2 - (cos(lambda2) * t_0)))
else
tmp = atan2(t_1, (t_2 - (cos((lambda1 - lambda2)) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.sin(lambda1) * Math.cos(phi2);
double t_2 = Math.sin(phi2) * Math.cos(phi1);
double tmp;
if (lambda1 <= -7.2e-18) {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
} else if (lambda1 <= 1.45e-8) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_2 - (Math.cos(lambda2) * t_0)));
} else {
tmp = Math.atan2(t_1, (t_2 - (Math.cos((lambda1 - lambda2)) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.sin(lambda1) * math.cos(phi2) t_2 = math.sin(phi2) * math.cos(phi1) tmp = 0 if lambda1 <= -7.2e-18: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) elif lambda1 <= 1.45e-8: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_2 - (math.cos(lambda2) * t_0))) else: tmp = math.atan2(t_1, (t_2 - (math.cos((lambda1 - lambda2)) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = Float64(sin(lambda1) * cos(phi2)) t_2 = Float64(sin(phi2) * cos(phi1)) tmp = 0.0 if (lambda1 <= -7.2e-18) tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); elseif (lambda1 <= 1.45e-8) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_2 - Float64(cos(lambda2) * t_0))); else tmp = atan(t_1, Float64(t_2 - Float64(cos(Float64(lambda1 - lambda2)) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = sin(lambda1) * cos(phi2); t_2 = sin(phi2) * cos(phi1); tmp = 0.0; if (lambda1 <= -7.2e-18) tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); elseif (lambda1 <= 1.45e-8) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_2 - (cos(lambda2) * t_0))); else tmp = atan2(t_1, (t_2 - (cos((lambda1 - lambda2)) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -7.2e-18], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 1.45e-8], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \phi_2\\
t_2 := \sin \phi_2 \cdot \cos \phi_1\\
\mathbf{if}\;\lambda_1 \leq -7.2 \cdot 10^{-18}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 1.45 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_2 - \cos \lambda_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_0}\\
\end{array}
\end{array}
if lambda1 < -7.20000000000000021e-18Initial program 64.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6481.4
Applied rewrites81.4%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-sin.f6467.5
Applied rewrites67.5%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6467.2
Applied rewrites67.2%
if -7.20000000000000021e-18 < lambda1 < 1.4500000000000001e-8Initial program 99.4%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6487.2
Applied rewrites87.2%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6487.2
Applied rewrites87.2%
if 1.4500000000000001e-8 < lambda1 Initial program 60.4%
Taylor expanded in lambda2 around 0
lower-sin.f6458.8
Applied rewrites58.8%
Final simplification74.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1 (* (sin phi2) (cos phi1)))
(t_2
(atan2 (* (sin lambda1) (cos phi2)) (- t_1 (* t_0 (cos lambda1))))))
(if (<= lambda1 -7.2e-18)
t_2
(if (<= lambda1 1.45e-8)
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_1 (* (cos lambda2) t_0)))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = sin(phi2) * cos(phi1);
double t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (t_0 * cos(lambda1))));
double tmp;
if (lambda1 <= -7.2e-18) {
tmp = t_2;
} else if (lambda1 <= 1.45e-8) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0)));
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin(phi2) * cos(phi1)
t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (t_0 * cos(lambda1))))
if (lambda1 <= (-7.2d-18)) then
tmp = t_2
else if (lambda1 <= 1.45d-8) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0)))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.sin(phi2) * Math.cos(phi1);
double t_2 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (t_0 * Math.cos(lambda1))));
double tmp;
if (lambda1 <= -7.2e-18) {
tmp = t_2;
} else if (lambda1 <= 1.45e-8) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_1 - (Math.cos(lambda2) * t_0)));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.sin(phi2) * math.cos(phi1) t_2 = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (t_0 * math.cos(lambda1)))) tmp = 0 if lambda1 <= -7.2e-18: tmp = t_2 elif lambda1 <= 1.45e-8: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_1 - (math.cos(lambda2) * t_0))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = Float64(sin(phi2) * cos(phi1)) t_2 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(t_0 * cos(lambda1)))) tmp = 0.0 if (lambda1 <= -7.2e-18) tmp = t_2; elseif (lambda1 <= 1.45e-8) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_1 - Float64(cos(lambda2) * t_0))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = sin(phi2) * cos(phi1); t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (t_0 * cos(lambda1)))); tmp = 0.0; if (lambda1 <= -7.2e-18) tmp = t_2; elseif (lambda1 <= 1.45e-8) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -7.2e-18], t$95$2, If[LessEqual[lambda1, 1.45e-8], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_2 \cdot \cos \phi_1\\
t_2 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{if}\;\lambda_1 \leq -7.2 \cdot 10^{-18}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 1.45 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_1 - \cos \lambda_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda1 < -7.20000000000000021e-18 or 1.4500000000000001e-8 < lambda1 Initial program 62.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6478.6
Applied rewrites78.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
lower-sin.f6463.1
Applied rewrites63.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6462.7
Applied rewrites62.7%
if -7.20000000000000021e-18 < lambda1 < 1.4500000000000001e-8Initial program 99.4%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6487.2
Applied rewrites87.2%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6487.2
Applied rewrites87.2%
Final simplification74.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1
(atan2
(* (sin lambda1) (cos phi2))
(- (* (sin phi2) (cos phi1)) (* t_0 (cos lambda1))))))
(if (<= lambda1 -3.3e-19)
t_1
(if (<= lambda1 1e-5)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (cos (- lambda1 lambda2)) t_0)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = atan2((sin(lambda1) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (t_0 * cos(lambda1))));
double tmp;
if (lambda1 <= -3.3e-19) {
tmp = t_1;
} else if (lambda1 <= 1e-5) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (cos((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 = sin(phi1) * cos(phi2)
t_1 = atan2((sin(lambda1) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (t_0 * cos(lambda1))))
if (lambda1 <= (-3.3d-19)) then
tmp = t_1
else if (lambda1 <= 1d-5) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (cos((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.sin(phi1) * Math.cos(phi2);
double t_1 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.sin(phi2) * Math.cos(phi1)) - (t_0 * Math.cos(lambda1))));
double tmp;
if (lambda1 <= -3.3e-19) {
tmp = t_1;
} else if (lambda1 <= 1e-5) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - (Math.cos((lambda1 - lambda2)) * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - (t_0 * math.cos(lambda1)))) tmp = 0 if lambda1 <= -3.3e-19: tmp = t_1 elif lambda1 <= 1e-5: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - (math.cos((lambda1 - lambda2)) * t_0))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(t_0 * cos(lambda1)))) tmp = 0.0 if (lambda1 <= -3.3e-19) tmp = t_1; elseif (lambda1 <= 1e-5) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(cos(Float64(lambda1 - lambda2)) * t_0))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = atan2((sin(lambda1) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (t_0 * cos(lambda1)))); tmp = 0.0; if (lambda1 <= -3.3e-19) tmp = t_1; elseif (lambda1 <= 1e-5) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (cos((lambda1 - lambda2)) * t_0))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3.3e-19], t$95$1, If[LessEqual[lambda1, 1e-5], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{if}\;\lambda_1 \leq -3.3 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -3.2999999999999998e-19 or 1.00000000000000008e-5 < lambda1 Initial program 62.7%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6478.8
Applied rewrites78.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
lower-sin.f6463.4
Applied rewrites63.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6463.0
Applied rewrites63.0%
if -3.2999999999999998e-19 < lambda1 < 1.00000000000000008e-5Initial program 99.4%
Taylor expanded in phi1 around 0
lower-sin.f6485.4
Applied rewrites85.4%
Final simplification73.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (sin phi2) (cos phi1)) (* (* (cos (- lambda1 lambda2)) (sin phi1)) (cos phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))));
}
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)), ((sin(phi2) * cos(phi1)) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))))
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.sin(phi2) * Math.cos(phi1)) - ((Math.cos((lambda1 - lambda2)) * Math.sin(phi1)) * Math.cos(phi2))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - ((math.cos((lambda1 - lambda2)) * math.sin(phi1)) * math.cos(phi2))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}
\end{array}
Initial program 80.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6480.3
Applied rewrites80.3%
Final simplification80.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (sin phi2) (cos phi1)) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * 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(phi2)), ((sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * 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(phi2)), ((Math.sin(phi2) * Math.cos(phi1)) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 80.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
*-lft-identityN/A
*-inversesN/A
/-rgt-identityN/A
times-fracN/A
*-rgt-identityN/A
associate-*r/N/A
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
sub-negN/A
lower-cos.f64N/A
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
Applied rewrites67.4%
Final simplification67.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (sin phi2) (* (cos (- lambda1 lambda2)) (* (sin phi1) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))));
}
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)), (sin(phi2) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))))
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.sin(phi2) - (Math.cos((lambda1 - lambda2)) * (Math.sin(phi1) * Math.cos(phi2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - (math.cos((lambda1 - lambda2)) * (math.sin(phi1) * math.cos(phi2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(cos(Float64(lambda1 - lambda2)) * Float64(sin(phi1) * cos(phi2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}
\end{array}
Initial program 80.3%
Taylor expanded in phi1 around 0
lower-sin.f6467.2
Applied rewrites67.2%
Final simplification67.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1))))
(t_1 (atan2 (* (cos phi2) (sin lambda1)) t_0)))
(if (<= lambda1 -5.6e-53)
t_1
(if (<= lambda1 1.45e-8)
(atan2 (* (- (cos phi2)) (sin lambda2)) t_0)
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1));
double t_1 = atan2((cos(phi2) * sin(lambda1)), t_0);
double tmp;
if (lambda1 <= -5.6e-53) {
tmp = t_1;
} else if (lambda1 <= 1.45e-8) {
tmp = atan2((-cos(phi2) * sin(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 = sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))
t_1 = atan2((cos(phi2) * sin(lambda1)), t_0)
if (lambda1 <= (-5.6d-53)) then
tmp = t_1
else if (lambda1 <= 1.45d-8) then
tmp = atan2((-cos(phi2) * sin(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.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1));
double t_1 = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), t_0);
double tmp;
if (lambda1 <= -5.6e-53) {
tmp = t_1;
} else if (lambda1 <= 1.45e-8) {
tmp = Math.atan2((-Math.cos(phi2) * Math.sin(lambda2)), t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1)) t_1 = math.atan2((math.cos(phi2) * math.sin(lambda1)), t_0) tmp = 0 if lambda1 <= -5.6e-53: tmp = t_1 elif lambda1 <= 1.45e-8: tmp = math.atan2((-math.cos(phi2) * math.sin(lambda2)), t_0) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1))) t_1 = atan(Float64(cos(phi2) * sin(lambda1)), t_0) tmp = 0.0 if (lambda1 <= -5.6e-53) tmp = t_1; elseif (lambda1 <= 1.45e-8) tmp = atan(Float64(Float64(-cos(phi2)) * sin(lambda2)), t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)); t_1 = atan2((cos(phi2) * sin(lambda1)), t_0); tmp = 0.0; if (lambda1 <= -5.6e-53) tmp = t_1; elseif (lambda1 <= 1.45e-8) tmp = atan2((-cos(phi2) * sin(lambda2)), t_0); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]}, If[LessEqual[lambda1, -5.6e-53], t$95$1, If[LessEqual[lambda1, 1.45e-8], N[ArcTan[N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\\
t_1 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_0}\\
\mathbf{if}\;\lambda_1 \leq -5.6 \cdot 10^{-53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 1.45 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\cos \phi_2\right) \cdot \sin \lambda_2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -5.59999999999999971e-53 or 1.4500000000000001e-8 < lambda1 Initial program 64.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6437.7
Applied rewrites37.7%
Taylor expanded in phi1 around 0
lower-sin.f6436.9
Applied rewrites36.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6436.9
Applied rewrites36.9%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6451.0
Applied rewrites51.0%
if -5.59999999999999971e-53 < lambda1 < 1.4500000000000001e-8Initial program 99.4%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.6
Applied rewrites60.6%
Taylor expanded in phi1 around 0
lower-sin.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6460.3
Applied rewrites60.3%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6474.3
Applied rewrites74.3%
Final simplification61.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (- lambda2 lambda1)) (sin phi1)))
(t_1 (atan2 (* (cos phi2) (sin lambda1)) (- (sin phi2) t_0))))
(if (<= phi2 -145000.0)
t_1
(if (<= phi2 0.145)
(atan2 (sin (- lambda1 lambda2)) (- (* (cos phi1) phi2) t_0))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1)) * sin(phi1);
double t_1 = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - t_0));
double tmp;
if (phi2 <= -145000.0) {
tmp = t_1;
} else if (phi2 <= 0.145) {
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * 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((lambda2 - lambda1)) * sin(phi1)
t_1 = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - t_0))
if (phi2 <= (-145000.0d0)) then
tmp = t_1
else if (phi2 <= 0.145d0) then
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * 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((lambda2 - lambda1)) * Math.sin(phi1);
double t_1 = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), (Math.sin(phi2) - t_0));
double tmp;
if (phi2 <= -145000.0) {
tmp = t_1;
} else if (phi2 <= 0.145) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), ((Math.cos(phi1) * phi2) - t_0));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) * math.sin(phi1) t_1 = math.atan2((math.cos(phi2) * math.sin(lambda1)), (math.sin(phi2) - t_0)) tmp = 0 if phi2 <= -145000.0: tmp = t_1 elif phi2 <= 0.145: tmp = math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * phi2) - t_0)) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) t_1 = atan(Float64(cos(phi2) * sin(lambda1)), Float64(sin(phi2) - t_0)) tmp = 0.0 if (phi2 <= -145000.0) tmp = t_1; elseif (phi2 <= 0.145) tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * phi2) - t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)) * sin(phi1); t_1 = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - t_0)); tmp = 0.0; if (phi2 <= -145000.0) tmp = t_1; elseif (phi2 <= 0.145) tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * phi2) - t_0)); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -145000.0], t$95$1, If[LessEqual[phi2, 0.145], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\\
t_1 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{\sin \phi_2 - t\_0}\\
\mathbf{if}\;\phi_2 \leq -145000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.145:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -145000 or 0.14499999999999999 < phi2 Initial program 77.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6415.9
Applied rewrites15.9%
Taylor expanded in phi1 around 0
lower-sin.f6414.8
Applied rewrites14.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6415.7
Applied rewrites15.7%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6435.4
Applied rewrites35.4%
if -145000 < phi2 < 0.14499999999999999Initial program 83.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6483.1
Applied rewrites83.1%
Taylor expanded in phi1 around 0
lower-sin.f6482.2
Applied rewrites82.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6482.2
Applied rewrites82.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6483.2
Applied rewrites83.2%
Final simplification58.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (cos((lambda2 - lambda1)) * 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(phi2)), (sin(phi2) - (cos((lambda2 - lambda1)) * 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(phi2)), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 80.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6447.6
Applied rewrites47.6%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
neg-mul-1N/A
lower-sin.f64N/A
neg-mul-1N/A
sub-negN/A
lower--.f64N/A
lower-cos.f6466.6
Applied rewrites66.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= lambda1 -2.75e-24)
(atan2
(sin lambda1)
(- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1))))
(if (<= lambda1 9e-6)
(atan2 t_0 (- (sin phi2) (* (cos lambda2) (sin phi1))))
(atan2 t_0 (- (sin phi2) (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -2.75e-24) {
tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))));
} else if (lambda1 <= 9e-6) {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))));
}
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) :: tmp
t_0 = sin((lambda1 - lambda2))
if (lambda1 <= (-2.75d-24)) then
tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
else if (lambda1 <= 9d-6) then
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))))
else
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -2.75e-24) {
tmp = Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
} else if (lambda1 <= 9e-6) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if lambda1 <= -2.75e-24: tmp = math.atan2(math.sin(lambda1), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) elif lambda1 <= 9e-6: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda2) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (lambda1 <= -2.75e-24) tmp = atan(sin(lambda1), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); elseif (lambda1 <= 9e-6) tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda2) * sin(phi1)))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (lambda1 <= -2.75e-24) tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); elseif (lambda1 <= 9e-6) tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1)))); else tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -2.75e-24], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 9e-6], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -2.75 \cdot 10^{-24}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -2.7499999999999999e-24Initial program 65.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6435.3
Applied rewrites35.3%
Taylor expanded in phi1 around 0
lower-sin.f6434.7
Applied rewrites34.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6434.7
Applied rewrites34.7%
Taylor expanded in lambda2 around 0
Applied rewrites36.9%
if -2.7499999999999999e-24 < lambda1 < 9.00000000000000023e-6Initial program 99.4%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in phi1 around 0
lower-sin.f6459.5
Applied rewrites59.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6460.5
Applied rewrites60.5%
Taylor expanded in lambda1 around 0
Applied rewrites60.5%
if 9.00000000000000023e-6 < lambda1 Initial program 60.4%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6437.9
Applied rewrites37.9%
Taylor expanded in phi1 around 0
lower-sin.f6437.0
Applied rewrites37.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6437.1
Applied rewrites37.1%
Taylor expanded in lambda2 around 0
Applied rewrites37.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos((lambda2 - lambda1)) * 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)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 80.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6447.6
Applied rewrites47.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (cos lambda1) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda1) * 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)), (sin(phi2) - (cos(lambda1) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda1) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}
\end{array}
Initial program 80.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6447.6
Applied rewrites47.6%
Taylor expanded in lambda2 around 0
Applied rewrites41.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * 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), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 80.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6447.6
Applied rewrites47.6%
Taylor expanded in lambda2 around 0
Applied rewrites30.3%
herbie shell --seed 2024268
(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))))))