
(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 28 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
(*
R
(acos
(fma
(* (cos phi1) (cos phi2))
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))
(* (sin phi1) (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma((cos(phi1) * cos(phi2)), ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))), (sin(phi1) * sin(phi2))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))), Float64(sin(phi1) * sin(phi2))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1, \sin \phi_1 \cdot \sin \phi_2\right)\right)
\end{array}
Initial program 74.5%
*-commutative74.5%
*-commutative74.5%
Simplified74.5%
cos-diff95.7%
+-commutative95.7%
Applied egg-rr95.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1900.0)
(*
R
(acos
(+
t_0
(*
(* (cos phi2) (log1p (expm1 (cos phi1))))
(cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(* (cos phi1) (cos phi2))
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda2) (sin lambda1)))))))
(*
R
(pow
(pow
(acos (fma (cos phi1) (* (cos phi2) (cos (- lambda2 lambda1))) t_0))
3.0)
0.3333333333333333))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -1900.0) {
tmp = R * acos((t_0 + ((cos(phi2) * log1p(expm1(cos(phi1)))) * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos(((phi2 * sin(phi1)) + ((cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1))))));
} else {
tmp = R * pow(pow(acos(fma(cos(phi1), (cos(phi2) * cos((lambda2 - lambda1))), t_0)), 3.0), 0.3333333333333333);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -1900.0) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi2) * log1p(expm1(cos(phi1)))) * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1))))))); else tmp = Float64(R * ((acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda2 - lambda1))), t_0)) ^ 3.0) ^ 0.3333333333333333)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1900.0], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[phi1], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Power[N[Power[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -1900:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1\right)\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot {\left({\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)}^{3}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if phi2 < -1900Initial program 68.3%
log1p-expm1-u68.3%
Applied egg-rr68.3%
if -1900 < phi2 < 1.28000000000000009e-15Initial program 71.4%
cos-diff91.9%
distribute-lft-in91.9%
*-commutative91.9%
*-commutative91.9%
Applied egg-rr91.9%
distribute-lft-out91.9%
fma-define92.0%
Simplified92.0%
Taylor expanded in phi2 around 0 91.5%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
add-cbrt-cube87.3%
pow1/387.8%
Applied egg-rr87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.0058)
(*
R
(acos
(+
t_0
(*
(* (cos phi2) (log1p (expm1 (cos phi1))))
(cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(fma
(* (cos phi1) (cos phi2))
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))
(* phi2 (sin phi1)))))
(*
R
(pow
(pow
(acos (fma (cos phi1) (* (cos phi2) (cos (- lambda2 lambda1))) t_0))
3.0)
0.3333333333333333))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.0058) {
tmp = R * acos((t_0 + ((cos(phi2) * log1p(expm1(cos(phi1)))) * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos(fma((cos(phi1) * cos(phi2)), ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))), (phi2 * sin(phi1))));
} else {
tmp = R * pow(pow(acos(fma(cos(phi1), (cos(phi2) * cos((lambda2 - lambda1))), t_0)), 3.0), 0.3333333333333333);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.0058) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi2) * log1p(expm1(cos(phi1)))) * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))), Float64(phi2 * sin(phi1))))); else tmp = Float64(R * ((acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda2 - lambda1))), t_0)) ^ 3.0) ^ 0.3333333333333333)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.0058], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[phi1], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Power[N[Power[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.0058:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1\right)\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1, \phi_2 \cdot \sin \phi_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot {\left({\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)}^{3}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if phi2 < -0.0058Initial program 69.1%
log1p-expm1-u69.1%
Applied egg-rr69.1%
if -0.0058 < phi2 < 1.28000000000000009e-15Initial program 70.9%
*-commutative70.9%
*-commutative70.9%
Simplified70.9%
cos-diff91.9%
+-commutative91.9%
Applied egg-rr91.9%
Taylor expanded in phi2 around 0 91.4%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
add-cbrt-cube87.3%
pow1/387.8%
Applied egg-rr87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(*
R
(acos
(+
t_0
(*
(* (cos phi2) (log1p (expm1 (cos phi1))))
(cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(pow
(pow
(acos (fma (cos phi1) (* (cos phi2) (cos (- lambda2 lambda1))) t_0))
3.0)
0.3333333333333333))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_0 + ((cos(phi2) * log1p(expm1(cos(phi1)))) * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos((t_0 + (cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * pow(pow(acos(fma(cos(phi1), (cos(phi2) * cos((lambda2 - lambda1))), t_0)), 3.0), 0.3333333333333333);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi2) * log1p(expm1(cos(phi1)))) * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * ((acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda2 - lambda1))), t_0)) ^ 3.0) ^ 0.3333333333333333)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[phi1], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Power[N[Power[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1\right)\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot {\left({\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)}^{3}\right)}^{0.3333333333333333}\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
log1p-expm1-u69.5%
Applied egg-rr69.5%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
cos-diff91.8%
distribute-lft-in91.8%
*-commutative91.8%
*-commutative91.8%
Applied egg-rr91.8%
distribute-lft-out91.8%
fma-define91.8%
Simplified91.8%
Taylor expanded in phi2 around 0 91.3%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
add-cbrt-cube87.3%
pow1/387.8%
Applied egg-rr87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(*
R
(acos
(+
t_0
(*
(* (cos phi2) (log1p (expm1 (cos phi1))))
(cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(exp
(log
(acos
(fma
(cos phi1)
(* (cos phi2) (cos (- lambda2 lambda1)))
t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_0 + ((cos(phi2) * log1p(expm1(cos(phi1)))) * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos((t_0 + (cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * exp(log(acos(fma(cos(phi1), (cos(phi2) * cos((lambda2 - lambda1))), t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi2) * log1p(expm1(cos(phi1)))) * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * exp(log(acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda2 - lambda1))), t_0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[phi1], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Exp[N[Log[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1\right)\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot e^{\log \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)}\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
log1p-expm1-u69.5%
Applied egg-rr69.5%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
cos-diff91.8%
distribute-lft-in91.8%
*-commutative91.8%
*-commutative91.8%
Applied egg-rr91.8%
distribute-lft-out91.8%
fma-define91.8%
Simplified91.8%
Taylor expanded in phi2 around 0 91.3%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
add-exp-log87.8%
cos-diff99.2%
*-commutative99.2%
*-commutative99.2%
cos-diff87.8%
fma-define87.8%
associate-*r*87.8%
fma-undefine87.8%
cos-diff99.2%
*-commutative99.2%
*-commutative99.2%
cos-diff87.8%
Applied egg-rr87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * 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(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))))))
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.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))))); 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[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)
\end{array}
Initial program 74.5%
*-commutative74.5%
*-commutative74.5%
Simplified74.5%
cos-diff95.7%
+-commutative95.7%
Applied egg-rr95.7%
Taylor expanded in phi1 around 0 95.7%
Final simplification95.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(*
R
(acos
(+
t_0
(*
(* (cos phi2) (log1p (expm1 (cos phi1))))
(cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(acos
(fma (* (cos phi1) (cos phi2)) (cos (- lambda2 lambda1)) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_0 + ((cos(phi2) * log1p(expm1(cos(phi1)))) * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos((t_0 + (cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), t_0));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi2) * log1p(expm1(cos(phi1)))) * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), t_0))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[phi1], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1\right)\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
log1p-expm1-u69.5%
Applied egg-rr69.5%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
cos-diff91.8%
distribute-lft-in91.8%
*-commutative91.8%
*-commutative91.8%
Applied egg-rr91.8%
distribute-lft-out91.8%
fma-define91.8%
Simplified91.8%
Taylor expanded in phi2 around 0 91.3%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(*
R
(acos
(+
t_0
(*
(* (cos phi2) (log1p (expm1 (cos phi1))))
(cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(acos
(fma (* (cos phi1) (cos phi2)) (cos (- lambda2 lambda1)) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_0 + ((cos(phi2) * log1p(expm1(cos(phi1)))) * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), t_0));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi2) * log1p(expm1(cos(phi1)))) * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), t_0))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[phi1], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1\right)\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
log1p-expm1-u69.5%
Applied egg-rr69.5%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
cos-diff91.8%
+-commutative91.8%
Applied egg-rr91.8%
Taylor expanded in phi2 around 0 91.3%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(*
R
(acos
(+
t_0
(* (cos (- lambda1 lambda2)) (* (cos phi2) (log (exp (cos phi1))))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(acos
(fma (* (cos phi1) (cos phi2)) (cos (- lambda2 lambda1)) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_0 + (cos((lambda1 - lambda2)) * (cos(phi2) * log(exp(cos(phi1)))))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), t_0));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(Float64(lambda1 - lambda2)) * Float64(cos(phi2) * log(exp(cos(phi1)))))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), t_0))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Log[N[Exp[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_2 \cdot \log \left(e^{\cos \phi_1}\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
add-log-exp69.5%
Applied egg-rr69.5%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
cos-diff91.8%
+-commutative91.8%
Applied egg-rr91.8%
Taylor expanded in phi2 around 0 91.3%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda2 lambda1)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(* R (acos (+ t_2 (expm1 (log1p (* t_0 t_1))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(* R (acos (fma t_0 t_1 t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda2 - lambda1));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_2 + expm1(log1p((t_0 * t_1)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(fma(t_0, t_1, t_2));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda2 - lambda1)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_2 + expm1(log1p(Float64(t_0 * t_1)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(fma(t_0, t_1, t_2))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$2 + N[(Exp[N[Log[1 + N[(t$95$0 * t$95$1), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 * t$95$1 + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0 \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(t\_0, t\_1, t\_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
expm1-log1p-u69.3%
expm1-undefine69.3%
cos-diff98.5%
*-commutative98.5%
*-commutative98.5%
cos-diff69.3%
associate-*l*69.3%
Applied egg-rr69.3%
expm1-define69.4%
associate-*r*69.3%
*-commutative69.3%
Simplified69.3%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
cos-diff91.8%
+-commutative91.8%
Applied egg-rr91.8%
Taylor expanded in phi2 around 0 91.3%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Final simplification83.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(* R (acos (+ t_1 (* t_0 (cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(* R (acos (fma t_0 (cos (- lambda2 lambda1)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_1 + (t_0 * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(fma(t_0, cos((lambda2 - lambda1)), t_1));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(fma(t_0, cos(Float64(lambda2 - lambda1)), t_1))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(t\_0, \cos \left(\lambda_2 - \lambda_1\right), t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
cos-diff91.8%
+-commutative91.8%
Applied egg-rr91.8%
Taylor expanded in phi2 around 0 91.3%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.00025)
(* R (acos (+ t_1 (* t_0 (cos (- lambda1 lambda2))))))
(if (<= phi2 1.28e-15)
(*
R
(acos
(*
(cos phi1)
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1))))))
(* R (acos (fma t_0 (cos (- lambda2 lambda1)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.00025) {
tmp = R * acos((t_1 + (t_0 * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.28e-15) {
tmp = R * acos((cos(phi1) * fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1)))));
} else {
tmp = R * acos(fma(t_0, cos((lambda2 - lambda1)), t_1));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.00025) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.28e-15) tmp = Float64(R * acos(Float64(cos(phi1) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1)))))); else tmp = Float64(R * acos(fma(t_0, cos(Float64(lambda2 - lambda1)), t_1))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00025], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.28e-15], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.28 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(t\_0, \cos \left(\lambda_2 - \lambda_1\right), t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4Initial program 69.5%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in phi2 around 0 70.2%
cos-diff90.7%
Applied egg-rr90.7%
fma-define90.7%
Simplified90.7%
if 1.28000000000000009e-15 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Final simplification83.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -0.00025) (not (<= phi2 1.28e-15)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi1)
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi1) * fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi1) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -0.00025], N[Not[LessEqual[phi2, 1.28e-15]], $MachinePrecision]], 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], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00025 \lor \neg \left(\phi_2 \leq 1.28 \cdot 10^{-15}\right):\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4 or 1.28000000000000009e-15 < phi2 Initial program 77.6%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in phi2 around 0 70.2%
cos-diff90.7%
Applied egg-rr90.7%
fma-define90.7%
Simplified90.7%
Final simplification83.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -0.00025) (not (<= phi2 1.28e-15)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * 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 ((phi2 <= (-0.00025d0)) .or. (.not. (phi2 <= 1.28d-15))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * 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 ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -0.00025) or not (phi2 <= 1.28e-15): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -0.00025) || ~((phi2 <= 1.28e-15))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -0.00025], N[Not[LessEqual[phi2, 1.28e-15]], $MachinePrecision]], 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], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00025 \lor \neg \left(\phi_2 \leq 1.28 \cdot 10^{-15}\right):\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4 or 1.28000000000000009e-15 < phi2 Initial program 77.6%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in phi2 around 0 70.2%
cos-diff91.8%
+-commutative91.8%
Applied egg-rr90.7%
Final simplification83.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -0.00025) (not (<= phi2 1.28e-15)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda1)))))
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * 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 ((phi2 <= (-0.00025d0)) .or. (.not. (phi2 <= 1.28d-15))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
else
tmp = r * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * 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 ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -0.00025) or not (phi2 <= 1.28e-15): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) else: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -0.00025) || !(phi2 <= 1.28e-15)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -0.00025) || ~((phi2 <= 1.28e-15))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -0.00025], N[Not[LessEqual[phi2, 1.28e-15]], $MachinePrecision]], 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[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00025 \lor \neg \left(\phi_2 \leq 1.28 \cdot 10^{-15}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.5000000000000001e-4 or 1.28000000000000009e-15 < phi2 Initial program 77.6%
Taylor expanded in lambda2 around 0 60.0%
if -2.5000000000000001e-4 < phi2 < 1.28000000000000009e-15Initial program 70.7%
*-commutative70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in phi2 around 0 70.2%
cos-diff91.8%
+-commutative91.8%
Applied egg-rr90.7%
Final simplification74.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi1 -4.9e-5)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 7e+40)
(* R (acos (* (cos phi2) t_0)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi1 <= -4.9e-5) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 7e+40) {
tmp = R * acos((cos(phi2) * t_0));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * 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) :: t_0
real(8) :: tmp
t_0 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))
if (phi1 <= (-4.9d-5)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 7d+40) then
tmp = r * acos((cos(phi2) * t_0))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * 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 t_0 = (Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi1 <= -4.9e-5) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 7e+40) {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi1 <= -4.9e-5: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 7e+40: tmp = R * math.acos((math.cos(phi2) * t_0)) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi1 <= -4.9e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 7e+40) tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)); tmp = 0.0; if (phi1 <= -4.9e-5) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 7e+40) tmp = R * acos((cos(phi2) * t_0)); else tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.9e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 7e+40], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_1 \leq -4.9 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 7 \cdot 10^{+40}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi1 < -4.9e-5Initial program 74.3%
*-commutative74.3%
*-commutative74.3%
Simplified74.3%
Taylor expanded in phi2 around 0 56.1%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr66.2%
if -4.9e-5 < phi1 < 6.9999999999999998e40Initial program 72.7%
*-commutative72.7%
*-commutative72.7%
Simplified72.7%
cos-diff93.4%
+-commutative93.4%
Applied egg-rr93.4%
Taylor expanded in phi1 around 0 87.2%
if 6.9999999999999998e40 < phi1 Initial program 81.0%
*-commutative81.0%
*-commutative81.0%
Simplified81.0%
Taylor expanded in lambda1 around 0 61.5%
Final simplification78.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 0.0005)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi2 <= 0.0005) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((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) :: tmp
t_0 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))
if (phi2 <= 0.0005d0) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((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.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi2 <= 0.0005) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi2 <= 0.0005: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi2 <= 0.0005) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)); tmp = 0.0; if (phi2 <= 0.0005) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((cos(phi2) * t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.0005], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq 0.0005:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 5.0000000000000001e-4Initial program 70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in phi2 around 0 50.0%
cos-diff94.6%
+-commutative94.6%
Applied egg-rr62.6%
if 5.0000000000000001e-4 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
cos-diff99.2%
+-commutative99.2%
Applied egg-rr99.2%
Taylor expanded in phi1 around 0 63.0%
Final simplification62.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.00065)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00065) {
tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - 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 (phi2 <= 0.00065d0) then
tmp = r * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00065) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.00065: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1))))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00065) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.00065) tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.00065], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.00065:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < 6.4999999999999997e-4Initial program 70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in phi2 around 0 50.0%
cos-diff94.6%
+-commutative94.6%
Applied egg-rr62.6%
if 6.4999999999999997e-4 < phi2 Initial program 87.8%
Taylor expanded in phi1 around 0 60.1%
Final simplification62.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.0008)
(* R (acos (* (cos phi1) (cos (- lambda2 lambda1)))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.0008) {
tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - 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 (phi2 <= 0.0008d0) then
tmp = r * acos((cos(phi1) * cos((lambda2 - lambda1))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.0008) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos((lambda2 - lambda1))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.0008: tmp = R * math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1)))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.0008) tmp = Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.0008) tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1)))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.0008], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.0008:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < 8.00000000000000038e-4Initial program 70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in phi2 around 0 50.0%
if 8.00000000000000038e-4 < phi2 Initial program 87.8%
Taylor expanded in phi1 around 0 60.1%
Final simplification52.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi2 0.00285)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 0.00285) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((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) :: tmp
t_0 = cos((lambda2 - lambda1))
if (phi2 <= 0.00285d0) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((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 tmp;
if (phi2 <= 0.00285) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= 0.00285: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 0.00285) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi2 <= 0.00285) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((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]}, If[LessEqual[phi2, 0.00285], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq 0.00285:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 0.0028500000000000001Initial program 70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in phi2 around 0 50.0%
if 0.0028500000000000001 < phi2 Initial program 87.8%
*-commutative87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in phi1 around 0 59.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -3.9e-8) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (* (cos phi1) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -3.9e-8) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos((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) :: tmp
if (lambda1 <= (-3.9d-8)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos((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 tmp;
if (lambda1 <= -3.9e-8) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -3.9e-8: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -3.9e-8) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -3.9e-8) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos((cos(phi1) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -3.9e-8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -3.9 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -3.89999999999999985e-8Initial program 61.0%
*-commutative61.0%
*-commutative61.0%
Simplified61.0%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in lambda2 around 0 38.6%
cos-neg38.6%
Simplified38.6%
if -3.89999999999999985e-8 < lambda1 Initial program 79.5%
*-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in phi2 around 0 43.2%
Taylor expanded in lambda1 around 0 35.9%
*-commutative35.9%
Simplified35.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 7.2e-11) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (cos (- lambda2 lambda1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 7.2e-11) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos(cos((lambda2 - 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 (lambda2 <= 7.2d-11) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos(cos((lambda2 - lambda1)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 7.2e-11) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 7.2e-11: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos(math.cos((lambda2 - lambda1))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 7.2e-11) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 7.2e-11) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos(cos((lambda2 - lambda1))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 7.2e-11], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 7.2 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\end{array}
\end{array}
if lambda2 < 7.19999999999999969e-11Initial program 81.3%
*-commutative81.3%
*-commutative81.3%
Simplified81.3%
Taylor expanded in phi2 around 0 42.7%
Taylor expanded in lambda2 around 0 35.8%
cos-neg35.8%
Simplified35.8%
if 7.19999999999999969e-11 < lambda2 Initial program 56.3%
*-commutative56.3%
*-commutative56.3%
Simplified56.3%
Taylor expanded in phi2 around 0 39.8%
Taylor expanded in phi1 around 0 31.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* (cos phi1) (cos (- lambda2 lambda1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos(phi1) * cos((lambda2 - 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((lambda2 - 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((lambda2 - lambda1))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)
\end{array}
Initial program 74.5%
*-commutative74.5%
*-commutative74.5%
Simplified74.5%
Taylor expanded in phi2 around 0 41.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -4.7e-8) (* R (acos (cos lambda1))) (* R (acos (cos lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -4.7e-8) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * acos(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 (lambda1 <= (-4.7d-8)) then
tmp = r * acos(cos(lambda1))
else
tmp = r * acos(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 (lambda1 <= -4.7e-8) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -4.7e-8: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -4.7e-8) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -4.7e-8) tmp = R * acos(cos(lambda1)); else tmp = R * acos(cos(lambda2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -4.7e-8], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -4.7 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda1 < -4.6999999999999997e-8Initial program 61.0%
*-commutative61.0%
*-commutative61.0%
Simplified61.0%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 29.7%
Taylor expanded in lambda2 around 0 30.0%
cos-neg30.0%
Simplified30.0%
if -4.6999999999999997e-8 < lambda1 Initial program 79.5%
*-commutative79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in phi2 around 0 43.2%
Taylor expanded in phi1 around 0 25.8%
Taylor expanded in lambda1 around 0 20.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda2 lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos((lambda2 - 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((lambda2 - lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda2 - lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda2 - lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda2 - lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos((lambda2 - lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 74.5%
*-commutative74.5%
*-commutative74.5%
Simplified74.5%
Taylor expanded in phi2 around 0 41.9%
Taylor expanded in phi1 around 0 26.8%
(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.5%
*-commutative74.5%
*-commutative74.5%
Simplified74.5%
Taylor expanded in phi2 around 0 41.9%
Taylor expanded in phi1 around 0 26.8%
Taylor expanded in lambda2 around 0 18.1%
cos-neg18.1%
Simplified18.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (- lambda2 lambda1)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (lambda2 - 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 * (lambda2 - lambda1)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (lambda2 - lambda1);
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (lambda2 - lambda1)
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(lambda2 - lambda1)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (lambda2 - lambda1); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 74.5%
*-commutative74.5%
*-commutative74.5%
Simplified74.5%
Taylor expanded in phi2 around 0 41.9%
Taylor expanded in phi1 around 0 26.8%
Taylor expanded in R around 0 5.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R lambda2))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * 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 * lambda2
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * lambda2;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * lambda2
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * lambda2) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * lambda2; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * lambda2), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \lambda_2
\end{array}
Initial program 74.5%
*-commutative74.5%
*-commutative74.5%
Simplified74.5%
Taylor expanded in phi2 around 0 41.9%
Taylor expanded in phi1 around 0 26.8%
Taylor expanded in lambda2 around inf 5.7%
*-commutative5.7%
Simplified5.7%
Final simplification5.7%
herbie shell --seed 2024149
(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))