
(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 29 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(fma
(* (cos lambda1) (- (sin lambda2)))
(cos phi2)
(* (* (cos lambda2) (sin lambda1)) (cos phi2)))
(-
(* (sin phi2) (cos phi1))
(*
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2)))
(* (sin phi1) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(fma((cos(lambda1) * -sin(lambda2)), cos(phi2), ((cos(lambda2) * sin(lambda1)) * cos(phi2))), ((sin(phi2) * cos(phi1)) - (fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))) * (sin(phi1) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(fma(Float64(cos(lambda1) * Float64(-sin(lambda2))), cos(phi2), Float64(Float64(cos(lambda2) * sin(lambda1)) * cos(phi2))), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))) * Float64(sin(phi1) * cos(phi2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $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[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_1 \cdot \left(-\sin \lambda_2\right), \cos \phi_2, \left(\cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2\right)}{\sin \phi_2 \cdot \cos \phi_1 - \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}
\end{array}
Initial program 81.2%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6481.4
Applied rewrites81.4%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
unsub-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
distribute-rgt-outN/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(-
(* (sin phi2) (cos phi1))
(*
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2)))
(* (sin phi1) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))) * (sin(phi1) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))) * Float64(sin(phi1) * cos(phi2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $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[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}
\end{array}
Initial program 81.2%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6481.4
Applied rewrites81.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
sin-sumN/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
lift-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (sin phi2) (cos phi1))
(*
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin 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)) - (fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))) * (sin(phi1) * 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(fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))) * Float64(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[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $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 - \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)}
\end{array}
Initial program 81.2%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6481.4
Applied rewrites81.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin lambda2)))
(t_1 (* (cos lambda1) t_0))
(t_2 (* (sin phi2) (cos phi1)))
(t_3 (* (cos lambda2) (sin lambda1)))
(t_4 (* (sin phi1) (cos phi2)))
(t_5 (- t_2 (* (cos (- lambda1 lambda2)) t_4))))
(if (<= phi2 -6.8e-6)
(atan2 (fma t_3 (cos phi2) (* (cos phi2) t_1)) t_5)
(if (<= phi2 4.4e-45)
(atan2
(fma t_0 (cos lambda1) t_3)
(-
t_2
(*
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2)))
t_4)))
(atan2 (* (fma (sin lambda1) (cos lambda2) t_1) (cos phi2)) t_5)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -sin(lambda2);
double t_1 = cos(lambda1) * t_0;
double t_2 = sin(phi2) * cos(phi1);
double t_3 = cos(lambda2) * sin(lambda1);
double t_4 = sin(phi1) * cos(phi2);
double t_5 = t_2 - (cos((lambda1 - lambda2)) * t_4);
double tmp;
if (phi2 <= -6.8e-6) {
tmp = atan2(fma(t_3, cos(phi2), (cos(phi2) * t_1)), t_5);
} else if (phi2 <= 4.4e-45) {
tmp = atan2(fma(t_0, cos(lambda1), t_3), (t_2 - (fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))) * t_4)));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), t_1) * cos(phi2)), t_5);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-sin(lambda2)) t_1 = Float64(cos(lambda1) * t_0) t_2 = Float64(sin(phi2) * cos(phi1)) t_3 = Float64(cos(lambda2) * sin(lambda1)) t_4 = Float64(sin(phi1) * cos(phi2)) t_5 = Float64(t_2 - Float64(cos(Float64(lambda1 - lambda2)) * t_4)) tmp = 0.0 if (phi2 <= -6.8e-6) tmp = atan(fma(t_3, cos(phi2), Float64(cos(phi2) * t_1)), t_5); elseif (phi2 <= 4.4e-45) tmp = atan(fma(t_0, cos(lambda1), t_3), Float64(t_2 - Float64(fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))) * t_4))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), t_1) * cos(phi2)), t_5); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Sin[lambda2], $MachinePrecision])}, Block[{t$95$1 = N[(N[Cos[lambda1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -6.8e-6], N[ArcTan[N[(t$95$3 * N[Cos[phi2], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / t$95$5], $MachinePrecision], If[LessEqual[phi2, 4.4e-45], N[ArcTan[N[(t$95$0 * N[Cos[lambda1], $MachinePrecision] + t$95$3), $MachinePrecision] / N[(t$95$2 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$5], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin \lambda_2\\
t_1 := \cos \lambda_1 \cdot t\_0\\
t_2 := \sin \phi_2 \cdot \cos \phi_1\\
t_3 := \cos \lambda_2 \cdot \sin \lambda_1\\
t_4 := \sin \phi_1 \cdot \cos \phi_2\\
t_5 := t\_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_4\\
\mathbf{if}\;\phi_2 \leq -6.8 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(t\_3, \cos \phi_2, \cos \phi_2 \cdot t\_1\right)}{t\_5}\\
\mathbf{elif}\;\phi_2 \leq 4.4 \cdot 10^{-45}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(t\_0, \cos \lambda_1, t\_3\right)}{t\_2 - \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot t\_4}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, t\_1\right) \cdot \cos \phi_2}{t\_5}\\
\end{array}
\end{array}
if phi2 < -6.80000000000000012e-6Initial program 79.0%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.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.f6491.8
Applied rewrites91.8%
if -6.80000000000000012e-6 < phi2 < 4.39999999999999987e-45Initial program 83.4%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6483.8
Applied rewrites83.8%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
unsub-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
distribute-rgt-outN/A
Applied rewrites99.9%
Taylor expanded in phi2 around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sin-negN/A
lower-fma.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6499.9
Applied rewrites99.9%
if 4.39999999999999987e-45 < phi2 Initial program 79.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.f6487.2
Applied rewrites87.2%
Final simplification93.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (fma (* (sin lambda1) (cos phi2)) (cos lambda2) (* (cos phi2) (* (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(fma((sin(lambda1) * cos(phi2)), cos(lambda2), (cos(phi2) * (cos(lambda1) * -sin(lambda2)))), ((sin(phi2) * cos(phi1)) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(fma(Float64(sin(lambda1) * cos(phi2)), cos(lambda2), Float64(cos(phi2) * 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[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[phi2], $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{\mathsf{fma}\left(\sin \lambda_1 \cdot \cos \phi_2, \cos \lambda_2, \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\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 81.2%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.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.f6489.9
Applied rewrites89.9%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.9
Applied rewrites89.9%
Final simplification89.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (fma (* (cos lambda2) (sin lambda1)) (cos phi2) (* (* (cos phi2) (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(fma((cos(lambda2) * sin(lambda1)), cos(phi2), ((cos(phi2) * cos(lambda1)) * -sin(lambda2))), ((sin(phi2) * cos(phi1)) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(fma(Float64(cos(lambda2) * sin(lambda1)), cos(phi2), Float64(Float64(cos(phi2) * 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[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * (-N[Sin[lambda2], $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{\mathsf{fma}\left(\cos \lambda_2 \cdot \sin \lambda_1, \cos \phi_2, \left(\cos \phi_2 \cdot \cos \lambda_1\right) \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 81.2%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.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.f6489.9
Applied rewrites89.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6489.9
Applied rewrites89.9%
Final simplification89.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1
(atan2
(*
(fma
(sin lambda2)
(- (cos lambda1))
(* (cos lambda2) (sin lambda1)))
(cos phi2))
(- t_0 (* (* (cos phi2) (cos lambda1)) (sin phi1))))))
(if (<= lambda1 -0.00245)
t_1
(if (<= lambda1 3.65e-7)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos (- lambda1 lambda2)) (cos phi2)) (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((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), (t_0 - ((cos(phi2) * cos(lambda1)) * sin(phi1))));
double tmp;
if (lambda1 <= -0.00245) {
tmp = t_1;
} else if (lambda1 <= 3.65e-7) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos((lambda1 - lambda2)) * cos(phi2)) * 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(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * cos(lambda1)) * sin(phi1)))) tmp = 0.0 if (lambda1 <= -0.00245) tmp = t_1; elseif (lambda1 <= 3.65e-7) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * sin(phi1)))); else tmp = t_1; 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[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $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]}, If[LessEqual[lambda1, -0.00245], t$95$1, If[LessEqual[lambda1, 3.65e-7], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $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{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \phi_2 \cdot \cos \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\lambda_1 \leq -0.00245:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 3.65 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -0.0024499999999999999 or 3.65e-7 < lambda1 Initial program 62.0%
Taylor expanded in phi1 around 0
Applied rewrites37.1%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
sin-sumN/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
lift-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6452.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.1
Applied rewrites52.1%
Taylor expanded in lambda2 around 0
associate-*r*N/A
cos-negN/A
neg-mul-1N/A
lower-*.f64N/A
neg-mul-1N/A
cos-negN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-sin.f6479.1
Applied rewrites79.1%
if -0.0024499999999999999 < lambda1 < 3.65e-7Initial program 99.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification89.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (sin lambda1) (cos lambda2) (* (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((fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - (cos((lambda1 - lambda2)) * (sin(phi1) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2)))) * cos(phi2)), 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[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $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{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\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 81.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.f6489.9
Applied rewrites89.9%
Final simplification89.9%
(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 81.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.9
Applied rewrites89.9%
Final simplification89.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos (- lambda1 lambda2)) (cos phi2)) (sin phi1))))))
(if (<= phi1 -0.0205)
t_1
(if (<= phi1 0.028)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2))))
(cos phi2))
(-
t_0
(*
(*
(+
(* (* 0.008333333333333333 (* phi1 phi1)) (* phi1 phi1))
(fma (* phi1 phi1) -0.16666666666666666 1.0))
(* (cos (- lambda2 lambda1)) (cos phi2)))
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((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos((lambda1 - lambda2)) * cos(phi2)) * sin(phi1))));
double tmp;
if (phi1 <= -0.0205) {
tmp = t_1;
} else if (phi1 <= 0.028) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2))) * cos(phi2)), (t_0 - (((((0.008333333333333333 * (phi1 * phi1)) * (phi1 * phi1)) + fma((phi1 * phi1), -0.16666666666666666, 1.0)) * (cos((lambda2 - lambda1)) * cos(phi2))) * 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(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -0.0205) tmp = t_1; elseif (phi1 <= 0.028) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2)))) * cos(phi2)), Float64(t_0 - Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * Float64(phi1 * phi1)) * Float64(phi1 * phi1)) + fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0)) * Float64(cos(Float64(lambda2 - lambda1)) * cos(phi2))) * phi1))); else tmp = t_1; 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[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0205], t$95$1, If[LessEqual[phi1, 0.028], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[(N[(N[(0.008333333333333333 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] + N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * phi1), $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_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -0.0205:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 0.028:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right) \cdot \cos \phi_2}{t\_0 - \left(\left(\left(0.008333333333333333 \cdot \left(\phi_1 \cdot \phi_1\right)\right) \cdot \left(\phi_1 \cdot \phi_1\right) + \mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right)\right) \cdot \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \cos \phi_2\right)\right) \cdot \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -0.0205000000000000009 or 0.0280000000000000006 < phi1 Initial program 78.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.2
Applied rewrites78.2%
if -0.0205000000000000009 < phi1 < 0.0280000000000000006Initial program 84.4%
Taylor expanded in phi1 around 0
Applied rewrites84.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
sin-sumN/A
lift-neg.f64N/A
cos-negN/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
lift-neg.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.5
Applied rewrites99.5%
Final simplification88.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1 (* (cos (- lambda1 lambda2)) (cos phi2)))
(t_2
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* t_1 (sin phi1))))))
(if (<= phi1 -0.00375)
t_2
(if (<= phi1 0.0025)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(- t_0 (* (* (fma (* phi1 phi1) -0.16666666666666666 1.0) t_1) phi1)))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = cos((lambda1 - lambda2)) * cos(phi2);
double t_2 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * sin(phi1))));
double tmp;
if (phi1 <= -0.00375) {
tmp = t_2;
} else if (phi1 <= 0.0025) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), (t_0 - ((fma((phi1 * phi1), -0.16666666666666666, 1.0) * t_1) * phi1)));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) t_2 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * sin(phi1)))) tmp = 0.0 if (phi1 <= -0.00375) tmp = t_2; elseif (phi1 <= 0.0025) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(t_0 - Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * t_1) * phi1))); else tmp = 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.00375], t$95$2, If[LessEqual[phi1, 0.0025], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -0.00375:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 0.0025:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_0 - \left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot t\_1\right) \cdot \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -0.0037499999999999999 or 0.00250000000000000005 < phi1 Initial program 78.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.2
Applied rewrites78.2%
if -0.0037499999999999999 < phi1 < 0.00250000000000000005Initial program 84.4%
Taylor expanded in phi1 around 0
Applied rewrites84.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
sin-sumN/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
lift-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Final simplification88.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1 (cos (- lambda1 lambda2)))
(t_2
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* t_1 (cos phi2)) (sin phi1))))))
(if (<= phi1 -1.35e-5)
t_2
(if (<= phi1 9.2e-5)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(- t_0 (* (* phi1 (cos phi2)) t_1)))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = cos((lambda1 - lambda2));
double t_2 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_1 * cos(phi2)) * sin(phi1))));
double tmp;
if (phi1 <= -1.35e-5) {
tmp = t_2;
} else if (phi1 <= 9.2e-5) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), (t_0 - ((phi1 * cos(phi2)) * t_1)));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(t_1 * cos(phi2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -1.35e-5) tmp = t_2; elseif (phi1 <= 9.2e-5) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(t_0 - Float64(Float64(phi1 * cos(phi2)) * t_1))); else tmp = 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.35e-5], t$95$2, If[LessEqual[phi1, 9.2e-5], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(phi1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(t\_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -1.35 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 9.2 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_0 - \left(\phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -1.3499999999999999e-5 or 9.20000000000000001e-5 < phi1 Initial program 78.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.2
Applied rewrites78.2%
if -1.3499999999999999e-5 < phi1 < 9.20000000000000001e-5Initial program 84.4%
Taylor expanded in phi1 around 0
Applied rewrites84.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
sin-sumN/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
lift-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in phi1 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
sub-negN/A
neg-mul-1N/A
lower-cos.f64N/A
neg-mul-1N/A
sub-negN/A
lower--.f6499.5
Applied rewrites99.5%
Final simplification88.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1 (cos (- lambda1 lambda2)))
(t_2
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* t_1 (cos phi2)) (sin phi1))))))
(if (<= phi1 -0.021)
t_2
(if (<= phi1 9.5e-11)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(- t_0 (* t_1 (sin phi1))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = cos((lambda1 - lambda2));
double t_2 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_1 * cos(phi2)) * sin(phi1))));
double tmp;
if (phi1 <= -0.021) {
tmp = t_2;
} else if (phi1 <= 9.5e-11) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), (t_0 - (t_1 * sin(phi1))));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(t_1 * cos(phi2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -0.021) tmp = t_2; elseif (phi1 <= 9.5e-11) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(t_0 - Float64(t_1 * sin(phi1)))); else tmp = 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.021], t$95$2, If[LessEqual[phi1, 9.5e-11], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(t\_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -0.021:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 9.5 \cdot 10^{-11}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -0.0210000000000000013 or 9.49999999999999951e-11 < phi1 Initial program 78.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.1
Applied rewrites78.1%
if -0.0210000000000000013 < phi1 < 9.49999999999999951e-11Initial program 84.6%
Taylor expanded in phi1 around 0
Applied rewrites84.6%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
+-commutativeN/A
sin-sumN/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
lift-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
neg-mul-1N/A
lower-cos.f64N/A
neg-mul-1N/A
sub-negN/A
lower--.f64N/A
lower-sin.f6499.4
Applied rewrites99.4%
Final simplification88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos (- lambda1 lambda2)) (cos phi2)) (sin phi1))))))
(if (<= phi2 -0.00032)
t_1
(if (<= phi2 5.2e-7)
(atan2
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(- t_0 (* (cos (- lambda2 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((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos((lambda1 - lambda2)) * cos(phi2)) * sin(phi1))));
double tmp;
if (phi2 <= -0.00032) {
tmp = t_1;
} else if (phi2 <= 5.2e-7) {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (t_0 - (cos((lambda2 - 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((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos((lambda1 - lambda2)) * cos(phi2)) * sin(phi1))))
if (phi2 <= (-0.00032d0)) then
tmp = t_1
else if (phi2 <= 5.2d-7) then
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (t_0 - (cos((lambda2 - 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((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos((lambda1 - lambda2)) * Math.cos(phi2)) * Math.sin(phi1))));
double tmp;
if (phi2 <= -0.00032) {
tmp = t_1;
} else if (phi2 <= 5.2e-7) {
tmp = Math.atan2(((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))), (t_0 - (Math.cos((lambda2 - 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((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos((lambda1 - lambda2)) * math.cos(phi2)) * math.sin(phi1)))) tmp = 0 if phi2 <= -0.00032: tmp = t_1 elif phi2 <= 5.2e-7: tmp = math.atan2(((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))), (t_0 - (math.cos((lambda2 - 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(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * sin(phi1)))) tmp = 0.0 if (phi2 <= -0.00032) tmp = t_1; elseif (phi2 <= 5.2e-7) tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))), Float64(t_0 - Float64(cos(Float64(lambda2 - 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((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos((lambda1 - lambda2)) * cos(phi2)) * sin(phi1)))); tmp = 0.0; if (phi2 <= -0.00032) tmp = t_1; elseif (phi2 <= 5.2e-7) tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (t_0 - (cos((lambda2 - 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.00032], t$95$1, If[LessEqual[phi2, 5.2e-7], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda2 - 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_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_2 \leq -0.00032:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 5.2 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2}{t\_0 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -3.20000000000000026e-4 or 5.19999999999999998e-7 < phi2 Initial program 79.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6479.4
Applied rewrites79.4%
if -3.20000000000000026e-4 < phi2 < 5.19999999999999998e-7Initial program 83.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6483.2
Applied rewrites83.2%
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
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6483.2
Applied rewrites83.2%
Applied rewrites91.5%
Final simplification85.1%
(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 lambda2)) (cos phi2))
(- t_1 (* (cos (- lambda2 lambda1)) (sin phi1))))))
(if (<= lambda2 -0.0112)
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_1 (* (cos lambda2) t_0)))
(if (<= lambda2 -7.5e-182)
t_2
(if (<= lambda2 3.1e-184)
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* (cos (- lambda1 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 - lambda2)) * cos(phi2)), (t_1 - (cos((lambda2 - lambda1)) * sin(phi1))));
double tmp;
if (lambda2 <= -0.0112) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0)));
} else if (lambda2 <= -7.5e-182) {
tmp = t_2;
} else if (lambda2 <= 3.1e-184) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos((lambda1 - 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 - lambda2)) * cos(phi2)), (t_1 - (cos((lambda2 - lambda1)) * sin(phi1))))
if (lambda2 <= (-0.0112d0)) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0)))
else if (lambda2 <= (-7.5d-182)) then
tmp = t_2
else if (lambda2 <= 3.1d-184) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos((lambda1 - 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 - lambda2)) * Math.cos(phi2)), (t_1 - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
double tmp;
if (lambda2 <= -0.0112) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_1 - (Math.cos(lambda2) * t_0)));
} else if (lambda2 <= -7.5e-182) {
tmp = t_2;
} else if (lambda2 <= 3.1e-184) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (Math.cos((lambda1 - 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 - lambda2)) * math.cos(phi2)), (t_1 - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) tmp = 0 if lambda2 <= -0.0112: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_1 - (math.cos(lambda2) * t_0))) elif lambda2 <= -7.5e-182: tmp = t_2 elif lambda2 <= 3.1e-184: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (math.cos((lambda1 - 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(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_1 - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) tmp = 0.0 if (lambda2 <= -0.0112) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_1 - Float64(cos(lambda2) * t_0))); elseif (lambda2 <= -7.5e-182) tmp = t_2; elseif (lambda2 <= 3.1e-184) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(cos(Float64(lambda1 - 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 - lambda2)) * cos(phi2)), (t_1 - (cos((lambda2 - lambda1)) * sin(phi1)))); tmp = 0.0; if (lambda2 <= -0.0112) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0))); elseif (lambda2 <= -7.5e-182) tmp = t_2; elseif (lambda2 <= 3.1e-184) tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos((lambda1 - 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -0.0112], 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], If[LessEqual[lambda2, -7.5e-182], t$95$2, If[LessEqual[lambda2, 3.1e-184], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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 \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\lambda_2 \leq -0.0112:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_1 - \cos \lambda_2 \cdot t\_0}\\
\mathbf{elif}\;\lambda_2 \leq -7.5 \cdot 10^{-182}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 3.1 \cdot 10^{-184}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -0.0111999999999999999Initial program 66.9%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6468.9
Applied rewrites68.9%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6468.8
Applied rewrites68.8%
if -0.0111999999999999999 < lambda2 < -7.49999999999999935e-182 or 3.1000000000000002e-184 < lambda2 Initial program 80.5%
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
*-commutativeN/A
*-lft-identityN/A
*-inversesN/A
/-rgt-identityN/A
times-fracN/A
*-rgt-identityN/A
associate-*r/N/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
*-commutativeN/A
Applied rewrites69.6%
if -7.49999999999999935e-182 < lambda2 < 3.1000000000000002e-184Initial program 99.8%
Taylor expanded in lambda2 around 0
lower-sin.f6495.0
Applied rewrites95.0%
Final simplification75.2%
(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 (<= lambda2 -0.0056)
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_2 (* (* (cos (- lambda1 lambda2)) (cos phi2)) (sin phi1))))
(if (<= lambda2 2.8e-6)
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))
(atan2 t_1 (- t_2 (* (cos 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 - lambda2)) * cos(phi2);
double t_2 = sin(phi2) * cos(phi1);
double tmp;
if (lambda2 <= -0.0056) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_2 - ((cos((lambda1 - lambda2)) * cos(phi2)) * sin(phi1))));
} else if (lambda2 <= 2.8e-6) {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
} else {
tmp = atan2(t_1, (t_2 - (cos(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 - lambda2)) * cos(phi2)
t_2 = sin(phi2) * cos(phi1)
if (lambda2 <= (-0.0056d0)) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_2 - ((cos((lambda1 - lambda2)) * cos(phi2)) * sin(phi1))))
else if (lambda2 <= 2.8d-6) then
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
else
tmp = atan2(t_1, (t_2 - (cos(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 - lambda2)) * Math.cos(phi2);
double t_2 = Math.sin(phi2) * Math.cos(phi1);
double tmp;
if (lambda2 <= -0.0056) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_2 - ((Math.cos((lambda1 - lambda2)) * Math.cos(phi2)) * Math.sin(phi1))));
} else if (lambda2 <= 2.8e-6) {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
} else {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(lambda2) * t_0)));
}
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 lambda2 <= -0.0056: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_2 - ((math.cos((lambda1 - lambda2)) * math.cos(phi2)) * math.sin(phi1)))) elif lambda2 <= 2.8e-6: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) else: tmp = math.atan2(t_1, (t_2 - (math.cos(lambda2) * t_0))) 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 (lambda2 <= -0.0056) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_2 - Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * sin(phi1)))); elseif (lambda2 <= 2.8e-6) tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); else tmp = atan(t_1, Float64(t_2 - Float64(cos(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 - lambda2)) * cos(phi2); t_2 = sin(phi2) * cos(phi1); tmp = 0.0; if (lambda2 <= -0.0056) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_2 - ((cos((lambda1 - lambda2)) * cos(phi2)) * sin(phi1)))); elseif (lambda2 <= 2.8e-6) tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); else tmp = atan2(t_1, (t_2 - (cos(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[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[lambda2, -0.0056], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 2.8e-6], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[lambda2], $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 \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_2 \cdot \cos \phi_1\\
\mathbf{if}\;\lambda_2 \leq -0.0056:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_2 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_2 \leq 2.8 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - \cos \lambda_2 \cdot t\_0}\\
\end{array}
\end{array}
if lambda2 < -0.00559999999999999994Initial program 66.9%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6468.9
Applied rewrites68.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6468.9
Applied rewrites68.9%
if -0.00559999999999999994 < lambda2 < 2.79999999999999987e-6Initial program 99.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
if 2.79999999999999987e-6 < lambda2 Initial program 56.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6455.0
Applied rewrites55.0%
Final simplification81.4%
(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)))
(t_3 (- t_2 (* (cos lambda2) t_0))))
(if (<= lambda2 -0.0056)
(atan2 (* (sin (- lambda2)) (cos phi2)) t_3)
(if (<= lambda2 2.8e-6)
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))
(atan2 t_1 t_3)))))
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 t_3 = t_2 - (cos(lambda2) * t_0);
double tmp;
if (lambda2 <= -0.0056) {
tmp = atan2((sin(-lambda2) * cos(phi2)), t_3);
} else if (lambda2 <= 2.8e-6) {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
} else {
tmp = atan2(t_1, t_3);
}
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) :: t_3
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
t_2 = sin(phi2) * cos(phi1)
t_3 = t_2 - (cos(lambda2) * t_0)
if (lambda2 <= (-0.0056d0)) then
tmp = atan2((sin(-lambda2) * cos(phi2)), t_3)
else if (lambda2 <= 2.8d-6) then
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
else
tmp = atan2(t_1, t_3)
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 t_3 = t_2 - (Math.cos(lambda2) * t_0);
double tmp;
if (lambda2 <= -0.0056) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), t_3);
} else if (lambda2 <= 2.8e-6) {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
} else {
tmp = Math.atan2(t_1, t_3);
}
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) t_3 = t_2 - (math.cos(lambda2) * t_0) tmp = 0 if lambda2 <= -0.0056: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), t_3) elif lambda2 <= 2.8e-6: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) else: tmp = math.atan2(t_1, t_3) 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)) t_3 = Float64(t_2 - Float64(cos(lambda2) * t_0)) tmp = 0.0 if (lambda2 <= -0.0056) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), t_3); elseif (lambda2 <= 2.8e-6) tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); else tmp = atan(t_1, t_3); 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); t_3 = t_2 - (cos(lambda2) * t_0); tmp = 0.0; if (lambda2 <= -0.0056) tmp = atan2((sin(-lambda2) * cos(phi2)), t_3); elseif (lambda2 <= 2.8e-6) tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); else tmp = atan2(t_1, t_3); 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]}, Block[{t$95$3 = N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.0056], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$3], $MachinePrecision], If[LessEqual[lambda2, 2.8e-6], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / t$95$3], $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\\
t_3 := t\_2 - \cos \lambda_2 \cdot t\_0\\
\mathbf{if}\;\lambda_2 \leq -0.0056:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_3}\\
\mathbf{elif}\;\lambda_2 \leq 2.8 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_3}\\
\end{array}
\end{array}
if lambda2 < -0.00559999999999999994Initial program 66.9%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6468.9
Applied rewrites68.9%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6468.8
Applied rewrites68.8%
if -0.00559999999999999994 < lambda2 < 2.79999999999999987e-6Initial program 99.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6499.8
Applied rewrites99.8%
if 2.79999999999999987e-6 < lambda2 Initial program 56.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6455.0
Applied rewrites55.0%
Final simplification81.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1 (* (sin phi2) (cos phi1)))
(t_2
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_1 (* (cos lambda2) t_0)))))
(if (<= lambda2 -0.0056)
t_2
(if (<= lambda2 1.7e+28)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_1 (* t_0 (cos lambda1))))
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(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0)));
double tmp;
if (lambda2 <= -0.0056) {
tmp = t_2;
} else if (lambda2 <= 1.7e+28) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (t_0 * cos(lambda1))));
} 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(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0)))
if (lambda2 <= (-0.0056d0)) then
tmp = t_2
else if (lambda2 <= 1.7d+28) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (t_0 * cos(lambda1))))
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(-lambda2) * Math.cos(phi2)), (t_1 - (Math.cos(lambda2) * t_0)));
double tmp;
if (lambda2 <= -0.0056) {
tmp = t_2;
} else if (lambda2 <= 1.7e+28) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_1 - (t_0 * Math.cos(lambda1))));
} 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(-lambda2) * math.cos(phi2)), (t_1 - (math.cos(lambda2) * t_0))) tmp = 0 if lambda2 <= -0.0056: tmp = t_2 elif lambda2 <= 1.7e+28: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_1 - (t_0 * math.cos(lambda1)))) 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(Float64(-lambda2)) * cos(phi2)), Float64(t_1 - Float64(cos(lambda2) * t_0))) tmp = 0.0 if (lambda2 <= -0.0056) tmp = t_2; elseif (lambda2 <= 1.7e+28) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_1 - Float64(t_0 * cos(lambda1)))); 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(-lambda2) * cos(phi2)), (t_1 - (cos(lambda2) * t_0))); tmp = 0.0; if (lambda2 <= -0.0056) tmp = t_2; elseif (lambda2 <= 1.7e+28) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (t_0 * cos(lambda1)))); 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[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -0.0056], t$95$2, If[LessEqual[lambda2, 1.7e+28], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $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 \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_1 - \cos \lambda_2 \cdot t\_0}\\
\mathbf{if}\;\lambda_2 \leq -0.0056:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 1.7 \cdot 10^{+28}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -0.00559999999999999994 or 1.7e28 < lambda2 Initial program 62.6%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6462.8
Applied rewrites62.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6462.8
Applied rewrites62.8%
if -0.00559999999999999994 < lambda2 < 1.7e28Initial program 97.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6497.8
Applied rewrites97.8%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6497.8
Applied rewrites97.8%
Final simplification81.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1))))
(if (<= lambda2 -0.0112)
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (cos lambda2) (* (sin phi1) (cos phi2)))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (cos (- lambda2 lambda1)) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double tmp;
if (lambda2 <= -0.0112) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(lambda2) * (sin(phi1) * cos(phi2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - 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(phi2) * cos(phi1)
if (lambda2 <= (-0.0112d0)) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(lambda2) * (sin(phi1) * cos(phi2)))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - 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(phi2) * Math.cos(phi1);
double tmp;
if (lambda2 <= -0.0112) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (Math.cos(lambda2) * (Math.sin(phi1) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) * math.cos(phi1) tmp = 0 if lambda2 <= -0.0112: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (math.cos(lambda2) * (math.sin(phi1) * math.cos(phi2))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) tmp = 0.0 if (lambda2 <= -0.0112) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(lambda2) * Float64(sin(phi1) * cos(phi2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) * cos(phi1); tmp = 0.0; if (lambda2 <= -0.0112) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(lambda2) * (sin(phi1) * cos(phi2))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.0112], 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], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
\mathbf{if}\;\lambda_2 \leq -0.0112:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda2 < -0.0111999999999999999Initial program 66.9%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6468.9
Applied rewrites68.9%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6468.8
Applied rewrites68.8%
if -0.0111999999999999999 < lambda2 Initial program 86.7%
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
*-commutativeN/A
*-lft-identityN/A
*-inversesN/A
/-rgt-identityN/A
times-fracN/A
*-rgt-identityN/A
associate-*r/N/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
*-commutativeN/A
Applied rewrites73.1%
Final simplification71.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (sin phi2) (cos phi1)) (* (* (cos (- lambda1 lambda2)) (cos phi2)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda1 - lambda2)) * cos(phi2)) * 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((lambda1 - lambda2)) * cos(phi2)) * 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((lambda1 - lambda2)) * Math.cos(phi2)) * 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((lambda1 - lambda2)) * math.cos(phi2)) * 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(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda1 - lambda2)) * cos(phi2)) * 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[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $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 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \sin \phi_1}
\end{array}
Initial program 81.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6481.2
Applied rewrites81.2%
Final simplification81.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (sin phi2) (cos phi1))
(* (cos (- lambda2 lambda1)) (sin phi1))))
(t_1 (atan2 (* (sin (- lambda2)) (cos phi2)) t_0)))
(if (<= lambda2 -8.8e-35)
t_1
(if (<= lambda2 27000000000.0)
(atan2 (* (sin lambda1) (cos phi2)) t_0)
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * sin(phi1));
double t_1 = atan2((sin(-lambda2) * cos(phi2)), t_0);
double tmp;
if (lambda2 <= -8.8e-35) {
tmp = t_1;
} else if (lambda2 <= 27000000000.0) {
tmp = atan2((sin(lambda1) * cos(phi2)), t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * sin(phi1))
t_1 = atan2((sin(-lambda2) * cos(phi2)), t_0)
if (lambda2 <= (-8.8d-35)) then
tmp = t_1
else if (lambda2 <= 27000000000.0d0) then
tmp = atan2((sin(lambda1) * cos(phi2)), t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.sin(phi2) * Math.cos(phi1)) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1));
double t_1 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), t_0);
double tmp;
if (lambda2 <= -8.8e-35) {
tmp = t_1;
} else if (lambda2 <= 27000000000.0) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.sin(phi2) * math.cos(phi1)) - (math.cos((lambda2 - lambda1)) * math.sin(phi1)) t_1 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), t_0) tmp = 0 if lambda2 <= -8.8e-35: tmp = t_1 elif lambda2 <= 27000000000.0: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi2) * cos(phi1)) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1))) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), t_0) tmp = 0.0 if (lambda2 <= -8.8e-35) tmp = t_1; elseif (lambda2 <= 27000000000.0) tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * sin(phi1)); t_1 = atan2((sin(-lambda2) * cos(phi2)), t_0); tmp = 0.0; if (lambda2 <= -8.8e-35) tmp = t_1; elseif (lambda2 <= 27000000000.0) tmp = atan2((sin(lambda1) * cos(phi2)), t_0); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]}, If[LessEqual[lambda2, -8.8e-35], t$95$1, If[LessEqual[lambda2, 27000000000.0], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\\
t_1 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0}\\
\mathbf{if}\;\lambda_2 \leq -8.8 \cdot 10^{-35}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 27000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -8.79999999999999975e-35 or 2.7e10 < lambda2 Initial program 63.3%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6462.7
Applied rewrites62.7%
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
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6451.8
Applied rewrites51.8%
if -8.79999999999999975e-35 < lambda2 < 2.7e10Initial program 99.0%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.7
Applied rewrites60.7%
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
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6469.7
Applied rewrites69.7%
Final simplification60.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (sin phi2) (cos phi1))
(* (cos (- lambda2 lambda1)) (sin phi1))))
(t_1 (atan2 (* (sin lambda1) (cos phi2)) t_0)))
(if (<= phi2 -1.2e+14)
t_1
(if (<= phi2 4.4e+15)
(atan2 (* (fma -0.5 (* phi2 phi2) 1.0) (sin (- lambda1 lambda2))) t_0)
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * sin(phi1));
double t_1 = atan2((sin(lambda1) * cos(phi2)), t_0);
double tmp;
if (phi2 <= -1.2e+14) {
tmp = t_1;
} else if (phi2 <= 4.4e+15) {
tmp = atan2((fma(-0.5, (phi2 * phi2), 1.0) * sin((lambda1 - lambda2))), t_0);
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi2) * cos(phi1)) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1))) t_1 = atan(Float64(sin(lambda1) * cos(phi2)), t_0) tmp = 0.0 if (phi2 <= -1.2e+14) tmp = t_1; elseif (phi2 <= 4.4e+15) tmp = atan(Float64(fma(-0.5, Float64(phi2 * phi2), 1.0) * sin(Float64(lambda1 - lambda2))), t_0); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]}, If[LessEqual[phi2, -1.2e+14], t$95$1, If[LessEqual[phi2, 4.4e+15], N[ArcTan[N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0}\\
\mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 4.4 \cdot 10^{+15}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -1.2e14 or 4.4e15 < phi2 Initial program 80.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6419.0
Applied rewrites19.0%
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
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6419.2
Applied rewrites19.2%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6434.5
Applied rewrites34.5%
if -1.2e14 < phi2 < 4.4e15Initial program 82.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6479.9
Applied rewrites79.9%
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
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
neg-mul-1N/A
lower-sin.f64N/A
neg-mul-1N/A
sub-negN/A
lower--.f6481.0
Applied rewrites81.0%
Final simplification58.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 81.2%
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
*-commutativeN/A
*-lft-identityN/A
*-inversesN/A
/-rgt-identityN/A
times-fracN/A
*-rgt-identityN/A
associate-*r/N/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
*-commutativeN/A
Applied rewrites67.9%
Final simplification67.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 0.0007)
(atan2
t_0
(- (fma (cos phi1) phi2 0.0) (* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2 t_0 (- (* (sin phi2) (cos phi1)) (* (cos lambda1) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.0007) {
tmp = atan2(t_0, (fma(cos(phi1), phi2, 0.0) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - (cos(lambda1) * sin(phi1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.0007) tmp = atan(t_0, Float64(fma(cos(phi1), phi2, 0.0) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = atan(t_0, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.0007], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2 + 0.0), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $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}\;\phi_2 \leq 0.0007:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \phi_1, \phi_2, 0\right) - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 \cdot \cos \phi_1 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < 6.99999999999999993e-4Initial program 81.9%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.4
Applied rewrites60.4%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6460.1
Applied rewrites60.1%
Taylor expanded in phi2 around 0
lower--.f64N/A
Applied rewrites59.3%
if 6.99999999999999993e-4 < phi2 Initial program 79.0%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6421.4
Applied rewrites21.4%
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
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6421.4
Applied rewrites21.4%
Taylor expanded in lambda2 around 0
Applied rewrites21.1%
Final simplification49.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (* (sin phi2) (cos phi1)) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), ((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)), ((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.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.sin(phi2) * math.cos(phi1)) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), 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)), ((sin(phi2) * cos(phi1)) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $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)}{\sin \phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 81.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6450.2
Applied rewrites50.2%
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
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6450.3
Applied rewrites50.3%
Final simplification50.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi2 2.2)
(atan2 t_1 (- (fma (cos phi1) phi2 0.0) (* t_0 (sin phi1))))
(atan2 t_1 (- (* (sin phi2) (cos phi1)) (/ (* 0.0 t_0) 2.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 2.2) {
tmp = atan2(t_1, (fma(cos(phi1), phi2, 0.0) - (t_0 * sin(phi1))));
} else {
tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((0.0 * t_0) / 2.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 2.2) tmp = atan(t_1, Float64(fma(cos(phi1), phi2, 0.0) - Float64(t_0 * sin(phi1)))); else tmp = atan(t_1, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(0.0 * t_0) / 2.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 2.2], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2 + 0.0), $MachinePrecision] - N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(0.0 * t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 2.2:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \phi_1, \phi_2, 0\right) - t\_0 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 \cdot \cos \phi_1 - \frac{0 \cdot t\_0}{2}}\\
\end{array}
\end{array}
if phi2 < 2.2000000000000002Initial program 82.0%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.6
Applied rewrites60.6%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6460.3
Applied rewrites60.3%
Taylor expanded in phi2 around 0
lower--.f64N/A
Applied rewrites59.5%
if 2.2000000000000002 < phi2 Initial program 78.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6420.2
Applied rewrites20.2%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6420.1
Applied rewrites20.1%
Taylor expanded in phi1 around 0
sin-negN/A
unsub-negN/A
+-inverses19.6
Applied rewrites19.6%
Final simplification49.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 7.2e+14)
(atan2
t_0
(- (fma (cos phi1) phi2 0.0) (* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 7.2e+14) {
tmp = atan2(t_0, (fma(cos(phi1), phi2, 0.0) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_0, sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 7.2e+14) tmp = atan(t_0, Float64(fma(cos(phi1), phi2, 0.0) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = atan(t_0, sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 7.2e+14], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2 + 0.0), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 7.2 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \phi_1, \phi_2, 0\right) - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 7.2e14Initial program 81.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.1
Applied rewrites60.1%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6459.8
Applied rewrites59.8%
Taylor expanded in phi2 around 0
lower--.f64N/A
Applied rewrites59.0%
if 7.2e14 < phi2 Initial program 81.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6420.5
Applied rewrites20.5%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6420.4
Applied rewrites20.4%
Taylor expanded in phi1 around 0
sub-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
sin-negN/A
unsub-negN/A
+-inversesN/A
cancel-sign-sub-invN/A
mul0-rgtN/A
lower--.f64N/A
lower-sin.f6417.7
Applied rewrites17.7%
Final simplification48.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 t_0 (* (- (sin phi1)) (cos (- lambda1 lambda2))))))
(if (<= phi1 -7.6e-16)
t_1
(if (<= phi1 3.4e-15) (atan2 t_0 (sin phi2)) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2(t_0, (-sin(phi1) * cos((lambda1 - lambda2))));
double tmp;
if (phi1 <= -7.6e-16) {
tmp = t_1;
} else if (phi1 <= 3.4e-15) {
tmp = atan2(t_0, sin(phi2));
} 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((lambda1 - lambda2))
t_1 = atan2(t_0, (-sin(phi1) * cos((lambda1 - lambda2))))
if (phi1 <= (-7.6d-16)) then
tmp = t_1
else if (phi1 <= 3.4d-15) then
tmp = atan2(t_0, sin(phi2))
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((lambda1 - lambda2));
double t_1 = Math.atan2(t_0, (-Math.sin(phi1) * Math.cos((lambda1 - lambda2))));
double tmp;
if (phi1 <= -7.6e-16) {
tmp = t_1;
} else if (phi1 <= 3.4e-15) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2(t_0, (-math.sin(phi1) * math.cos((lambda1 - lambda2)))) tmp = 0 if phi1 <= -7.6e-16: tmp = t_1 elif phi1 <= 3.4e-15: tmp = math.atan2(t_0, math.sin(phi2)) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(t_0, Float64(Float64(-sin(phi1)) * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi1 <= -7.6e-16) tmp = t_1; elseif (phi1 <= 3.4e-15) tmp = atan(t_0, sin(phi2)); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2(t_0, (-sin(phi1) * cos((lambda1 - lambda2)))); tmp = 0.0; if (phi1 <= -7.6e-16) tmp = t_1; elseif (phi1 <= 3.4e-15) tmp = atan2(t_0, sin(phi2)); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[t$95$0 / N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7.6e-16], t$95$1, If[LessEqual[phi1, 3.4e-15], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0}{\left(-\sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -7.6 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 3.4 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -7.60000000000000024e-16 or 3.4e-15 < phi1 Initial program 77.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6449.3
Applied rewrites49.3%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6448.9
Applied rewrites48.9%
Taylor expanded in phi2 around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
sub-negN/A
neg-mul-1N/A
lower-cos.f64N/A
neg-mul-1N/A
sub-negN/A
lower--.f6448.3
Applied rewrites48.3%
if -7.60000000000000024e-16 < phi1 < 3.4e-15Initial program 85.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6451.2
Applied rewrites51.2%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6451.2
Applied rewrites51.2%
Taylor expanded in phi1 around 0
sub-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
sin-negN/A
unsub-negN/A
+-inversesN/A
cancel-sign-sub-invN/A
mul0-rgtN/A
lower--.f64N/A
lower-sin.f6449.9
Applied rewrites49.9%
Final simplification49.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), sin(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)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}
\end{array}
Initial program 81.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6450.2
Applied rewrites50.2%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6449.9
Applied rewrites49.9%
Taylor expanded in phi1 around 0
sub-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
sin-negN/A
unsub-negN/A
+-inversesN/A
cancel-sign-sub-invN/A
mul0-rgtN/A
lower--.f64N/A
lower-sin.f6431.0
Applied rewrites31.0%
Final simplification31.0%
herbie shell --seed 2024242
(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))))))