
(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
(let* ((t_0 (* (cos lambda2) (sin lambda1)))
(t_1 (fma (cos lambda1) (sin lambda2) t_0)))
(atan2
(* (* t_1 (/ (- t_0 (* (cos lambda1) (sin lambda2))) t_1)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda1) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda2) * sin(lambda1);
double t_1 = fma(cos(lambda1), sin(lambda2), t_0);
return atan2(((t_1 * ((t_0 - (cos(lambda1) * sin(lambda2))) / t_1)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda2) * sin(lambda1)) t_1 = fma(cos(lambda1), sin(lambda2), t_0) return atan(Float64(Float64(t_1 * Float64(Float64(t_0 - Float64(cos(lambda1) * sin(lambda2))) / t_1)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda1) * cos(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + t$95$0), $MachinePrecision]}, N[ArcTan[N[(N[(t$95$1 * N[(N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \sin \lambda_1\\
t_1 := \mathsf{fma}\left(\cos \lambda_1, \sin \lambda_2, t\_0\right)\\
\tan^{-1}_* \frac{\left(t\_1 \cdot \frac{t\_0 - \cos \lambda_1 \cdot \sin \lambda_2}{t\_1}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
\end{array}
Initial program 79.7%
sin-diff89.7%
flip--87.5%
Applied egg-rr87.5%
difference-of-squares87.5%
sub-neg87.5%
associate-/l*89.7%
+-commutative89.7%
fma-define89.7%
cos-neg89.7%
*-commutative89.7%
cos-neg89.7%
Simplified89.7%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda1) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(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) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda1) * math.cos(lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda1) * cos(lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 79.7%
sin-diff89.7%
Applied egg-rr89.7%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(*
(sin phi1)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda1) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(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) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda1) * Math.cos(lambda2)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda1) * math.cos(lambda2)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda1) * cos(lambda2))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2))))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $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[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \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(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)}
\end{array}
Initial program 79.7%
sin-diff89.7%
flip--87.5%
Applied egg-rr87.5%
difference-of-squares87.5%
sub-neg87.5%
associate-/l*89.7%
+-commutative89.7%
fma-define89.7%
cos-neg89.7%
*-commutative89.7%
cos-neg89.7%
Simplified89.7%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in lambda1 around 0 99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (* (cos lambda2) (sin lambda1)))
(t_4 (- t_3 t_0))
(t_5 (* (cos phi2) (sin phi1))))
(if (<= phi2 -6e-6)
(atan2 (* (cos phi2) (- t_3 (log1p (expm1 t_0)))) (- t_1 (* t_5 t_2)))
(if (<= phi2 2.75e-9)
(atan2
t_4
(-
t_1
(*
t_5
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda1) (cos lambda2))))))
(atan2 (* (cos phi2) t_4) (- t_1 (* t_5 (pow (cbrt t_2) 3.0))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = cos((lambda1 - lambda2));
double t_3 = cos(lambda2) * sin(lambda1);
double t_4 = t_3 - t_0;
double t_5 = cos(phi2) * sin(phi1);
double tmp;
if (phi2 <= -6e-6) {
tmp = atan2((cos(phi2) * (t_3 - log1p(expm1(t_0)))), (t_1 - (t_5 * t_2)));
} else if (phi2 <= 2.75e-9) {
tmp = atan2(t_4, (t_1 - (t_5 * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = atan2((cos(phi2) * t_4), (t_1 - (t_5 * pow(cbrt(t_2), 3.0))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = Math.cos(lambda2) * Math.sin(lambda1);
double t_4 = t_3 - t_0;
double t_5 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if (phi2 <= -6e-6) {
tmp = Math.atan2((Math.cos(phi2) * (t_3 - Math.log1p(Math.expm1(t_0)))), (t_1 - (t_5 * t_2)));
} else if (phi2 <= 2.75e-9) {
tmp = Math.atan2(t_4, (t_1 - (t_5 * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_4), (t_1 - (t_5 * Math.pow(Math.cbrt(t_2), 3.0))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = Float64(cos(lambda2) * sin(lambda1)) t_4 = Float64(t_3 - t_0) t_5 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if (phi2 <= -6e-6) tmp = atan(Float64(cos(phi2) * Float64(t_3 - log1p(expm1(t_0)))), Float64(t_1 - Float64(t_5 * t_2))); elseif (phi2 <= 2.75e-9) tmp = atan(t_4, Float64(t_1 - Float64(t_5 * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = atan(Float64(cos(phi2) * t_4), Float64(t_1 - Float64(t_5 * (cbrt(t_2) ^ 3.0)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 - t$95$0), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -6e-6], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$3 - N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$5 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 2.75e-9], N[ArcTan[t$95$4 / N[(t$95$1 - N[(t$95$5 * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision] / N[(t$95$1 - N[(t$95$5 * N[Power[N[Power[t$95$2, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \cos \lambda_2 \cdot \sin \lambda_1\\
t_4 := t\_3 - t\_0\\
t_5 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t\_3 - \mathsf{log1p}\left(\mathsf{expm1}\left(t\_0\right)\right)\right)}{t\_1 - t\_5 \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 2.75 \cdot 10^{-9}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{t\_1 - t\_5 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_1 \cdot \cos \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_4}{t\_1 - t\_5 \cdot {\left(\sqrt[3]{t\_2}\right)}^{3}}\\
\end{array}
\end{array}
if phi2 < -6.0000000000000002e-6Initial program 77.4%
sin-diff91.3%
Applied egg-rr91.3%
log1p-expm1-u91.4%
*-commutative91.4%
Applied egg-rr91.4%
if -6.0000000000000002e-6 < phi2 < 2.7499999999999998e-9Initial program 80.9%
sin-diff88.3%
flip--86.1%
Applied egg-rr86.1%
difference-of-squares86.1%
sub-neg86.1%
associate-/l*88.3%
+-commutative88.3%
fma-define88.3%
cos-neg88.3%
*-commutative88.3%
cos-neg88.3%
Simplified88.3%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 2.7499999999999998e-9 < phi2 Initial program 79.8%
add-cube-cbrt79.9%
pow379.9%
Applied egg-rr79.9%
sin-diff90.8%
Applied egg-rr90.9%
Final simplification95.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(-
(* (cos lambda2) (sin lambda1))
(log1p (expm1 (* (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) * ((cos(lambda2) * sin(lambda1)) - log1p(expm1((cos(lambda1) * sin(lambda2)))))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - Math.log1p(Math.expm1((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.cos(lambda2) * math.sin(lambda1)) - math.log1p(math.expm1((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(cos(lambda2) * sin(lambda1)) - log1p(expm1(Float64(cos(lambda1) * sin(lambda2)))))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[Log[1 + N[(Exp[N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.7%
sin-diff89.7%
Applied egg-rr89.7%
log1p-expm1-u89.7%
*-commutative89.7%
Applied egg-rr89.7%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -1.8e+18) (not (<= lambda1 3.4e-65)))
(atan2
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
t_0
(*
(cos phi2)
(*
(sin phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda1) (cos lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -1.8e+18) || !(lambda1 <= 3.4e-65)) {
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2)))))));
}
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.8d+18)) .or. (.not. (lambda1 <= 3.4d-65))) then
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2)))))))
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.8e+18) || !(lambda1 <= 3.4e-65)) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_0 - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda1) * Math.cos(lambda2)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -1.8e+18) or not (lambda1 <= 3.4e-65): tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.sin(phi1) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda1) * math.cos(lambda2))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -1.8e+18) || !(lambda1 <= 3.4e-65)) tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda1) * cos(lambda2))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -1.8e+18) || ~((lambda1 <= 3.4e-65))) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda1) * cos(lambda2))))))); 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.8e+18], N[Not[LessEqual[lambda1, 3.4e-65]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $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], 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[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $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.8 \cdot 10^{+18} \lor \neg \left(\lambda_1 \leq 3.4 \cdot 10^{-65}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_0 - \cos \lambda_1 \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 \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -1.8e18 or 3.39999999999999987e-65 < lambda1 Initial program 62.7%
sin-diff81.5%
Applied egg-rr81.5%
Taylor expanded in lambda2 around 0 81.4%
if -1.8e18 < lambda1 < 3.39999999999999987e-65Initial program 99.2%
*-commutative99.2%
associate-*l*99.2%
Simplified99.2%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.3%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))))
(t_2 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -2.2e+16) (not (<= lambda1 1850000000.0)))
(atan2 t_1 (- t_0 (* (cos lambda1) t_2)))
(atan2 t_1 (- t_0 (* (cos lambda2) t_2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)));
double t_2 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda1 <= -2.2e+16) || !(lambda1 <= 1850000000.0)) {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * t_2)));
} else {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))
t_2 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-2.2d+16)) .or. (.not. (lambda1 <= 1850000000.0d0))) then
tmp = atan2(t_1, (t_0 - (cos(lambda1) * t_2)))
else
tmp = atan2(t_1, (t_0 - (cos(lambda2) * 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(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)));
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -2.2e+16) || !(lambda1 <= 1850000000.0)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * t_2)));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda2) * t_2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))) t_2 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda1 <= -2.2e+16) or not (lambda1 <= 1850000000.0): tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * t_2))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda2) * t_2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))) t_2 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -2.2e+16) || !(lambda1 <= 1850000000.0)) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * t_2))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * t_2))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))); t_2 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda1 <= -2.2e+16) || ~((lambda1 <= 1850000000.0))) tmp = atan2(t_1, (t_0 - (cos(lambda1) * t_2))); else tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2))); 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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -2.2e+16], N[Not[LessEqual[lambda1, 1850000000.0]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$2), $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(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -2.2 \cdot 10^{+16} \lor \neg \left(\lambda_1 \leq 1850000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \lambda_1 \cdot t\_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \lambda_2 \cdot t\_2}\\
\end{array}
\end{array}
if lambda1 < -2.2e16 or 1.85e9 < lambda1 Initial program 59.2%
sin-diff80.3%
Applied egg-rr80.3%
Taylor expanded in lambda2 around 0 80.4%
if -2.2e16 < lambda1 < 1.85e9Initial program 98.0%
sin-diff98.2%
Applied egg-rr98.2%
Taylor expanded in lambda1 around 0 98.2%
cos-neg98.2%
Simplified98.2%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -2.2e+16) (not (<= lambda1 3.4e-65)))
(atan2
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
t_0
(*
t_1
(+
(cos lambda2)
(*
lambda1
(+ (sin lambda2) (* -0.5 (* lambda1 (cos lambda2))))))))))))
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 tmp;
if ((lambda1 <= -2.2e+16) || !(lambda1 <= 3.4e-65)) {
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * (sin(lambda2) + (-0.5 * (lambda1 * cos(lambda2)))))))));
}
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(phi1)
if ((lambda1 <= (-2.2d+16)) .or. (.not. (lambda1 <= 3.4d-65))) then
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * (sin(lambda2) + ((-0.5d0) * (lambda1 * cos(lambda2)))))))))
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 tmp;
if ((lambda1 <= -2.2e+16) || !(lambda1 <= 3.4e-65)) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (t_1 * (Math.cos(lambda2) + (lambda1 * (Math.sin(lambda2) + (-0.5 * (lambda1 * Math.cos(lambda2)))))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda1 <= -2.2e+16) or not (lambda1 <= 3.4e-65): tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (t_1 * (math.cos(lambda2) + (lambda1 * (math.sin(lambda2) + (-0.5 * (lambda1 * math.cos(lambda2))))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -2.2e+16) || !(lambda1 <= 3.4e-65)) tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(t_1 * Float64(cos(lambda2) + Float64(lambda1 * Float64(sin(lambda2) + Float64(-0.5 * Float64(lambda1 * cos(lambda2))))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda1 <= -2.2e+16) || ~((lambda1 <= 3.4e-65))) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * (sin(lambda2) + (-0.5 * (lambda1 * cos(lambda2))))))))); 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]}, If[Or[LessEqual[lambda1, -2.2e+16], N[Not[LessEqual[lambda1, 3.4e-65]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * N[(N[Sin[lambda2], $MachinePrecision] + N[(-0.5 * N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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\\
\mathbf{if}\;\lambda_1 \leq -2.2 \cdot 10^{+16} \lor \neg \left(\lambda_1 \leq 3.4 \cdot 10^{-65}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_0 - \cos \lambda_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - t\_1 \cdot \left(\cos \lambda_2 + \lambda_1 \cdot \left(\sin \lambda_2 + -0.5 \cdot \left(\lambda_1 \cdot \cos \lambda_2\right)\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -2.2e16 or 3.39999999999999987e-65 < lambda1 Initial program 62.9%
sin-diff81.6%
Applied egg-rr81.6%
Taylor expanded in lambda2 around 0 81.6%
if -2.2e16 < lambda1 < 3.39999999999999987e-65Initial program 99.2%
Taylor expanded in lambda1 around 0 99.3%
cos-neg99.3%
*-commutative99.3%
cos-neg99.3%
sin-neg99.3%
Simplified99.3%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (cos lambda2) (sin lambda1)) (* (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) * ((cos(lambda2) * sin(lambda1)) - (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) * ((cos(lambda2) * sin(lambda1)) - (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.cos(lambda2) * Math.sin(lambda1)) - (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.cos(lambda2) * math.sin(lambda1)) - (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(cos(lambda2) * sin(lambda1)) - 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) * ((cos(lambda2) * sin(lambda1)) - (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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $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(\cos \lambda_2 \cdot \sin \lambda_1 - \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 79.7%
*-commutative79.7%
associate-*l*79.7%
Simplified79.7%
sin-diff89.7%
Applied egg-rr89.7%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda2) (sin lambda1)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(t_3 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -1.05e-7)
(atan2 (* (cos phi2) (- (sin lambda1) t_3)) t_2)
(if (<= phi1 2e-27)
(atan2
(* (cos phi2) (- t_0 t_3))
(- t_1 (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 (* (cos phi2) (- t_0 (sin lambda2))) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda2) * sin(lambda1);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)));
double t_3 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -1.05e-7) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_3)), t_2);
} else if (phi1 <= 2e-27) {
tmp = atan2((cos(phi2) * (t_0 - t_3)), (t_1 - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), 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(lambda2) * sin(lambda1)
t_1 = cos(phi1) * sin(phi2)
t_2 = t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))
t_3 = cos(lambda1) * sin(lambda2)
if (phi1 <= (-1.05d-7)) then
tmp = atan2((cos(phi2) * (sin(lambda1) - t_3)), t_2)
else if (phi1 <= 2d-27) then
tmp = atan2((cos(phi2) * (t_0 - t_3)), (t_1 - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), 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(lambda2) * Math.sin(lambda1);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = t_1 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)));
double t_3 = Math.cos(lambda1) * Math.sin(lambda2);
double tmp;
if (phi1 <= -1.05e-7) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_3)), t_2);
} else if (phi1 <= 2e-27) {
tmp = Math.atan2((Math.cos(phi2) * (t_0 - t_3)), (t_1 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * (t_0 - Math.sin(lambda2))), t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda2) * math.sin(lambda1) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = t_1 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))) t_3 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if phi1 <= -1.05e-7: tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_3)), t_2) elif phi1 <= 2e-27: tmp = math.atan2((math.cos(phi2) * (t_0 - t_3)), (t_1 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * (t_0 - math.sin(lambda2))), t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda2) * sin(lambda1)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2)))) t_3 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -1.05e-7) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_3)), t_2); elseif (phi1 <= 2e-27) tmp = atan(Float64(cos(phi2) * Float64(t_0 - t_3)), Float64(t_1 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * Float64(t_0 - sin(lambda2))), t_2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda2) * sin(lambda1); t_1 = cos(phi1) * sin(phi2); t_2 = t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))); t_3 = cos(lambda1) * sin(lambda2); tmp = 0.0; if (phi1 <= -1.05e-7) tmp = atan2((cos(phi2) * (sin(lambda1) - t_3)), t_2); elseif (phi1 <= 2e-27) tmp = atan2((cos(phi2) * (t_0 - t_3)), (t_1 - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), t_2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.05e-7], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$3), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 2e-27], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 - t$95$3), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \sin \lambda_1\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t\_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -1.05 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t\_3\right)}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 2 \cdot 10^{-27}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t\_0 - t\_3\right)}{t\_1 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t\_0 - \sin \lambda_2\right)}{t\_2}\\
\end{array}
\end{array}
if phi1 < -1.05e-7Initial program 81.6%
sin-diff82.9%
Applied egg-rr82.9%
Taylor expanded in lambda2 around 0 82.3%
if -1.05e-7 < phi1 < 2.0000000000000001e-27Initial program 81.4%
sin-diff99.8%
Applied egg-rr99.8%
Taylor expanded in phi2 around 0 99.8%
sub-neg99.8%
remove-double-neg99.8%
mul-1-neg99.8%
distribute-neg-in99.8%
+-commutative99.8%
cos-neg99.8%
mul-1-neg99.8%
unsub-neg99.8%
Simplified99.8%
if 2.0000000000000001e-27 < phi1 Initial program 74.3%
sin-diff77.8%
Applied egg-rr77.8%
Taylor expanded in lambda1 around 0 76.1%
Final simplification89.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1)))
(t_1 (cos (- lambda2 lambda1)))
(t_2 (* (cos phi1) (sin phi2)))
(t_3 (* (cos lambda2) (sin lambda1))))
(if (<= phi1 -23500000000000.0)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_2 (* t_0 (expm1 (log1p t_1)))))
(if (<= phi1 5.6e-27)
(atan2
(* (cos phi2) (- t_3 (* (cos lambda1) (sin lambda2))))
(- t_2 (* (sin phi1) t_1)))
(atan2
(* (cos phi2) (- t_3 (sin lambda2)))
(- t_2 (* t_0 (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double t_1 = cos((lambda2 - lambda1));
double t_2 = cos(phi1) * sin(phi2);
double t_3 = cos(lambda2) * sin(lambda1);
double tmp;
if (phi1 <= -23500000000000.0) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_2 - (t_0 * expm1(log1p(t_1)))));
} else if (phi1 <= 5.6e-27) {
tmp = atan2((cos(phi2) * (t_3 - (cos(lambda1) * sin(lambda2)))), (t_2 - (sin(phi1) * t_1)));
} else {
tmp = atan2((cos(phi2) * (t_3 - sin(lambda2))), (t_2 - (t_0 * cos((lambda1 - lambda2)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
double t_1 = Math.cos((lambda2 - lambda1));
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double t_3 = Math.cos(lambda2) * Math.sin(lambda1);
double tmp;
if (phi1 <= -23500000000000.0) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_2 - (t_0 * Math.expm1(Math.log1p(t_1)))));
} else if (phi1 <= 5.6e-27) {
tmp = Math.atan2((Math.cos(phi2) * (t_3 - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_2 - (Math.sin(phi1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * (t_3 - Math.sin(lambda2))), (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) t_1 = math.cos((lambda2 - lambda1)) t_2 = math.cos(phi1) * math.sin(phi2) t_3 = math.cos(lambda2) * math.sin(lambda1) tmp = 0 if phi1 <= -23500000000000.0: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_2 - (t_0 * math.expm1(math.log1p(t_1))))) elif phi1 <= 5.6e-27: tmp = math.atan2((math.cos(phi2) * (t_3 - (math.cos(lambda1) * math.sin(lambda2)))), (t_2 - (math.sin(phi1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * (t_3 - math.sin(lambda2))), (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) t_1 = cos(Float64(lambda2 - lambda1)) t_2 = Float64(cos(phi1) * sin(phi2)) t_3 = Float64(cos(lambda2) * sin(lambda1)) tmp = 0.0 if (phi1 <= -23500000000000.0) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_2 - Float64(t_0 * expm1(log1p(t_1))))); elseif (phi1 <= 5.6e-27) tmp = atan(Float64(cos(phi2) * Float64(t_3 - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_2 - Float64(sin(phi1) * t_1))); else tmp = atan(Float64(cos(phi2) * Float64(t_3 - sin(lambda2))), Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -23500000000000.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[(Exp[N[Log[1 + t$95$1], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 5.6e-27], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$3 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$3 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
t_1 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
t_3 := \cos \lambda_2 \cdot \sin \lambda_1\\
\mathbf{if}\;\phi_1 \leq -23500000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_2 - t\_0 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t\_1\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 5.6 \cdot 10^{-27}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t\_3 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_2 - \sin \phi_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t\_3 - \sin \lambda_2\right)}{t\_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi1 < -2.35e13Initial program 83.1%
expm1-log1p-u83.1%
expm1-undefine83.1%
Applied egg-rr83.1%
expm1-define83.1%
sub-neg83.1%
neg-mul-183.1%
remove-double-neg83.1%
mul-1-neg83.1%
neg-mul-183.1%
distribute-neg-in83.1%
+-commutative83.1%
cos-neg83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
if -2.35e13 < phi1 < 5.5999999999999999e-27Initial program 80.6%
sin-diff98.7%
Applied egg-rr98.7%
Taylor expanded in phi2 around 0 98.7%
sub-neg98.7%
remove-double-neg98.7%
mul-1-neg98.7%
distribute-neg-in98.7%
+-commutative98.7%
cos-neg98.7%
mul-1-neg98.7%
unsub-neg98.7%
Simplified98.7%
if 5.5999999999999999e-27 < phi1 Initial program 74.3%
sin-diff77.8%
Applied egg-rr77.8%
Taylor expanded in lambda1 around 0 76.1%
Final simplification88.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (cos lambda2) (sin 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) * ((cos(lambda2) * sin(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) * ((cos(lambda2) * sin(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.cos(lambda2) * Math.sin(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.cos(lambda2) * math.sin(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(cos(lambda2) * sin(lambda1)) - sin(lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.7%
sin-diff89.7%
Applied egg-rr89.7%
Taylor expanded in lambda1 around 0 80.7%
Final simplification80.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (expm1 (log1p (cos (- lambda2 lambda1))))))))
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)) * expm1(log1p(cos((lambda2 - lambda1)))))));
}
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.expm1(Math.log1p(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)) - ((math.cos(phi2) * math.sin(phi1)) * math.expm1(math.log1p(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(Float64(cos(phi2) * sin(phi1)) * expm1(log1p(cos(Float64(lambda2 - lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(Exp[N[Log[1 + N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $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 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\lambda_2 - \lambda_1\right)\right)\right)}
\end{array}
Initial program 79.7%
expm1-log1p-u79.7%
expm1-undefine79.7%
Applied egg-rr79.7%
expm1-define79.7%
sub-neg79.7%
neg-mul-179.7%
remove-double-neg79.7%
mul-1-neg79.7%
neg-mul-179.7%
distribute-neg-in79.7%
+-commutative79.7%
cos-neg79.7%
mul-1-neg79.7%
unsub-neg79.7%
Simplified79.7%
Final simplification79.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (expm1 (log1p (* (sin 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)) - (cos(phi2) * expm1(log1p((sin(phi1) * cos((lambda2 - lambda1))))))));
}
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.expm1(Math.log1p((Math.sin(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)) - (math.cos(phi2) * math.expm1(math.log1p((math.sin(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(cos(phi2) * expm1(log1p(Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $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 \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)}
\end{array}
Initial program 79.7%
*-commutative79.7%
associate-*l*79.7%
Simplified79.7%
expm1-log1p-u79.7%
expm1-undefine78.2%
*-commutative78.2%
Applied egg-rr78.2%
expm1-define79.7%
sub-neg79.7%
neg-mul-179.7%
remove-double-neg79.7%
mul-1-neg79.7%
neg-mul-179.7%
distribute-neg-in79.7%
+-commutative79.7%
cos-neg79.7%
mul-1-neg79.7%
unsub-neg79.7%
Simplified79.7%
Final simplification79.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (* (cos phi2) (sin phi1))))
(if (<= lambda2 -1600000000.0)
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(if (<= lambda2 9.2e-10)
(atan2 t_1 (- t_0 (* (cos lambda1) t_2)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* t_2 (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double t_2 = cos(phi2) * sin(phi1);
double tmp;
if (lambda2 <= -1600000000.0) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else if (lambda2 <= 9.2e-10) {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * t_2)));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_2 * cos((lambda1 - lambda2)))));
}
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((lambda1 - lambda2))
t_2 = cos(phi2) * sin(phi1)
if (lambda2 <= (-1600000000.0d0)) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else if (lambda2 <= 9.2d-10) then
tmp = atan2(t_1, (t_0 - (cos(lambda1) * t_2)))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_2 * cos((lambda1 - lambda2)))))
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 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if (lambda2 <= -1600000000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else if (lambda2 <= 9.2e-10) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * t_2)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (t_2 * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin(phi1) tmp = 0 if lambda2 <= -1600000000.0: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) elif lambda2 <= 9.2e-10: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * t_2))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (t_2 * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if (lambda2 <= -1600000000.0) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); elseif (lambda2 <= 9.2e-10) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * t_2))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(t_2 * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); t_2 = cos(phi2) * sin(phi1); tmp = 0.0; if (lambda2 <= -1600000000.0) tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); elseif (lambda2 <= 9.2e-10) tmp = atan2(t_1, (t_0 - (cos(lambda1) * t_2))); else tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_2 * cos((lambda1 - lambda2))))); 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1600000000.0], 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], If[LessEqual[lambda2, 9.2e-10], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $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 \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_2 \leq -1600000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{elif}\;\lambda_2 \leq 9.2 \cdot 10^{-10}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \lambda_1 \cdot t\_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_0 - t\_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -1.6e9Initial program 49.5%
*-commutative49.5%
associate-*l*49.5%
Simplified49.5%
Taylor expanded in lambda1 around 0 49.2%
*-commutative49.2%
cos-neg49.2%
Simplified49.2%
if -1.6e9 < lambda2 < 9.20000000000000028e-10Initial program 99.8%
Taylor expanded in lambda2 around 0 99.8%
if 9.20000000000000028e-10 < lambda2 Initial program 65.9%
Taylor expanded in lambda1 around 0 67.0%
Final simplification79.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= lambda1 -2.2e+16) (not (<= lambda1 1850000000.0)))
(atan2 t_1 (- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1)))))
(atan2 t_1 (- 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((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -2.2e+16) || !(lambda1 <= 1850000000.0)) {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2(t_1, (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) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if ((lambda1 <= (-2.2d+16)) .or. (.not. (lambda1 <= 1850000000.0d0))) then
tmp = atan2(t_1, (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
else
tmp = atan2(t_1, (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((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -2.2e+16) || !(lambda1 <= 1850000000.0)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_1, (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((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -2.2e+16) or not (lambda1 <= 1850000000.0): tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) else: tmp = math.atan2(t_1, (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(Float64(lambda1 - lambda2))) tmp = 0.0 if ((lambda1 <= -2.2e+16) || !(lambda1 <= 1850000000.0)) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(t_1, 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((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 <= -2.2e+16) || ~((lambda1 <= 1850000000.0))) tmp = atan2(t_1, (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1))))); else tmp = atan2(t_1, (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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -2.2e+16], N[Not[LessEqual[lambda1, 1850000000.0]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $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[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 \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -2.2 \cdot 10^{+16} \lor \neg \left(\lambda_1 \leq 1850000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda1 < -2.2e16 or 1.85e9 < lambda1 Initial program 59.2%
Taylor expanded in lambda2 around 0 59.2%
if -2.2e16 < lambda1 < 1.85e9Initial program 98.0%
*-commutative98.0%
associate-*l*98.0%
Simplified98.0%
Taylor expanded in lambda1 around 0 98.0%
*-commutative98.0%
cos-neg98.0%
Simplified98.0%
Final simplification79.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -2.2e+16) (not (<= lambda1 0.000405)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
(* (cos phi2) (sin (- lambda1 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 <= -2.2e+16) || !(lambda1 <= 0.000405)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - 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 <= (-2.2d+16)) .or. (.not. (lambda1 <= 0.000405d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - 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 <= -2.2e+16) || !(lambda1 <= 0.000405)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - 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 <= -2.2e+16) or not (lambda1 <= 0.000405): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - 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 <= -2.2e+16) || !(lambda1 <= 0.000405)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - 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 <= -2.2e+16) || ~((lambda1 <= 0.000405))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - 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, -2.2e+16], N[Not[LessEqual[lambda1, 0.000405]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[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 -2.2 \cdot 10^{+16} \lor \neg \left(\lambda_1 \leq 0.000405\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda1 < -2.2e16 or 4.0499999999999998e-4 < lambda1 Initial program 58.8%
Taylor expanded in lambda2 around 0 58.4%
if -2.2e16 < lambda1 < 4.0499999999999998e-4Initial program 99.2%
*-commutative99.2%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in lambda1 around 0 99.3%
*-commutative99.3%
cos-neg99.3%
Simplified99.3%
Final simplification79.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= lambda1 -3.1e+34) (not (<= lambda1 1.35e-61)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -3.1e+34) || !(lambda1 <= 1.35e-61)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if ((lambda1 <= (-3.1d+34)) .or. (.not. (lambda1 <= 1.35d-61))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * 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((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -3.1e+34) || !(lambda1 <= 1.35e-61)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -3.1e+34) or not (lambda1 <= 1.35e-61): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((lambda1 <= -3.1e+34) || !(lambda1 <= 1.35e-61)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 <= -3.1e+34) || ~((lambda1 <= 1.35e-61))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -3.1e+34], N[Not[LessEqual[lambda1, 1.35e-61]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -3.1 \cdot 10^{+34} \lor \neg \left(\lambda_1 \leq 1.35 \cdot 10^{-61}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \sin \phi_1 \cdot t\_1}\\
\end{array}
\end{array}
if lambda1 < -3.09999999999999977e34 or 1.34999999999999997e-61 < lambda1 Initial program 63.4%
Taylor expanded in lambda2 around 0 62.1%
if -3.09999999999999977e34 < lambda1 < 1.34999999999999997e-61Initial program 96.4%
Taylor expanded in phi2 around 0 80.7%
Final simplification71.2%
(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 79.7%
*-commutative79.7%
associate-*l*79.7%
Simplified79.7%
Final simplification79.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.042) (not (<= phi2 1.5e+81)))
(atan2 (* (cos phi2) t_0) (sin phi2))
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.042) || !(phi2 <= 1.5e+81)) {
tmp = atan2((cos(phi2) * t_0), sin(phi2));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.042d0)) .or. (.not. (phi2 <= 1.5d+81))) then
tmp = atan2((cos(phi2) * t_0), sin(phi2))
else
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.042) || !(phi2 <= 1.5e+81)) {
tmp = Math.atan2((Math.cos(phi2) * t_0), Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.042) or not (phi2 <= 1.5e+81): tmp = math.atan2((math.cos(phi2) * t_0), math.sin(phi2)) else: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.042) || !(phi2 <= 1.5e+81)) tmp = atan(Float64(cos(phi2) * t_0), sin(phi2)); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.042) || ~((phi2 <= 1.5e+81))) tmp = atan2((cos(phi2) * t_0), sin(phi2)); else tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.042], N[Not[LessEqual[phi2, 1.5e+81]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / 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}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.042 \lor \neg \left(\phi_2 \leq 1.5 \cdot 10^{+81}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\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}
\end{array}
if phi2 < -0.0420000000000000026 or 1.49999999999999999e81 < phi2 Initial program 78.3%
add-cube-cbrt78.3%
pow378.3%
Applied egg-rr78.3%
rem-cube-cbrt78.3%
add-cbrt-cube78.2%
pow378.2%
cancel-sign-sub-inv78.2%
fma-define78.2%
Applied egg-rr78.2%
Taylor expanded in phi1 around 0 51.6%
if -0.0420000000000000026 < phi2 < 1.49999999999999999e81Initial program 80.8%
*-commutative80.8%
associate-*l*80.8%
Simplified80.8%
Taylor expanded in phi2 around 0 77.5%
Final simplification65.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin 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)) - (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)) - (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.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.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(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)) - (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[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $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 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.7%
Taylor expanded in phi2 around 0 67.0%
Final simplification67.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.00037) (not (<= phi2 3.45e+59)))
(atan2 (* (cos phi2) t_0) (sin phi2))
(atan2
t_0
(-
(sin phi2)
(* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00037) || !(phi2 <= 3.45e+59)) {
tmp = atan2((cos(phi2) * t_0), sin(phi2));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.00037d0)) .or. (.not. (phi2 <= 3.45d+59))) then
tmp = atan2((cos(phi2) * t_0), sin(phi2))
else
tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00037) || !(phi2 <= 3.45e+59)) {
tmp = Math.atan2((Math.cos(phi2) * t_0), Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.00037) or not (phi2 <= 3.45e+59): tmp = math.atan2((math.cos(phi2) * t_0), math.sin(phi2)) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.00037) || !(phi2 <= 3.45e+59)) tmp = atan(Float64(cos(phi2) * t_0), sin(phi2)); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.00037) || ~((phi2 <= 3.45e+59))) tmp = atan2((cos(phi2) * t_0), sin(phi2)); else tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00037], N[Not[LessEqual[phi2, 3.45e+59]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.00037 \lor \neg \left(\phi_2 \leq 3.45 \cdot 10^{+59}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -3.6999999999999999e-4 or 3.4499999999999999e59 < phi2 Initial program 77.9%
add-cube-cbrt77.8%
pow377.8%
Applied egg-rr77.8%
rem-cube-cbrt77.9%
add-cbrt-cube77.8%
pow377.8%
cancel-sign-sub-inv77.8%
fma-define77.8%
Applied egg-rr77.8%
Taylor expanded in phi1 around 0 50.4%
if -3.6999999999999999e-4 < phi2 < 3.4499999999999999e59Initial program 81.3%
*-commutative81.3%
associate-*l*81.3%
Simplified81.3%
Taylor expanded in phi2 around 0 79.1%
Taylor expanded in phi1 around 0 78.9%
Final simplification65.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= phi1 -1.05e-91) (not (<= phi1 6.4e+19)))
(atan2 t_0 (* (sin phi1) (- (cos (- lambda1 lambda2)))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) {
tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2))));
} else {
tmp = atan2(t_0, sin(phi2));
}
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(phi2) * sin((lambda1 - lambda2))
if ((phi1 <= (-1.05d-91)) .or. (.not. (phi1 <= 6.4d+19))) then
tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2))))
else
tmp = atan2(t_0, sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) {
tmp = Math.atan2(t_0, (Math.sin(phi1) * -Math.cos((lambda1 - lambda2))));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1.05e-91) or not (phi1 <= 6.4e+19): tmp = math.atan2(t_0, (math.sin(phi1) * -math.cos((lambda1 - lambda2)))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) tmp = atan(t_0, Float64(sin(phi1) * Float64(-cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1.05e-91) || ~((phi1 <= 6.4e+19))) tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2)))); else tmp = atan2(t_0, sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -1.05e-91], N[Not[LessEqual[phi1, 6.4e+19]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.05 \cdot 10^{-91} \lor \neg \left(\phi_1 \leq 6.4 \cdot 10^{+19}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.05e-91 or 6.4e19 < phi1 Initial program 77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
log1p-expm1-u77.6%
*-commutative77.6%
Applied egg-rr77.6%
Taylor expanded in phi2 around 0 50.8%
*-commutative50.8%
neg-mul-150.8%
distribute-rgt-neg-in50.8%
Simplified50.8%
if -1.05e-91 < phi1 < 6.4e19Initial program 82.0%
add-cube-cbrt82.0%
pow382.0%
Applied egg-rr82.0%
rem-cube-cbrt82.0%
add-cbrt-cube79.7%
pow379.6%
cancel-sign-sub-inv79.6%
fma-define79.6%
Applied egg-rr79.6%
Taylor expanded in phi1 around 0 79.1%
Final simplification63.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= phi1 -1.05e-91) (not (<= phi1 6.4e+19)))
(atan2 t_0 (* (cos lambda2) (- (sin phi1))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) {
tmp = atan2(t_0, (cos(lambda2) * -sin(phi1)));
} else {
tmp = atan2(t_0, sin(phi2));
}
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(phi2) * sin((lambda1 - lambda2))
if ((phi1 <= (-1.05d-91)) .or. (.not. (phi1 <= 6.4d+19))) then
tmp = atan2(t_0, (cos(lambda2) * -sin(phi1)))
else
tmp = atan2(t_0, sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) {
tmp = Math.atan2(t_0, (Math.cos(lambda2) * -Math.sin(phi1)));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1.05e-91) or not (phi1 <= 6.4e+19): tmp = math.atan2(t_0, (math.cos(lambda2) * -math.sin(phi1))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) tmp = atan(t_0, Float64(cos(lambda2) * Float64(-sin(phi1)))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1.05e-91) || ~((phi1 <= 6.4e+19))) tmp = atan2(t_0, (cos(lambda2) * -sin(phi1))); else tmp = atan2(t_0, sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -1.05e-91], N[Not[LessEqual[phi1, 6.4e+19]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.05 \cdot 10^{-91} \lor \neg \left(\phi_1 \leq 6.4 \cdot 10^{+19}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \lambda_2 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.05e-91 or 6.4e19 < phi1 Initial program 77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
log1p-expm1-u77.6%
*-commutative77.6%
Applied egg-rr77.6%
Taylor expanded in phi2 around 0 50.8%
*-commutative50.8%
neg-mul-150.8%
distribute-rgt-neg-in50.8%
Simplified50.8%
Taylor expanded in lambda1 around 0 44.4%
cos-neg68.6%
Simplified44.4%
if -1.05e-91 < phi1 < 6.4e19Initial program 82.0%
add-cube-cbrt82.0%
pow382.0%
Applied egg-rr82.0%
rem-cube-cbrt82.0%
add-cbrt-cube79.7%
pow379.6%
cancel-sign-sub-inv79.6%
fma-define79.6%
Applied egg-rr79.6%
Taylor expanded in phi1 around 0 79.1%
Final simplification60.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= phi1 -1.05e-91) (not (<= phi1 6.4e+19)))
(atan2 t_0 (* (cos lambda1) (- (sin phi1))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) {
tmp = atan2(t_0, (cos(lambda1) * -sin(phi1)));
} else {
tmp = atan2(t_0, sin(phi2));
}
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(phi2) * sin((lambda1 - lambda2))
if ((phi1 <= (-1.05d-91)) .or. (.not. (phi1 <= 6.4d+19))) then
tmp = atan2(t_0, (cos(lambda1) * -sin(phi1)))
else
tmp = atan2(t_0, sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) {
tmp = Math.atan2(t_0, (Math.cos(lambda1) * -Math.sin(phi1)));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1.05e-91) or not (phi1 <= 6.4e+19): tmp = math.atan2(t_0, (math.cos(lambda1) * -math.sin(phi1))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi1 <= -1.05e-91) || !(phi1 <= 6.4e+19)) tmp = atan(t_0, Float64(cos(lambda1) * Float64(-sin(phi1)))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1.05e-91) || ~((phi1 <= 6.4e+19))) tmp = atan2(t_0, (cos(lambda1) * -sin(phi1))); else tmp = atan2(t_0, sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -1.05e-91], N[Not[LessEqual[phi1, 6.4e+19]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.05 \cdot 10^{-91} \lor \neg \left(\phi_1 \leq 6.4 \cdot 10^{+19}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \lambda_1 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.05e-91 or 6.4e19 < phi1 Initial program 77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
log1p-expm1-u77.6%
*-commutative77.6%
Applied egg-rr77.6%
Taylor expanded in phi2 around 0 50.8%
*-commutative50.8%
neg-mul-150.8%
distribute-rgt-neg-in50.8%
Simplified50.8%
Taylor expanded in lambda2 around 0 39.7%
if -1.05e-91 < phi1 < 6.4e19Initial program 82.0%
add-cube-cbrt82.0%
pow382.0%
Applied egg-rr82.0%
rem-cube-cbrt82.0%
add-cbrt-cube79.7%
pow379.6%
cancel-sign-sub-inv79.6%
fma-define79.6%
Applied egg-rr79.6%
Taylor expanded in phi1 around 0 79.1%
Final simplification57.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -3e-8) (not (<= phi1 680.0)))
(atan2
(* (sin lambda1) (cos phi2))
(* (sin phi1) (- (cos (- lambda1 lambda2)))))
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3e-8) || !(phi1 <= 680.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi1) * -cos((lambda1 - lambda2))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), sin(phi2));
}
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 <= (-3d-8)) .or. (.not. (phi1 <= 680.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi1) * -cos((lambda1 - lambda2))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3e-8) || !(phi1 <= 680.0)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi1) * -Math.cos((lambda1 - lambda2))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -3e-8) or not (phi1 <= 680.0): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi1) * -math.cos((lambda1 - lambda2)))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -3e-8) || !(phi1 <= 680.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi1) * Float64(-cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -3e-8) || ~((phi1 <= 680.0))) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi1) * -cos((lambda1 - lambda2)))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -3e-8], N[Not[LessEqual[phi1, 680.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 680\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -2.99999999999999973e-8 or 680 < phi1 Initial program 78.3%
*-commutative78.3%
associate-*l*78.3%
Simplified78.3%
log1p-expm1-u78.3%
*-commutative78.3%
Applied egg-rr78.3%
Taylor expanded in phi2 around 0 49.9%
*-commutative49.9%
neg-mul-149.9%
distribute-rgt-neg-in49.9%
Simplified49.9%
Taylor expanded in lambda2 around 0 30.3%
if -2.99999999999999973e-8 < phi1 < 680Initial program 81.1%
add-cube-cbrt81.1%
pow381.1%
Applied egg-rr81.1%
rem-cube-cbrt81.1%
add-cbrt-cube78.9%
pow378.9%
cancel-sign-sub-inv78.9%
fma-define78.9%
Applied egg-rr78.9%
Taylor expanded in phi1 around 0 78.1%
Final simplification53.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), sin(phi2));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), sin(phi2))
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.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}
\end{array}
Initial program 79.7%
add-cube-cbrt79.6%
pow379.6%
Applied egg-rr79.6%
rem-cube-cbrt79.7%
add-cbrt-cube78.5%
pow378.5%
cancel-sign-sub-inv78.5%
fma-define78.5%
Applied egg-rr78.5%
Taylor expanded in phi1 around 0 48.5%
Final simplification48.5%
herbie shell --seed 2024113
(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))))))