
(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 (* (sin lambda1) (sin lambda2)))
(t_1 (* (cos lambda2) (cos lambda1))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(log1p
(expm1
(/
(+ (pow t_1 3.0) (pow t_0 3.0))
(+ (pow t_1 2.0) (* t_0 (- t_0 t_1)))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * sin(lambda2);
double t_1 = cos(lambda2) * cos(lambda1);
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * log1p(expm1(((pow(t_1, 3.0) + pow(t_0, 3.0)) / (pow(t_1, 2.0) + (t_0 * (t_0 - t_1)))))))));
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(lambda2) * Math.cos(lambda1);
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.log1p(Math.expm1(((Math.pow(t_1, 3.0) + Math.pow(t_0, 3.0)) / (Math.pow(t_1, 2.0) + (t_0 * (t_0 - t_1)))))))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(lambda1) * math.sin(lambda2) t_1 = math.cos(lambda2) * math.cos(lambda1) return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.log1p(math.expm1(((math.pow(t_1, 3.0) + math.pow(t_0, 3.0)) / (math.pow(t_1, 2.0) + (t_0 * (t_0 - t_1)))))))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * sin(lambda2)) t_1 = Float64(cos(lambda2) * cos(lambda1)) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * log1p(expm1(Float64(Float64((t_1 ^ 3.0) + (t_0 ^ 3.0)) / Float64((t_1 ^ 2.0) + Float64(t_0 * Float64(t_0 - t_1))))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Log[1 + N[(Exp[N[(N[(N[Power[t$95$1, 3.0], $MachinePrecision] + N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[t$95$1, 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \lambda_2 \cdot \cos \lambda_1\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{{t\_1}^{3} + {t\_0}^{3}}{{t\_1}^{2} + t\_0 \cdot \left(t\_0 - t\_1\right)}\right)\right)}
\end{array}
\end{array}
Initial program 80.5%
sin-diff86.2%
Applied egg-rr86.2%
cos-diff99.7%
flip3-+99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
fma-define99.8%
distribute-rgt-out--99.8%
Simplified99.8%
log1p-expm1-u99.8%
fma-undefine99.8%
pow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda2) (cos lambda1)))
(t_1 (* (sin lambda1) (sin lambda2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(+
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(/
(+ (pow t_0 3.0) (pow t_1 3.0))
(- (* t_1 (- t_0 t_1)) (pow t_0 2.0))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda2) * cos(lambda1);
double t_1 = sin(lambda1) * sin(lambda2);
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) + ((cos(phi2) * sin(phi1)) * ((pow(t_0, 3.0) + pow(t_1, 3.0)) / ((t_1 * (t_0 - t_1)) - pow(t_0, 2.0))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(lambda2) * cos(lambda1)
t_1 = sin(lambda1) * sin(lambda2)
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) + ((cos(phi2) * sin(phi1)) * (((t_0 ** 3.0d0) + (t_1 ** 3.0d0)) / ((t_1 * (t_0 - t_1)) - (t_0 ** 2.0d0))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda2) * Math.cos(lambda1);
double t_1 = Math.sin(lambda1) * Math.sin(lambda2);
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) + ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.pow(t_0, 3.0) + Math.pow(t_1, 3.0)) / ((t_1 * (t_0 - t_1)) - Math.pow(t_0, 2.0))))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda2) * math.cos(lambda1) t_1 = math.sin(lambda1) * math.sin(lambda2) return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) + ((math.cos(phi2) * math.sin(phi1)) * ((math.pow(t_0, 3.0) + math.pow(t_1, 3.0)) / ((t_1 * (t_0 - t_1)) - math.pow(t_0, 2.0))))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda2) * cos(lambda1)) t_1 = Float64(sin(lambda1) * sin(lambda2)) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) + Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64((t_0 ^ 3.0) + (t_1 ^ 3.0)) / Float64(Float64(t_1 * Float64(t_0 - t_1)) - (t_0 ^ 2.0)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda2) * cos(lambda1); t_1 = sin(lambda1) * sin(lambda2); tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) + ((cos(phi2) * sin(phi1)) * (((t_0 ^ 3.0) + (t_1 ^ 3.0)) / ((t_1 * (t_0 - t_1)) - (t_0 ^ 2.0)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[t$95$0, 3.0], $MachinePrecision] + N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[(t$95$1 * N[(t$95$0 - t$95$1), $MachinePrecision]), $MachinePrecision] - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \cos \lambda_1\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \frac{{t\_0}^{3} + {t\_1}^{3}}{t\_1 \cdot \left(t\_0 - t\_1\right) - {t\_0}^{2}}}
\end{array}
\end{array}
Initial program 80.5%
sin-diff86.2%
Applied egg-rr86.2%
cos-diff99.7%
flip3-+99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
fma-define99.8%
distribute-rgt-out--99.8%
Simplified99.8%
fma-undefine99.8%
pow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(+
(* t_0 (* (cos lambda2) (cos lambda1)))
(* t_0 (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * (cos(lambda2) * cos(lambda1))) + (t_0 * (sin(lambda1) * sin(lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = cos(phi2) * sin(phi1)
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * (cos(lambda2) * cos(lambda1))) + (t_0 * (sin(lambda1) * sin(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((t_0 * (Math.cos(lambda2) * Math.cos(lambda1))) + (t_0 * (Math.sin(lambda1) * Math.sin(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((t_0 * (math.cos(lambda2) * math.cos(lambda1))) + (t_0 * (math.sin(lambda1) * math.sin(lambda2))))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * Float64(cos(lambda2) * cos(lambda1))) + Float64(t_0 * Float64(sin(lambda1) * sin(lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin(phi1); tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * (cos(lambda2) * cos(lambda1))) + (t_0 * (sin(lambda1) * sin(lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
\end{array}
Initial program 80.5%
sin-diff86.2%
Applied egg-rr86.2%
cos-diff99.7%
distribute-lft-in99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 80.5%
sin-diff86.2%
Applied egg-rr86.2%
cos-diff99.7%
*-commutative99.7%
Applied egg-rr99.7%
fma-define99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 80.5%
sin-diff86.2%
Applied egg-rr86.2%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -2500000000.0) (not (<= lambda1 1.4e-19)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (- (* lambda1 (cos lambda2)) (sin lambda2)))
(- t_0 (* t_1 (+ (cos lambda2) (* lambda1 (sin 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 <= -2500000000.0) || !(lambda1 <= 1.4e-19)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * sin(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 <= (-2500000000.0d0)) .or. (.not. (lambda1 <= 1.4d-19))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * sin(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 <= -2500000000.0) || !(lambda1 <= 1.4e-19)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((lambda1 * Math.cos(lambda2)) - Math.sin(lambda2))), (t_0 - (t_1 * (Math.cos(lambda2) + (lambda1 * Math.sin(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 <= -2500000000.0) or not (lambda1 <= 1.4e-19): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * ((lambda1 * math.cos(lambda2)) - math.sin(lambda2))), (t_0 - (t_1 * (math.cos(lambda2) + (lambda1 * math.sin(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 <= -2500000000.0) || !(lambda1 <= 1.4e-19)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(lambda1 * cos(lambda2)) - sin(lambda2))), Float64(t_0 - Float64(t_1 * Float64(cos(lambda2) + Float64(lambda1 * sin(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 <= -2500000000.0) || ~((lambda1 <= 1.4e-19))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * sin(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, -2500000000.0], N[Not[LessEqual[lambda1, 1.4e-19]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $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[(N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * N[Sin[lambda2], $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 -2500000000 \lor \neg \left(\lambda_1 \leq 1.4 \cdot 10^{-19}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \lambda_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2\right)}{t\_0 - t\_1 \cdot \left(\cos \lambda_2 + \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -2.5e9 or 1.40000000000000001e-19 < lambda1 Initial program 62.6%
sin-diff73.7%
Applied egg-rr73.7%
Taylor expanded in lambda2 around 0 74.0%
if -2.5e9 < lambda1 < 1.40000000000000001e-19Initial program 99.6%
Taylor expanded in lambda1 around 0 99.6%
mul-1-neg99.6%
unsub-neg99.6%
sin-neg99.6%
distribute-rgt-neg-out99.6%
distribute-lft-neg-in99.6%
cancel-sign-sub99.6%
cos-neg99.6%
Simplified99.6%
Taylor expanded in lambda1 around 0 99.8%
+-commutative84.7%
sin-neg84.7%
unsub-neg84.7%
*-commutative84.7%
cos-neg84.7%
Simplified99.8%
Final simplification86.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((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((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((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.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((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.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((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(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), 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((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(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{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.5%
sin-diff86.2%
Applied egg-rr86.2%
Final simplification86.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -1.25e-7) (not (<= phi1 1.1e-9)))
(atan2
(* (cos phi2) (- t_0 (sin lambda2)))
(- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) t_1)))
(atan2
(* (- t_0 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (sin phi2) (* (cos phi2) (* (sin phi1) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.25e-7) || !(phi1 <= 1.1e-9)) {
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_1)));
} else {
tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (cos(phi2) * (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 = sin(lambda1) * cos(lambda2)
t_1 = cos((lambda1 - lambda2))
if ((phi1 <= (-1.25d-7)) .or. (.not. (phi1 <= 1.1d-9))) then
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_1)))
else
tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (cos(phi2) * (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.sin(lambda1) * Math.cos(lambda2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.25e-7) || !(phi1 <= 1.1e-9)) {
tmp = Math.atan2((Math.cos(phi2) * (t_0 - Math.sin(lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
} else {
tmp = Math.atan2(((t_0 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.cos(phi2) * (Math.sin(phi1) * t_1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(lambda1) * math.cos(lambda2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1.25e-7) or not (phi1 <= 1.1e-9): tmp = math.atan2((math.cos(phi2) * (t_0 - math.sin(lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * t_1))) else: tmp = math.atan2(((t_0 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.cos(phi2) * (math.sin(phi1) * t_1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -1.25e-7) || !(phi1 <= 1.1e-9)) tmp = atan(Float64(cos(phi2) * Float64(t_0 - sin(lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); else tmp = atan(Float64(Float64(t_0 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(cos(phi2) * Float64(sin(phi1) * t_1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(lambda1) * cos(lambda2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1.25e-7) || ~((phi1 <= 1.1e-9))) tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_1))); else tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (cos(phi2) * (sin(phi1) * t_1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.25e-7], N[Not[LessEqual[phi1, 1.1e-9]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 - 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] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.25 \cdot 10^{-7} \lor \neg \left(\phi_1 \leq 1.1 \cdot 10^{-9}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t\_0 - \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_1\right)}\\
\end{array}
\end{array}
if phi1 < -1.24999999999999994e-7 or 1.0999999999999999e-9 < phi1 Initial program 70.8%
sin-diff73.7%
Applied egg-rr73.7%
Taylor expanded in lambda1 around 0 71.6%
if -1.24999999999999994e-7 < phi1 < 1.0999999999999999e-9Initial program 90.8%
*-commutative90.8%
associate-*l*90.8%
Simplified90.8%
Taylor expanded in phi1 around 0 90.8%
sin-diff99.6%
Applied egg-rr99.6%
Final simplification85.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (sin lambda1) (cos lambda2)) (sin lambda2))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - sin(lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - sin(lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - Math.sin(lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - math.sin(lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - sin(lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - sin(lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[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(\sin \lambda_1 \cdot \cos \lambda_2 - \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 80.5%
sin-diff86.2%
Applied egg-rr86.2%
Taylor expanded in lambda1 around 0 81.0%
Final simplification81.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (log1p (expm1 (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)) * log1p(expm1(cos((lambda1 - lambda2)))))));
}
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.log1p(Math.expm1(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.log1p(math.expm1(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(Float64(cos(phi2) * sin(phi1)) * log1p(expm1(cos(Float64(lambda1 - lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]] - 1), $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 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\lambda_1 - \lambda_2\right)\right)\right)}
\end{array}
Initial program 80.5%
log1p-expm1-u80.5%
Applied egg-rr80.5%
Final simplification80.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= lambda1 -1.7e+123) (not (<= lambda1 1.4e-19)))
(atan2
(* (sin lambda1) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) t_0)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (cos phi2) (* (sin phi1) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1.7e+123) || !(lambda1 <= 1.4e-19)) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (sin(phi1) * t_0))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if ((lambda1 <= (-1.7d+123)) .or. (.not. (lambda1 <= 1.4d-19))) then
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (sin(phi1) * t_0))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1.7e+123) || !(lambda1 <= 1.4e-19)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * t_0)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(phi2) * (Math.sin(phi1) * t_0))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -1.7e+123) or not (lambda1 <= 1.4e-19): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * t_0))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(phi2) * (math.sin(phi1) * t_0)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((lambda1 <= -1.7e+123) || !(lambda1 <= 1.4e-19)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * t_0))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(phi2) * Float64(sin(phi1) * t_0)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 <= -1.7e+123) || ~((lambda1 <= 1.4e-19))) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (sin(phi1) * t_0)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.7e+123], N[Not[LessEqual[lambda1, 1.4e-19]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -1.7 \cdot 10^{+123} \lor \neg \left(\lambda_1 \leq 1.4 \cdot 10^{-19}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t\_0\right)}\\
\end{array}
\end{array}
if lambda1 < -1.70000000000000001e123 or 1.40000000000000001e-19 < lambda1 Initial program 61.7%
Taylor expanded in lambda2 around 0 61.4%
if -1.70000000000000001e123 < lambda1 < 1.40000000000000001e-19Initial program 94.0%
*-commutative94.0%
associate-*l*94.0%
Simplified94.0%
Taylor expanded in phi1 around 0 81.1%
Final simplification72.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -28000000000000.0) (not (<= lambda1 3e+14)))
(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 <= -28000000000000.0) || !(lambda1 <= 3e+14)) {
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 <= (-28000000000000.0d0)) .or. (.not. (lambda1 <= 3d+14))) 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 <= -28000000000000.0) || !(lambda1 <= 3e+14)) {
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 <= -28000000000000.0) or not (lambda1 <= 3e+14): 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 <= -28000000000000.0) || !(lambda1 <= 3e+14)) 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 <= -28000000000000.0) || ~((lambda1 <= 3e+14))) 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, -28000000000000.0], N[Not[LessEqual[lambda1, 3e+14]], $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 -28000000000000 \lor \neg \left(\lambda_1 \leq 3 \cdot 10^{+14}\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.8e13 or 3e14 < lambda1 Initial program 63.8%
Taylor expanded in lambda2 around 0 62.0%
if -2.8e13 < lambda1 < 3e14Initial program 94.6%
Taylor expanded in lambda1 around 0 94.6%
*-commutative94.6%
cos-neg94.6%
Simplified94.6%
Final simplification79.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda1 -2500000000.0)
(atan2 t_2 (- t_0 (* (cos lambda1) t_1)))
(if (<= lambda1 2.8e+14)
(atan2 t_2 (- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* t_1 (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(phi1);
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -2500000000.0) {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)));
} else if (lambda1 <= 2.8e+14) {
tmp = atan2(t_2, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * 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(phi1)
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda1 <= (-2500000000.0d0)) then
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)))
else if (lambda1 <= 2.8d+14) then
tmp = atan2(t_2, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * 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(phi1);
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -2500000000.0) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * t_1)));
} else if (lambda1 <= 2.8e+14) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (t_1 * 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(phi1) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda1 <= -2500000000.0: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * t_1))) elif lambda1 <= 2.8e+14: tmp = math.atan2(t_2, (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (t_1 * 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(phi1)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda1 <= -2500000000.0) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * t_1))); elseif (lambda1 <= 2.8e+14) tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(t_1 * 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(phi1); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda1 <= -2500000000.0) tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1))); elseif (lambda1 <= 2.8e+14) tmp = atan2(t_2, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * 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[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -2500000000.0], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 2.8e+14], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * 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 \phi_1\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -2500000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \lambda_1 \cdot t\_1}\\
\mathbf{elif}\;\lambda_1 \leq 2.8 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -2.5e9Initial program 57.3%
Taylor expanded in lambda2 around 0 57.4%
if -2.5e9 < lambda1 < 2.8e14Initial program 95.2%
Taylor expanded in lambda1 around 0 95.2%
*-commutative95.2%
cos-neg95.2%
Simplified95.2%
if 2.8e14 < lambda1 Initial program 71.5%
Taylor expanded in lambda2 around 0 71.9%
Final simplification80.6%
(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 80.5%
*-commutative80.5%
associate-*l*80.5%
Simplified80.5%
Final simplification80.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.0046) (not (<= phi2 5.2e-122)))
(atan2
(* (cos phi2) t_0)
(- (sin phi2) (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(atan2 t_0 (* (sin phi1) (- (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0046) || !(phi2 <= 5.2e-122)) {
tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else {
tmp = atan2(t_0, (sin(phi1) * -cos((lambda2 - lambda1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.0046d0)) .or. (.not. (phi2 <= 5.2d-122))) then
tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else
tmp = atan2(t_0, (sin(phi1) * -cos((lambda2 - lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0046) || !(phi2 <= 5.2e-122)) {
tmp = Math.atan2((Math.cos(phi2) * t_0), (Math.sin(phi2) - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi1) * -Math.cos((lambda2 - lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.0046) or not (phi2 <= 5.2e-122): tmp = math.atan2((math.cos(phi2) * t_0), (math.sin(phi2) - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) else: tmp = math.atan2(t_0, (math.sin(phi1) * -math.cos((lambda2 - lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.0046) || !(phi2 <= 5.2e-122)) tmp = atan(Float64(cos(phi2) * t_0), Float64(sin(phi2) - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); else tmp = atan(t_0, Float64(sin(phi1) * Float64(-cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.0046) || ~((phi2 <= 5.2e-122))) tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1))))); else tmp = atan2(t_0, (sin(phi1) * -cos((lambda2 - lambda1)))); 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.0046], N[Not[LessEqual[phi2, 5.2e-122]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda2 - lambda1), $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.0046 \lor \neg \left(\phi_2 \leq 5.2 \cdot 10^{-122}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\sin \phi_2 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_2 - \lambda_1\right)\right)}\\
\end{array}
\end{array}
if phi2 < -0.0045999999999999999 or 5.1999999999999995e-122 < phi2 Initial program 80.3%
*-commutative80.3%
associate-*l*80.3%
Simplified80.3%
Taylor expanded in phi1 around 0 60.4%
Taylor expanded in lambda2 around 0 59.7%
if -0.0045999999999999999 < phi2 < 5.1999999999999995e-122Initial program 80.8%
*-commutative80.8%
associate-*l*80.8%
Simplified80.8%
Taylor expanded in phi1 around 0 79.1%
Taylor expanded in phi2 around 0 79.1%
Taylor expanded in phi2 around 0 79.1%
Taylor expanded in phi2 around 0 79.2%
neg-mul-179.2%
distribute-rgt-neg-in79.2%
sub-neg79.2%
remove-double-neg79.2%
mul-1-neg79.2%
distribute-neg-in79.2%
+-commutative79.2%
cos-neg79.2%
mul-1-neg79.2%
unsub-neg79.2%
Simplified79.2%
Final simplification67.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.00048) (not (<= phi2 3.5e-5)))
(atan2
(* (cos phi2) t_0)
(- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1))))
(atan2
t_0
(expm1
(log1p (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00048) || !(phi2 <= 3.5e-5)) {
tmp = atan2((cos(phi2) * t_0), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
} else {
tmp = atan2(t_0, expm1(log1p((sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00048) || !(phi2 <= 3.5e-5)) {
tmp = Math.atan2((Math.cos(phi2) * t_0), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, Math.expm1(Math.log1p((Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.00048) or not (phi2 <= 3.5e-5): tmp = math.atan2((math.cos(phi2) * t_0), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * math.sin(phi1)))) else: tmp = math.atan2(t_0, math.expm1(math.log1p((math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.00048) || !(phi2 <= 3.5e-5)) tmp = atan(Float64(cos(phi2) * t_0), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))); else tmp = atan(t_0, expm1(log1p(Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00048], N[Not[LessEqual[phi2, 3.5e-5]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(Exp[N[Log[1 + N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.00048 \lor \neg \left(\phi_2 \leq 3.5 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)}\\
\end{array}
\end{array}
if phi2 < -4.80000000000000012e-4 or 3.4999999999999997e-5 < phi2 Initial program 78.8%
Taylor expanded in lambda1 around 0 64.7%
mul-1-neg64.7%
unsub-neg64.7%
sin-neg64.7%
distribute-rgt-neg-out64.7%
distribute-lft-neg-in64.7%
cancel-sign-sub64.7%
cos-neg64.7%
Simplified64.7%
Taylor expanded in lambda2 around 0 59.1%
*-commutative59.1%
Simplified59.1%
if -4.80000000000000012e-4 < phi2 < 3.4999999999999997e-5Initial program 82.2%
*-commutative82.2%
associate-*l*82.2%
Simplified82.2%
Taylor expanded in phi1 around 0 81.5%
Taylor expanded in phi2 around 0 81.5%
Taylor expanded in phi2 around 0 81.5%
expm1-log1p-u81.5%
Applied egg-rr81.5%
sub-neg81.5%
remove-double-neg81.5%
mul-1-neg81.5%
distribute-neg-in81.5%
+-commutative81.5%
*-commutative81.5%
cos-neg81.5%
mul-1-neg81.5%
unsub-neg81.5%
Simplified81.5%
Final simplification70.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 -3.9e+14)
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1))))
(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 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -3.9e+14) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
} 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 = cos(phi2) * sin((lambda1 - lambda2))
if (phi2 <= (-3.9d+14)) then
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))))
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.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -3.9e+14) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
} 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.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -3.9e+14: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * math.sin(phi1)))) 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 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= -3.9e+14) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))); 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 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -3.9e+14) tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1)))); 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[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.9e+14], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $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 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -3.9 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\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.9e14Initial program 75.2%
Taylor expanded in lambda1 around 0 62.2%
mul-1-neg62.2%
unsub-neg62.2%
sin-neg62.2%
distribute-rgt-neg-out62.2%
distribute-lft-neg-in62.2%
cancel-sign-sub62.2%
cos-neg62.2%
Simplified62.2%
Taylor expanded in lambda2 around 0 54.5%
*-commutative54.5%
Simplified54.5%
if -3.9e14 < phi2 Initial program 82.1%
*-commutative82.1%
associate-*l*82.1%
Simplified82.1%
Taylor expanded in phi1 around 0 73.7%
Final simplification69.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 3.3e+14)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= 3.3e+14) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (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) :: tmp
if (lambda1 <= 3.3d+14) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (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 tmp;
if (lambda1 <= 3.3e+14) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= 3.3e+14: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= 3.3e+14) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), 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) tmp = 0.0; if (lambda1 <= 3.3e+14) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, 3.3e+14], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / 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}
\mathbf{if}\;\lambda_1 \leq 3.3 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\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 lambda1 < 3.3e14Initial program 83.0%
*-commutative83.0%
associate-*l*83.0%
Simplified83.0%
Taylor expanded in phi1 around 0 71.0%
Taylor expanded in lambda1 around 0 69.7%
cos-neg69.7%
Simplified69.7%
if 3.3e14 < lambda1 Initial program 71.5%
*-commutative71.5%
associate-*l*71.5%
Simplified71.5%
Taylor expanded in phi1 around 0 55.7%
Taylor expanded in lambda2 around 0 56.0%
Final simplification66.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos (- lambda1 lambda2))))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (- (sin phi2) (* (cos phi2) t_0))))
(if (<= (- lambda1 lambda2) -200.0)
(atan2 t_1 t_2)
(if (<= (- lambda1 lambda2) 5e-6)
(atan2 (* (cos phi2) (- lambda1 lambda2)) t_2)
(atan2 t_1 (- (sin phi2) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double t_2 = sin(phi2) - (cos(phi2) * t_0);
double tmp;
if ((lambda1 - lambda2) <= -200.0) {
tmp = atan2(t_1, t_2);
} else if ((lambda1 - lambda2) <= 5e-6) {
tmp = atan2((cos(phi2) * (lambda1 - lambda2)), t_2);
} else {
tmp = atan2(t_1, (sin(phi2) - t_0));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
t_2 = sin(phi2) - (cos(phi2) * t_0)
if ((lambda1 - lambda2) <= (-200.0d0)) then
tmp = atan2(t_1, t_2)
else if ((lambda1 - lambda2) <= 5d-6) then
tmp = atan2((cos(phi2) * (lambda1 - lambda2)), t_2)
else
tmp = atan2(t_1, (sin(phi2) - t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double t_2 = Math.sin(phi2) - (Math.cos(phi2) * t_0);
double tmp;
if ((lambda1 - lambda2) <= -200.0) {
tmp = Math.atan2(t_1, t_2);
} else if ((lambda1 - lambda2) <= 5e-6) {
tmp = Math.atan2((Math.cos(phi2) * (lambda1 - lambda2)), t_2);
} else {
tmp = Math.atan2(t_1, (Math.sin(phi2) - t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) t_2 = math.sin(phi2) - (math.cos(phi2) * t_0) tmp = 0 if (lambda1 - lambda2) <= -200.0: tmp = math.atan2(t_1, t_2) elif (lambda1 - lambda2) <= 5e-6: tmp = math.atan2((math.cos(phi2) * (lambda1 - lambda2)), t_2) else: tmp = math.atan2(t_1, (math.sin(phi2) - t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi2) - Float64(cos(phi2) * t_0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -200.0) tmp = atan(t_1, t_2); elseif (Float64(lambda1 - lambda2) <= 5e-6) tmp = atan(Float64(cos(phi2) * Float64(lambda1 - lambda2)), t_2); else tmp = atan(t_1, Float64(sin(phi2) - t_0)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); t_2 = sin(phi2) - (cos(phi2) * t_0); tmp = 0.0; if ((lambda1 - lambda2) <= -200.0) tmp = atan2(t_1, t_2); elseif ((lambda1 - lambda2) <= 5e-6) tmp = atan2((cos(phi2) * (lambda1 - lambda2)), t_2); else tmp = atan2(t_1, (sin(phi2) - t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -200.0], N[ArcTan[t$95$1 / t$95$2], $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e-6], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_2 - \cos \phi_2 \cdot t\_0\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -200:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2}\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 - \lambda_2\right)}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -200Initial program 69.0%
*-commutative69.0%
associate-*l*69.0%
Simplified69.0%
Taylor expanded in phi1 around 0 57.4%
Taylor expanded in phi2 around 0 41.6%
if -200 < (-.f64 lambda1 lambda2) < 5.00000000000000041e-6Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in phi1 around 0 89.2%
Taylor expanded in lambda1 around 0 88.8%
+-commutative88.8%
sin-neg88.8%
unsub-neg88.8%
*-commutative88.8%
cos-neg88.8%
Simplified88.8%
Taylor expanded in lambda2 around 0 87.5%
+-commutative87.5%
associate-*r*87.5%
neg-mul-187.5%
distribute-rgt-out87.5%
sub-neg87.5%
Simplified87.5%
if 5.00000000000000041e-6 < (-.f64 lambda1 lambda2) Initial program 79.0%
*-commutative79.0%
associate-*l*79.0%
Simplified79.0%
Taylor expanded in phi1 around 0 63.3%
Taylor expanded in phi2 around 0 45.1%
Taylor expanded in phi2 around 0 45.2%
Final simplification54.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (cos (- lambda2 lambda1))))
(if (<= phi1 -0.0125)
(atan2 t_0 (- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))
(if (<= phi1 140.0)
(atan2 (* (cos phi2) t_0) (- (sin phi2) (* (cos phi2) (* phi1 t_1))))
(atan2 t_0 (* (sin phi1) (- t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -0.0125) {
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else if (phi1 <= 140.0) {
tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(phi2) * (phi1 * t_1))));
} else {
tmp = atan2(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 = sin((lambda1 - lambda2))
t_1 = cos((lambda2 - lambda1))
if (phi1 <= (-0.0125d0)) then
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))))
else if (phi1 <= 140.0d0) then
tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(phi2) * (phi1 * t_1))))
else
tmp = atan2(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.sin((lambda1 - lambda2));
double t_1 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -0.0125) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else if (phi1 <= 140.0) {
tmp = Math.atan2((Math.cos(phi2) * t_0), (Math.sin(phi2) - (Math.cos(phi2) * (phi1 * t_1))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi1) * -t_1));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -0.0125: tmp = math.atan2(t_0, (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) elif phi1 <= 140.0: tmp = math.atan2((math.cos(phi2) * t_0), (math.sin(phi2) - (math.cos(phi2) * (phi1 * t_1)))) else: tmp = math.atan2(t_0, (math.sin(phi1) * -t_1)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -0.0125) tmp = atan(t_0, Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); elseif (phi1 <= 140.0) tmp = atan(Float64(cos(phi2) * t_0), Float64(sin(phi2) - Float64(cos(phi2) * Float64(phi1 * t_1)))); else tmp = atan(t_0, Float64(sin(phi1) * Float64(-t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi1 <= -0.0125) tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); elseif (phi1 <= 140.0) tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(phi2) * (phi1 * t_1)))); else tmp = atan2(t_0, (sin(phi1) * -t_1)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0125], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 140.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi1], $MachinePrecision] * (-t$95$1)), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -0.0125:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\phi_1 \leq 140:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\sin \phi_2 - \cos \phi_2 \cdot \left(\phi_1 \cdot t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_1 \cdot \left(-t\_1\right)}\\
\end{array}
\end{array}
if phi1 < -0.012500000000000001Initial program 68.7%
*-commutative68.7%
associate-*l*68.7%
Simplified68.7%
Taylor expanded in phi1 around 0 45.8%
Taylor expanded in phi2 around 0 43.6%
Taylor expanded in phi2 around 0 43.6%
if -0.012500000000000001 < phi1 < 140Initial program 90.7%
*-commutative90.7%
associate-*l*90.7%
Simplified90.7%
Taylor expanded in phi1 around 0 90.0%
Taylor expanded in phi1 around 0 90.1%
sub-neg90.1%
remove-double-neg90.1%
mul-1-neg90.1%
distribute-neg-in90.1%
+-commutative90.1%
cos-neg90.1%
mul-1-neg90.1%
unsub-neg90.1%
Simplified90.1%
if 140 < phi1 Initial program 71.8%
*-commutative71.8%
associate-*l*71.8%
Simplified71.8%
Taylor expanded in phi1 around 0 45.0%
Taylor expanded in phi2 around 0 36.6%
Taylor expanded in phi2 around 0 36.6%
Taylor expanded in phi2 around 0 36.7%
neg-mul-136.7%
distribute-rgt-neg-in36.7%
sub-neg36.7%
remove-double-neg36.7%
mul-1-neg36.7%
distribute-neg-in36.7%
+-commutative36.7%
cos-neg36.7%
mul-1-neg36.7%
unsub-neg36.7%
Simplified36.7%
Final simplification65.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (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(sin((lambda1 - lambda2)), (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.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 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}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 80.5%
*-commutative80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in phi1 around 0 67.7%
Taylor expanded in phi2 around 0 48.6%
Final simplification48.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 3700000.0)
(atan2 t_0 (- phi2 (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 t_0 (- (sin phi2) (* (cos lambda1) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 3700000.0) {
tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (phi2 <= 3700000.0d0) then
tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 3700000.0) {
tmp = Math.atan2(t_0, (phi2 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 3700000.0: tmp = math.atan2(t_0, (phi2 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 3700000.0) tmp = atan(t_0, Float64(phi2 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 3700000.0) tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 3700000.0], N[ArcTan[t$95$0 / N[(phi2 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 3700000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < 3.7e6Initial program 79.9%
*-commutative79.9%
associate-*l*79.9%
Simplified79.9%
Taylor expanded in phi1 around 0 70.5%
Taylor expanded in phi2 around 0 60.0%
Taylor expanded in phi2 around 0 60.0%
Taylor expanded in phi2 around 0 59.1%
neg-mul-159.1%
unsub-neg59.1%
sub-neg59.1%
remove-double-neg59.1%
mul-1-neg59.1%
distribute-neg-in59.1%
+-commutative59.1%
*-commutative59.1%
cos-neg59.1%
mul-1-neg59.1%
unsub-neg59.1%
Simplified59.1%
if 3.7e6 < phi2 Initial program 82.2%
*-commutative82.2%
associate-*l*82.2%
Simplified82.2%
Taylor expanded in phi1 around 0 59.9%
Taylor expanded in phi2 around 0 16.2%
Taylor expanded in phi2 around 0 16.1%
Taylor expanded in lambda2 around 0 15.9%
Final simplification47.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 2.3e-35)
(atan2
(sin (- lambda1 lambda2))
(- (sin phi2) (* (cos lambda2) (sin phi1))))
(atan2
(sin lambda1)
(- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= 2.3e-35) {
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda2) * sin(phi1))));
} else {
tmp = atan2(sin(lambda1), (sin(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) :: tmp
if (lambda1 <= 2.3d-35) then
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda2) * sin(phi1))))
else
tmp = atan2(sin(lambda1), (sin(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 tmp;
if (lambda1 <= 2.3e-35) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.cos(lambda2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= 2.3e-35: tmp = math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.cos(lambda2) * math.sin(phi1)))) else: tmp = math.atan2(math.sin(lambda1), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= 2.3e-35) tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(cos(lambda2) * sin(phi1)))); else tmp = atan(sin(lambda1), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= 2.3e-35) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda2) * sin(phi1)))); else tmp = atan2(sin(lambda1), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, 2.3e-35], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq 2.3 \cdot 10^{-35}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < 2.2999999999999999e-35Initial program 84.6%
*-commutative84.6%
associate-*l*84.6%
Simplified84.6%
Taylor expanded in phi1 around 0 72.9%
Taylor expanded in phi2 around 0 52.3%
Taylor expanded in phi2 around 0 52.3%
Taylor expanded in lambda1 around 0 50.9%
cos-neg50.9%
Simplified50.9%
if 2.2999999999999999e-35 < lambda1 Initial program 69.9%
*-commutative69.9%
associate-*l*69.9%
Simplified69.9%
Taylor expanded in phi1 around 0 54.5%
Taylor expanded in phi2 around 0 39.0%
Taylor expanded in phi2 around 0 39.0%
Taylor expanded in lambda2 around 0 40.5%
Final simplification48.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (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(sin((lambda1 - lambda2)), (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.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.5%
*-commutative80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in phi1 around 0 67.7%
Taylor expanded in phi2 around 0 48.6%
Taylor expanded in phi2 around 0 48.5%
Final simplification48.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 2.4e-24)
(atan2 t_0 (- phi2 (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 2.4e-24) {
tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda2 - lambda1)))));
} 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 = sin((lambda1 - lambda2))
if (phi2 <= 2.4d-24) then
tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda2 - lambda1)))))
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.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 2.4e-24) {
tmp = Math.atan2(t_0, (phi2 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 2.4e-24: tmp = math.atan2(t_0, (phi2 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 2.4e-24) tmp = atan(t_0, Float64(phi2 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 2.4e-24) tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2(t_0, sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 2.4e-24], N[ArcTan[t$95$0 / N[(phi2 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 2.4 \cdot 10^{-24}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 2.3999999999999998e-24Initial program 80.1%
*-commutative80.1%
associate-*l*80.1%
Simplified80.1%
Taylor expanded in phi1 around 0 70.2%
Taylor expanded in phi2 around 0 59.8%
Taylor expanded in phi2 around 0 59.8%
Taylor expanded in phi2 around 0 58.9%
neg-mul-158.9%
unsub-neg58.9%
sub-neg58.9%
remove-double-neg58.9%
mul-1-neg58.9%
distribute-neg-in58.9%
+-commutative58.9%
*-commutative58.9%
cos-neg58.9%
mul-1-neg58.9%
unsub-neg58.9%
Simplified58.9%
if 2.3999999999999998e-24 < phi2 Initial program 81.6%
*-commutative81.6%
associate-*l*81.6%
Simplified81.6%
Taylor expanded in phi1 around 0 61.8%
Taylor expanded in phi2 around 0 21.4%
Taylor expanded in phi2 around 0 21.3%
Taylor expanded in phi1 around 0 21.0%
Final simplification47.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (* (sin phi1) (- (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda2 - lambda1))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda2 - lambda1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi1) * -Math.cos((lambda2 - lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi1) * -math.cos((lambda2 - lambda1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi1) * Float64(-cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda2 - lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_2 - \lambda_1\right)\right)}
\end{array}
Initial program 80.5%
*-commutative80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in phi1 around 0 67.7%
Taylor expanded in phi2 around 0 48.6%
Taylor expanded in phi2 around 0 48.5%
Taylor expanded in phi2 around 0 45.0%
neg-mul-145.0%
distribute-rgt-neg-in45.0%
sub-neg45.0%
remove-double-neg45.0%
mul-1-neg45.0%
distribute-neg-in45.0%
+-commutative45.0%
cos-neg45.0%
mul-1-neg45.0%
unsub-neg45.0%
Simplified45.0%
Final simplification45.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), sin(phi2));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}
\end{array}
Initial program 80.5%
*-commutative80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in phi1 around 0 67.7%
Taylor expanded in phi2 around 0 48.6%
Taylor expanded in phi2 around 0 48.5%
Taylor expanded in phi1 around 0 34.3%
Final simplification34.3%
herbie shell --seed 2024050
(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))))))