
(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 27 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
(+
(* (sin phi1) (sin phi2))
(+
(* (* (cos phi1) (cos phi2)) (* (cos lambda1) (cos lambda2)))
(log1p
(expm1 (* (cos phi1) (* (cos phi2) (* (sin lambda1) (sin 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) * cos(lambda2))) + log1p(expm1((cos(phi1) * (cos(phi2) * (sin(lambda1) * sin(lambda2))))))))) * R;
}
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) * Math.cos(lambda2))) + Math.log1p(Math.expm1((Math.cos(phi1) * (Math.cos(phi2) * (Math.sin(lambda1) * Math.sin(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) * math.cos(lambda2))) + math.log1p(math.expm1((math.cos(phi1) * (math.cos(phi2) * (math.sin(lambda1) * math.sin(lambda2))))))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(cos(lambda1) * cos(lambda2))) + log1p(expm1(Float64(cos(phi1) * Float64(cos(phi2) * Float64(sin(lambda1) * sin(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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Log[1 + N[(Exp[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)\right)\right)\right) \cdot R
\end{array}
Initial program 72.9%
cos-diff94.6%
distribute-lft-in94.6%
Applied egg-rr94.6%
log1p-expm1-u94.6%
associate-*l*94.6%
Applied egg-rr94.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(+
(* t_0 (* (cos lambda1) (cos lambda2)))
(* t_0 (* (sin lambda1) (sin lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
return R * acos(((sin(phi1) * sin(phi2)) + ((t_0 * (cos(lambda1) * cos(lambda2))) + (t_0 * (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
real(8) :: t_0
t_0 = cos(phi1) * cos(phi2)
code = r * acos(((sin(phi1) * sin(phi2)) + ((t_0 * (cos(lambda1) * cos(lambda2))) + (t_0 * (sin(lambda1) * sin(lambda2))))))
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);
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((t_0 * (Math.cos(lambda1) * Math.cos(lambda2))) + (t_0 * (Math.sin(lambda1) * Math.sin(lambda2))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((t_0 * (math.cos(lambda1) * math.cos(lambda2))) + (t_0 * (math.sin(lambda1) * math.sin(lambda2))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(t_0 * Float64(cos(lambda1) * cos(lambda2))) + Float64(t_0 * Float64(sin(lambda1) * sin(lambda2))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); tmp = R * acos(((sin(phi1) * sin(phi2)) + ((t_0 * (cos(lambda1) * cos(lambda2))) + (t_0 * (sin(lambda1) * sin(lambda2)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(t\_0 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)
\end{array}
\end{array}
Initial program 72.9%
cos-diff94.6%
distribute-lft-in94.6%
Applied egg-rr94.6%
Final simplification94.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (cos lambda1) (* (* (cos phi1) (cos phi2)) (cos lambda2)))
(+
(* (sin phi1) (sin phi2))
(* (cos phi1) (* (cos phi2) (* (sin lambda1) (sin lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((cos(lambda1) * ((cos(phi1) * cos(phi2)) * cos(lambda2))) + ((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * (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(((cos(lambda1) * ((cos(phi1) * cos(phi2)) * cos(lambda2))) + ((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * (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.cos(lambda1) * ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda2))) + ((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.cos(lambda1) * ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda2))) + ((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * (math.sin(lambda1) * math.sin(lambda2)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(cos(lambda1) * Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2))) + Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * Float64(sin(lambda1) * sin(lambda2)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((cos(lambda1) * ((cos(phi1) * cos(phi2)) * cos(lambda2))) + ((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * (sin(lambda1) * sin(lambda2))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[lambda1], $MachinePrecision] * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $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(\cos \lambda_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right) + \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)\right)
\end{array}
Initial program 72.9%
cos-diff94.6%
distribute-lft-in94.6%
Applied egg-rr94.6%
Taylor expanded in phi1 around 0 94.6%
Final simplification94.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(*
(cos phi2)
(fma (cos lambda2) (cos lambda1) (* (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) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * 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) * fma(cos(lambda2), cos(lambda1), Float64(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[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $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 \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)
\end{array}
Initial program 72.9%
cos-diff94.6%
distribute-lft-in94.6%
Applied egg-rr94.6%
distribute-lft-out94.6%
associate-*l*94.6%
cos-neg94.6%
*-commutative94.6%
fma-define94.6%
cos-neg94.6%
Simplified94.6%
Final simplification94.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -28500.0)
(* R (log (+ 1.0 (expm1 (acos (fma t_0 t_1 t_2))))))
(if (<= phi2 5.5e-6)
(*
R
(acos
(+
t_2
(*
(cos phi1)
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (+ t_2 (* t_1 (cbrt (pow t_0 3.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -28500.0) {
tmp = R * log((1.0 + expm1(acos(fma(t_0, t_1, t_2)))));
} else if (phi2 <= 5.5e-6) {
tmp = R * acos((t_2 + (cos(phi1) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_2 + (t_1 * cbrt(pow(t_0, 3.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -28500.0) tmp = Float64(R * log(Float64(1.0 + expm1(acos(fma(t_0, t_1, t_2)))))); elseif (phi2 <= 5.5e-6) tmp = Float64(R * acos(Float64(t_2 + Float64(cos(phi1) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(Float64(t_2 + Float64(t_1 * cbrt((t_0 ^ 3.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -28500.0], N[(R * N[Log[N[(1.0 + N[(Exp[N[ArcCos[N[(t$95$0 * t$95$1 + t$95$2), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 5.5e-6], N[(R * N[ArcCos[N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $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$1 * N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -28500:\\
\;\;\;\;R \cdot \log \left(1 + \mathsf{expm1}\left(\cos^{-1} \left(\mathsf{fma}\left(t\_0, t\_1, t\_2\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 5.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + \cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_1 \cdot \sqrt[3]{{t\_0}^{3}}\right)\\
\end{array}
\end{array}
if phi2 < -28500Initial program 76.2%
log1p-expm1-u76.2%
log1p-undefine76.2%
+-commutative76.2%
*-commutative76.2%
fma-define76.2%
Applied egg-rr76.2%
if -28500 < phi2 < 5.4999999999999999e-6Initial program 69.1%
Taylor expanded in phi2 around 0 68.9%
sub-neg68.9%
remove-double-neg68.9%
mul-1-neg68.9%
distribute-neg-in68.9%
+-commutative68.9%
cos-neg68.9%
mul-1-neg68.9%
unsub-neg68.9%
Simplified68.9%
cos-diff90.4%
*-commutative90.4%
fma-define90.4%
Applied egg-rr90.4%
if 5.4999999999999999e-6 < phi2 Initial program 78.3%
add-cbrt-cube78.4%
pow378.4%
Applied egg-rr78.4%
Final simplification84.2%
(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.75e-14)
(* R (acos (+ t_2 (log (+ 1.0 (expm1 (* t_0 t_1)))))))
(if (<= phi2 4e-6)
(*
R
(acos
(+
t_2
(*
(cos phi1)
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (+ t_2 (* t_0 (cbrt (pow t_1 3.0))))))))))
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.75e-14) {
tmp = R * acos((t_2 + log((1.0 + expm1((t_0 * t_1))))));
} else if (phi2 <= 4e-6) {
tmp = R * acos((t_2 + (cos(phi1) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_2 + (t_0 * cbrt(pow(t_1, 3.0)))));
}
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.75e-14) tmp = Float64(R * acos(Float64(t_2 + log(Float64(1.0 + expm1(Float64(t_0 * t_1))))))); elseif (phi2 <= 4e-6) tmp = Float64(R * acos(Float64(t_2 + Float64(cos(phi1) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * cbrt((t_1 ^ 3.0)))))); 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.75e-14], N[(R * N[ArcCos[N[(t$95$2 + N[Log[N[(1.0 + N[(Exp[N[(t$95$0 * t$95$1), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4e-6], N[(R * N[ArcCos[N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $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[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 1/3], $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.75 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + \log \left(1 + \mathsf{expm1}\left(t\_0 \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + \cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \sqrt[3]{{t\_1}^{3}}\right)\\
\end{array}
\end{array}
if phi2 < -1.7500000000000001e-14Initial program 74.0%
log1p-expm1-u74.0%
log1p-undefine73.9%
*-commutative73.9%
Applied egg-rr73.9%
if -1.7500000000000001e-14 < phi2 < 3.99999999999999982e-6Initial program 70.0%
Taylor expanded in phi2 around 0 70.0%
sub-neg70.0%
remove-double-neg70.0%
mul-1-neg70.0%
distribute-neg-in70.0%
+-commutative70.0%
cos-neg70.0%
mul-1-neg70.0%
unsub-neg70.0%
Simplified70.0%
cos-diff91.7%
*-commutative91.7%
fma-define91.7%
Applied egg-rr91.7%
if 3.99999999999999982e-6 < phi2 Initial program 78.3%
add-cbrt-cube78.4%
pow378.4%
Applied egg-rr78.4%
Final simplification83.9%
(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 72.9%
cos-diff94.6%
+-commutative94.6%
Applied egg-rr94.6%
Final simplification94.6%
(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.75e-14)
(* R (acos (+ t_2 (log (+ 1.0 (expm1 (* t_0 t_1)))))))
(if (<= phi2 6.8e-6)
(*
R
(acos
(+
t_2
(*
(cos phi1)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (+ t_2 (* t_0 (cbrt (pow t_1 3.0))))))))))
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.75e-14) {
tmp = R * acos((t_2 + log((1.0 + expm1((t_0 * t_1))))));
} else if (phi2 <= 6.8e-6) {
tmp = R * acos((t_2 + (cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_2 + (t_0 * cbrt(pow(t_1, 3.0)))));
}
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.75e-14) {
tmp = R * Math.acos((t_2 + Math.log((1.0 + Math.expm1((t_0 * t_1))))));
} else if (phi2 <= 6.8e-6) {
tmp = R * Math.acos((t_2 + (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.cbrt(Math.pow(t_1, 3.0)))));
}
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.75e-14) tmp = Float64(R * acos(Float64(t_2 + log(Float64(1.0 + expm1(Float64(t_0 * t_1))))))); elseif (phi2 <= 6.8e-6) tmp = Float64(R * acos(Float64(t_2 + 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 * cbrt((t_1 ^ 3.0)))))); 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.75e-14], N[(R * N[ArcCos[N[(t$95$2 + N[Log[N[(1.0 + N[(Exp[N[(t$95$0 * t$95$1), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.8e-6], N[(R * N[ArcCos[N[(t$95$2 + 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[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 1/3], $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.75 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + \log \left(1 + \mathsf{expm1}\left(t\_0 \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 6.8 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + \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 \sqrt[3]{{t\_1}^{3}}\right)\\
\end{array}
\end{array}
if phi2 < -1.7500000000000001e-14Initial program 74.0%
log1p-expm1-u74.0%
log1p-undefine73.9%
*-commutative73.9%
Applied egg-rr73.9%
if -1.7500000000000001e-14 < phi2 < 6.80000000000000012e-6Initial program 70.0%
Taylor expanded in phi2 around 0 70.0%
sub-neg70.0%
remove-double-neg70.0%
mul-1-neg70.0%
distribute-neg-in70.0%
+-commutative70.0%
cos-neg70.0%
mul-1-neg70.0%
unsub-neg70.0%
Simplified70.0%
cos-diff91.7%
*-commutative91.7%
*-commutative91.7%
Applied egg-rr91.7%
if 6.80000000000000012e-6 < phi2 Initial program 78.3%
add-cbrt-cube78.4%
pow378.4%
Applied egg-rr78.4%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -3.6e-155) (not (<= phi2 3.1e-125)))
(*
R
(+
(* PI 0.5)
(-
(acos
(fma
(* (cos phi1) (cos phi2))
(cos (- lambda2 lambda1))
(* (sin phi1) (sin phi2))))
(/ PI 2.0))))
(*
R
(acos
(+
(*
(cos phi1)
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))
(* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -3.6e-155) || !(phi2 <= 3.1e-125)) {
tmp = R * ((((double) M_PI) * 0.5) + (acos(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), (sin(phi1) * sin(phi2)))) - (((double) M_PI) / 2.0)));
} else {
tmp = R * acos(((cos(phi1) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -3.6e-155) || !(phi2 <= 3.1e-125)) tmp = Float64(R * Float64(Float64(pi * 0.5) + Float64(acos(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), Float64(sin(phi1) * sin(phi2)))) - Float64(pi / 2.0)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -3.6e-155], N[Not[LessEqual[phi2, 3.1e-125]], $MachinePrecision]], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] + N[(N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{-155} \lor \neg \left(\phi_2 \leq 3.1 \cdot 10^{-125}\right):\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 + \left(\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right) - \frac{\pi}{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_1 \cdot \sin \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi2 < -3.59999999999999989e-155 or 3.10000000000000013e-125 < phi2 Initial program 75.4%
acos-asin75.2%
sub-neg75.2%
div-inv75.2%
metadata-eval75.2%
+-commutative75.2%
*-commutative75.2%
fma-define75.2%
Applied egg-rr75.2%
sub-neg75.2%
fma-undefine75.2%
*-commutative75.2%
associate-*r*75.2%
fma-define75.2%
sub-neg75.2%
neg-mul-175.2%
Simplified75.2%
asin-acos75.4%
Applied egg-rr75.4%
fma-define75.4%
associate-*r*75.4%
fma-undefine75.4%
Simplified75.4%
if -3.59999999999999989e-155 < phi2 < 3.10000000000000013e-125Initial program 67.2%
Taylor expanded in phi2 around 0 67.2%
sub-neg67.2%
remove-double-neg67.2%
mul-1-neg67.2%
distribute-neg-in67.2%
+-commutative67.2%
cos-neg67.2%
mul-1-neg67.2%
unsub-neg67.2%
Simplified67.2%
Taylor expanded in phi1 around 0 55.7%
cos-diff93.0%
*-commutative93.0%
fma-define93.0%
Applied egg-rr77.9%
Final simplification76.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -6.5e-155) (not (<= phi2 4.3e-125)))
(*
R
(+
(* PI 0.5)
(-
(acos
(fma
(* (cos phi1) (cos phi2))
(cos (- lambda2 lambda1))
(* (sin phi1) (sin phi2))))
(/ PI 2.0))))
(*
R
(acos
(+
(*
(cos phi1)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
(* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -6.5e-155) || !(phi2 <= 4.3e-125)) {
tmp = R * ((((double) M_PI) * 0.5) + (acos(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), (sin(phi1) * sin(phi2)))) - (((double) M_PI) / 2.0)));
} else {
tmp = R * acos(((cos(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -6.5e-155) || !(phi2 <= 4.3e-125)) tmp = Float64(R * Float64(Float64(pi * 0.5) + Float64(acos(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), Float64(sin(phi1) * sin(phi2)))) - Float64(pi / 2.0)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -6.5e-155], N[Not[LessEqual[phi2, 4.3e-125]], $MachinePrecision]], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] + N[(N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(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] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -6.5 \cdot 10^{-155} \lor \neg \left(\phi_2 \leq 4.3 \cdot 10^{-125}\right):\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 + \left(\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right) - \frac{\pi}{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) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi2 < -6.5e-155 or 4.3000000000000002e-125 < phi2 Initial program 75.4%
acos-asin75.2%
sub-neg75.2%
div-inv75.2%
metadata-eval75.2%
+-commutative75.2%
*-commutative75.2%
fma-define75.2%
Applied egg-rr75.2%
sub-neg75.2%
fma-undefine75.2%
*-commutative75.2%
associate-*r*75.2%
fma-define75.2%
sub-neg75.2%
neg-mul-175.2%
Simplified75.2%
asin-acos75.4%
Applied egg-rr75.4%
fma-define75.4%
associate-*r*75.4%
fma-undefine75.4%
Simplified75.4%
if -6.5e-155 < phi2 < 4.3000000000000002e-125Initial program 67.2%
Taylor expanded in phi2 around 0 67.2%
sub-neg67.2%
remove-double-neg67.2%
mul-1-neg67.2%
distribute-neg-in67.2%
+-commutative67.2%
cos-neg67.2%
mul-1-neg67.2%
unsub-neg67.2%
Simplified67.2%
Taylor expanded in phi1 around 0 55.7%
cos-diff93.0%
*-commutative93.0%
*-commutative93.0%
Applied egg-rr77.9%
Final simplification76.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -8.5e-156) (not (<= phi2 2.5e-124)))
(*
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))))
(* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -8.5e-156) || !(phi2 <= 2.5e-124)) {
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)))) + (phi1 * sin(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi2 <= (-8.5d-156)) .or. (.not. (phi2 <= 2.5d-124))) 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)))) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -8.5e-156) || !(phi2 <= 2.5e-124)) {
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)))) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -8.5e-156) or not (phi2 <= 2.5e-124): 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)))) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -8.5e-156) || !(phi2 <= 2.5e-124)) 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(Float64(cos(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -8.5e-156) || ~((phi2 <= 2.5e-124))) 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)))) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -8.5e-156], N[Not[LessEqual[phi2, 2.5e-124]], $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[(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] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -8.5 \cdot 10^{-156} \lor \neg \left(\phi_2 \leq 2.5 \cdot 10^{-124}\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) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi2 < -8.5e-156 or 2.5000000000000001e-124 < phi2 Initial program 75.4%
if -8.5e-156 < phi2 < 2.5000000000000001e-124Initial program 67.2%
Taylor expanded in phi2 around 0 67.2%
sub-neg67.2%
remove-double-neg67.2%
mul-1-neg67.2%
distribute-neg-in67.2%
+-commutative67.2%
cos-neg67.2%
mul-1-neg67.2%
unsub-neg67.2%
Simplified67.2%
Taylor expanded in phi1 around 0 55.7%
cos-diff93.0%
*-commutative93.0%
*-commutative93.0%
Applied egg-rr77.9%
Final simplification76.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda2)))))))
(t_2 (cos (- lambda2 lambda1))))
(if (<= phi2 -9.2e-8)
t_1
(if (<= phi2 3.5e-12)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_2))))
(if (<= phi2 5e+181) (* R (acos (+ t_0 (* (cos phi2) t_2)))) t_1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
double t_2 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= -9.2e-8) {
tmp = t_1;
} else if (phi2 <= 3.5e-12) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_2)));
} else if (phi2 <= 5e+181) {
tmp = R * acos((t_0 + (cos(phi2) * t_2)));
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
t_1 = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
t_2 = cos((lambda2 - lambda1))
if (phi2 <= (-9.2d-8)) then
tmp = t_1
else if (phi2 <= 3.5d-12) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_2)))
else if (phi2 <= 5d+181) then
tmp = r * acos((t_0 + (cos(phi2) * t_2)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
double t_2 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= -9.2e-8) {
tmp = t_1;
} else if (phi2 <= 3.5e-12) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_2)));
} else if (phi2 <= 5e+181) {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * t_2)));
} else {
tmp = t_1;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) t_2 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= -9.2e-8: tmp = t_1 elif phi2 <= 3.5e-12: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_2))) elif phi2 <= 5e+181: tmp = R * math.acos((t_0 + (math.cos(phi2) * t_2))) else: tmp = t_1 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))) t_2 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= -9.2e-8) tmp = t_1; elseif (phi2 <= 3.5e-12) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_2)))); elseif (phi2 <= 5e+181) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * t_2)))); else tmp = t_1; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2))))); t_2 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi2 <= -9.2e-8) tmp = t_1; elseif (phi2 <= 3.5e-12) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_2))); elseif (phi2 <= 5e+181) tmp = R * acos((t_0 + (cos(phi2) * t_2))); else tmp = t_1; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -9.2e-8], t$95$1, If[LessEqual[phi2, 3.5e-12], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 5e+181], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
t_2 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq -9.2 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 3.5 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_2\right)\\
\mathbf{elif}\;\phi_2 \leq 5 \cdot 10^{+181}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_2 \cdot t\_2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -9.2000000000000003e-8 or 5.0000000000000003e181 < phi2 Initial program 79.3%
Taylor expanded in lambda1 around 0 57.0%
*-commutative57.0%
cos-neg57.0%
Simplified57.0%
if -9.2000000000000003e-8 < phi2 < 3.5e-12Initial program 69.8%
Taylor expanded in phi2 around 0 69.8%
sub-neg69.8%
remove-double-neg69.8%
mul-1-neg69.8%
distribute-neg-in69.8%
+-commutative69.8%
cos-neg69.8%
mul-1-neg69.8%
unsub-neg69.8%
Simplified69.8%
Taylor expanded in phi2 around 0 69.8%
if 3.5e-12 < phi2 < 5.0000000000000003e181Initial program 68.1%
Taylor expanded in phi1 around 0 51.6%
sub-neg51.6%
neg-mul-151.6%
neg-mul-151.6%
remove-double-neg51.6%
mul-1-neg51.6%
distribute-neg-in51.6%
+-commutative51.6%
cos-neg51.6%
mul-1-neg51.6%
unsub-neg51.6%
Simplified51.6%
Final simplification62.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= lambda2 9e-8)
(* 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 <= 9e-8) {
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 <= 9d-8) 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 <= 9e-8) {
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 <= 9e-8: 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 <= 9e-8) 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 <= 9e-8) 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, 9e-8], 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 9 \cdot 10^{-8}:\\
\;\;\;\;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 < 8.99999999999999986e-8Initial program 77.2%
Taylor expanded in lambda2 around 0 62.9%
if 8.99999999999999986e-8 < lambda2 Initial program 59.7%
Taylor expanded in lambda1 around 0 58.5%
cos-neg58.5%
Simplified58.5%
Final simplification61.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda2 9e-8)
(* R (acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= 9e-8) {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = R * acos((t_0 + (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(phi1) * sin(phi2)
if (lambda2 <= 9d-8) then
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
else
tmp = r * acos((t_0 + (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(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= 9e-8) {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 9e-8: tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= 9e-8) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 9e-8) tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 9e-8], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 9 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda2 < 8.99999999999999986e-8Initial program 77.2%
Taylor expanded in lambda2 around 0 62.9%
if 8.99999999999999986e-8 < lambda2 Initial program 59.7%
Taylor expanded in lambda1 around 0 58.4%
*-commutative58.4%
cos-neg58.4%
Simplified58.4%
Final simplification61.9%
(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 72.9%
Final simplification72.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -2.5e-6)
(*
R
(acos
(+
(* (cos phi1) t_0)
(/ (- (cos (- phi2 phi1)) (cos (+ phi1 phi2))) 2.0))))
(* R (acos (+ (* (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 (phi1 <= -2.5e-6) {
tmp = R * acos(((cos(phi1) * t_0) + ((cos((phi2 - phi1)) - cos((phi1 + phi2))) / 2.0)));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (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 (phi1 <= (-2.5d-6)) then
tmp = r * acos(((cos(phi1) * t_0) + ((cos((phi2 - phi1)) - cos((phi1 + phi2))) / 2.0d0)))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (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 (phi1 <= -2.5e-6) {
tmp = R * Math.acos(((Math.cos(phi1) * t_0) + ((Math.cos((phi2 - phi1)) - Math.cos((phi1 + phi2))) / 2.0)));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -2.5e-6: tmp = R * math.acos(((math.cos(phi1) * t_0) + ((math.cos((phi2 - phi1)) - math.cos((phi1 + phi2))) / 2.0))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -2.5e-6) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * t_0) + Float64(Float64(cos(Float64(phi2 - phi1)) - cos(Float64(phi1 + phi2))) / 2.0)))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + 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 (phi1 <= -2.5e-6) tmp = R * acos(((cos(phi1) * t_0) + ((cos((phi2 - phi1)) - cos((phi1 + phi2))) / 2.0))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (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[phi1, -2.5e-6], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[(N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(phi1 + phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $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_1 \leq -2.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0 + \frac{\cos \left(\phi_2 - \phi_1\right) - \cos \left(\phi_1 + \phi_2\right)}{2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -2.5000000000000002e-6Initial program 79.7%
Taylor expanded in phi2 around 0 56.1%
sub-neg56.1%
remove-double-neg56.1%
mul-1-neg56.1%
distribute-neg-in56.1%
+-commutative56.1%
cos-neg56.1%
mul-1-neg56.1%
unsub-neg56.1%
Simplified56.1%
*-commutative56.1%
sin-mult56.7%
Applied egg-rr56.7%
if -2.5000000000000002e-6 < phi1 Initial program 70.7%
Taylor expanded in phi1 around 0 53.0%
sub-neg53.0%
neg-mul-153.0%
neg-mul-153.0%
remove-double-neg53.0%
mul-1-neg53.0%
distribute-neg-in53.0%
+-commutative53.0%
cos-neg53.0%
mul-1-neg53.0%
unsub-neg53.0%
Simplified53.0%
Final simplification53.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -2.4e-6)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(* R (acos (+ t_1 (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -2.4e-6) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-2.4d-6)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else
tmp = r * acos((t_1 + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -2.4e-6) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -2.4e-6: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -2.4e-6) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -2.4e-6) tmp = R * acos((t_1 + (cos(phi1) * t_0))); else tmp = R * acos((t_1 + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.4e-6], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -2.4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -2.3999999999999999e-6Initial program 79.7%
Taylor expanded in phi2 around 0 56.1%
sub-neg56.1%
remove-double-neg56.1%
mul-1-neg56.1%
distribute-neg-in56.1%
+-commutative56.1%
cos-neg56.1%
mul-1-neg56.1%
unsub-neg56.1%
Simplified56.1%
if -2.3999999999999999e-6 < phi1 Initial program 70.7%
Taylor expanded in phi1 around 0 53.0%
sub-neg53.0%
neg-mul-153.0%
neg-mul-153.0%
remove-double-neg53.0%
mul-1-neg53.0%
distribute-neg-in53.0%
+-commutative53.0%
cos-neg53.0%
mul-1-neg53.0%
unsub-neg53.0%
Simplified53.0%
Final simplification53.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda2 9e-8)
(* 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 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= 9e-8) {
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 = sin(phi1) * sin(phi2)
if (lambda2 <= 9d-8) 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 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= 9e-8) {
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 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 9e-8: 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(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= 9e-8) 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 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 9e-8) 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[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 9e-8], 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 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 9 \cdot 10^{-8}:\\
\;\;\;\;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 < 8.99999999999999986e-8Initial program 77.2%
Taylor expanded in phi2 around 0 44.0%
sub-neg44.0%
remove-double-neg44.0%
mul-1-neg44.0%
distribute-neg-in44.0%
+-commutative44.0%
cos-neg44.0%
mul-1-neg44.0%
unsub-neg44.0%
Simplified44.0%
Taylor expanded in lambda2 around 0 35.4%
cos-neg35.4%
Simplified35.4%
if 8.99999999999999986e-8 < lambda2 Initial program 59.7%
Taylor expanded in phi2 around 0 44.9%
sub-neg44.9%
remove-double-neg44.9%
mul-1-neg44.9%
distribute-neg-in44.9%
+-commutative44.9%
cos-neg44.9%
mul-1-neg44.9%
unsub-neg44.9%
Simplified44.9%
Taylor expanded in lambda1 around 0 44.6%
Final simplification37.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.0055)
(*
R
(acos (+ (* (sin phi1) phi2) (* (cos phi1) (cos (- lambda2 lambda1))))))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.0055) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * 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.0055d0) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * 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.0055) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.0055: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.0055) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.0055) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.0055], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * 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[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.0055:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \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_1 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < 0.0054999999999999997Initial program 71.4%
Taylor expanded in phi2 around 0 51.2%
sub-neg51.2%
remove-double-neg51.2%
mul-1-neg51.2%
distribute-neg-in51.2%
+-commutative51.2%
cos-neg51.2%
mul-1-neg51.2%
unsub-neg51.2%
Simplified51.2%
Taylor expanded in phi2 around 0 48.3%
if 0.0054999999999999997 < phi2 Initial program 78.3%
Taylor expanded in phi2 around 0 18.5%
sub-neg18.5%
remove-double-neg18.5%
mul-1-neg18.5%
distribute-neg-in18.5%
+-commutative18.5%
cos-neg18.5%
mul-1-neg18.5%
unsub-neg18.5%
Simplified18.5%
Taylor expanded in lambda2 around 0 17.9%
cos-neg17.9%
Simplified17.9%
Final simplification41.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos (- lambda2 lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (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(((sin(phi1) * sin(phi2)) + (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.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos((lambda2 - lambda1)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos((lambda2 - 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[Cos[N[(lambda2 - lambda1), $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 \cos \left(\lambda_2 - \lambda_1\right)\right)
\end{array}
Initial program 72.9%
Taylor expanded in phi2 around 0 44.2%
sub-neg44.2%
remove-double-neg44.2%
mul-1-neg44.2%
distribute-neg-in44.2%
+-commutative44.2%
cos-neg44.2%
mul-1-neg44.2%
unsub-neg44.2%
Simplified44.2%
Final simplification44.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -1.8e-10)
(* R (acos (+ (* (sin phi1) phi2) (* (cos 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((lambda2 - lambda1));
double tmp;
if (phi1 <= -1.8e-10) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(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((lambda2 - lambda1))
if (phi1 <= (-1.8d-10)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(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((lambda2 - lambda1));
double tmp;
if (phi1 <= -1.8e-10) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(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((lambda2 - lambda1)) tmp = 0 if phi1 <= -1.8e-10: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(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 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -1.8e-10) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(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((lambda2 - lambda1)); tmp = 0.0; if (phi1 <= -1.8e-10) tmp = R * acos(((sin(phi1) * phi2) + (cos(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[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.8e-10], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -1.8 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -1.8e-10Initial program 78.5%
Taylor expanded in phi2 around 0 55.3%
sub-neg55.3%
remove-double-neg55.3%
mul-1-neg55.3%
distribute-neg-in55.3%
+-commutative55.3%
cos-neg55.3%
mul-1-neg55.3%
unsub-neg55.3%
Simplified55.3%
Taylor expanded in phi2 around 0 49.0%
if -1.8e-10 < phi1 Initial program 71.1%
Taylor expanded in phi2 around 0 40.6%
sub-neg40.6%
remove-double-neg40.6%
mul-1-neg40.6%
distribute-neg-in40.6%
+-commutative40.6%
cos-neg40.6%
mul-1-neg40.6%
unsub-neg40.6%
Simplified40.6%
Taylor expanded in phi1 around 0 31.8%
Taylor expanded in phi1 around 0 27.9%
Final simplification33.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda2 9e-8)
(* 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 <= 9e-8) {
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 <= 9d-8) 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 <= 9e-8) {
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 <= 9e-8: 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 <= 9e-8) 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 <= 9e-8) 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, 9e-8], 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 9 \cdot 10^{-8}:\\
\;\;\;\;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 < 8.99999999999999986e-8Initial program 77.2%
Taylor expanded in phi2 around 0 44.0%
sub-neg44.0%
remove-double-neg44.0%
mul-1-neg44.0%
distribute-neg-in44.0%
+-commutative44.0%
cos-neg44.0%
mul-1-neg44.0%
unsub-neg44.0%
Simplified44.0%
Taylor expanded in phi1 around 0 26.8%
Taylor expanded in lambda2 around 0 20.6%
cos-neg35.4%
Simplified20.6%
if 8.99999999999999986e-8 < lambda2 Initial program 59.7%
Taylor expanded in phi2 around 0 44.9%
sub-neg44.9%
remove-double-neg44.9%
mul-1-neg44.9%
distribute-neg-in44.9%
+-commutative44.9%
cos-neg44.9%
mul-1-neg44.9%
unsub-neg44.9%
Simplified44.9%
Taylor expanded in phi1 around 0 32.3%
Taylor expanded in lambda1 around 0 32.3%
Final simplification23.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= phi1 -0.000155)
(* R (acos (+ t_0 (* (cos phi1) (cos lambda1)))))
(* R (acos (+ (cos (- lambda2 lambda1)) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (phi1 <= -0.000155) {
tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((cos((lambda2 - lambda1)) + 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 = phi1 * sin(phi2)
if (phi1 <= (-0.000155d0)) then
tmp = r * acos((t_0 + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((cos((lambda2 - lambda1)) + 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 tmp;
if (phi1 <= -0.000155) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((Math.cos((lambda2 - lambda1)) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if phi1 <= -0.000155: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((math.cos((lambda2 - lambda1)) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (phi1 <= -0.000155) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (phi1 <= -0.000155) tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((cos((lambda2 - lambda1)) + t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.000155], 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[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.000155:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + t\_0\right)\\
\end{array}
\end{array}
if phi1 < -1.55e-4Initial program 79.7%
Taylor expanded in phi2 around 0 56.1%
sub-neg56.1%
remove-double-neg56.1%
mul-1-neg56.1%
distribute-neg-in56.1%
+-commutative56.1%
cos-neg56.1%
mul-1-neg56.1%
unsub-neg56.1%
Simplified56.1%
Taylor expanded in phi1 around 0 17.2%
Taylor expanded in lambda2 around 0 14.5%
cos-neg44.6%
Simplified14.5%
if -1.55e-4 < phi1 Initial program 70.7%
Taylor expanded in phi2 around 0 40.4%
sub-neg40.4%
remove-double-neg40.4%
mul-1-neg40.4%
distribute-neg-in40.4%
+-commutative40.4%
cos-neg40.4%
mul-1-neg40.4%
unsub-neg40.4%
Simplified40.4%
Taylor expanded in phi1 around 0 31.7%
Taylor expanded in phi1 around 0 27.8%
Final simplification24.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi1) (cos (- lambda2 lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * sin(phi2)) + (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(((phi1 * sin(phi2)) + (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(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * math.cos((lambda2 - lambda1)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda2 - lambda1))))); 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[(lambda2 - lambda1), $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_2 - \lambda_1\right)\right)
\end{array}
Initial program 72.9%
Taylor expanded in phi2 around 0 44.2%
sub-neg44.2%
remove-double-neg44.2%
mul-1-neg44.2%
distribute-neg-in44.2%
+-commutative44.2%
cos-neg44.2%
mul-1-neg44.2%
unsub-neg44.2%
Simplified44.2%
Taylor expanded in phi1 around 0 28.2%
Final simplification28.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda2 3.8e-8)
(* R (acos (+ (cos lambda1) t_0)))
(* R (acos (+ (cos lambda2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda2 <= 3.8e-8) {
tmp = R * acos((cos(lambda1) + t_0));
} else {
tmp = R * acos((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) :: tmp
t_0 = phi1 * sin(phi2)
if (lambda2 <= 3.8d-8) then
tmp = r * acos((cos(lambda1) + t_0))
else
tmp = r * acos((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 tmp;
if (lambda2 <= 3.8e-8) {
tmp = R * Math.acos((Math.cos(lambda1) + t_0));
} else {
tmp = R * Math.acos((Math.cos(lambda2) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda2 <= 3.8e-8: tmp = R * math.acos((math.cos(lambda1) + t_0)) else: tmp = R * math.acos((math.cos(lambda2) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda2 <= 3.8e-8) tmp = Float64(R * acos(Float64(cos(lambda1) + t_0))); else tmp = Float64(R * acos(Float64(cos(lambda2) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda2 <= 3.8e-8) tmp = R * acos((cos(lambda1) + t_0)); else tmp = R * acos((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]}, If[LessEqual[lambda2, 3.8e-8], N[(R * N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 3.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 + t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_2 + t\_0\right)\\
\end{array}
\end{array}
if lambda2 < 3.80000000000000028e-8Initial program 77.2%
Taylor expanded in phi2 around 0 44.0%
sub-neg44.0%
remove-double-neg44.0%
mul-1-neg44.0%
distribute-neg-in44.0%
+-commutative44.0%
cos-neg44.0%
mul-1-neg44.0%
unsub-neg44.0%
Simplified44.0%
Taylor expanded in phi1 around 0 26.8%
Taylor expanded in phi1 around 0 20.2%
Taylor expanded in lambda2 around 0 15.4%
cos-neg35.4%
Simplified15.4%
if 3.80000000000000028e-8 < lambda2 Initial program 59.7%
Taylor expanded in phi2 around 0 44.9%
sub-neg44.9%
remove-double-neg44.9%
mul-1-neg44.9%
distribute-neg-in44.9%
+-commutative44.9%
cos-neg44.9%
mul-1-neg44.9%
unsub-neg44.9%
Simplified44.9%
Taylor expanded in phi1 around 0 32.3%
Taylor expanded in phi1 around 0 28.5%
Taylor expanded in lambda1 around 0 28.4%
Final simplification18.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos((lambda2 - lambda1)) + (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((lambda2 - lambda1)) + (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((lambda2 - lambda1)) + (phi1 * Math.sin(phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * math.sin(phi2))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * sin(phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * sin(phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)
\end{array}
Initial program 72.9%
Taylor expanded in phi2 around 0 44.2%
sub-neg44.2%
remove-double-neg44.2%
mul-1-neg44.2%
distribute-neg-in44.2%
+-commutative44.2%
cos-neg44.2%
mul-1-neg44.2%
unsub-neg44.2%
Simplified44.2%
Taylor expanded in phi1 around 0 28.2%
Taylor expanded in phi1 around 0 22.2%
Final simplification22.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos((lambda2 - lambda1)) + (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((lambda2 - lambda1)) + (phi1 * phi2)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos((lambda2 - lambda1)) + (phi1 * phi2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * phi2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * phi2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)
\end{array}
Initial program 72.9%
Taylor expanded in phi2 around 0 44.2%
sub-neg44.2%
remove-double-neg44.2%
mul-1-neg44.2%
distribute-neg-in44.2%
+-commutative44.2%
cos-neg44.2%
mul-1-neg44.2%
unsub-neg44.2%
Simplified44.2%
Taylor expanded in phi1 around 0 28.2%
Taylor expanded in phi1 around 0 22.2%
Taylor expanded in phi2 around 0 20.6%
Final simplification20.6%
herbie shell --seed 2024091
(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))