
(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))
(+
(expm1 (log1p (* (sin lambda1) (sin lambda2))))
(* (cos lambda1) (cos lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * (expm1(log1p((sin(lambda1) * sin(lambda2)))) + (cos(lambda1) * cos(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.expm1(Math.log1p((Math.sin(lambda1) * Math.sin(lambda2)))) + (Math.cos(lambda1) * Math.cos(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.expm1(math.log1p((math.sin(lambda1) * math.sin(lambda2)))) + (math.cos(lambda1) * math.cos(lambda2)))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(expm1(log1p(Float64(sin(lambda1) * sin(lambda2)))) + Float64(cos(lambda1) * cos(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[(N[(Exp[N[Log[1 + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $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 \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right) + \cos \lambda_1 \cdot \cos \lambda_2\right)\right) \cdot R
\end{array}
Initial program 72.6%
cos-diff93.9%
+-commutative93.9%
Applied egg-rr93.9%
expm1-log1p-u93.9%
Applied egg-rr93.9%
Final simplification93.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (or (<= phi1 -2.7e-24) (not (<= phi1 7.2e-6)))
(*
R
(acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(+
t_0
(*
(cos phi2)
(fma
(sin lambda2)
(sin lambda1)
(* (cos lambda1) (cos lambda2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if ((phi1 <= -2.7e-24) || !(phi1 <= 7.2e-6)) {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if ((phi1 <= -2.7e-24) || !(phi1 <= 7.2e-6)) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -2.7e-24], N[Not[LessEqual[phi1, 7.2e-6]], $MachinePrecision]], N[(R * N[ArcCos[N[(t$95$0 + 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[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -2.7 \cdot 10^{-24} \lor \neg \left(\phi_1 \leq 7.2 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \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(t_0 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.70000000000000007e-24 or 7.19999999999999967e-6 < phi1 Initial program 75.7%
if -2.70000000000000007e-24 < phi1 < 7.19999999999999967e-6Initial program 69.3%
cos-diff88.6%
+-commutative88.6%
Applied egg-rr88.6%
Taylor expanded in phi1 around 0 88.4%
+-commutative88.4%
fma-def88.4%
Simplified88.4%
Final simplification81.9%
(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 (<= phi1 -2.7e-24)
(* R (log (+ 1.0 (expm1 (acos (fma t_0 t_1 t_2))))))
(if (<= phi1 1e-6)
(*
R
(acos
(+
t_2
(*
(cos phi2)
(fma
(sin lambda2)
(sin lambda1)
(* (cos lambda1) (cos lambda2)))))))
(* R (acos (+ t_2 (* t_1 t_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 (phi1 <= -2.7e-24) {
tmp = R * log((1.0 + expm1(acos(fma(t_0, t_1, t_2)))));
} else if (phi1 <= 1e-6) {
tmp = R * acos((t_2 + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos((t_2 + (t_1 * t_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 (phi1 <= -2.7e-24) tmp = Float64(R * log(Float64(1.0 + expm1(acos(fma(t_0, t_1, t_2)))))); elseif (phi1 <= 1e-6) tmp = Float64(R * acos(Float64(t_2 + Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(Float64(t_2 + Float64(t_1 * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.7e-24], 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[phi1, 1e-6], N[(R * N[ArcCos[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$1 * t$95$0), $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_1 \leq -2.7 \cdot 10^{-24}:\\
\;\;\;\;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_1 \leq 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_2 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_2 + t_1 \cdot t_0\right)\\
\end{array}
\end{array}
if phi1 < -2.70000000000000007e-24Initial program 80.4%
log1p-expm1-u80.4%
log1p-udef80.4%
+-commutative80.4%
*-commutative80.4%
fma-def80.4%
Applied egg-rr80.4%
if -2.70000000000000007e-24 < phi1 < 9.99999999999999955e-7Initial program 69.1%
cos-diff88.5%
+-commutative88.5%
Applied egg-rr88.5%
Taylor expanded in phi1 around 0 88.4%
+-commutative88.4%
fma-def88.5%
Simplified88.5%
if 9.99999999999999955e-7 < phi1 Initial program 72.3%
Final simplification82.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(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)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(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.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(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(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(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[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[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(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)
\end{array}
Initial program 72.6%
cos-diff93.9%
+-commutative93.9%
Applied egg-rr93.9%
Final simplification93.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (or (<= phi1 -2.7e-24) (not (<= phi1 3.1e-6)))
(*
R
(acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(+
t_0
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if ((phi1 <= -2.7e-24) || !(phi1 <= 3.1e-6)) {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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 ((phi1 <= (-2.7d-24)) .or. (.not. (phi1 <= 3.1d-6))) then
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((t_0 + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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 ((phi1 <= -2.7e-24) || !(phi1 <= 3.1e-6)) {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if (phi1 <= -2.7e-24) or not (phi1 <= 3.1e-6): tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if ((phi1 <= -2.7e-24) || !(phi1 <= 3.1e-6)) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * 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 ((phi1 <= -2.7e-24) || ~((phi1 <= 3.1e-6))) tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = R * acos((t_0 + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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[Or[LessEqual[phi1, -2.7e-24], N[Not[LessEqual[phi1, 3.1e-6]], $MachinePrecision]], N[(R * N[ArcCos[N[(t$95$0 + 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[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -2.7 \cdot 10^{-24} \lor \neg \left(\phi_1 \leq 3.1 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \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(t_0 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.70000000000000007e-24 or 3.1e-6 < phi1 Initial program 75.9%
if -2.70000000000000007e-24 < phi1 < 3.1e-6Initial program 69.1%
cos-diff88.5%
+-commutative88.5%
Applied egg-rr88.5%
Taylor expanded in phi1 around 0 88.4%
Final simplification82.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -2.3e-8)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))
(if (<= phi2 5.5e-9)
(*
R
(acos
(+
(* (sin phi1) phi2)
(*
(cos phi1)
(fma
(sin lambda2)
(sin lambda1)
(* (cos lambda1) (cos lambda2)))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -2.3e-8) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
} else if (phi2 <= 5.5e-9) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -2.3e-8) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); elseif (phi2 <= 5.5e-9) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2.3e-8], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 5.5e-9], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -2.3 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 5.5 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
\end{array}
\end{array}
if phi2 < -2.3000000000000001e-8Initial program 83.5%
fma-def83.5%
associate-*l*83.6%
Simplified83.6%
if -2.3000000000000001e-8 < phi2 < 5.4999999999999996e-9Initial program 65.6%
Taylor expanded in phi2 around 0 65.6%
sub-neg65.6%
+-commutative65.6%
neg-mul-165.6%
neg-mul-165.6%
remove-double-neg65.6%
mul-1-neg65.6%
distribute-neg-in65.6%
+-commutative65.6%
cos-neg65.6%
+-commutative65.6%
mul-1-neg65.6%
unsub-neg65.6%
Simplified65.6%
cos-diff87.5%
*-commutative87.5%
*-commutative87.5%
+-commutative87.5%
Applied egg-rr87.5%
*-commutative87.5%
*-commutative87.5%
fma-def87.5%
Simplified87.5%
Taylor expanded in phi2 around 0 87.5%
if 5.4999999999999996e-9 < phi2 Initial program 72.7%
Final simplification82.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -1150.0)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))))
(*
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) {
double tmp;
if (lambda2 <= -1150.0) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= (-1150.0d0)) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -1150.0) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= -1150.0: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -1150.0) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= -1150.0) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -1150.0], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(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}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -1150:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\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}
\end{array}
if lambda2 < -1150Initial program 56.5%
Taylor expanded in phi2 around 0 31.5%
sub-neg31.5%
+-commutative31.5%
neg-mul-131.5%
neg-mul-131.5%
remove-double-neg31.5%
mul-1-neg31.5%
distribute-neg-in31.5%
+-commutative31.5%
cos-neg31.5%
+-commutative31.5%
mul-1-neg31.5%
unsub-neg31.5%
Simplified31.5%
Taylor expanded in phi1 around 0 20.5%
cos-diff55.7%
*-commutative55.7%
*-commutative55.7%
+-commutative55.7%
Applied egg-rr37.8%
if -1150 < lambda2 Initial program 78.9%
Final simplification67.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda2 -2.5e+120)
(*
R
(acos
(+
t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(+ t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -2.5e+120) {
tmp = R * acos((t_0 + ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (lambda2 <= (-2.5d+120)) then
tmp = r * acos((t_0 + ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -2.5e+120) {
tmp = R * Math.acos((t_0 + ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= -2.5e+120: tmp = R * math.acos((t_0 + ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) else: tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -2.5e+120) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - 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 <= -2.5e+120) tmp = R * acos((t_0 + ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - 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, -2.5e+120], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + 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}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -2.5 \cdot 10^{+120}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda2 < -2.50000000000000009e120Initial program 54.6%
Taylor expanded in phi2 around 0 34.1%
sub-neg34.1%
+-commutative34.1%
neg-mul-134.1%
neg-mul-134.1%
remove-double-neg34.1%
mul-1-neg34.1%
distribute-neg-in34.1%
+-commutative34.1%
cos-neg34.1%
+-commutative34.1%
mul-1-neg34.1%
unsub-neg34.1%
Simplified34.1%
cos-diff61.4%
*-commutative61.4%
*-commutative61.4%
+-commutative61.4%
Applied egg-rr61.4%
*-commutative61.4%
*-commutative61.4%
fma-def61.4%
Simplified61.4%
Taylor expanded in phi1 around 0 38.3%
if -2.50000000000000009e120 < lambda2 Initial program 76.9%
Final simplification69.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda2 1.42e-6)
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda1))))))
(* R (acos (+ t_0 (* (cos phi2) (cos (- lambda2 lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= 1.42e-6) {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (lambda2 <= 1.42d-6) then
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))))
else
tmp = r * acos((t_0 + (cos(phi2) * cos((lambda2 - lambda1)))))
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 <= 1.42e-6) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 1.42e-6: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * math.cos((lambda2 - lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= 1.42e-6) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * cos(Float64(lambda2 - lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 1.42e-6) tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1))))); else tmp = R * acos((t_0 + (cos(phi2) * cos((lambda2 - lambda1))))); 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, 1.42e-6], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $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 1.42 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\end{array}
\end{array}
if lambda2 < 1.42e-6Initial program 75.4%
cos-diff92.1%
+-commutative92.1%
Applied egg-rr92.1%
Taylor expanded in lambda2 around 0 61.4%
associate-*r*61.4%
*-commutative61.4%
associate-*l*61.4%
Simplified61.4%
if 1.42e-6 < lambda2 Initial program 64.7%
Taylor expanded in phi1 around 0 41.5%
sub-neg41.5%
+-commutative41.5%
neg-mul-141.5%
neg-mul-141.5%
remove-double-neg41.5%
mul-1-neg41.5%
distribute-neg-in41.5%
+-commutative41.5%
cos-neg41.5%
+-commutative41.5%
mul-1-neg41.5%
unsub-neg41.5%
Simplified41.5%
Final simplification56.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -1.72e-6)
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda1))))))
(* R (acos (+ t_0 (* (cos phi2) (* (cos phi1) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -1.72e-6) {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (lambda1 <= (-1.72d-6)) then
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))))
else
tmp = r * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -1.72e-6) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -1.72e-6: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -1.72e-6) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -1.72e-6) tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1))))); else tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.72e-6], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.72 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -1.72e-6Initial program 62.1%
cos-diff98.8%
+-commutative98.8%
Applied egg-rr98.8%
Taylor expanded in lambda2 around 0 61.1%
associate-*r*61.2%
*-commutative61.2%
associate-*l*61.2%
Simplified61.2%
if -1.72e-6 < lambda1 Initial program 75.6%
Taylor expanded in lambda1 around 0 61.1%
*-commutative61.1%
cos-neg61.1%
Simplified61.1%
Final simplification61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -2.55e-6)
(* 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 (lambda1 <= -2.55e-6) {
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 (lambda1 <= (-2.55d-6)) 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 (lambda1 <= -2.55e-6) {
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 lambda1 <= -2.55e-6: 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 (lambda1 <= -2.55e-6) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * 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 (lambda1 <= -2.55e-6) 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[lambda1, -2.55e-6], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -2.55 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -2.5500000000000001e-6Initial program 62.1%
cos-diff98.8%
+-commutative98.8%
Applied egg-rr98.8%
Taylor expanded in lambda2 around 0 61.1%
associate-*r*61.2%
*-commutative61.2%
associate-*l*61.2%
Simplified61.2%
if -2.5500000000000001e-6 < lambda1 Initial program 75.6%
Taylor expanded in lambda1 around 0 61.1%
cos-neg61.1%
Simplified61.1%
Final simplification61.1%
(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.6%
Final simplification72.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -0.0016)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 0.185)
(*
R
(acos (+ t_1 (* (* (cos phi2) t_0) (+ 1.0 (* (* phi1 phi1) -0.5))))))
(* R (acos (+ t_1 (* (cos phi1) (cos phi2)))))))))
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 <= -0.0016) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 0.185) {
tmp = R * acos((t_1 + ((cos(phi2) * t_0) * (1.0 + ((phi1 * phi1) * -0.5)))));
} else {
tmp = R * acos((t_1 + (cos(phi1) * cos(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-0.0016d0)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 0.185d0) then
tmp = r * acos((t_1 + ((cos(phi2) * t_0) * (1.0d0 + ((phi1 * phi1) * (-0.5d0))))))
else
tmp = r * acos((t_1 + (cos(phi1) * cos(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -0.0016) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 0.185) {
tmp = R * Math.acos((t_1 + ((Math.cos(phi2) * t_0) * (1.0 + ((phi1 * phi1) * -0.5)))));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * Math.cos(phi2))));
}
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 <= -0.0016: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 0.185: tmp = R * math.acos((t_1 + ((math.cos(phi2) * t_0) * (1.0 + ((phi1 * phi1) * -0.5))))) else: tmp = R * math.acos((t_1 + (math.cos(phi1) * math.cos(phi2)))) 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 <= -0.0016) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 0.185) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi2) * t_0) * Float64(1.0 + Float64(Float64(phi1 * phi1) * -0.5)))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * cos(phi2))))); 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 <= -0.0016) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 0.185) tmp = R * acos((t_1 + ((cos(phi2) * t_0) * (1.0 + ((phi1 * phi1) * -0.5))))); else tmp = R * acos((t_1 + (cos(phi1) * cos(phi2)))); 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, -0.0016], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.185], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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 -0.0016:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.185:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \left(\cos \phi_2 \cdot t_0\right) \cdot \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -0.00160000000000000008Initial program 78.3%
Taylor expanded in phi2 around 0 49.1%
sub-neg49.1%
+-commutative49.1%
neg-mul-149.1%
neg-mul-149.1%
remove-double-neg49.1%
mul-1-neg49.1%
distribute-neg-in49.1%
+-commutative49.1%
cos-neg49.1%
+-commutative49.1%
mul-1-neg49.1%
unsub-neg49.1%
Simplified49.1%
if -0.00160000000000000008 < phi1 < 0.185Initial program 70.3%
Taylor expanded in phi1 around 0 70.3%
*-rgt-identity70.3%
*-commutative70.3%
associate-*r*70.3%
associate-*l*70.3%
distribute-lft-out70.3%
Simplified70.3%
if 0.185 < phi1 Initial program 72.7%
cos-diff99.2%
+-commutative99.2%
Applied egg-rr99.2%
Taylor expanded in lambda1 around 0 59.6%
Taylor expanded in lambda2 around 0 35.6%
Final simplification56.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -2.6e-6)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 0.00245)
(* R (acos (+ t_1 (* (cos phi2) t_0))))
(* R (acos (+ t_1 (* (cos phi1) (cos phi2)))))))))
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.6e-6) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 0.00245) {
tmp = R * acos((t_1 + (cos(phi2) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(phi1) * cos(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-2.6d-6)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 0.00245d0) then
tmp = r * acos((t_1 + (cos(phi2) * t_0)))
else
tmp = r * acos((t_1 + (cos(phi1) * cos(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -2.6e-6) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 0.00245) {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * Math.cos(phi2))));
}
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.6e-6: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 0.00245: tmp = R * math.acos((t_1 + (math.cos(phi2) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(phi1) * math.cos(phi2)))) 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.6e-6) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 0.00245) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * cos(phi2))))); 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.6e-6) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 0.00245) tmp = R * acos((t_1 + (cos(phi2) * t_0))); else tmp = R * acos((t_1 + (cos(phi1) * cos(phi2)))); 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.6e-6], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00245], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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.6 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00245:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -2.60000000000000009e-6Initial program 79.0%
Taylor expanded in phi2 around 0 49.0%
sub-neg49.0%
+-commutative49.0%
neg-mul-149.0%
neg-mul-149.0%
remove-double-neg49.0%
mul-1-neg49.0%
distribute-neg-in49.0%
+-commutative49.0%
cos-neg49.0%
+-commutative49.0%
mul-1-neg49.0%
unsub-neg49.0%
Simplified49.0%
if -2.60000000000000009e-6 < phi1 < 0.0024499999999999999Initial program 69.9%
Taylor expanded in phi1 around 0 69.7%
sub-neg69.7%
+-commutative69.7%
neg-mul-169.7%
neg-mul-169.7%
remove-double-neg69.7%
mul-1-neg69.7%
distribute-neg-in69.7%
+-commutative69.7%
cos-neg69.7%
+-commutative69.7%
mul-1-neg69.7%
unsub-neg69.7%
Simplified69.7%
if 0.0024499999999999999 < phi1 Initial program 72.7%
cos-diff99.2%
+-commutative99.2%
Applied egg-rr99.2%
Taylor expanded in lambda1 around 0 59.6%
Taylor expanded in lambda2 around 0 35.6%
Final simplification55.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -2.3e-8)
(* R (acos (+ t_0 (* (cos phi1) (cos phi2)))))
(if (<= phi2 0.00045)
(*
R
(acos
(+ (* (sin phi1) phi2) (* (cos phi1) (cos (- lambda2 lambda1))))))
(* R (acos (+ t_0 (* (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 (phi2 <= -2.3e-8) {
tmp = R * acos((t_0 + (cos(phi1) * cos(phi2))));
} else if (phi2 <= 0.00045) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos((t_0 + (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 (phi2 <= (-2.3d-8)) then
tmp = r * acos((t_0 + (cos(phi1) * cos(phi2))))
else if (phi2 <= 0.00045d0) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))))
else
tmp = r * acos((t_0 + (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 (phi2 <= -2.3e-8) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(phi2))));
} else if (phi2 <= 0.00045) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (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 phi2 <= -2.3e-8: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(phi2)))) elif phi2 <= 0.00045: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = R * math.acos((t_0 + (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 (phi2 <= -2.3e-8) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(phi2))))); elseif (phi2 <= 0.00045) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + 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 (phi2 <= -2.3e-8) tmp = R * acos((t_0 + (cos(phi1) * cos(phi2)))); elseif (phi2 <= 0.00045) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1))))); else tmp = R * acos((t_0 + (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[phi2, -2.3e-8], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00045], 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[(t$95$0 + N[(N[Cos[phi2], $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}\;\phi_2 \leq -2.3 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00045:\\
\;\;\;\;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(t_0 + \cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < -2.3000000000000001e-8Initial program 83.5%
cos-diff99.0%
+-commutative99.0%
Applied egg-rr99.0%
Taylor expanded in lambda1 around 0 61.8%
Taylor expanded in lambda2 around 0 37.7%
if -2.3000000000000001e-8 < phi2 < 4.4999999999999999e-4Initial program 65.9%
Taylor expanded in phi2 around 0 65.5%
sub-neg65.5%
+-commutative65.5%
neg-mul-165.5%
neg-mul-165.5%
remove-double-neg65.5%
mul-1-neg65.5%
distribute-neg-in65.5%
+-commutative65.5%
cos-neg65.5%
+-commutative65.5%
mul-1-neg65.5%
unsub-neg65.5%
Simplified65.5%
Taylor expanded in phi2 around 0 65.5%
if 4.4999999999999999e-4 < phi2 Initial program 72.3%
cos-diff99.4%
+-commutative99.4%
Applied egg-rr99.4%
Taylor expanded in lambda1 around 0 56.2%
Taylor expanded in phi1 around 0 41.9%
Final simplification51.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 0.00045)
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1))))))
(* R (acos (+ t_0 (* (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 (phi2 <= 0.00045) {
tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos((t_0 + (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 (phi2 <= 0.00045d0) then
tmp = r * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))
else
tmp = r * acos((t_0 + (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 (phi2 <= 0.00045) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (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 phi2 <= 0.00045: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = R * math.acos((t_0 + (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 (phi2 <= 0.00045) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + 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 (phi2 <= 0.00045) tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))); else tmp = R * acos((t_0 + (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[phi2, 0.00045], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq 0.00045:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < 4.4999999999999999e-4Initial program 72.7%
Taylor expanded in phi2 around 0 47.4%
sub-neg47.4%
+-commutative47.4%
neg-mul-147.4%
neg-mul-147.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
+-commutative47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
if 4.4999999999999999e-4 < phi2 Initial program 72.3%
cos-diff99.4%
+-commutative99.4%
Applied egg-rr99.4%
Taylor expanded in lambda1 around 0 56.2%
Taylor expanded in phi1 around 0 41.9%
Final simplification46.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.00045)
(*
R
(acos (+ (* (sin phi1) phi2) (* (cos phi1) (cos (- lambda2 lambda1))))))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi2) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00045) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 0.00045d0) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00045) {
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(phi2) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.00045: 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(phi2) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00045) 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(phi2) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.00045) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.00045], 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[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.00045:\\
\;\;\;\;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_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < 4.4999999999999999e-4Initial program 72.7%
Taylor expanded in phi2 around 0 47.4%
sub-neg47.4%
+-commutative47.4%
neg-mul-147.4%
neg-mul-147.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
+-commutative47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
Taylor expanded in phi2 around 0 41.8%
if 4.4999999999999999e-4 < phi2 Initial program 72.3%
cos-diff99.4%
+-commutative99.4%
Applied egg-rr99.4%
Taylor expanded in lambda1 around 0 56.2%
Taylor expanded in phi1 around 0 41.9%
Final simplification41.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= R -1.6e-305)
(*
R
(acos (+ (* (sin phi1) phi2) (* (cos phi1) (cos (- lambda2 lambda1))))))
(pow (sqrt (* R (acos (* (cos phi1) (cos (- lambda1 lambda2)))))) 2.0)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= -1.6e-305) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = pow(sqrt((R * acos((cos(phi1) * cos((lambda1 - lambda2)))))), 2.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) :: tmp
if (r <= (-1.6d-305)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))))
else
tmp = sqrt((r * acos((cos(phi1) * cos((lambda1 - lambda2)))))) ** 2.0d0
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= -1.6e-305) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.pow(Math.sqrt((R * Math.acos((Math.cos(phi1) * Math.cos((lambda1 - lambda2)))))), 2.0);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if R <= -1.6e-305: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.pow(math.sqrt((R * math.acos((math.cos(phi1) * math.cos((lambda1 - lambda2)))))), 2.0) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= -1.6e-305) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = sqrt(Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))) ^ 2.0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (R <= -1.6e-305) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1))))); else tmp = sqrt((R * acos((cos(phi1) * cos((lambda1 - lambda2)))))) ^ 2.0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, -1.6e-305], 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[Power[N[Sqrt[N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq -1.6 \cdot 10^{-305}:\\
\;\;\;\;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}:\\
\;\;\;\;{\left(\sqrt{R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\right)}^{2}\\
\end{array}
\end{array}
if R < -1.60000000000000004e-305Initial program 77.1%
Taylor expanded in phi2 around 0 40.5%
sub-neg40.5%
+-commutative40.5%
neg-mul-140.5%
neg-mul-140.5%
remove-double-neg40.5%
mul-1-neg40.5%
distribute-neg-in40.5%
+-commutative40.5%
cos-neg40.5%
+-commutative40.5%
mul-1-neg40.5%
unsub-neg40.5%
Simplified40.5%
Taylor expanded in phi2 around 0 33.8%
if -1.60000000000000004e-305 < R Initial program 68.0%
add-sqr-sqrt67.8%
pow267.8%
Applied egg-rr67.8%
Taylor expanded in phi2 around 0 39.9%
Final simplification36.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 19500000000.0)
(*
R
(acos (+ (* (sin phi1) phi2) (* (cos phi1) (cos (- lambda2 lambda1))))))
(pow (sqrt (* R (acos (* (cos phi2) (cos (- lambda1 lambda2)))))) 2.0)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 19500000000.0) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = pow(sqrt((R * acos((cos(phi2) * cos((lambda1 - lambda2)))))), 2.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) :: tmp
if (phi2 <= 19500000000.0d0) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1)))))
else
tmp = sqrt((r * acos((cos(phi2) * cos((lambda1 - lambda2)))))) ** 2.0d0
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 19500000000.0) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.pow(Math.sqrt((R * Math.acos((Math.cos(phi2) * Math.cos((lambda1 - lambda2)))))), 2.0);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 19500000000.0: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.pow(math.sqrt((R * math.acos((math.cos(phi2) * math.cos((lambda1 - lambda2)))))), 2.0) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 19500000000.0) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = sqrt(Float64(R * acos(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) ^ 2.0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 19500000000.0) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos((lambda2 - lambda1))))); else tmp = sqrt((R * acos((cos(phi2) * cos((lambda1 - lambda2)))))) ^ 2.0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 19500000000.0], 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[Power[N[Sqrt[N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 19500000000:\\
\;\;\;\;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}:\\
\;\;\;\;{\left(\sqrt{R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\right)}^{2}\\
\end{array}
\end{array}
if phi2 < 1.95e10Initial program 72.6%
Taylor expanded in phi2 around 0 46.8%
sub-neg46.8%
+-commutative46.8%
neg-mul-146.8%
neg-mul-146.8%
remove-double-neg46.8%
mul-1-neg46.8%
distribute-neg-in46.8%
+-commutative46.8%
cos-neg46.8%
+-commutative46.8%
mul-1-neg46.8%
unsub-neg46.8%
Simplified46.8%
Taylor expanded in phi2 around 0 41.3%
if 1.95e10 < phi2 Initial program 72.3%
add-sqr-sqrt32.8%
pow232.8%
Applied egg-rr32.8%
Taylor expanded in phi1 around 0 20.7%
Final simplification36.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos (- lambda2 lambda1)))))
(if (<= phi2 50000.0)
(* R (acos (+ (* (sin phi1) phi2) t_0)))
(* R (acos (+ (* phi1 (sin phi2)) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 50000.0) {
tmp = R * acos(((sin(phi1) * phi2) + t_0));
} else {
tmp = R * acos(((phi1 * sin(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(phi1) * cos((lambda2 - lambda1))
if (phi2 <= 50000.0d0) then
tmp = r * acos(((sin(phi1) * phi2) + t_0))
else
tmp = r * acos(((phi1 * sin(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(phi1) * Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 50000.0) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + t_0));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= 50000.0: tmp = R * math.acos(((math.sin(phi1) * phi2) + t_0)) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))) tmp = 0.0 if (phi2 <= 50000.0) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + t_0))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos((lambda2 - lambda1)); tmp = 0.0; if (phi2 <= 50000.0) tmp = R * acos(((sin(phi1) * phi2) + t_0)); else tmp = R * acos(((phi1 * sin(phi2)) + t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 50000.0], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq 50000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + t_0\right)\\
\end{array}
\end{array}
if phi2 < 5e4Initial program 72.5%
Taylor expanded in phi2 around 0 47.0%
sub-neg47.0%
+-commutative47.0%
neg-mul-147.0%
neg-mul-147.0%
remove-double-neg47.0%
mul-1-neg47.0%
distribute-neg-in47.0%
+-commutative47.0%
cos-neg47.0%
+-commutative47.0%
mul-1-neg47.0%
unsub-neg47.0%
Simplified47.0%
Taylor expanded in phi2 around 0 41.5%
if 5e4 < phi2 Initial program 72.8%
Taylor expanded in phi2 around 0 18.6%
sub-neg18.6%
+-commutative18.6%
neg-mul-118.6%
neg-mul-118.6%
remove-double-neg18.6%
mul-1-neg18.6%
distribute-neg-in18.6%
+-commutative18.6%
cos-neg18.6%
+-commutative18.6%
mul-1-neg18.6%
unsub-neg18.6%
Simplified18.6%
Taylor expanded in phi1 around 0 10.9%
Final simplification33.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 6.4e+103) (* R (acos (+ (* (cos phi1) (cos (- lambda2 lambda1))) (* phi1 phi2)))) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi1) (cos lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 6.4e+103) {
tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (phi1 * phi2)));
} else {
tmp = R * acos(((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 <= 6.4d+103) then
tmp = r * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (phi1 * phi2)))
else
tmp = r * acos(((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 <= 6.4e+103) {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos((lambda2 - lambda1))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 6.4e+103: tmp = R * math.acos(((math.cos(phi1) * math.cos((lambda2 - lambda1))) + (phi1 * phi2))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 6.4e+103) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(Float64(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 <= 6.4e+103) tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (phi1 * phi2))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 6.4e+103], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * 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 6.4 \cdot 10^{+103}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < 6.39999999999999985e103Initial program 72.3%
Taylor expanded in phi2 around 0 43.5%
sub-neg43.5%
+-commutative43.5%
neg-mul-143.5%
neg-mul-143.5%
remove-double-neg43.5%
mul-1-neg43.5%
distribute-neg-in43.5%
+-commutative43.5%
cos-neg43.5%
+-commutative43.5%
mul-1-neg43.5%
unsub-neg43.5%
Simplified43.5%
Taylor expanded in phi1 around 0 29.0%
Taylor expanded in phi2 around 0 27.5%
*-commutative27.5%
Simplified27.5%
if 6.39999999999999985e103 < phi2 Initial program 74.2%
Taylor expanded in phi2 around 0 19.9%
sub-neg19.9%
+-commutative19.9%
neg-mul-119.9%
neg-mul-119.9%
remove-double-neg19.9%
mul-1-neg19.9%
distribute-neg-in19.9%
+-commutative19.9%
cos-neg19.9%
+-commutative19.9%
mul-1-neg19.9%
unsub-neg19.9%
Simplified19.9%
Taylor expanded in phi1 around 0 11.6%
Taylor expanded in lambda2 around 0 7.3%
cos-neg7.3%
Simplified7.3%
Final simplification24.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda1 -13500000000000.0)
(* 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 (lambda1 <= -13500000000000.0) {
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 (lambda1 <= (-13500000000000.0d0)) 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 (lambda1 <= -13500000000000.0) {
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 lambda1 <= -13500000000000.0: 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 (lambda1 <= -13500000000000.0) 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 (lambda1 <= -13500000000000.0) 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[lambda1, -13500000000000.0], 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_1 \leq -13500000000000:\\
\;\;\;\;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 lambda1 < -1.35e13Initial program 61.2%
Taylor expanded in phi2 around 0 38.3%
sub-neg38.3%
+-commutative38.3%
neg-mul-138.3%
neg-mul-138.3%
remove-double-neg38.3%
mul-1-neg38.3%
distribute-neg-in38.3%
+-commutative38.3%
cos-neg38.3%
+-commutative38.3%
mul-1-neg38.3%
unsub-neg38.3%
Simplified38.3%
Taylor expanded in phi1 around 0 32.1%
Taylor expanded in lambda2 around 0 32.4%
cos-neg32.4%
Simplified32.4%
if -1.35e13 < lambda1 Initial program 75.5%
Taylor expanded in phi2 around 0 40.3%
sub-neg40.3%
+-commutative40.3%
neg-mul-140.3%
neg-mul-140.3%
remove-double-neg40.3%
mul-1-neg40.3%
distribute-neg-in40.3%
+-commutative40.3%
cos-neg40.3%
+-commutative40.3%
mul-1-neg40.3%
unsub-neg40.3%
Simplified40.3%
Taylor expanded in phi1 around 0 24.8%
Taylor expanded in lambda1 around 0 17.5%
Final simplification20.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.6%
Taylor expanded in phi2 around 0 39.9%
sub-neg39.9%
+-commutative39.9%
neg-mul-139.9%
neg-mul-139.9%
remove-double-neg39.9%
mul-1-neg39.9%
distribute-neg-in39.9%
+-commutative39.9%
cos-neg39.9%
+-commutative39.9%
mul-1-neg39.9%
unsub-neg39.9%
Simplified39.9%
Taylor expanded in phi1 around 0 26.3%
Final simplification26.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.00175)
(* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1)))))
(*
R
(acos
(+
(* phi1 phi2)
(* (cos (- lambda1 lambda2)) (+ 1.0 (* (* phi1 phi1) -0.5))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00175) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos(((phi1 * phi2) + (cos((lambda1 - lambda2)) * (1.0 + ((phi1 * phi1) * -0.5)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi1 <= (-0.00175d0)) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos(((phi1 * phi2) + (cos((lambda1 - lambda2)) * (1.0d0 + ((phi1 * phi1) * (-0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00175) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos((lambda1 - lambda2)) * (1.0 + ((phi1 * phi1) * -0.5)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00175: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos(((phi1 * phi2) + (math.cos((lambda1 - lambda2)) * (1.0 + ((phi1 * phi1) * -0.5))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00175) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(Float64(lambda1 - lambda2)) * Float64(1.0 + Float64(Float64(phi1 * phi1) * -0.5)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.00175) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos(((phi1 * phi2) + (cos((lambda1 - lambda2)) * (1.0 + ((phi1 * phi1) * -0.5))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00175], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00175:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.5\right)\right)\\
\end{array}
\end{array}
if phi1 < -0.00175000000000000004Initial program 77.9%
Taylor expanded in phi2 around 0 48.2%
sub-neg48.2%
+-commutative48.2%
neg-mul-148.2%
neg-mul-148.2%
remove-double-neg48.2%
mul-1-neg48.2%
distribute-neg-in48.2%
+-commutative48.2%
cos-neg48.2%
+-commutative48.2%
mul-1-neg48.2%
unsub-neg48.2%
Simplified48.2%
Taylor expanded in phi1 around 0 15.8%
Taylor expanded in phi2 around 0 15.8%
*-commutative15.8%
Simplified15.8%
Taylor expanded in lambda2 around 0 14.1%
cos-neg14.1%
Simplified14.1%
if -0.00175000000000000004 < phi1 Initial program 71.2%
Taylor expanded in phi2 around 0 37.8%
sub-neg37.8%
+-commutative37.8%
neg-mul-137.8%
neg-mul-137.8%
remove-double-neg37.8%
mul-1-neg37.8%
distribute-neg-in37.8%
+-commutative37.8%
cos-neg37.8%
+-commutative37.8%
mul-1-neg37.8%
unsub-neg37.8%
Simplified37.8%
Taylor expanded in phi1 around 0 29.0%
Taylor expanded in phi2 around 0 25.5%
*-commutative25.5%
Simplified25.5%
Taylor expanded in phi1 around 0 20.7%
associate-*r*20.7%
distribute-lft1-in20.6%
unpow220.6%
sub-neg20.6%
+-commutative20.6%
neg-mul-120.6%
neg-mul-120.6%
remove-double-neg20.6%
distribute-neg-in20.6%
+-commutative20.6%
mul-1-neg20.6%
cos-neg20.6%
mul-1-neg20.6%
+-commutative20.6%
sub-neg20.6%
Simplified20.6%
Final simplification19.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -8.4e+17) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (* (cos phi1) (cos lambda2)) (* phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.4e+17) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos(((cos(phi1) * cos(lambda2)) + (phi1 * phi2)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-8.4d+17)) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos(((cos(phi1) * cos(lambda2)) + (phi1 * phi2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.4e+17) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos(lambda2)) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -8.4e+17: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos(((math.cos(phi1) * math.cos(lambda2)) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -8.4e+17) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(lambda2)) + Float64(phi1 * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -8.4e+17) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos(((cos(phi1) * cos(lambda2)) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -8.4e+17], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -8.4 \cdot 10^{+17}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2 + \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if lambda1 < -8.4e17Initial program 60.5%
Taylor expanded in phi2 around 0 38.7%
sub-neg38.7%
+-commutative38.7%
neg-mul-138.7%
neg-mul-138.7%
remove-double-neg38.7%
mul-1-neg38.7%
distribute-neg-in38.7%
+-commutative38.7%
cos-neg38.7%
+-commutative38.7%
mul-1-neg38.7%
unsub-neg38.7%
Simplified38.7%
Taylor expanded in phi1 around 0 32.7%
Taylor expanded in phi2 around 0 31.2%
*-commutative31.2%
Simplified31.2%
Taylor expanded in lambda2 around 0 31.5%
cos-neg31.5%
Simplified31.5%
if -8.4e17 < lambda1 Initial program 75.7%
Taylor expanded in phi2 around 0 40.2%
sub-neg40.2%
+-commutative40.2%
neg-mul-140.2%
neg-mul-140.2%
remove-double-neg40.2%
mul-1-neg40.2%
distribute-neg-in40.2%
+-commutative40.2%
cos-neg40.2%
+-commutative40.2%
mul-1-neg40.2%
unsub-neg40.2%
Simplified40.2%
Taylor expanded in phi1 around 0 24.7%
Taylor expanded in phi2 around 0 21.6%
*-commutative21.6%
Simplified21.6%
Taylor expanded in lambda1 around 0 15.0%
Final simplification18.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* (cos phi1) (cos (- lambda2 lambda1))) (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((cos(phi1) * 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(phi1) * 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(phi1) * Math.cos((lambda2 - lambda1))) + (phi1 * phi2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.cos(phi1) * math.cos((lambda2 - lambda1))) + (phi1 * phi2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))) + Float64(phi1 * phi2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (phi1 * phi2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)
\end{array}
Initial program 72.6%
Taylor expanded in phi2 around 0 39.9%
sub-neg39.9%
+-commutative39.9%
neg-mul-139.9%
neg-mul-139.9%
remove-double-neg39.9%
mul-1-neg39.9%
distribute-neg-in39.9%
+-commutative39.9%
cos-neg39.9%
+-commutative39.9%
mul-1-neg39.9%
unsub-neg39.9%
Simplified39.9%
Taylor expanded in phi1 around 0 26.3%
Taylor expanded in phi2 around 0 23.6%
*-commutative23.6%
Simplified23.6%
Final simplification23.6%
(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.6%
Taylor expanded in phi2 around 0 39.9%
sub-neg39.9%
+-commutative39.9%
neg-mul-139.9%
neg-mul-139.9%
remove-double-neg39.9%
mul-1-neg39.9%
distribute-neg-in39.9%
+-commutative39.9%
cos-neg39.9%
+-commutative39.9%
mul-1-neg39.9%
unsub-neg39.9%
Simplified39.9%
Taylor expanded in phi1 around 0 26.3%
Taylor expanded in phi2 around 0 23.6%
*-commutative23.6%
Simplified23.6%
Taylor expanded in phi1 around 0 18.0%
Final simplification18.0%
herbie shell --seed 2023228
(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))