
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 21 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right)\right) \cdot R
\end{array}
Initial program 74.9%
Simplified74.9%
cos-diff93.9%
+-commutative93.9%
Applied egg-rr93.9%
Final simplification93.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))
(* (cos phi1) (cos phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) * (cos(phi1) * cos(phi2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + (((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) * (cos(phi1) * cos(phi2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))) * (Math.cos(phi1) * Math.cos(phi2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))) * (math.cos(phi1) * math.cos(phi2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) * Float64(cos(phi1) * cos(phi2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) * (cos(phi1) * cos(phi2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)
\end{array}
Initial program 74.9%
cos-diff93.9%
+-commutative93.9%
Applied egg-rr93.9%
Final simplification93.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -4.5e-7)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))
(if (<= phi2 3.9e-5)
(*
R
(acos
(+
t_1
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (acos (+ t_1 (* (cos phi2) (* (cos phi1) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -4.5e-7) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
} else if (phi2 <= 3.9e-5) {
tmp = R * acos((t_1 + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos((t_1 + (cos(phi2) * (cos(phi1) * t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -4.5e-7) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); elseif (phi2 <= 3.9e-5) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * Float64(cos(phi1) * t_0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -4.5e-7], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3.9e-5], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -4.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 3.9 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\\
\end{array}
\end{array}
if phi2 < -4.4999999999999998e-7Initial program 81.8%
Simplified81.9%
if -4.4999999999999998e-7 < phi2 < 3.8999999999999999e-5Initial program 68.9%
cos-diff88.7%
+-commutative88.7%
Applied egg-rr88.7%
Taylor expanded in phi2 around 0 88.6%
if 3.8999999999999999e-5 < phi2 Initial program 80.6%
log1p-expm1-u80.6%
log1p-udef80.5%
*-commutative80.5%
Applied egg-rr80.5%
log1p-def80.6%
log1p-expm1-u80.6%
associate-*r*80.7%
Applied egg-rr80.7%
Final simplification85.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -1.12e-7)
(* R (acos (+ t_1 (* (cos phi2) (* (cos phi1) t_0)))))
(if (<= phi1 1.65e-6)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* phi1 (sin phi2)))))
(*
R
(acos (+ t_1 (* (* (cos phi1) (cos phi2)) (pow (cbrt t_0) 3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -1.12e-7) {
tmp = R * acos((t_1 + (cos(phi2) * (cos(phi1) * t_0))));
} else if (phi1 <= 1.65e-6) {
tmp = R * acos(((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * pow(cbrt(t_0), 3.0))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -1.12e-7) {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * (Math.cos(phi1) * t_0))));
} else if (phi1 <= 1.65e-6) {
tmp = R * Math.acos(((Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos((t_1 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.pow(Math.cbrt(t_0), 3.0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -1.12e-7) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * Float64(cos(phi1) * t_0))))); elseif (phi1 <= 1.65e-6) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * (cbrt(t_0) ^ 3.0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.12e-7], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.65e-6], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.12 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.65 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot {\left(\sqrt[3]{t_0}\right)}^{3}\right)\\
\end{array}
\end{array}
if phi1 < -1.12e-7Initial program 83.5%
log1p-expm1-u83.5%
log1p-udef83.4%
*-commutative83.4%
Applied egg-rr83.4%
log1p-def83.5%
log1p-expm1-u83.5%
associate-*r*83.5%
Applied egg-rr83.5%
if -1.12e-7 < phi1 < 1.65000000000000008e-6Initial program 66.0%
Simplified66.0%
Taylor expanded in phi1 around 0 66.0%
cos-diff88.0%
+-commutative88.0%
Applied egg-rr88.0%
if 1.65000000000000008e-6 < phi1 Initial program 81.5%
add-cube-cbrt81.4%
pow381.4%
Applied egg-rr81.4%
Final simplification85.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -1.65e-6)
(* R (acos (+ t_1 (* (cos phi2) (* (cos phi1) t_0)))))
(if (<= phi1 3.3e-8)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* phi1 (sin phi2)))))
(* R (acos (+ t_1 (* (* (cos phi1) (cos phi2)) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -1.65e-6) {
tmp = R * acos((t_1 + (cos(phi2) * (cos(phi1) * t_0))));
} else if (phi1 <= 3.3e-8) {
tmp = R * acos(((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
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((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-1.65d-6)) then
tmp = r * acos((t_1 + (cos(phi2) * (cos(phi1) * t_0))))
else if (phi1 <= 3.3d-8) then
tmp = r * acos(((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2))))
else
tmp = r * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -1.65e-6) {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * (Math.cos(phi1) * t_0))));
} else if (phi1 <= 3.3e-8) {
tmp = R * Math.acos(((Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos((t_1 + ((Math.cos(phi1) * Math.cos(phi2)) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -1.65e-6: tmp = R * math.acos((t_1 + (math.cos(phi2) * (math.cos(phi1) * t_0)))) elif phi1 <= 3.3e-8: tmp = R * math.acos(((math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos((t_1 + ((math.cos(phi1) * math.cos(phi2)) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -1.65e-6) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * Float64(cos(phi1) * t_0))))); elseif (phi1 <= 3.3e-8) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -1.65e-6) tmp = R * acos((t_1 + (cos(phi2) * (cos(phi1) * t_0)))); elseif (phi1 <= 3.3e-8) tmp = R * acos(((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2)))); else tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.65e-6], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.3e-8], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.65 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 3.3 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
\end{array}
\end{array}
if phi1 < -1.65000000000000008e-6Initial program 83.5%
log1p-expm1-u83.5%
log1p-udef83.4%
*-commutative83.4%
Applied egg-rr83.4%
log1p-def83.5%
log1p-expm1-u83.5%
associate-*r*83.5%
Applied egg-rr83.5%
if -1.65000000000000008e-6 < phi1 < 3.29999999999999977e-8Initial program 66.0%
Simplified66.0%
Taylor expanded in phi1 around 0 66.0%
cos-diff88.0%
+-commutative88.0%
Applied egg-rr88.0%
if 3.29999999999999977e-8 < phi1 Initial program 81.5%
Final simplification85.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -4.5e-5)
(* R (acos (+ t_0 (* (cos phi2) (cos (- lambda2 lambda1))))))
(* R (acos (+ t_0 (* (cos phi2) (* (cos phi1) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -4.5e-5) {
tmp = R * acos((t_0 + (cos(phi2) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
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(phi1) * sin(phi2)
if (lambda1 <= (-4.5d-5)) then
tmp = r * acos((t_0 + (cos(phi2) * cos((lambda2 - lambda1)))))
else
tmp = r * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -4.5e-5) {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -4.5e-5: tmp = R * math.acos((t_0 + (math.cos(phi2) * math.cos((lambda2 - lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -4.5e-5) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * cos(Float64(lambda2 - lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -4.5e-5) tmp = R * acos((t_0 + (cos(phi2) * cos((lambda2 - lambda1))))); else tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -4.5e-5], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -4.5 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -4.50000000000000028e-5Initial program 55.8%
Taylor expanded in phi1 around 0 32.6%
sub-neg32.6%
neg-mul-132.6%
neg-mul-132.6%
remove-double-neg32.6%
mul-1-neg32.6%
distribute-neg-in32.6%
+-commutative32.6%
cos-neg32.6%
mul-1-neg32.6%
unsub-neg32.6%
Simplified32.6%
if -4.50000000000000028e-5 < lambda1 Initial program 80.9%
cos-diff92.2%
+-commutative92.2%
Applied egg-rr92.2%
Taylor expanded in lambda1 around 0 64.9%
cos-neg64.9%
associate-*r*64.9%
*-commutative64.9%
*-commutative64.9%
cos-neg64.9%
Simplified64.9%
Final simplification57.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -3.4e-8)
(* R (acos (+ t_0 (* (cos phi2) (* (cos phi1) (cos lambda1))))))
(* R (acos (+ t_0 (* (cos phi2) (* (cos phi1) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -3.4e-8) {
tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda1)))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
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(phi1) * sin(phi2)
if (lambda1 <= (-3.4d-8)) then
tmp = r * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda1)))))
else
tmp = r * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -3.4e-8) {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -3.4e-8: tmp = R * math.acos((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -3.4e-8) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -3.4e-8) tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda1))))); else tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -3.4e-8], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -3.4 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -3.4e-8Initial program 56.5%
add-sqr-sqrt20.0%
pow220.0%
*-commutative20.0%
Applied egg-rr20.0%
Taylor expanded in lambda2 around 0 55.6%
associate-*r*55.6%
*-commutative55.6%
Simplified55.6%
if -3.4e-8 < lambda1 Initial program 80.8%
cos-diff92.2%
+-commutative92.2%
Applied egg-rr92.1%
Taylor expanded in lambda1 around 0 64.8%
cos-neg64.8%
associate-*r*64.8%
*-commutative64.8%
*-commutative64.8%
cos-neg64.8%
Simplified64.8%
Final simplification62.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 74.9%
Final simplification74.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi2) (* (cos phi1) (cos (- lambda1 lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos((lambda1 - lambda2))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos((lambda1 - lambda2))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * (math.cos(phi1) * math.cos((lambda1 - lambda2))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * Float64(cos(phi1) * cos(Float64(lambda1 - lambda2))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos((lambda1 - lambda2)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)
\end{array}
Initial program 74.9%
log1p-expm1-u74.8%
log1p-udef74.8%
*-commutative74.8%
Applied egg-rr74.8%
log1p-def74.8%
log1p-expm1-u74.9%
associate-*r*74.9%
Applied egg-rr74.9%
Final simplification74.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.0017)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(if (<= phi1 0.0032)
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2)))))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.0017) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else if (phi1 <= 0.0032) {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
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 (phi1 <= (-0.0017d0)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else if (phi1 <= 0.0032d0) then
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.0017) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 0.0032) {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -0.0017: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) elif phi1 <= 0.0032: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.0017) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 0.0032) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -0.0017) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); elseif (phi1 <= 0.0032) tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0017], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.0032], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.0017:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.0032:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_0 + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -0.00169999999999999991Initial program 83.5%
Simplified83.5%
Taylor expanded in phi2 around 0 41.6%
if -0.00169999999999999991 < phi1 < 0.00320000000000000015Initial program 65.9%
Simplified65.9%
Taylor expanded in phi1 around 0 65.5%
if 0.00320000000000000015 < phi1 Initial program 82.2%
Simplified82.2%
Taylor expanded in lambda2 around 0 66.9%
Taylor expanded in lambda1 around 0 41.8%
Final simplification52.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi1 -8.2e-5)
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1))))))
(if (<= phi1 0.011)
(*
R
(acos
(+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 (sin phi2)))))
(* R (acos (+ t_0 (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -8.2e-5) {
tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))));
} else if (phi1 <= 0.011) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * cos(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
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(phi1) * sin(phi2)
if (phi1 <= (-8.2d-5)) then
tmp = r * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))
else if (phi1 <= 0.011d0) then
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
else
tmp = r * acos((t_0 + (cos(phi1) * cos(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -8.2e-5) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (phi1 <= 0.011) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -8.2e-5: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) elif phi1 <= 0.011: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -8.2e-5) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); elseif (phi1 <= 0.011) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -8.2e-5) tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))); elseif (phi1 <= 0.011) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); else tmp = R * acos((t_0 + (cos(phi1) * cos(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -8.2e-5], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.011], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -8.2 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.011:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -8.20000000000000009e-5Initial program 83.5%
Taylor expanded in phi2 around 0 51.5%
sub-neg51.5%
remove-double-neg51.5%
mul-1-neg51.5%
distribute-neg-in51.5%
+-commutative51.5%
cos-neg51.5%
mul-1-neg51.5%
unsub-neg51.5%
Simplified51.5%
if -8.20000000000000009e-5 < phi1 < 0.010999999999999999Initial program 65.9%
Simplified65.9%
Taylor expanded in phi1 around 0 65.5%
if 0.010999999999999999 < phi1 Initial program 82.2%
Simplified82.2%
Taylor expanded in lambda2 around 0 66.9%
Taylor expanded in lambda1 around 0 41.8%
Final simplification55.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -7e-5)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(* R (acos (+ t_1 (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -7e-5) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-7d-5)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else
tmp = r * acos((t_1 + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -7e-5) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -7e-5: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -7e-5) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -7e-5) tmp = R * acos((t_1 + (cos(phi1) * t_0))); else tmp = R * acos((t_1 + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -7e-5], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot t_0\right)\\
\end{array}
\end{array}
if phi1 < -6.9999999999999994e-5Initial program 83.5%
Taylor expanded in phi2 around 0 51.5%
sub-neg51.5%
remove-double-neg51.5%
mul-1-neg51.5%
distribute-neg-in51.5%
+-commutative51.5%
cos-neg51.5%
mul-1-neg51.5%
unsub-neg51.5%
Simplified51.5%
if -6.9999999999999994e-5 < phi1 Initial program 71.8%
Taylor expanded in phi1 around 0 48.1%
sub-neg48.1%
neg-mul-148.1%
neg-mul-148.1%
remove-double-neg48.1%
mul-1-neg48.1%
distribute-neg-in48.1%
+-commutative48.1%
cos-neg48.1%
mul-1-neg48.1%
unsub-neg48.1%
Simplified48.1%
Final simplification49.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= phi1 -0.029)
(* R (acos (* (cos phi1) (cos lambda1))))
(if (<= phi1 -4.8e-148)
(* R (acos (+ (cos (- lambda1 lambda2)) t_0)))
(* R (acos (+ t_0 (* (cos phi2) (cos lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (phi1 <= -0.029) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else if (phi1 <= -4.8e-148) {
tmp = R * acos((cos((lambda1 - lambda2)) + t_0));
} else {
tmp = R * acos((t_0 + (cos(phi2) * cos(lambda1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
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 = phi1 * sin(phi2)
if (phi1 <= (-0.029d0)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else if (phi1 <= (-4.8d-148)) then
tmp = r * acos((cos((lambda1 - lambda2)) + t_0))
else
tmp = r * acos((t_0 + (cos(phi2) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * Math.sin(phi2);
double tmp;
if (phi1 <= -0.029) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else if (phi1 <= -4.8e-148) {
tmp = R * Math.acos((Math.cos((lambda1 - lambda2)) + t_0));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if phi1 <= -0.029: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) elif phi1 <= -4.8e-148: tmp = R * math.acos((math.cos((lambda1 - lambda2)) + t_0)) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (phi1 <= -0.029) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); elseif (phi1 <= -4.8e-148) tmp = Float64(R * acos(Float64(cos(Float64(lambda1 - lambda2)) + t_0))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (phi1 <= -0.029) tmp = R * acos((cos(phi1) * cos(lambda1))); elseif (phi1 <= -4.8e-148) tmp = R * acos((cos((lambda1 - lambda2)) + t_0)); else tmp = R * acos((t_0 + (cos(phi2) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.029], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, -4.8e-148], N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.029:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\phi_1 \leq -4.8 \cdot 10^{-148}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi1 < -0.0290000000000000015Initial program 83.3%
Simplified83.3%
Taylor expanded in lambda2 around 0 59.4%
Taylor expanded in phi2 around 0 40.2%
*-commutative40.2%
Simplified40.2%
if -0.0290000000000000015 < phi1 < -4.8000000000000002e-148Initial program 65.6%
Simplified65.6%
Taylor expanded in phi1 around 0 63.2%
Taylor expanded in phi2 around 0 39.2%
if -4.8000000000000002e-148 < phi1 Initial program 73.0%
Simplified73.0%
Taylor expanded in phi1 around 0 39.7%
Taylor expanded in lambda2 around 0 26.9%
Final simplification31.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.061)
(* R (acos (* (cos phi1) (cos lambda1))))
(*
R
(acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.061) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi1 <= (-0.061d0)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.061) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.061: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.061) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.061) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.061], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.061:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -0.060999999999999999Initial program 83.3%
Simplified83.3%
Taylor expanded in lambda2 around 0 59.4%
Taylor expanded in phi2 around 0 40.2%
*-commutative40.2%
Simplified40.2%
if -0.060999999999999999 < phi1 Initial program 71.9%
Simplified71.9%
Taylor expanded in phi1 around 0 43.2%
Final simplification42.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.00115)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.00115) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
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 (phi1 <= (-0.00115d0)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.00115) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -0.00115: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) else: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.00115) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -0.00115) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); else tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.00115], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.00115:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_0 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -0.00115Initial program 83.5%
Simplified83.5%
Taylor expanded in phi2 around 0 41.6%
if -0.00115 < phi1 Initial program 71.8%
Simplified71.8%
Taylor expanded in phi1 around 0 43.2%
Final simplification42.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.029) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.029) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi1 <= (-0.029d0)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.029) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.029: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.029) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.029) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.029], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.029:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi1 < -0.0290000000000000015Initial program 83.3%
Simplified83.3%
Taylor expanded in lambda2 around 0 59.4%
Taylor expanded in phi2 around 0 40.2%
*-commutative40.2%
Simplified40.2%
if -0.0290000000000000015 < phi1 Initial program 71.9%
Simplified71.9%
Taylor expanded in phi1 around 0 43.2%
Taylor expanded in lambda1 around 0 30.5%
cos-neg30.5%
Simplified30.5%
Final simplification33.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.029) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.029) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi1 <= (-0.029d0)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.029) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.029: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.029) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.029) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.029], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.029:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -0.0290000000000000015Initial program 83.3%
Simplified83.3%
Taylor expanded in lambda2 around 0 59.4%
Taylor expanded in phi2 around 0 40.2%
*-commutative40.2%
Simplified40.2%
if -0.0290000000000000015 < phi1 Initial program 71.9%
Simplified71.9%
Taylor expanded in phi1 around 0 43.2%
Taylor expanded in phi2 around 0 24.8%
Final simplification28.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* (cos phi1) (cos lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos(phi1) * cos(lambda1)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos((cos(phi1) * cos(lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos(phi1) * math.cos(lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos(phi1) * cos(lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)
\end{array}
Initial program 74.9%
Simplified74.9%
Taylor expanded in lambda2 around 0 54.1%
Taylor expanded in phi2 around 0 31.9%
*-commutative31.9%
Simplified31.9%
Final simplification31.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -8.5e-7) (* R (acos (cos phi1))) (* R (acos (cos lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -8.5e-7) {
tmp = R * acos(cos(phi1));
} else {
tmp = R * acos(cos(lambda1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi1 <= (-8.5d-7)) then
tmp = r * acos(cos(phi1))
else
tmp = r * acos(cos(lambda1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -8.5e-7) {
tmp = R * Math.acos(Math.cos(phi1));
} else {
tmp = R * Math.acos(Math.cos(lambda1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -8.5e-7: tmp = R * math.acos(math.cos(phi1)) else: tmp = R * math.acos(math.cos(lambda1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -8.5e-7) tmp = Float64(R * acos(cos(phi1))); else tmp = Float64(R * acos(cos(lambda1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -8.5e-7) tmp = R * acos(cos(phi1)); else tmp = R * acos(cos(lambda1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -8.5e-7], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -8.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\end{array}
\end{array}
if phi1 < -8.50000000000000014e-7Initial program 83.5%
Simplified83.5%
Taylor expanded in lambda2 around 0 60.0%
Taylor expanded in phi2 around 0 41.1%
*-commutative41.1%
Simplified41.1%
Taylor expanded in lambda1 around 0 34.1%
if -8.50000000000000014e-7 < phi1 Initial program 71.8%
Simplified71.8%
Taylor expanded in lambda2 around 0 52.0%
Taylor expanded in phi2 around 0 28.6%
*-commutative28.6%
Simplified28.6%
Taylor expanded in phi1 around 0 18.2%
Final simplification22.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos lambda1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos(lambda1));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(cos(lambda1))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos(lambda1));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos(lambda1))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(lambda1))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos(lambda1)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \lambda_1
\end{array}
Initial program 74.9%
Simplified74.9%
Taylor expanded in lambda2 around 0 54.1%
Taylor expanded in phi2 around 0 31.9%
*-commutative31.9%
Simplified31.9%
Taylor expanded in phi1 around 0 16.3%
Final simplification16.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* lambda1 R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return lambda1 * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(lambda1 * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = lambda1 * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 * R), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 \cdot R
\end{array}
Initial program 74.9%
Simplified74.9%
Taylor expanded in lambda2 around 0 54.1%
Taylor expanded in phi2 around 0 31.9%
*-commutative31.9%
Simplified31.9%
Taylor expanded in phi1 around 0 16.3%
Taylor expanded in lambda1 around 0 6.1%
Final simplification6.1%
herbie shell --seed 2023314
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Spherical law of cosines"
:precision binary64
(* (acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))) R))