
(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 27 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
(*
(-
(log1p (expm1 (* (sin lambda1) (cos lambda2))))
(* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(+
(* (* (cos lambda2) (cos lambda1)) (sin phi1))
(* (sin phi1) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(((log1p(expm1((sin(lambda1) * cos(lambda2)))) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (((cos(lambda2) * cos(lambda1)) * sin(phi1)) + (sin(phi1) * (sin(lambda1) * sin(lambda2)))))));
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(((Math.log1p(Math.expm1((Math.sin(lambda1) * Math.cos(lambda2)))) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (((Math.cos(lambda2) * Math.cos(lambda1)) * Math.sin(phi1)) + (Math.sin(phi1) * (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(((math.log1p(math.expm1((math.sin(lambda1) * math.cos(lambda2)))) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (((math.cos(lambda2) * math.cos(lambda1)) * math.sin(phi1)) + (math.sin(phi1) * (math.sin(lambda1) * math.sin(lambda2)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(log1p(expm1(Float64(sin(lambda1) * cos(lambda2)))) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(Float64(Float64(cos(lambda2) * cos(lambda1)) * sin(phi1)) + Float64(sin(phi1) * Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Log[1 + N[(Exp[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\sin \lambda_1 \cdot \cos \lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \sin \phi_1 + \sin \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
sin-diff87.0%
Applied egg-rr87.0%
cos-diff99.8%
distribute-rgt-in99.8%
*-commutative99.8%
Applied egg-rr99.8%
log1p-expm1-u99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(+
(* (* (cos lambda2) (cos lambda1)) (sin phi1))
(* (sin phi1) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (((cos(lambda2) * cos(lambda1)) * sin(phi1)) + (sin(phi1) * (sin(lambda1) * sin(lambda2)))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (((cos(lambda2) * cos(lambda1)) * sin(phi1)) + (sin(phi1) * (sin(lambda1) * sin(lambda2)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (((Math.cos(lambda2) * Math.cos(lambda1)) * Math.sin(phi1)) + (Math.sin(phi1) * (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (((math.cos(lambda2) * math.cos(lambda1)) * math.sin(phi1)) + (math.sin(phi1) * (math.sin(lambda1) * math.sin(lambda2)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(Float64(Float64(cos(lambda2) * cos(lambda1)) * sin(phi1)) + Float64(sin(phi1) * Float64(sin(lambda1) * sin(lambda2))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (((cos(lambda2) * cos(lambda1)) * sin(phi1)) + (sin(phi1) * (sin(lambda1) * sin(lambda2))))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \sin \phi_1 + \sin \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
sin-diff87.0%
Applied egg-rr87.0%
cos-diff99.8%
distribute-rgt-in99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(*
(sin phi1)
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
sin-diff87.0%
Applied egg-rr87.0%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -1.9e-7) (not (<= lambda1 8.5e-6)))
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(atan2
(* (cos phi2) (- (* lambda1 (cos lambda2)) (sin lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -1.9e-7) || !(lambda1 <= 8.5e-6)) {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * 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 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-1.9d-7)) .or. (.not. (lambda1 <= 8.5d-6))) then
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -1.9e-7) || !(lambda1 <= 8.5e-6)) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((lambda1 * Math.cos(lambda2)) - Math.sin(lambda2))), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -1.9e-7) or not (lambda1 <= 8.5e-6): tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * ((lambda1 * math.cos(lambda2)) - math.sin(lambda2))), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -1.9e-7) || !(lambda1 <= 8.5e-6)) tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(lambda1 * cos(lambda2)) - sin(lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -1.9e-7) || ~((lambda1 <= 8.5e-6))) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); else tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.9e-7], N[Not[LessEqual[lambda1, 8.5e-6]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.9 \cdot 10^{-7} \lor \neg \left(\lambda_1 \leq 8.5 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda1 < -1.90000000000000007e-7 or 8.4999999999999999e-6 < lambda1 Initial program 53.4%
*-commutative53.4%
associate-*l*53.4%
Simplified53.4%
sin-diff76.4%
Applied egg-rr76.4%
Taylor expanded in lambda2 around 0 76.3%
if -1.90000000000000007e-7 < lambda1 < 8.4999999999999999e-6Initial program 99.3%
*-commutative99.3%
associate-*l*99.3%
Simplified99.3%
sin-diff99.3%
Applied egg-rr99.3%
Taylor expanded in lambda1 around 0 99.3%
cos-neg83.9%
Simplified99.3%
Taylor expanded in lambda1 around 0 99.3%
neg-mul-199.3%
+-commutative99.3%
unsub-neg99.3%
Simplified99.3%
Final simplification86.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(cos phi2)
(-
(* (sin lambda1) (cos lambda2))
(* (cos lambda1) (sin lambda2))))))
(if (or (<= lambda2 -1.45e+14) (not (<= lambda2 300000.0)))
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)));
double tmp;
if ((lambda2 <= -1.45e+14) || !(lambda2 <= 300000.0)) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))
if ((lambda2 <= (-1.45d+14)) .or. (.not. (lambda2 <= 300000.0d0))) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)));
double tmp;
if ((lambda2 <= -1.45e+14) || !(lambda2 <= 300000.0)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) tmp = 0 if (lambda2 <= -1.45e+14) or not (lambda2 <= 300000.0): tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))) tmp = 0.0 if ((lambda2 <= -1.45e+14) || !(lambda2 <= 300000.0)) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))); tmp = 0.0; if ((lambda2 <= -1.45e+14) || ~((lambda2 <= 300000.0))) tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.45e+14], N[Not[LessEqual[lambda2, 300000.0]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -1.45 \cdot 10^{+14} \lor \neg \left(\lambda_2 \leq 300000\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -1.45e14 or 3e5 < lambda2 Initial program 54.0%
*-commutative54.0%
associate-*l*54.0%
Simplified54.0%
sin-diff77.5%
Applied egg-rr77.5%
Taylor expanded in lambda1 around 0 77.7%
cos-neg45.1%
Simplified77.7%
if -1.45e14 < lambda2 < 3e5Initial program 95.4%
*-commutative95.4%
associate-*l*95.4%
Simplified95.4%
sin-diff96.5%
Applied egg-rr96.5%
Taylor expanded in lambda2 around 0 96.5%
Final simplification87.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
sin-diff87.0%
Applied egg-rr87.0%
Final simplification87.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -0.00015)
(atan2
(* (cos phi2) (- (sin lambda1) t_2))
(- t_0 (* (cos phi2) (* (sin phi1) t_1))))
(if (<= phi1 1.02e-36)
(atan2
(* (cos phi2) (- (* (sin lambda1) (cos lambda2)) t_2))
(- t_0 (* (cos phi2) (* phi1 (cos (- lambda2 lambda1))))))
(atan2
(* (cos phi2) (expm1 (log1p (sin (- lambda1 lambda2)))))
(- t_0 (* t_1 (* (cos phi2) (sin phi1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -0.00015) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_2)), (t_0 - (cos(phi2) * (sin(phi1) * t_1))));
} else if (phi1 <= 1.02e-36) {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_2)), (t_0 - (cos(phi2) * (phi1 * cos((lambda2 - lambda1))))));
} else {
tmp = atan2((cos(phi2) * expm1(log1p(sin((lambda1 - lambda2))))), (t_0 - (t_1 * (cos(phi2) * sin(phi1)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(lambda1) * Math.sin(lambda2);
double tmp;
if (phi1 <= -0.00015) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_2)), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * t_1))));
} else if (phi1 <= 1.02e-36) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - t_2)), (t_0 - (Math.cos(phi2) * (phi1 * Math.cos((lambda2 - lambda1))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.expm1(Math.log1p(Math.sin((lambda1 - lambda2))))), (t_0 - (t_1 * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if phi1 <= -0.00015: tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_2)), (t_0 - (math.cos(phi2) * (math.sin(phi1) * t_1)))) elif phi1 <= 1.02e-36: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - t_2)), (t_0 - (math.cos(phi2) * (phi1 * math.cos((lambda2 - lambda1)))))) else: tmp = math.atan2((math.cos(phi2) * math.expm1(math.log1p(math.sin((lambda1 - lambda2))))), (t_0 - (t_1 * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -0.00015) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_2)), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * t_1)))); elseif (phi1 <= 1.02e-36) tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - t_2)), Float64(t_0 - Float64(cos(phi2) * Float64(phi1 * cos(Float64(lambda2 - lambda1)))))); else tmp = atan(Float64(cos(phi2) * expm1(log1p(sin(Float64(lambda1 - lambda2))))), Float64(t_0 - Float64(t_1 * Float64(cos(phi2) * sin(phi1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.00015], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.02e-36], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -0.00015:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t\_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.02 \cdot 10^{-36}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\lambda_1 - \lambda_2\right)\right)\right)}{t\_0 - t\_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -1.49999999999999987e-4Initial program 70.3%
*-commutative70.3%
associate-*l*70.3%
Simplified70.3%
sin-diff74.6%
Applied egg-rr74.6%
Taylor expanded in lambda2 around 0 73.4%
if -1.49999999999999987e-4 < phi1 < 1.02e-36Initial program 78.8%
*-commutative78.8%
associate-*l*78.8%
Simplified78.8%
sin-diff99.9%
Applied egg-rr99.9%
Taylor expanded in phi1 around 0 99.9%
sub-neg99.9%
remove-double-neg99.9%
mul-1-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
cos-neg99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
if 1.02e-36 < phi1 Initial program 70.2%
expm1-log1p-u70.3%
Applied egg-rr70.3%
Final simplification85.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sin (- lambda1 lambda2))))
(if (<= phi1 -4.5e-16)
(atan2 (* (cos phi2) t_2) (- t_0 (* (cos phi2) (* (sin phi1) t_1))))
(if (<= phi1 1.02e-36)
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* phi1 (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (expm1 (log1p t_2)))
(- t_0 (* t_1 (* (cos phi2) (sin phi1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -4.5e-16) {
tmp = atan2((cos(phi2) * t_2), (t_0 - (cos(phi2) * (sin(phi1) * t_1))));
} else if (phi1 <= 1.02e-36) {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * expm1(log1p(t_2))), (t_0 - (t_1 * (cos(phi2) * sin(phi1)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -4.5e-16) {
tmp = Math.atan2((Math.cos(phi2) * t_2), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * t_1))));
} else if (phi1 <= 1.02e-36) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_0 - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.expm1(Math.log1p(t_2))), (t_0 - (t_1 * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -4.5e-16: tmp = math.atan2((math.cos(phi2) * t_2), (t_0 - (math.cos(phi2) * (math.sin(phi1) * t_1)))) elif phi1 <= 1.02e-36: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (t_0 - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.expm1(math.log1p(t_2))), (t_0 - (t_1 * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -4.5e-16) tmp = atan(Float64(cos(phi2) * t_2), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * t_1)))); elseif (phi1 <= 1.02e-36) tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * expm1(log1p(t_2))), Float64(t_0 - Float64(t_1 * Float64(cos(phi2) * sin(phi1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -4.5e-16], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.02e-36], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -4.5 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_2}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.02 \cdot 10^{-36}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_0 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t\_2\right)\right)}{t\_0 - t\_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -4.5000000000000002e-16Initial program 71.1%
*-commutative71.1%
associate-*l*71.1%
Simplified71.1%
if -4.5000000000000002e-16 < phi1 < 1.02e-36Initial program 78.5%
Taylor expanded in phi1 around 0 78.5%
*-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi2 around 0 78.5%
sin-diff99.9%
Applied egg-rr99.9%
if 1.02e-36 < phi1 Initial program 70.2%
expm1-log1p-u70.3%
Applied egg-rr70.3%
Final simplification85.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -4.5e-16)
(atan2
(* (cos phi2) (- (sin lambda1) t_2))
(- t_0 (* (cos phi2) (* (sin phi1) t_1))))
(if (<= phi1 1.02e-36)
(atan2
(* (cos phi2) (- (* (sin lambda1) (cos lambda2)) t_2))
(- t_0 (* phi1 (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (expm1 (log1p (sin (- lambda1 lambda2)))))
(- t_0 (* t_1 (* (cos phi2) (sin phi1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -4.5e-16) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_2)), (t_0 - (cos(phi2) * (sin(phi1) * t_1))));
} else if (phi1 <= 1.02e-36) {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_2)), (t_0 - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * expm1(log1p(sin((lambda1 - lambda2))))), (t_0 - (t_1 * (cos(phi2) * sin(phi1)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(lambda1) * Math.sin(lambda2);
double tmp;
if (phi1 <= -4.5e-16) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_2)), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * t_1))));
} else if (phi1 <= 1.02e-36) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - t_2)), (t_0 - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.expm1(Math.log1p(Math.sin((lambda1 - lambda2))))), (t_0 - (t_1 * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if phi1 <= -4.5e-16: tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_2)), (t_0 - (math.cos(phi2) * (math.sin(phi1) * t_1)))) elif phi1 <= 1.02e-36: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - t_2)), (t_0 - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.expm1(math.log1p(math.sin((lambda1 - lambda2))))), (t_0 - (t_1 * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -4.5e-16) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_2)), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * t_1)))); elseif (phi1 <= 1.02e-36) tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - t_2)), Float64(t_0 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * expm1(log1p(sin(Float64(lambda1 - lambda2))))), Float64(t_0 - Float64(t_1 * Float64(cos(phi2) * sin(phi1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.5e-16], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.02e-36], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -4.5 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t\_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.02 \cdot 10^{-36}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right)}{t\_0 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\lambda_1 - \lambda_2\right)\right)\right)}{t\_0 - t\_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -4.5000000000000002e-16Initial program 71.1%
*-commutative71.1%
associate-*l*71.1%
Simplified71.1%
sin-diff75.3%
Applied egg-rr75.3%
Taylor expanded in lambda2 around 0 74.1%
if -4.5000000000000002e-16 < phi1 < 1.02e-36Initial program 78.5%
Taylor expanded in phi1 around 0 78.5%
*-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi2 around 0 78.5%
sin-diff99.9%
Applied egg-rr99.9%
if 1.02e-36 < phi1 Initial program 70.2%
expm1-log1p-u70.3%
Applied egg-rr70.3%
Final simplification85.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= phi1 -2.6e-16) (not (<= phi1 1.02e-36)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* phi1 (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((phi1 <= -2.6e-16) || !(phi1 <= 1.02e-36)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (phi1 * cos((lambda2 - lambda1)))));
}
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 = cos(phi1) * sin(phi2)
if ((phi1 <= (-2.6d-16)) .or. (.not. (phi1 <= 1.02d-36))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((phi1 <= -2.6e-16) || !(phi1 <= 1.02e-36)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_0 - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (phi1 <= -2.6e-16) or not (phi1 <= 1.02e-36): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (t_0 - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((phi1 <= -2.6e-16) || !(phi1 <= 1.02e-36)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((phi1 <= -2.6e-16) || ~((phi1 <= 1.02e-36))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -2.6e-16], N[Not[LessEqual[phi1, 1.02e-36]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-16} \lor \neg \left(\phi_1 \leq 1.02 \cdot 10^{-36}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_0 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -2.5999999999999998e-16 or 1.02e-36 < phi1 Initial program 70.7%
*-commutative70.7%
associate-*l*70.7%
Simplified70.7%
if -2.5999999999999998e-16 < phi1 < 1.02e-36Initial program 78.5%
Taylor expanded in phi1 around 0 78.5%
*-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi2 around 0 78.5%
sin-diff99.9%
Applied egg-rr99.9%
Final simplification85.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2
(atan2
(* (sin lambda2) (- (cos phi2)))
(- t_1 (* (cos phi2) (* (cos lambda2) (sin phi1))))))
(t_3
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_1 (/ (* t_0 (* (sin phi1) 2.0)) 2.0)))))
(if (<= lambda2 -1.45e+14)
t_2
(if (<= lambda2 -1.85e-174)
t_3
(if (<= lambda2 1.9e-175)
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* (cos phi2) (* (sin phi1) t_0))))
(if (<= lambda2 1e-8) t_3 t_2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = atan2((sin(lambda2) * -cos(phi2)), (t_1 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
double t_3 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - ((t_0 * (sin(phi1) * 2.0)) / 2.0)));
double tmp;
if (lambda2 <= -1.45e+14) {
tmp = t_2;
} else if (lambda2 <= -1.85e-174) {
tmp = t_3;
} else if (lambda2 <= 1.9e-175) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * (sin(phi1) * t_0))));
} else if (lambda2 <= 1e-8) {
tmp = t_3;
} 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) :: t_3
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
t_2 = atan2((sin(lambda2) * -cos(phi2)), (t_1 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
t_3 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - ((t_0 * (sin(phi1) * 2.0d0)) / 2.0d0)))
if (lambda2 <= (-1.45d+14)) then
tmp = t_2
else if (lambda2 <= (-1.85d-174)) then
tmp = t_3
else if (lambda2 <= 1.9d-175) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * (sin(phi1) * t_0))))
else if (lambda2 <= 1d-8) then
tmp = t_3
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.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.atan2((Math.sin(lambda2) * -Math.cos(phi2)), (t_1 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
double t_3 = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_1 - ((t_0 * (Math.sin(phi1) * 2.0)) / 2.0)));
double tmp;
if (lambda2 <= -1.45e+14) {
tmp = t_2;
} else if (lambda2 <= -1.85e-174) {
tmp = t_3;
} else if (lambda2 <= 1.9e-175) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (Math.cos(phi2) * (Math.sin(phi1) * t_0))));
} else if (lambda2 <= 1e-8) {
tmp = t_3;
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.atan2((math.sin(lambda2) * -math.cos(phi2)), (t_1 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) t_3 = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_1 - ((t_0 * (math.sin(phi1) * 2.0)) / 2.0))) tmp = 0 if lambda2 <= -1.45e+14: tmp = t_2 elif lambda2 <= -1.85e-174: tmp = t_3 elif lambda2 <= 1.9e-175: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (math.cos(phi2) * (math.sin(phi1) * t_0)))) elif lambda2 <= 1e-8: tmp = t_3 else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = atan(Float64(sin(lambda2) * Float64(-cos(phi2))), Float64(t_1 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))) t_3 = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_1 - Float64(Float64(t_0 * Float64(sin(phi1) * 2.0)) / 2.0))) tmp = 0.0 if (lambda2 <= -1.45e+14) tmp = t_2; elseif (lambda2 <= -1.85e-174) tmp = t_3; elseif (lambda2 <= 1.9e-175) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(cos(phi2) * Float64(sin(phi1) * t_0)))); elseif (lambda2 <= 1e-8) tmp = t_3; else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); t_2 = atan2((sin(lambda2) * -cos(phi2)), (t_1 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); t_3 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - ((t_0 * (sin(phi1) * 2.0)) / 2.0))); tmp = 0.0; if (lambda2 <= -1.45e+14) tmp = t_2; elseif (lambda2 <= -1.85e-174) tmp = t_3; elseif (lambda2 <= 1.9e-175) tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * (sin(phi1) * t_0)))); elseif (lambda2 <= 1e-8) tmp = t_3; else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $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[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(t$95$0 * N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1.45e+14], t$95$2, If[LessEqual[lambda2, -1.85e-174], t$95$3, If[LessEqual[lambda2, 1.9e-175], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 1e-8], t$95$3, t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \tan^{-1}_* \frac{\sin \lambda_2 \cdot \left(-\cos \phi_2\right)}{t\_1 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
t_3 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_1 - \frac{t\_0 \cdot \left(\sin \phi_1 \cdot 2\right)}{2}}\\
\mathbf{if}\;\lambda_2 \leq -1.45 \cdot 10^{+14}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq -1.85 \cdot 10^{-174}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_2 \leq 1.9 \cdot 10^{-175}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_0\right)}\\
\mathbf{elif}\;\lambda_2 \leq 10^{-8}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -1.45e14 or 1e-8 < lambda2 Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
Simplified54.3%
sin-diff77.2%
Applied egg-rr77.2%
Taylor expanded in lambda1 around 0 77.3%
cos-neg45.7%
Simplified77.3%
Taylor expanded in lambda1 around 0 55.1%
neg-mul-155.1%
Simplified55.1%
if -1.45e14 < lambda2 < -1.85000000000000005e-174 or 1.9e-175 < lambda2 < 1e-8Initial program 94.1%
sin-cos-mult83.7%
associate-*l/83.7%
Applied egg-rr83.7%
Taylor expanded in phi2 around 0 84.0%
if -1.85000000000000005e-174 < lambda2 < 1.9e-175Initial program 99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in lambda2 around 0 95.6%
Final simplification71.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 -1.45e+14)
(atan2 t_2 (- t_0 (* (cos lambda2) t_1)))
(if (<= lambda2 1e-8)
(atan2 t_2 (- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (cos (- lambda1 lambda2)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -1.45e+14) {
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)));
} else if (lambda2 <= 1e-8) {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos((lambda1 - lambda2)) * 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) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= (-1.45d+14)) then
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)))
else if (lambda2 <= 1d-8) then
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos((lambda1 - lambda2)) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -1.45e+14) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda2) * t_1)));
} else if (lambda2 <= 1e-8) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.cos((lambda1 - lambda2)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -1.45e+14: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda2) * t_1))) elif lambda2 <= 1e-8: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.cos((lambda1 - lambda2)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= -1.45e+14) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda2) * t_1))); elseif (lambda2 <= 1e-8) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -1.45e+14) tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1))); elseif (lambda2 <= 1e-8) tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos((lambda1 - lambda2)) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.45e+14], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 1e-8], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -1.45 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \lambda_2 \cdot t\_1}\\
\mathbf{elif}\;\lambda_2 \leq 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \lambda_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_1}\\
\end{array}
\end{array}
if lambda2 < -1.45e14Initial program 56.5%
Taylor expanded in lambda1 around 0 56.6%
cos-neg48.1%
Simplified56.6%
if -1.45e14 < lambda2 < 1e-8Initial program 96.8%
Taylor expanded in lambda2 around 0 96.8%
if 1e-8 < lambda2 Initial program 51.9%
Taylor expanded in lambda1 around 0 54.6%
Final simplification75.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -1.45e+14) (not (<= lambda2 1e-8)))
(atan2
(* (sin lambda2) (- (cos phi2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -1.45e+14) || !(lambda2 <= 1e-8)) {
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * (cos(phi2) * 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 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-1.45d+14)) .or. (.not. (lambda2 <= 1d-8))) then
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -1.45e+14) || !(lambda2 <= 1e-8)) {
tmp = Math.atan2((Math.sin(lambda2) * -Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -1.45e+14) or not (lambda2 <= 1e-8): tmp = math.atan2((math.sin(lambda2) * -math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -1.45e+14) || !(lambda2 <= 1e-8)) tmp = atan(Float64(sin(lambda2) * Float64(-cos(phi2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -1.45e+14) || ~((lambda2 <= 1e-8))) tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.45e+14], N[Not[LessEqual[lambda2, 1e-8]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -1.45 \cdot 10^{+14} \lor \neg \left(\lambda_2 \leq 10^{-8}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_2 \cdot \left(-\cos \phi_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -1.45e14 or 1e-8 < lambda2 Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
Simplified54.3%
sin-diff77.2%
Applied egg-rr77.2%
Taylor expanded in lambda1 around 0 77.3%
cos-neg45.7%
Simplified77.3%
Taylor expanded in lambda1 around 0 55.1%
neg-mul-155.1%
Simplified55.1%
if -1.45e14 < lambda2 < 1e-8Initial program 96.8%
Taylor expanded in lambda2 around 0 96.8%
Final simplification75.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 -1.45e+14)
(atan2 t_2 (- t_0 (* (cos lambda2) t_1)))
(if (<= lambda2 1e-8)
(atan2 t_2 (- t_0 (* (cos lambda1) t_1)))
(atan2
(* (sin lambda2) (- (cos phi2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -1.45e+14) {
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)));
} else if (lambda2 <= 1e-8) {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= (-1.45d+14)) then
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)))
else if (lambda2 <= 1d-8) then
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -1.45e+14) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda2) * t_1)));
} else if (lambda2 <= 1e-8) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.sin(lambda2) * -Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -1.45e+14: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda2) * t_1))) elif lambda2 <= 1e-8: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.sin(lambda2) * -math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= -1.45e+14) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda2) * t_1))); elseif (lambda2 <= 1e-8) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(sin(lambda2) * Float64(-cos(phi2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -1.45e+14) tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1))); elseif (lambda2 <= 1e-8) tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.45e+14], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 1e-8], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -1.45 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \lambda_2 \cdot t\_1}\\
\mathbf{elif}\;\lambda_2 \leq 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \lambda_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_2 \cdot \left(-\cos \phi_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -1.45e14Initial program 56.5%
Taylor expanded in lambda1 around 0 56.6%
cos-neg48.1%
Simplified56.6%
if -1.45e14 < lambda2 < 1e-8Initial program 96.8%
Taylor expanded in lambda2 around 0 96.8%
if 1e-8 < lambda2 Initial program 51.9%
*-commutative51.9%
associate-*l*51.9%
Simplified51.9%
sin-diff76.1%
Applied egg-rr76.1%
Taylor expanded in lambda1 around 0 76.2%
cos-neg43.2%
Simplified76.2%
Taylor expanded in lambda1 around 0 54.5%
neg-mul-154.5%
Simplified54.5%
Final simplification75.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -3.1e+14) (not (<= lambda2 1e-8)))
(atan2
(* (sin lambda2) (- (cos phi2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (/ (* (cos (- lambda1 lambda2)) (* (sin phi1) 2.0)) 2.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -3.1e+14) || !(lambda2 <= 1e-8)) {
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos((lambda1 - lambda2)) * (sin(phi1) * 2.0)) / 2.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) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-3.1d+14)) .or. (.not. (lambda2 <= 1d-8))) then
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos((lambda1 - lambda2)) * (sin(phi1) * 2.0d0)) / 2.0d0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -3.1e+14) || !(lambda2 <= 1e-8)) {
tmp = Math.atan2((Math.sin(lambda2) * -Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - ((Math.cos((lambda1 - lambda2)) * (Math.sin(phi1) * 2.0)) / 2.0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -3.1e+14) or not (lambda2 <= 1e-8): tmp = math.atan2((math.sin(lambda2) * -math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - ((math.cos((lambda1 - lambda2)) * (math.sin(phi1) * 2.0)) / 2.0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -3.1e+14) || !(lambda2 <= 1e-8)) tmp = atan(Float64(sin(lambda2) * Float64(-cos(phi2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(Float64(cos(Float64(lambda1 - lambda2)) * Float64(sin(phi1) * 2.0)) / 2.0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -3.1e+14) || ~((lambda2 <= 1e-8))) tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos((lambda1 - lambda2)) * (sin(phi1) * 2.0)) / 2.0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -3.1e+14], N[Not[LessEqual[lambda2, 1e-8]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -3.1 \cdot 10^{+14} \lor \neg \left(\lambda_2 \leq 10^{-8}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_2 \cdot \left(-\cos \phi_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \frac{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\sin \phi_1 \cdot 2\right)}{2}}\\
\end{array}
\end{array}
if lambda2 < -3.1e14 or 1e-8 < lambda2 Initial program 54.3%
*-commutative54.3%
associate-*l*54.3%
Simplified54.3%
sin-diff77.2%
Applied egg-rr77.2%
Taylor expanded in lambda1 around 0 77.3%
cos-neg45.7%
Simplified77.3%
Taylor expanded in lambda1 around 0 55.1%
neg-mul-155.1%
Simplified55.1%
if -3.1e14 < lambda2 < 1e-8Initial program 96.8%
sin-cos-mult81.5%
associate-*l/81.5%
Applied egg-rr81.5%
Taylor expanded in phi2 around 0 81.8%
Final simplification67.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
Final simplification74.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (- lambda1 lambda2)) (* (cos phi2) (sin phi1))))
(t_1 (sin (- lambda2)))
(t_2 (* (cos phi1) (sin phi2))))
(if (<= phi1 -0.0031)
(atan2 t_1 (- t_2 t_0))
(if (<= phi1 0.075)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_2 (* phi1 (* (cos lambda2) (cos phi2)))))
(atan2 (* (cos phi2) t_1) (- (sin phi2) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1));
double t_1 = sin(-lambda2);
double t_2 = cos(phi1) * sin(phi2);
double tmp;
if (phi1 <= -0.0031) {
tmp = atan2(t_1, (t_2 - t_0));
} else if (phi1 <= 0.075) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_2 - (phi1 * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2((cos(phi2) * t_1), (sin(phi2) - 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 = cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1))
t_1 = sin(-lambda2)
t_2 = cos(phi1) * sin(phi2)
if (phi1 <= (-0.0031d0)) then
tmp = atan2(t_1, (t_2 - t_0))
else if (phi1 <= 0.075d0) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_2 - (phi1 * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2((cos(phi2) * t_1), (sin(phi2) - t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2)) * (Math.cos(phi2) * Math.sin(phi1));
double t_1 = Math.sin(-lambda2);
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -0.0031) {
tmp = Math.atan2(t_1, (t_2 - t_0));
} else if (phi1 <= 0.075) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_2 - (phi1 * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_1), (Math.sin(phi2) - t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) * (math.cos(phi2) * math.sin(phi1)) t_1 = math.sin(-lambda2) t_2 = math.cos(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -0.0031: tmp = math.atan2(t_1, (t_2 - t_0)) elif phi1 <= 0.075: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_2 - (phi1 * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2((math.cos(phi2) * t_1), (math.sin(phi2) - t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(lambda1 - lambda2)) * Float64(cos(phi2) * sin(phi1))) t_1 = sin(Float64(-lambda2)) t_2 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -0.0031) tmp = atan(t_1, Float64(t_2 - t_0)); elseif (phi1 <= 0.075) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_2 - Float64(phi1 * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(Float64(cos(phi2) * t_1), Float64(sin(phi2) - t_0)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1)); t_1 = sin(-lambda2); t_2 = cos(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -0.0031) tmp = atan2(t_1, (t_2 - t_0)); elseif (phi1 <= 0.075) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_2 - (phi1 * (cos(lambda2) * cos(phi2))))); else tmp = atan2((cos(phi2) * t_1), (sin(phi2) - t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[(-lambda2)], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0031], N[ArcTan[t$95$1 / N[(t$95$2 - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.075], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(phi1 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\\
t_1 := \sin \left(-\lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.0031:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0}\\
\mathbf{elif}\;\phi_1 \leq 0.075:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_2 - \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if phi1 < -0.00309999999999999989Initial program 70.3%
Taylor expanded in lambda1 around 0 42.6%
Taylor expanded in phi2 around 0 28.5%
if -0.00309999999999999989 < phi1 < 0.0749999999999999972Initial program 79.8%
Taylor expanded in phi1 around 0 79.8%
*-commutative79.8%
sub-neg79.8%
remove-double-neg79.8%
mul-1-neg79.8%
distribute-neg-in79.8%
+-commutative79.8%
cos-neg79.8%
mul-1-neg79.8%
unsub-neg79.8%
Simplified79.8%
Taylor expanded in lambda1 around 0 79.8%
if 0.0749999999999999972 < phi1 Initial program 66.9%
Taylor expanded in lambda1 around 0 41.0%
Taylor expanded in phi1 around 0 29.0%
Final simplification55.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= phi1 -0.000112) (not (<= phi1 7e+92)))
(atan2
(sin (- lambda2))
(- t_0 (* (cos (- lambda1 lambda2)) (* (cos phi2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda1) phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((phi1 <= -0.000112) || !(phi1 <= 7e+92)) {
tmp = atan2(sin(-lambda2), (t_0 - (cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * 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 = cos(phi1) * sin(phi2)
if ((phi1 <= (-0.000112d0)) .or. (.not. (phi1 <= 7d+92))) then
tmp = atan2(sin(-lambda2), (t_0 - (cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((phi1 <= -0.000112) || !(phi1 <= 7e+92)) {
tmp = Math.atan2(Math.sin(-lambda2), (t_0 - (Math.cos((lambda1 - lambda2)) * (Math.cos(phi2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda1) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (phi1 <= -0.000112) or not (phi1 <= 7e+92): tmp = math.atan2(math.sin(-lambda2), (t_0 - (math.cos((lambda1 - lambda2)) * (math.cos(phi2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda1) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((phi1 <= -0.000112) || !(phi1 <= 7e+92)) tmp = atan(sin(Float64(-lambda2)), Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((phi1 <= -0.000112) || ~((phi1 <= 7e+92))) tmp = atan2(sin(-lambda2), (t_0 - (cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -0.000112], N[Not[LessEqual[phi1, 7e+92]], $MachinePrecision]], N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.000112 \lor \neg \left(\phi_1 \leq 7 \cdot 10^{+92}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi1 < -1.11999999999999998e-4 or 6.99999999999999972e92 < phi1 Initial program 67.5%
Taylor expanded in lambda1 around 0 41.0%
Taylor expanded in phi2 around 0 28.6%
if -1.11999999999999998e-4 < phi1 < 6.99999999999999972e92Initial program 79.5%
Taylor expanded in phi1 around 0 73.9%
*-commutative73.9%
sub-neg73.9%
remove-double-neg73.9%
mul-1-neg73.9%
distribute-neg-in73.9%
+-commutative73.9%
cos-neg73.9%
mul-1-neg73.9%
unsub-neg73.9%
Simplified73.9%
Taylor expanded in phi2 around 0 73.5%
Taylor expanded in lambda2 around 0 73.7%
cos-neg73.7%
*-commutative73.7%
Simplified73.7%
Final simplification55.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (- lambda1 lambda2)) (* (cos phi2) (sin phi1))))
(t_1 (sin (- lambda2)))
(t_2 (* (cos phi1) (sin phi2))))
(if (<= phi1 -0.006)
(atan2 t_1 (- t_2 t_0))
(if (<= phi1 7.8e-11)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_2 (* phi1 (cos (- lambda2 lambda1)))))
(atan2 (* (cos phi2) t_1) (- (sin phi2) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1));
double t_1 = sin(-lambda2);
double t_2 = cos(phi1) * sin(phi2);
double tmp;
if (phi1 <= -0.006) {
tmp = atan2(t_1, (t_2 - t_0));
} else if (phi1 <= 7.8e-11) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_2 - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * t_1), (sin(phi2) - 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 = cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1))
t_1 = sin(-lambda2)
t_2 = cos(phi1) * sin(phi2)
if (phi1 <= (-0.006d0)) then
tmp = atan2(t_1, (t_2 - t_0))
else if (phi1 <= 7.8d-11) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_2 - (phi1 * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * t_1), (sin(phi2) - t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2)) * (Math.cos(phi2) * Math.sin(phi1));
double t_1 = Math.sin(-lambda2);
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -0.006) {
tmp = Math.atan2(t_1, (t_2 - t_0));
} else if (phi1 <= 7.8e-11) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_2 - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_1), (Math.sin(phi2) - t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) * (math.cos(phi2) * math.sin(phi1)) t_1 = math.sin(-lambda2) t_2 = math.cos(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -0.006: tmp = math.atan2(t_1, (t_2 - t_0)) elif phi1 <= 7.8e-11: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_2 - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * t_1), (math.sin(phi2) - t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(lambda1 - lambda2)) * Float64(cos(phi2) * sin(phi1))) t_1 = sin(Float64(-lambda2)) t_2 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -0.006) tmp = atan(t_1, Float64(t_2 - t_0)); elseif (phi1 <= 7.8e-11) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_2 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * t_1), Float64(sin(phi2) - t_0)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)) * (cos(phi2) * sin(phi1)); t_1 = sin(-lambda2); t_2 = cos(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -0.006) tmp = atan2(t_1, (t_2 - t_0)); elseif (phi1 <= 7.8e-11) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_2 - (phi1 * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * t_1), (sin(phi2) - t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[(-lambda2)], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.006], N[ArcTan[t$95$1 / N[(t$95$2 - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 7.8e-11], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\\
t_1 := \sin \left(-\lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.006:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0}\\
\mathbf{elif}\;\phi_1 \leq 7.8 \cdot 10^{-11}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if phi1 < -0.0060000000000000001Initial program 70.3%
Taylor expanded in lambda1 around 0 42.6%
Taylor expanded in phi2 around 0 28.5%
if -0.0060000000000000001 < phi1 < 7.80000000000000021e-11Initial program 79.5%
Taylor expanded in phi1 around 0 79.5%
*-commutative79.5%
sub-neg79.5%
remove-double-neg79.5%
mul-1-neg79.5%
distribute-neg-in79.5%
+-commutative79.5%
cos-neg79.5%
mul-1-neg79.5%
unsub-neg79.5%
Simplified79.5%
Taylor expanded in phi2 around 0 79.4%
if 7.80000000000000021e-11 < phi1 Initial program 68.1%
Taylor expanded in lambda1 around 0 43.2%
Taylor expanded in phi1 around 0 31.3%
Final simplification55.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (/ (* (cos (- lambda1 lambda2)) (* (sin phi1) 2.0)) 2.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos((lambda1 - lambda2)) * (sin(phi1) * 2.0)) / 2.0)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos((lambda1 - lambda2)) * (sin(phi1) * 2.0d0)) / 2.0d0)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos((lambda1 - lambda2)) * (Math.sin(phi1) * 2.0)) / 2.0)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos((lambda1 - lambda2)) * (math.sin(phi1) * 2.0)) / 2.0)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(Float64(lambda1 - lambda2)) * Float64(sin(phi1) * 2.0)) / 2.0))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos((lambda1 - lambda2)) * (sin(phi1) * 2.0)) / 2.0))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \frac{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\sin \phi_1 \cdot 2\right)}{2}}
\end{array}
Initial program 74.5%
sin-cos-mult62.7%
associate-*l/62.7%
Applied egg-rr62.7%
Taylor expanded in phi2 around 0 62.7%
Final simplification62.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (/ (* (cos lambda2) (* (sin phi1) 2.0)) 2.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * (sin(phi1) * 2.0)) / 2.0)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * (sin(phi1) * 2.0d0)) / 2.0d0)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(lambda2) * (Math.sin(phi1) * 2.0)) / 2.0)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(lambda2) * (math.sin(phi1) * 2.0)) / 2.0)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda2) * Float64(sin(phi1) * 2.0)) / 2.0))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * (sin(phi1) * 2.0)) / 2.0))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \frac{\cos \lambda_2 \cdot \left(\sin \phi_1 \cdot 2\right)}{2}}
\end{array}
Initial program 74.5%
sin-cos-mult62.7%
associate-*l/62.7%
Applied egg-rr62.7%
Taylor expanded in lambda1 around 0 58.6%
cos-neg58.6%
Simplified58.6%
Taylor expanded in phi2 around 0 58.5%
Final simplification58.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -4.7e+36)
(atan2
(* (sin lambda1) (cos phi2))
(-
(* (sin phi2) (+ (* -0.5 (pow phi1 2.0)) 1.0))
(* phi1 (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (* (cos phi1) (sin phi2)) (* (cos lambda2) phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -4.7e+36) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((sin(phi2) * ((-0.5 * pow(phi1, 2.0)) + 1.0)) - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * 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) :: tmp
if (phi1 <= (-4.7d+36)) then
tmp = atan2((sin(lambda1) * cos(phi2)), ((sin(phi2) * (((-0.5d0) * (phi1 ** 2.0d0)) + 1.0d0)) - (phi1 * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -4.7e+36) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.sin(phi2) * ((-0.5 * Math.pow(phi1, 2.0)) + 1.0)) - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda2) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -4.7e+36: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.sin(phi2) * ((-0.5 * math.pow(phi1, 2.0)) + 1.0)) - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda2) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -4.7e+36) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(sin(phi2) * Float64(Float64(-0.5 * (phi1 ^ 2.0)) + 1.0)) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda2) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -4.7e+36) tmp = atan2((sin(lambda1) * cos(phi2)), ((sin(phi2) * ((-0.5 * (phi1 ^ 2.0)) + 1.0)) - (phi1 * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -4.7e+36], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[(N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -4.7 \cdot 10^{+36}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 \cdot \left(-0.5 \cdot {\phi_1}^{2} + 1\right) - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \phi_1}\\
\end{array}
\end{array}
if phi1 < -4.69999999999999989e36Initial program 67.4%
Taylor expanded in phi1 around 0 9.4%
*-commutative9.4%
sub-neg9.4%
remove-double-neg9.4%
mul-1-neg9.4%
distribute-neg-in9.4%
+-commutative9.4%
cos-neg9.4%
mul-1-neg9.4%
unsub-neg9.4%
Simplified9.4%
Taylor expanded in phi2 around 0 8.9%
Taylor expanded in lambda2 around 0 8.5%
Taylor expanded in phi1 around 0 15.4%
associate-*r*15.4%
distribute-rgt1-in15.4%
Simplified15.4%
if -4.69999999999999989e36 < phi1 Initial program 76.8%
Taylor expanded in phi1 around 0 61.0%
*-commutative61.0%
sub-neg61.0%
remove-double-neg61.0%
mul-1-neg61.0%
distribute-neg-in61.0%
+-commutative61.0%
cos-neg61.0%
mul-1-neg61.0%
unsub-neg61.0%
Simplified61.0%
Taylor expanded in phi2 around 0 60.7%
Taylor expanded in lambda1 around 0 60.9%
Final simplification49.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 74.5%
Taylor expanded in phi1 around 0 48.5%
*-commutative48.5%
sub-neg48.5%
remove-double-neg48.5%
mul-1-neg48.5%
distribute-neg-in48.5%
+-commutative48.5%
cos-neg48.5%
mul-1-neg48.5%
unsub-neg48.5%
Simplified48.5%
Taylor expanded in phi2 around 0 48.1%
Final simplification48.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos lambda2) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * 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((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda2) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda2) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda2) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \phi_1}
\end{array}
Initial program 74.5%
Taylor expanded in phi1 around 0 48.5%
*-commutative48.5%
sub-neg48.5%
remove-double-neg48.5%
mul-1-neg48.5%
distribute-neg-in48.5%
+-commutative48.5%
cos-neg48.5%
mul-1-neg48.5%
unsub-neg48.5%
Simplified48.5%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in lambda1 around 0 47.5%
Final simplification47.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos lambda1) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * 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((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda1) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda1) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda1) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_1 \cdot \phi_1}
\end{array}
Initial program 74.5%
Taylor expanded in phi1 around 0 48.5%
*-commutative48.5%
sub-neg48.5%
remove-double-neg48.5%
mul-1-neg48.5%
distribute-neg-in48.5%
+-commutative48.5%
cos-neg48.5%
mul-1-neg48.5%
unsub-neg48.5%
Simplified48.5%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in lambda2 around 0 47.9%
cos-neg47.9%
*-commutative47.9%
Simplified47.9%
Final simplification47.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (- (* (cos phi1) (sin phi2)) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin(lambda1), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), ((Math.cos(phi1) * Math.sin(phi2)) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), ((math.cos(phi1) * math.sin(phi2)) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\cos \phi_1 \cdot \sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 74.5%
Taylor expanded in phi1 around 0 48.5%
*-commutative48.5%
sub-neg48.5%
remove-double-neg48.5%
mul-1-neg48.5%
distribute-neg-in48.5%
+-commutative48.5%
cos-neg48.5%
mul-1-neg48.5%
unsub-neg48.5%
Simplified48.5%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in lambda2 around 0 26.1%
Taylor expanded in phi2 around 0 21.2%
Final simplification21.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 74.5%
Taylor expanded in phi1 around 0 48.5%
*-commutative48.5%
sub-neg48.5%
remove-double-neg48.5%
mul-1-neg48.5%
distribute-neg-in48.5%
+-commutative48.5%
cos-neg48.5%
mul-1-neg48.5%
unsub-neg48.5%
Simplified48.5%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in lambda2 around 0 26.1%
Taylor expanded in phi1 around 0 26.1%
Final simplification26.1%
herbie shell --seed 2024027
(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))))))