
(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 24 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
(* (cos phi1) (cos phi2))
(fma (sin lambda1) (sin lambda2) (* (cos lambda1) (cos lambda2)))
(* (sin phi1) (sin phi2))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma((cos(phi1) * cos(phi2)), fma(sin(lambda1), sin(lambda2), (cos(lambda1) * cos(lambda2))), (sin(phi1) * sin(phi2)))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(Float64(cos(phi1) * cos(phi2)), fma(sin(lambda1), sin(lambda2), Float64(cos(lambda1) * cos(lambda2))), Float64(sin(phi1) * sin(phi2)))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right), \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R
\end{array}
Initial program 75.6%
cos-diff96.5%
+-commutative96.5%
Applied egg-rr96.5%
distribute-rgt-in96.5%
Applied egg-rr96.5%
*-un-lft-identity96.5%
+-commutative96.5%
distribute-rgt-out96.5%
fma-define96.5%
fma-define96.5%
Applied egg-rr96.5%
Final simplification96.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -2.1e-7)
(* R (acos (+ t_1 (* (* (cos phi1) (cos phi2)) (cbrt (pow t_0 3.0))))))
(if (<= phi2 7.2e-7)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (fma (cos phi1) (* (cos phi2) (log (exp t_0))) t_1)))))))
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 <= -2.1e-7) {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * cbrt(pow(t_0, 3.0)))));
} else if (phi2 <= 7.2e-7) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * log(exp(t_0))), t_1));
}
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 <= -2.1e-7) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * cbrt((t_0 ^ 3.0)))))); elseif (phi2 <= 7.2e-7) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * log(exp(t_0))), t_1))); 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, -2.1e-7], 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, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 7.2e-7], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$1), $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 -2.1 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sqrt[3]{{t\_0}^{3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 7.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \log \left(e^{t\_0}\right), t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.1e-7Initial program 73.6%
add-cbrt-cube73.5%
pow373.5%
Applied egg-rr73.5%
if -2.1e-7 < phi2 < 7.19999999999999989e-7Initial program 73.1%
cos-diff94.4%
+-commutative94.4%
Applied egg-rr94.4%
distribute-rgt-in94.4%
Applied egg-rr94.4%
*-un-lft-identity94.4%
+-commutative94.4%
distribute-rgt-out94.4%
fma-define94.4%
fma-define94.4%
Applied egg-rr94.4%
Taylor expanded in phi2 around 0 94.4%
if 7.19999999999999989e-7 < phi2 Initial program 83.1%
*-commutative83.1%
*-commutative83.1%
+-commutative83.1%
*-commutative83.1%
associate-*l*83.1%
*-commutative83.1%
fma-define83.1%
Simplified83.1%
add-log-exp83.1%
Applied egg-rr83.1%
Final simplification86.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin 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) * cos(lambda2)) + (sin(lambda1) * sin(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) * cos(lambda2)) + (sin(lambda1) * sin(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) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(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) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $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 \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)
\end{array}
Initial program 75.6%
cos-diff96.5%
+-commutative96.5%
Applied egg-rr96.5%
Final simplification96.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin 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) * cos(lambda2)) + (sin(lambda1) * sin(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) * cos(lambda2)) + (sin(lambda1) * sin(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) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(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) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2)))))))
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(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $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(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)
\end{array}
Initial program 75.6%
cos-diff96.5%
+-commutative96.5%
Applied egg-rr96.5%
Taylor expanded in phi1 around inf 96.5%
Final simplification96.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1.95e-7)
(* R (acos (+ t_2 (* t_0 (cbrt (pow t_1 3.0))))))
(if (<= phi2 7.5e-7)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (+ t_2 (* t_0 (log1p (expm1 t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -1.95e-7) {
tmp = R * acos((t_2 + (t_0 * cbrt(pow(t_1, 3.0)))));
} else if (phi2 <= 7.5e-7) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_2 + (t_0 * log1p(expm1(t_1)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= -1.95e-7) {
tmp = R * Math.acos((t_2 + (t_0 * Math.cbrt(Math.pow(t_1, 3.0)))));
} else if (phi2 <= 7.5e-7) {
tmp = R * Math.acos(((phi2 * Math.sin(phi1)) + (Math.cos(phi1) * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
} else {
tmp = R * Math.acos((t_2 + (t_0 * Math.log1p(Math.expm1(t_1)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -1.95e-7) tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * cbrt((t_1 ^ 3.0)))))); elseif (phi2 <= 7.5e-7) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * log1p(expm1(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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.95e-7], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 7.5e-7], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.95 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \sqrt[3]{{t\_1}^{3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 7.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t\_1\right)\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.95000000000000012e-7Initial program 73.6%
add-cbrt-cube73.5%
pow373.5%
Applied egg-rr73.5%
if -1.95000000000000012e-7 < phi2 < 7.5000000000000002e-7Initial program 73.1%
cos-diff94.4%
+-commutative94.4%
Applied egg-rr94.4%
distribute-rgt-in94.4%
Applied egg-rr94.4%
*-un-lft-identity94.4%
+-commutative94.4%
distribute-rgt-out94.4%
fma-define94.4%
fma-define94.4%
Applied egg-rr94.4%
Taylor expanded in phi2 around 0 94.4%
if 7.5000000000000002e-7 < phi2 Initial program 83.1%
log1p-expm1-u83.1%
Applied egg-rr83.1%
Final simplification86.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -2.05e-7)
(* R (acos (+ t_2 (* t_0 t_1))))
(if (<= phi2 9e-7)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (+ t_2 (* t_0 (log1p (expm1 t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -2.05e-7) {
tmp = R * acos((t_2 + (t_0 * t_1)));
} else if (phi2 <= 9e-7) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_2 + (t_0 * log1p(expm1(t_1)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= -2.05e-7) {
tmp = R * Math.acos((t_2 + (t_0 * t_1)));
} else if (phi2 <= 9e-7) {
tmp = R * Math.acos(((phi2 * Math.sin(phi1)) + (Math.cos(phi1) * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
} else {
tmp = R * Math.acos((t_2 + (t_0 * Math.log1p(Math.expm1(t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= -2.05e-7: tmp = R * math.acos((t_2 + (t_0 * t_1))) elif phi2 <= 9e-7: tmp = R * math.acos(((phi2 * math.sin(phi1)) + (math.cos(phi1) * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2)))))) else: tmp = R * math.acos((t_2 + (t_0 * math.log1p(math.expm1(t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -2.05e-7) tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * t_1)))); elseif (phi2 <= 9e-7) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * log1p(expm1(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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.05e-7], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 9e-7], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.05 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot t\_1\right)\\
\mathbf{elif}\;\phi_2 \leq 9 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t\_1\right)\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.05e-7Initial program 73.6%
if -2.05e-7 < phi2 < 8.99999999999999959e-7Initial program 73.1%
cos-diff94.4%
+-commutative94.4%
Applied egg-rr94.4%
distribute-rgt-in94.4%
Applied egg-rr94.4%
*-un-lft-identity94.4%
+-commutative94.4%
distribute-rgt-out94.4%
fma-define94.4%
fma-define94.4%
Applied egg-rr94.4%
Taylor expanded in phi2 around 0 94.4%
if 8.99999999999999959e-7 < phi2 Initial program 83.1%
log1p-expm1-u83.1%
Applied egg-rr83.1%
Final simplification86.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1.95e-7)
(* R (acos (+ t_1 (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= phi2 7e-7)
(*
R
(acos
(+
(* phi2 (sin phi1))
(*
(cos phi1)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))))
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 <= -1.95e-7) {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0)));
} else if (phi2 <= 7e-7) {
tmp = R * acos(((phi2 * sin(phi1)) + (cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
}
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 <= -1.95e-7) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); elseif (phi2 <= 7e-7) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + Float64(cos(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); 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, -1.95e-7], 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], If[LessEqual[phi2, 7e-7], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $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 -1.95 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\mathbf{elif}\;\phi_2 \leq 7 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.95000000000000012e-7Initial program 73.6%
if -1.95000000000000012e-7 < phi2 < 6.99999999999999968e-7Initial program 73.1%
cos-diff94.4%
+-commutative94.4%
Applied egg-rr94.4%
distribute-rgt-in94.4%
Applied egg-rr94.4%
*-un-lft-identity94.4%
+-commutative94.4%
distribute-rgt-out94.4%
fma-define94.4%
fma-define94.4%
Applied egg-rr94.4%
Taylor expanded in phi2 around 0 94.4%
if 6.99999999999999968e-7 < phi2 Initial program 83.1%
*-commutative83.1%
*-commutative83.1%
+-commutative83.1%
*-commutative83.1%
associate-*l*83.1%
*-commutative83.1%
fma-define83.1%
Simplified83.1%
Final simplification86.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1.7e-8)
(* R (acos (+ t_1 (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= phi2 6.8e-9)
(*
R
(acos
(*
(cos phi1)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))))
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 <= -1.7e-8) {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0)));
} else if (phi2 <= 6.8e-9) {
tmp = R * acos((cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
}
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 <= -1.7e-8) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); elseif (phi2 <= 6.8e-9) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); 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, -1.7e-8], 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], If[LessEqual[phi2, 6.8e-9], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $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 -1.7 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\mathbf{elif}\;\phi_2 \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.7e-8Initial program 73.6%
if -1.7e-8 < phi2 < 6.7999999999999997e-9Initial program 73.1%
cos-diff94.4%
+-commutative94.4%
Applied egg-rr94.4%
distribute-rgt-in94.4%
Applied egg-rr94.4%
*-un-lft-identity94.4%
+-commutative94.4%
distribute-rgt-out94.4%
fma-define94.4%
fma-define94.4%
Applied egg-rr94.4%
Taylor expanded in phi2 around 0 94.2%
if 6.7999999999999997e-9 < phi2 Initial program 83.1%
*-commutative83.1%
*-commutative83.1%
+-commutative83.1%
*-commutative83.1%
associate-*l*83.1%
*-commutative83.1%
fma-define83.1%
Simplified83.1%
Final simplification86.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (cos (- lambda2 lambda1))))
(if (<= lambda2 3400.0)
(* R (acos (+ (* (sin phi1) (sin phi2)) (* t_0 (cos lambda1)))))
(if (<= lambda2 1.26e+58)
(* R (acos (+ (* t_0 (cos lambda2)) (* phi1 (sin phi2)))))
(if (<= lambda2 2.6e+182)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) t_1))))
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi2) t_1)))))))))
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 tmp;
if (lambda2 <= 3400.0) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (t_0 * cos(lambda1))));
} else if (lambda2 <= 1.26e+58) {
tmp = R * acos(((t_0 * cos(lambda2)) + (phi1 * sin(phi2))));
} else if (lambda2 <= 2.6e+182) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * t_1)));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi2) * t_1)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (lambda2 <= 3400.0) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * cos(lambda1))))); elseif (lambda2 <= 1.26e+58) tmp = Float64(R * acos(Float64(Float64(t_0 * cos(lambda2)) + Float64(phi1 * sin(phi2))))); elseif (lambda2 <= 2.6e+182) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * t_1)))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi2) * 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[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 3400.0], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 1.26e+58], N[(R * N[ArcCos[N[(N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 2.6e+182], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $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)\\
\mathbf{if}\;\lambda_2 \leq 3400:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\lambda_2 \leq 1.26 \cdot 10^{+58}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \cos \lambda_2 + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{elif}\;\lambda_2 \leq 2.6 \cdot 10^{+182}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot t\_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot t\_1\right)\right)\\
\end{array}
\end{array}
if lambda2 < 3400Initial program 79.8%
Taylor expanded in lambda2 around 0 69.7%
if 3400 < lambda2 < 1.26e58Initial program 94.2%
Taylor expanded in phi1 around 0 68.5%
Taylor expanded in lambda1 around 0 68.5%
cos-neg94.5%
Simplified68.5%
if 1.26e58 < lambda2 < 2.6e182Initial program 57.7%
Simplified57.7%
Taylor expanded in phi2 around 0 39.2%
sub-neg39.2%
remove-double-neg39.2%
mul-1-neg39.2%
distribute-neg-in39.2%
+-commutative39.2%
cos-neg39.2%
mul-1-neg39.2%
unsub-neg39.2%
Simplified39.2%
if 2.6e182 < lambda2 Initial program 47.9%
Simplified47.9%
Taylor expanded in phi1 around 0 36.4%
sub-neg36.4%
remove-double-neg36.4%
mul-1-neg36.4%
distribute-neg-in36.4%
+-commutative36.4%
cos-neg36.4%
mul-1-neg36.4%
unsub-neg36.4%
Simplified36.4%
Final simplification63.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -4.8e-8) (not (<= phi2 1.22e-8)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi1)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -4.8e-8) || !(phi2 <= 1.22e-8)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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 <= (-4.8d-8)) .or. (.not. (phi2 <= 1.22d-8))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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 <= -4.8e-8) || !(phi2 <= 1.22e-8)) {
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.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -4.8e-8) or not (phi2 <= 1.22e-8): 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.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -4.8e-8) || !(phi2 <= 1.22e-8)) 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(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -4.8e-8) || ~((phi2 <= 1.22e-8))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = R * acos((cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -4.8e-8], N[Not[LessEqual[phi2, 1.22e-8]], $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[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -4.8 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 1.22 \cdot 10^{-8}\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(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -4.79999999999999997e-8 or 1.22e-8 < phi2 Initial program 78.2%
if -4.79999999999999997e-8 < phi2 < 1.22e-8Initial program 73.1%
cos-diff94.4%
+-commutative94.4%
Applied egg-rr94.4%
distribute-rgt-in94.4%
Applied egg-rr94.4%
*-un-lft-identity94.4%
+-commutative94.4%
distribute-rgt-out94.4%
fma-define94.4%
fma-define94.4%
Applied egg-rr94.4%
Taylor expanded in phi2 around 0 94.2%
Final simplification86.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= lambda2 0.2)
(* R (acos (+ t_1 (* t_0 (cos lambda1)))))
(* R (acos (+ t_1 (* t_0 (cos lambda2))))))))
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 (lambda2 <= 0.2) {
tmp = R * acos((t_1 + (t_0 * cos(lambda1))));
} else {
tmp = R * acos((t_1 + (t_0 * 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) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(phi1) * sin(phi2)
if (lambda2 <= 0.2d0) then
tmp = r * acos((t_1 + (t_0 * cos(lambda1))))
else
tmp = r * acos((t_1 + (t_0 * 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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= 0.2) {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 0.2: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda1)))) else: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda2)))) 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 (lambda2 <= 0.2) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 0.2) tmp = R * acos((t_1 + (t_0 * cos(lambda1)))); else tmp = R * acos((t_1 + (t_0 * cos(lambda2)))); end tmp_2 = 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[lambda2, 0.2], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $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}\;\lambda_2 \leq 0.2:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 0.20000000000000001Initial program 80.5%
Taylor expanded in lambda2 around 0 70.2%
if 0.20000000000000001 < lambda2 Initial program 61.0%
Taylor expanded in lambda1 around 0 61.1%
cos-neg61.1%
Simplified61.1%
Final simplification67.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi2 2.25e-5)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) t_0))))
(* R (acos (fma (sin phi1) (sin phi2) (* (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 <= 2.25e-5) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * t_0)));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi2) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 2.25e-5) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi2) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 2.25e-5], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + 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)\\
\mathbf{if}\;\phi_2 \leq 2.25 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if phi2 < 2.25000000000000014e-5Initial program 73.4%
Simplified73.4%
Taylor expanded in phi2 around 0 55.0%
sub-neg55.0%
remove-double-neg55.0%
mul-1-neg55.0%
distribute-neg-in55.0%
+-commutative55.0%
cos-neg55.0%
mul-1-neg55.0%
unsub-neg55.0%
Simplified55.0%
if 2.25000000000000014e-5 < phi2 Initial program 82.8%
Simplified82.8%
Taylor expanded in phi1 around 0 56.6%
sub-neg56.6%
remove-double-neg56.6%
mul-1-neg56.6%
distribute-neg-in56.6%
+-commutative56.6%
cos-neg56.6%
mul-1-neg56.6%
unsub-neg56.6%
Simplified56.6%
Final simplification55.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -2050000.0)
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (cos (- lambda2 lambda1))))))
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))
(* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -2050000.0) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -2050000.0) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -2050000.0], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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 -2050000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -2.05e6Initial program 74.4%
Simplified74.3%
Taylor expanded in phi2 around 0 55.5%
sub-neg55.5%
remove-double-neg55.5%
mul-1-neg55.5%
distribute-neg-in55.5%
+-commutative55.5%
cos-neg55.5%
mul-1-neg55.5%
unsub-neg55.5%
Simplified55.5%
if -2.05e6 < phi1 Initial program 76.0%
Taylor expanded in phi1 around 0 52.9%
Final simplification53.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 75.6%
Final simplification75.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= phi1 -5e+19)
(* R (acos (+ (* phi2 (sin phi1)) t_0)))
(* R (acos (+ t_0 (* phi1 (sin phi2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -5e+19) {
tmp = R * acos(((phi2 * sin(phi1)) + t_0));
} else {
tmp = R * acos((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(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
if (phi1 <= (-5d+19)) then
tmp = r * acos(((phi2 * sin(phi1)) + t_0))
else
tmp = r * acos((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(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -5e+19) {
tmp = R * Math.acos(((phi2 * Math.sin(phi1)) + t_0));
} else {
tmp = R * Math.acos((t_0 + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -5e+19: tmp = R * math.acos(((phi2 * math.sin(phi1)) + t_0)) else: tmp = R * math.acos((t_0 + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -5e+19) tmp = Float64(R * acos(Float64(Float64(phi2 * sin(phi1)) + t_0))); else tmp = Float64(R * acos(Float64(t_0 + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -5e+19) tmp = R * acos(((phi2 * sin(phi1)) + t_0)); else tmp = R * acos((t_0 + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5e+19], N[(R * N[ArcCos[N[(N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{+19}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_2 \cdot \sin \phi_1 + t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -5e19Initial program 74.6%
Taylor expanded in phi2 around 0 50.9%
if -5e19 < phi1 Initial program 75.9%
Taylor expanded in phi1 around 0 52.1%
Final simplification51.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= lambda2 0.2)
(* R (acos (+ (* t_1 (cos lambda1)) t_0)))
(* R (acos (+ (* t_1 (cos lambda2)) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (lambda2 <= 0.2) {
tmp = R * acos(((t_1 * cos(lambda1)) + t_0));
} else {
tmp = R * acos(((t_1 * cos(lambda2)) + 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 = phi1 * sin(phi2)
t_1 = cos(phi1) * cos(phi2)
if (lambda2 <= 0.2d0) then
tmp = r * acos(((t_1 * cos(lambda1)) + t_0))
else
tmp = r * acos(((t_1 * cos(lambda2)) + 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 = phi1 * Math.sin(phi2);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (lambda2 <= 0.2) {
tmp = R * Math.acos(((t_1 * Math.cos(lambda1)) + t_0));
} else {
tmp = R * Math.acos(((t_1 * Math.cos(lambda2)) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) t_1 = math.cos(phi1) * math.cos(phi2) tmp = 0 if lambda2 <= 0.2: tmp = R * math.acos(((t_1 * math.cos(lambda1)) + t_0)) else: tmp = R * math.acos(((t_1 * math.cos(lambda2)) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (lambda2 <= 0.2) tmp = Float64(R * acos(Float64(Float64(t_1 * cos(lambda1)) + t_0))); else tmp = Float64(R * acos(Float64(Float64(t_1 * cos(lambda2)) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); t_1 = cos(phi1) * cos(phi2); tmp = 0.0; if (lambda2 <= 0.2) tmp = R * acos(((t_1 * cos(lambda1)) + t_0)); else tmp = R * acos(((t_1 * cos(lambda2)) + t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 0.2], N[(R * N[ArcCos[N[(N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq 0.2:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 \cdot \cos \lambda_1 + t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 \cdot \cos \lambda_2 + t\_0\right)\\
\end{array}
\end{array}
if lambda2 < 0.20000000000000001Initial program 80.5%
Taylor expanded in phi1 around 0 48.9%
Taylor expanded in lambda2 around 0 41.4%
if 0.20000000000000001 < lambda2 Initial program 61.0%
Taylor expanded in phi1 around 0 41.0%
Taylor expanded in lambda1 around 0 41.0%
cos-neg61.1%
Simplified41.0%
Final simplification41.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))
(* phi1 (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(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((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
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(phi2)) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)
\end{array}
Initial program 75.6%
Taylor expanded in phi1 around 0 46.9%
Final simplification46.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 2.8e-132)
(* R (acos (+ (* 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 (phi2 <= 2.8e-132) {
tmp = R * acos(((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 (phi2 <= 2.8d-132) then
tmp = r * acos(((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 (phi2 <= 2.8e-132) {
tmp = R * Math.acos(((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 phi2 <= 2.8e-132: tmp = R * math.acos(((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 (phi2 <= 2.8e-132) tmp = Float64(R * acos(Float64(Float64(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 (phi2 <= 2.8e-132) tmp = R * acos(((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[phi2, 2.8e-132], N[(R * N[ArcCos[N[(N[(phi1 * 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_2 \leq 2.8 \cdot 10^{-132}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\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 phi2 < 2.80000000000000002e-132Initial program 71.7%
Taylor expanded in phi1 around 0 45.7%
Taylor expanded in phi2 around 0 35.3%
Taylor expanded in phi2 around 0 33.9%
if 2.80000000000000002e-132 < phi2 Initial program 83.8%
Taylor expanded in phi1 around 0 49.5%
Taylor expanded in phi1 around 0 46.8%
Final simplification38.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda2 0.2)
(* R (acos (+ t_0 (* (cos phi1) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda2 <= 0.2) {
tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((t_0 + (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 = phi1 * sin(phi2)
if (lambda2 <= 0.2d0) then
tmp = r * acos((t_0 + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((t_0 + (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 = phi1 * Math.sin(phi2);
double tmp;
if (lambda2 <= 0.2) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda2 <= 0.2: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda2 <= 0.2) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda2 <= 0.2) tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((t_0 + (cos(phi1) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 0.2], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 0.2:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 0.20000000000000001Initial program 80.5%
Taylor expanded in phi1 around 0 48.9%
Taylor expanded in phi2 around 0 30.2%
Taylor expanded in lambda2 around 0 24.5%
if 0.20000000000000001 < lambda2 Initial program 61.0%
Taylor expanded in phi1 around 0 41.0%
Taylor expanded in phi2 around 0 28.9%
Taylor expanded in lambda1 around 0 29.1%
cos-neg61.1%
Simplified29.1%
Final simplification25.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi1) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * sin(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(((phi1 * sin(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(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 75.6%
Taylor expanded in phi1 around 0 46.9%
Taylor expanded in phi2 around 0 29.9%
Final simplification29.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -4.8e-12) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -4.8e-12) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos(((phi1 * 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) :: tmp
if (lambda1 <= (-4.8d-12)) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos(((phi1 * 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 tmp;
if (lambda1 <= -4.8e-12) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -4.8e-12: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -4.8e-12) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -4.8e-12) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -4.8e-12], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -4.8 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -4.79999999999999974e-12Initial program 64.4%
Taylor expanded in phi1 around 0 38.0%
Taylor expanded in phi2 around 0 26.3%
Taylor expanded in phi2 around 0 24.3%
Taylor expanded in lambda2 around 0 23.9%
*-commutative23.9%
Simplified23.9%
if -4.79999999999999974e-12 < lambda1 Initial program 79.0%
Taylor expanded in phi1 around 0 49.6%
Taylor expanded in phi2 around 0 30.9%
Taylor expanded in phi2 around 0 29.1%
Taylor expanded in lambda1 around 0 23.5%
cos-neg23.5%
Simplified23.5%
Final simplification23.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 1900000000.0) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 1900000000.0) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * 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 (lambda2 <= 1900000000.0d0) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((cos((lambda1 - lambda2)) + (phi1 * phi2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 1900000000.0) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 1900000000.0: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 1900000000.0) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 1900000000.0) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 1900000000.0], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 1900000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \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 \phi_2\right)\\
\end{array}
\end{array}
if lambda2 < 1.9e9Initial program 80.1%
Taylor expanded in phi1 around 0 48.7%
Taylor expanded in phi2 around 0 29.7%
Taylor expanded in phi2 around 0 27.7%
Taylor expanded in lambda2 around 0 22.5%
*-commutative22.5%
Simplified22.5%
if 1.9e9 < lambda2 Initial program 60.5%
Taylor expanded in phi1 around 0 40.8%
Taylor expanded in phi2 around 0 30.5%
Taylor expanded in phi2 around 0 28.8%
Taylor expanded in phi1 around 0 22.9%
Final simplification22.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * 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(((phi1 * 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(((phi1 * phi2) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 75.6%
Taylor expanded in phi1 around 0 46.9%
Taylor expanded in phi2 around 0 29.9%
Taylor expanded in phi2 around 0 28.0%
Final simplification28.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos((lambda1 - lambda2)) + (phi1 * 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((cos((lambda1 - lambda2)) + (phi1 * phi2)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * phi2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * phi2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * phi2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * phi2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)
\end{array}
Initial program 75.6%
Taylor expanded in phi1 around 0 46.9%
Taylor expanded in phi2 around 0 29.9%
Taylor expanded in phi2 around 0 28.0%
Taylor expanded in phi1 around 0 17.0%
Final simplification17.0%
herbie shell --seed 2024108
(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))