
(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
(let* ((t_0 (* (cos phi1) (cos phi2))))
(*
(acos
(+
(* (sin phi1) (sin phi2))
(+
(* t_0 (* (cos lambda1) (cos lambda2)))
(* t_0 (* (sin lambda1) (sin lambda2))))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
return acos(((sin(phi1) * sin(phi2)) + ((t_0 * (cos(lambda1) * cos(lambda2))) + (t_0 * (sin(lambda1) * sin(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
real(8) :: t_0
t_0 = cos(phi1) * cos(phi2)
code = acos(((sin(phi1) * sin(phi2)) + ((t_0 * (cos(lambda1) * cos(lambda2))) + (t_0 * (sin(lambda1) * sin(lambda2)))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((t_0 * (Math.cos(lambda1) * Math.cos(lambda2))) + (t_0 * (Math.sin(lambda1) * Math.sin(lambda2)))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((t_0 * (math.cos(lambda1) * math.cos(lambda2))) + (t_0 * (math.sin(lambda1) * math.sin(lambda2)))))) * R
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(t_0 * Float64(cos(lambda1) * cos(lambda2))) + Float64(t_0 * Float64(sin(lambda1) * sin(lambda2)))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); tmp = acos(((sin(phi1) * sin(phi2)) + ((t_0 * (cos(lambda1) * cos(lambda2))) + (t_0 * (sin(lambda1) * sin(lambda2)))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(t\_0 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right) \cdot R
\end{array}
\end{array}
Initial program 73.6%
cos-diff95.2%
distribute-lft-in95.2%
Applied egg-rr95.2%
Final simplification95.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(*
(* (cos phi1) (cos phi2))
(fma (sin lambda1) (sin lambda2) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma(sin(phi1), sin(phi2), ((cos(phi1) * cos(phi2)) * fma(sin(lambda1), sin(lambda2), (cos(lambda1) * cos(lambda2))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(Float64(cos(phi1) * cos(phi2)) * fma(sin(lambda1), sin(lambda2), Float64(cos(lambda1) * cos(lambda2))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right)
\end{array}
Initial program 73.6%
cos-diff95.2%
distribute-lft-in95.2%
Applied egg-rr95.2%
add-cbrt-cube95.1%
pow395.2%
associate-*l*95.2%
Applied egg-rr95.2%
Taylor expanded in phi1 around 0 95.2%
associate-+r+95.2%
Simplified95.2%
Final simplification95.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (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)) * fma(sin(lambda1), sin(lambda2), (cos(lambda1) * 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)) * fma(sin(lambda1), sin(lambda2), Float64(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[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $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 \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)
\end{array}
Initial program 73.6%
expm1-log1p-u73.6%
expm1-undefine73.5%
Applied egg-rr73.5%
expm1-define73.6%
expm1-log1p-u73.6%
cos-diff95.2%
Applied egg-rr95.2%
+-commutative95.2%
fma-define95.2%
Simplified95.2%
Final simplification95.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(fma
(cos phi1)
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
(* (sin phi1) (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma(cos(phi1), (cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))), (sin(phi1) * sin(phi2))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))), Float64(sin(phi1) * sin(phi2))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)
\end{array}
Initial program 73.6%
*-commutative73.6%
*-commutative73.6%
+-commutative73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
fma-define73.6%
Simplified73.6%
cos-diff44.2%
+-commutative44.2%
Applied egg-rr95.2%
Final simplification95.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi1 -9.5e-7)
(* R (acos (+ t_2 (* t_0 (log (exp t_1))))))
(if (<= phi1 1.9e-8)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
(* phi1 (sin phi2)))))
(* R (log (exp (acos (fma t_1 t_0 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -9.5e-7) {
tmp = R * acos((t_2 + (t_0 * log(exp(t_1)))));
} else if (phi1 <= 1.9e-8) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * log(exp(acos(fma(t_1, t_0, t_2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -9.5e-7) tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * log(exp(t_1)))))); elseif (phi1 <= 1.9e-8) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * log(exp(acos(fma(t_1, t_0, t_2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -9.5e-7], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-8], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Log[N[Exp[N[ArcCos[N[(t$95$1 * t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \log \left(e^{t\_1}\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(t\_1, t\_0, t\_2\right)\right)}\right)\\
\end{array}
\end{array}
if phi1 < -9.5000000000000001e-7Initial program 71.5%
add-log-exp71.6%
Applied egg-rr71.6%
if -9.5000000000000001e-7 < phi1 < 1.90000000000000014e-8Initial program 68.5%
*-commutative68.5%
*-commutative68.5%
+-commutative68.5%
*-commutative68.5%
associate-*l*68.5%
*-commutative68.5%
fma-define68.5%
Simplified68.5%
Taylor expanded in phi1 around 0 68.5%
cos-diff90.4%
+-commutative90.4%
Applied egg-rr90.4%
if 1.90000000000000014e-8 < phi1 Initial program 83.6%
+-commutative83.6%
associate-*r*83.6%
fma-undefine83.6%
add-log-exp83.6%
fma-undefine83.6%
associate-*r*83.6%
*-commutative83.6%
fma-define83.6%
Applied egg-rr83.6%
Final simplification83.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)
\end{array}
Initial program 73.6%
cos-diff95.2%
distribute-lft-in95.2%
Applied egg-rr95.2%
add-cbrt-cube95.1%
pow395.2%
associate-*l*95.2%
Applied egg-rr95.2%
Taylor expanded in phi1 around 0 95.2%
associate-+r+95.2%
Simplified95.2%
Taylor expanded in phi1 around 0 95.2%
Final simplification95.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi1 -5.9e-6)
(* R (acos (+ t_2 (* t_0 (log (exp t_1))))))
(if (<= phi1 1.9e-8)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
(* phi1 (sin phi2)))))
(* R (acos (+ t_2 (* t_0 (+ (+ t_1 1.0) -1.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -5.9e-6) {
tmp = R * acos((t_2 + (t_0 * log(exp(t_1)))));
} else if (phi1 <= 1.9e-8) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_2 + (t_0 * ((t_1 + 1.0) + -1.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin(phi1) * sin(phi2)
if (phi1 <= (-5.9d-6)) then
tmp = r * acos((t_2 + (t_0 * log(exp(t_1)))))
else if (phi1 <= 1.9d-8) then
tmp = r * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))))
else
tmp = r * acos((t_2 + (t_0 * ((t_1 + 1.0d0) + (-1.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -5.9e-6) {
tmp = R * Math.acos((t_2 + (t_0 * Math.log(Math.exp(t_1)))));
} else if (phi1 <= 1.9e-8) {
tmp = R * Math.acos(((Math.cos(phi2) * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2)))) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos((t_2 + (t_0 * ((t_1 + 1.0) + -1.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -5.9e-6: tmp = R * math.acos((t_2 + (t_0 * math.log(math.exp(t_1))))) elif phi1 <= 1.9e-8: tmp = R * math.acos(((math.cos(phi2) * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2)))) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos((t_2 + (t_0 * ((t_1 + 1.0) + -1.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -5.9e-6) tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * log(exp(t_1)))))); elseif (phi1 <= 1.9e-8) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * Float64(Float64(t_1 + 1.0) + -1.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -5.9e-6) tmp = R * acos((t_2 + (t_0 * log(exp(t_1))))); elseif (phi1 <= 1.9e-8) tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2)))); else tmp = R * acos((t_2 + (t_0 * ((t_1 + 1.0) + -1.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5.9e-6], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-8], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[(N[(t$95$1 + 1.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -5.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \log \left(e^{t\_1}\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \left(\left(t\_1 + 1\right) + -1\right)\right)\\
\end{array}
\end{array}
if phi1 < -5.90000000000000026e-6Initial program 71.5%
add-log-exp71.6%
Applied egg-rr71.6%
if -5.90000000000000026e-6 < phi1 < 1.90000000000000014e-8Initial program 68.5%
*-commutative68.5%
*-commutative68.5%
+-commutative68.5%
*-commutative68.5%
associate-*l*68.5%
*-commutative68.5%
fma-define68.5%
Simplified68.5%
Taylor expanded in phi1 around 0 68.5%
cos-diff90.4%
+-commutative90.4%
Applied egg-rr90.4%
if 1.90000000000000014e-8 < phi1 Initial program 83.6%
expm1-log1p-u83.6%
expm1-undefine83.6%
Applied egg-rr83.6%
sub-neg83.6%
log1p-undefine83.7%
rem-exp-log83.7%
metadata-eval83.7%
Applied egg-rr83.7%
Final simplification83.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -4.5e-42)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))
(if (<= phi1 1.9e-8)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
(* phi1 (sin phi2)))))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (+ (+ t_0 1.0) -1.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -4.5e-42) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
} else if (phi1 <= 1.9e-8) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((t_0 + 1.0) + -1.0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -4.5e-42) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); elseif (phi1 <= 1.9e-8) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(t_0 + 1.0) + -1.0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -4.5e-42], 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[phi1, 1.9e-8], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$0 + 1.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -4.5 \cdot 10^{-42}:\\
\;\;\;\;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_1 \leq 1.9 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \phi_1 \cdot \sin \phi_2\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 \left(\left(t\_0 + 1\right) + -1\right)\right)\\
\end{array}
\end{array}
if phi1 < -4.5e-42Initial program 71.5%
Simplified71.5%
if -4.5e-42 < phi1 < 1.90000000000000014e-8Initial program 68.4%
*-commutative68.4%
*-commutative68.4%
+-commutative68.4%
*-commutative68.4%
associate-*l*68.4%
*-commutative68.4%
fma-define68.4%
Simplified68.4%
Taylor expanded in phi1 around 0 68.4%
cos-diff90.2%
+-commutative90.2%
Applied egg-rr90.2%
if 1.90000000000000014e-8 < phi1 Initial program 83.6%
expm1-log1p-u83.6%
expm1-undefine83.6%
Applied egg-rr83.6%
sub-neg83.6%
log1p-undefine83.7%
rem-exp-log83.7%
metadata-eval83.7%
Applied egg-rr83.7%
Final simplification83.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -4.5e-42)
(*
R
(-
(/ PI 2.0)
(- (* PI 0.5) (acos (fma t_0 (cos (- lambda2 lambda1)) t_1)))))
(if (<= phi1 1.9e-8)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
(* phi1 (sin phi2)))))
(*
R
(acos (+ t_1 (* t_0 (+ (+ (cos (- lambda1 lambda2)) 1.0) -1.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -4.5e-42) {
tmp = R * ((((double) M_PI) / 2.0) - ((((double) M_PI) * 0.5) - acos(fma(t_0, cos((lambda2 - lambda1)), t_1))));
} else if (phi1 <= 1.9e-8) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_1 + (t_0 * ((cos((lambda1 - lambda2)) + 1.0) + -1.0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -4.5e-42) tmp = Float64(R * Float64(Float64(pi / 2.0) - Float64(Float64(pi * 0.5) - acos(fma(t_0, cos(Float64(lambda2 - lambda1)), t_1))))); elseif (phi1 <= 1.9e-8) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + 1.0) + -1.0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.5e-42], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcCos[N[(t$95$0 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-8], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -4.5 \cdot 10^{-42}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \left(\pi \cdot 0.5 - \cos^{-1} \left(\mathsf{fma}\left(t\_0, \cos \left(\lambda_2 - \lambda_1\right), t\_1\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \left(\left(\cos \left(\lambda_1 - \lambda_2\right) + 1\right) + -1\right)\right)\\
\end{array}
\end{array}
if phi1 < -4.5e-42Initial program 71.5%
cos-diff98.9%
distribute-lft-in99.0%
Applied egg-rr99.0%
acos-asin98.8%
distribute-lft-out98.8%
cos-diff71.4%
expm1-log1p-u71.4%
expm1-define71.3%
Applied egg-rr71.3%
asin-acos71.6%
div-inv71.6%
metadata-eval71.6%
cos-diff99.0%
*-commutative99.0%
*-commutative99.0%
cos-diff71.6%
Applied egg-rr71.6%
if -4.5e-42 < phi1 < 1.90000000000000014e-8Initial program 68.4%
*-commutative68.4%
*-commutative68.4%
+-commutative68.4%
*-commutative68.4%
associate-*l*68.4%
*-commutative68.4%
fma-define68.4%
Simplified68.4%
Taylor expanded in phi1 around 0 68.4%
cos-diff90.2%
+-commutative90.2%
Applied egg-rr90.2%
if 1.90000000000000014e-8 < phi1 Initial program 83.6%
expm1-log1p-u83.6%
expm1-undefine83.6%
Applied egg-rr83.6%
sub-neg83.6%
log1p-undefine83.7%
rem-exp-log83.7%
metadata-eval83.7%
Applied egg-rr83.7%
Final simplification83.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(fma
(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(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)
\end{array}
Initial program 73.6%
Simplified73.6%
Final simplification73.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.122)
(*
R
(acos (+ (* phi1 (sin phi2)) (* (cos phi2) (* (cos phi1) (cos lambda1))))))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi1) (* (cos phi2) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.122) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-0.122d0)) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.122) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -0.122: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda1))))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.122) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -0.122) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.122], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.122:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -0.122Initial program 58.4%
Taylor expanded in lambda2 around 0 58.2%
associate-*r*58.2%
Simplified58.2%
Taylor expanded in phi1 around 0 37.3%
if -0.122 < lambda1 Initial program 77.7%
Taylor expanded in lambda1 around 0 65.9%
*-commutative65.9%
cos-neg65.9%
Simplified65.9%
Final simplification59.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -7e-7)
(* R (acos (+ t_0 (* (cos phi2) (* (cos phi1) (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 <= -7e-7) {
tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * 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 <= (-7d-7)) then
tmp = r * acos((t_0 + (cos(phi2) * (cos(phi1) * 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 <= -7e-7) {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * 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 <= -7e-7: tmp = R * math.acos((t_0 + (math.cos(phi2) * (math.cos(phi1) * 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 <= -7e-7) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -7e-7) tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * 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, -7e-7], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -7 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -6.99999999999999968e-7Initial program 58.4%
Taylor expanded in lambda2 around 0 58.2%
associate-*r*58.2%
Simplified58.2%
if -6.99999999999999968e-7 < lambda1 Initial program 77.7%
Taylor expanded in lambda1 around 0 65.9%
*-commutative65.9%
cos-neg65.9%
Simplified65.9%
Final simplification64.3%
(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 73.6%
Final simplification73.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -0.52)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 0.04)
(*
R
(acos
(+
(* phi1 (sin phi2))
(* (+ 1.0 (* -0.5 (pow phi1 2.0))) (* (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 <= -0.52) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 0.04) {
tmp = R * acos(((phi1 * sin(phi2)) + ((1.0 + (-0.5 * pow(phi1, 2.0))) * (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 <= (-0.52d0)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 0.04d0) then
tmp = r * acos(((phi1 * sin(phi2)) + ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) * (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 <= -0.52) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 0.04) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) * (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 <= -0.52: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 0.04: tmp = R * math.acos(((phi1 * math.sin(phi2)) + ((1.0 + (-0.5 * math.pow(phi1, 2.0))) * (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 <= -0.52) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 0.04) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) * 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 <= -0.52) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 0.04) tmp = R * acos(((phi1 * sin(phi2)) + ((1.0 + (-0.5 * (phi1 ^ 2.0))) * (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, -0.52], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.04], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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.52:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.04:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(1 + -0.5 \cdot {\phi_1}^{2}\right) \cdot \left(\cos \phi_2 \cdot t\_0\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.52000000000000002Initial program 72.2%
Taylor expanded in phi2 around 0 47.5%
sub-neg47.5%
remove-double-neg47.5%
mul-1-neg47.5%
distribute-neg-in47.5%
+-commutative47.5%
cos-neg47.5%
mul-1-neg47.5%
unsub-neg47.5%
Simplified47.5%
if -0.52000000000000002 < phi1 < 0.0400000000000000008Initial program 68.4%
*-commutative68.4%
*-commutative68.4%
+-commutative68.4%
*-commutative68.4%
associate-*l*68.4%
*-commutative68.4%
fma-define68.4%
Simplified68.4%
Taylor expanded in phi1 around 0 68.3%
distribute-rgt-in68.3%
*-commutative68.3%
associate-+l+68.3%
associate-*l*68.3%
*-commutative68.3%
associate-*r*68.3%
unpow268.3%
*-commutative68.3%
associate-*r*68.3%
distribute-lft1-in68.3%
Simplified68.3%
if 0.0400000000000000008 < phi1 Initial program 83.4%
Taylor expanded in lambda2 around 0 58.7%
Taylor expanded in lambda1 around 0 44.9%
Final simplification56.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -2.6e-5)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 4.2e+24)
(* 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-5) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 4.2e+24) {
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-5)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 4.2d+24) 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-5) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 4.2e+24) {
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-5: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 4.2e+24: 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-5) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 4.2e+24) 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-5) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 4.2e+24) 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-5], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4.2e+24], 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^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 4.2 \cdot 10^{+24}:\\
\;\;\;\;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.59999999999999984e-5Initial program 71.5%
Taylor expanded in phi2 around 0 46.7%
sub-neg46.7%
remove-double-neg46.7%
mul-1-neg46.7%
distribute-neg-in46.7%
+-commutative46.7%
cos-neg46.7%
mul-1-neg46.7%
unsub-neg46.7%
Simplified46.7%
if -2.59999999999999984e-5 < phi1 < 4.2000000000000003e24Initial program 69.4%
Taylor expanded in phi1 around 0 65.4%
sub-neg65.4%
neg-mul-165.4%
neg-mul-165.4%
remove-double-neg65.4%
mul-1-neg65.4%
distribute-neg-in65.4%
+-commutative65.4%
cos-neg65.4%
mul-1-neg65.4%
unsub-neg65.4%
Simplified65.4%
if 4.2000000000000003e24 < phi1 Initial program 83.9%
Taylor expanded in lambda2 around 0 59.9%
Taylor expanded in lambda1 around 0 46.8%
Final simplification55.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -2.6e-5)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(if (<= phi1 0.01)
(* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) t_0))))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.6e-5) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else if (phi1 <= 0.01) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (phi1 <= (-2.6d-5)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else if (phi1 <= 0.01d0) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.6e-5) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 0.01) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * t_0)));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -2.6e-5: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) elif phi1 <= 0.01: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * t_0))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -2.6e-5) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 0.01) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * t_0)))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -2.6e-5) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); elseif (phi1 <= 0.01) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.6e-5], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.01], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.01:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -2.59999999999999984e-5Initial program 71.5%
*-commutative71.5%
*-commutative71.5%
+-commutative71.5%
*-commutative71.5%
associate-*l*71.5%
*-commutative71.5%
fma-define71.4%
Simplified71.4%
Taylor expanded in phi2 around 0 38.4%
if -2.59999999999999984e-5 < phi1 < 0.0100000000000000002Initial program 68.7%
*-commutative68.7%
*-commutative68.7%
+-commutative68.7%
*-commutative68.7%
associate-*l*68.7%
*-commutative68.7%
fma-define68.7%
Simplified68.7%
Taylor expanded in phi1 around 0 68.5%
if 0.0100000000000000002 < phi1 Initial program 83.4%
Taylor expanded in lambda2 around 0 58.7%
Taylor expanded in lambda1 around 0 44.9%
Final simplification54.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi1 -2.6e-5)
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1))))))
(if (<= phi1 0.0024)
(*
R
(acos
(+ (* phi1 (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2))))))
(* R (acos (+ t_0 (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -2.6e-5) {
tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))));
} else if (phi1 <= 0.0024) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * cos(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (phi1 <= (-2.6d-5)) then
tmp = r * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))
else if (phi1 <= 0.0024d0) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((t_0 + (cos(phi1) * cos(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -2.6e-5) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (phi1 <= 0.0024) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -2.6e-5: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) elif phi1 <= 0.0024: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -2.6e-5) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); elseif (phi1 <= 0.0024) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -2.6e-5) tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))); elseif (phi1 <= 0.0024) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); else tmp = R * acos((t_0 + (cos(phi1) * cos(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.6e-5], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.0024], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.0024:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -2.59999999999999984e-5Initial program 71.5%
Taylor expanded in phi2 around 0 46.7%
sub-neg46.7%
remove-double-neg46.7%
mul-1-neg46.7%
distribute-neg-in46.7%
+-commutative46.7%
cos-neg46.7%
mul-1-neg46.7%
unsub-neg46.7%
Simplified46.7%
if -2.59999999999999984e-5 < phi1 < 0.00239999999999999979Initial program 68.7%
*-commutative68.7%
*-commutative68.7%
+-commutative68.7%
*-commutative68.7%
associate-*l*68.7%
*-commutative68.7%
fma-define68.7%
Simplified68.7%
Taylor expanded in phi1 around 0 68.5%
if 0.00239999999999999979 < phi1 Initial program 83.4%
Taylor expanded in lambda2 around 0 58.7%
Taylor expanded in lambda1 around 0 44.9%
Final simplification56.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -2.6e-5)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(* R (acos (+ (* phi1 (sin phi2)) (* (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 (phi1 <= -2.6e-5) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (phi1 <= (-2.6d-5)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.6e-5) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -2.6e-5: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -2.6e-5) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -2.6e-5) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.6e-5], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -2.59999999999999984e-5Initial program 71.5%
*-commutative71.5%
*-commutative71.5%
+-commutative71.5%
*-commutative71.5%
associate-*l*71.5%
*-commutative71.5%
fma-define71.4%
Simplified71.4%
Taylor expanded in phi2 around 0 38.4%
if -2.59999999999999984e-5 < phi1 Initial program 74.3%
*-commutative74.3%
*-commutative74.3%
+-commutative74.3%
*-commutative74.3%
associate-*l*74.3%
*-commutative74.3%
fma-define74.3%
Simplified74.3%
Taylor expanded in phi1 around 0 43.9%
Final simplification42.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 9e-7) (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 phi2)))) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 9e-7) {
tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 9d-7) then
tmp = r * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 9e-7) {
tmp = R * Math.acos((Math.cos((lambda2 - lambda1)) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 9e-7: tmp = R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * phi2))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 9e-7) tmp = Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 9e-7) tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 9e-7], N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 9 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\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_2 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < 8.99999999999999959e-7Initial program 74.6%
*-commutative74.6%
*-commutative74.6%
+-commutative74.6%
*-commutative74.6%
associate-*l*74.6%
*-commutative74.6%
fma-define74.6%
Simplified74.6%
Taylor expanded in phi1 around 0 34.9%
Taylor expanded in phi2 around 0 24.4%
sub-neg24.4%
remove-double-neg24.4%
mul-1-neg24.4%
distribute-neg-in24.4%
+-commutative24.4%
cos-neg24.4%
mul-1-neg24.4%
unsub-neg24.4%
Simplified24.4%
Taylor expanded in phi2 around 0 23.3%
*-commutative23.3%
Simplified23.3%
if 8.99999999999999959e-7 < phi2 Initial program 70.6%
*-commutative70.6%
*-commutative70.6%
+-commutative70.6%
*-commutative70.6%
associate-*l*70.6%
*-commutative70.6%
fma-define70.6%
Simplified70.6%
Taylor expanded in phi1 around 0 31.5%
Taylor expanded in lambda2 around 0 22.2%
Final simplification23.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda1 -0.024)
(* R (acos (+ t_0 (* (cos phi2) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi2) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda1 <= -0.024) {
tmp = R * acos((t_0 + (cos(phi2) * cos(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 = phi1 * sin(phi2)
if (lambda1 <= (-0.024d0)) then
tmp = r * acos((t_0 + (cos(phi2) * cos(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 = phi1 * Math.sin(phi2);
double tmp;
if (lambda1 <= -0.024) {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * Math.cos(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 = phi1 * math.sin(phi2) tmp = 0 if lambda1 <= -0.024: tmp = R * math.acos((t_0 + (math.cos(phi2) * math.cos(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(phi1 * sin(phi2)) tmp = 0.0 if (lambda1 <= -0.024) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * cos(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 = phi1 * sin(phi2); tmp = 0.0; if (lambda1 <= -0.024) tmp = R * acos((t_0 + (cos(phi2) * cos(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[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.024], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $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 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.024:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -0.024Initial program 58.4%
*-commutative58.4%
*-commutative58.4%
+-commutative58.4%
*-commutative58.4%
associate-*l*58.4%
*-commutative58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in phi1 around 0 32.7%
Taylor expanded in lambda2 around 0 32.2%
if -0.024 < lambda1 Initial program 77.7%
*-commutative77.7%
*-commutative77.7%
+-commutative77.7%
*-commutative77.7%
associate-*l*77.7%
*-commutative77.7%
fma-define77.7%
Simplified77.7%
Taylor expanded in phi1 around 0 34.4%
Taylor expanded in lambda1 around 0 29.4%
cos-neg29.4%
Simplified29.4%
Final simplification30.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * sin(phi2)) + (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(((phi1 * sin(phi2)) + (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(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 73.6%
*-commutative73.6%
*-commutative73.6%
+-commutative73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
fma-define73.6%
Simplified73.6%
Taylor expanded in phi1 around 0 34.0%
Final simplification34.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 4.5e+67) (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 phi2)))) (* R (acos (+ (cos lambda1) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 4.5e+67) {
tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)));
} else {
tmp = R * acos((cos(lambda1) + (phi1 * sin(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 4.5d+67) then
tmp = r * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)))
else
tmp = r * acos((cos(lambda1) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 4.5e+67) {
tmp = R * Math.acos((Math.cos((lambda2 - lambda1)) + (phi1 * phi2)));
} else {
tmp = R * Math.acos((Math.cos(lambda1) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 4.5e+67: tmp = R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * phi2))) else: tmp = R * math.acos((math.cos(lambda1) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 4.5e+67) tmp = Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(cos(lambda1) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 4.5e+67) tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2))); else tmp = R * acos((cos(lambda1) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 4.5e+67], N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 4.5 \cdot 10^{+67}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi2 < 4.4999999999999998e67Initial program 75.1%
*-commutative75.1%
*-commutative75.1%
+-commutative75.1%
*-commutative75.1%
associate-*l*75.1%
*-commutative75.1%
fma-define75.1%
Simplified75.1%
Taylor expanded in phi1 around 0 35.6%
Taylor expanded in phi2 around 0 23.1%
sub-neg23.1%
remove-double-neg23.1%
mul-1-neg23.1%
distribute-neg-in23.1%
+-commutative23.1%
cos-neg23.1%
mul-1-neg23.1%
unsub-neg23.1%
Simplified23.1%
Taylor expanded in phi2 around 0 22.0%
*-commutative22.0%
Simplified22.0%
if 4.4999999999999998e67 < phi2 Initial program 66.8%
*-commutative66.8%
*-commutative66.8%
+-commutative66.8%
*-commutative66.8%
associate-*l*66.8%
*-commutative66.8%
fma-define66.8%
Simplified66.8%
Taylor expanded in phi1 around 0 27.1%
Taylor expanded in phi2 around 0 8.3%
sub-neg8.3%
remove-double-neg8.3%
mul-1-neg8.3%
distribute-neg-in8.3%
+-commutative8.3%
cos-neg8.3%
mul-1-neg8.3%
unsub-neg8.3%
Simplified8.3%
Taylor expanded in lambda2 around 0 6.6%
cos-neg1.8%
Simplified6.6%
Final simplification19.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda2 34800000000000.0)
(* R (acos (+ (cos lambda1) t_0)))
(* R (acos (+ (cos lambda2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda2 <= 34800000000000.0) {
tmp = R * acos((cos(lambda1) + t_0));
} else {
tmp = R * acos((cos(lambda2) + t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = phi1 * sin(phi2)
if (lambda2 <= 34800000000000.0d0) then
tmp = r * acos((cos(lambda1) + t_0))
else
tmp = r * acos((cos(lambda2) + t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * Math.sin(phi2);
double tmp;
if (lambda2 <= 34800000000000.0) {
tmp = R * Math.acos((Math.cos(lambda1) + t_0));
} else {
tmp = R * Math.acos((Math.cos(lambda2) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda2 <= 34800000000000.0: tmp = R * math.acos((math.cos(lambda1) + t_0)) else: tmp = R * math.acos((math.cos(lambda2) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda2 <= 34800000000000.0) tmp = Float64(R * acos(Float64(cos(lambda1) + t_0))); else tmp = Float64(R * acos(Float64(cos(lambda2) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda2 <= 34800000000000.0) tmp = R * acos((cos(lambda1) + t_0)); else tmp = R * acos((cos(lambda2) + t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 34800000000000.0], N[(R * N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 34800000000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 + t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_2 + t\_0\right)\\
\end{array}
\end{array}
if lambda2 < 3.48e13Initial program 78.6%
*-commutative78.6%
*-commutative78.6%
+-commutative78.6%
*-commutative78.6%
associate-*l*78.7%
*-commutative78.7%
fma-define78.6%
Simplified78.6%
Taylor expanded in phi1 around 0 33.6%
Taylor expanded in phi2 around 0 19.5%
sub-neg19.5%
remove-double-neg19.5%
mul-1-neg19.5%
distribute-neg-in19.5%
+-commutative19.5%
cos-neg19.5%
mul-1-neg19.5%
unsub-neg19.5%
Simplified19.5%
Taylor expanded in lambda2 around 0 13.3%
cos-neg12.2%
Simplified13.3%
if 3.48e13 < lambda2 Initial program 59.5%
*-commutative59.5%
*-commutative59.5%
+-commutative59.5%
*-commutative59.5%
associate-*l*59.5%
*-commutative59.5%
fma-define59.5%
Simplified59.5%
Taylor expanded in phi1 around 0 35.1%
Taylor expanded in phi2 around 0 22.7%
sub-neg22.7%
remove-double-neg22.7%
mul-1-neg22.7%
distribute-neg-in22.7%
+-commutative22.7%
cos-neg22.7%
mul-1-neg22.7%
unsub-neg22.7%
Simplified22.7%
Taylor expanded in lambda1 around 0 22.8%
Final simplification15.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 (sin phi2)) (cos (- lambda2 lambda1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * sin(phi2)) + 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((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((lambda2 - lambda1))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * math.sin(phi2)) + math.cos((lambda2 - lambda1))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + cos(Float64(lambda2 - lambda1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * sin(phi2)) + cos((lambda2 - lambda1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_2 - \lambda_1\right)\right)
\end{array}
Initial program 73.6%
*-commutative73.6%
*-commutative73.6%
+-commutative73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
fma-define73.6%
Simplified73.6%
Taylor expanded in phi1 around 0 34.0%
Taylor expanded in phi2 around 0 20.3%
sub-neg20.3%
remove-double-neg20.3%
mul-1-neg20.3%
distribute-neg-in20.3%
+-commutative20.3%
cos-neg20.3%
mul-1-neg20.3%
unsub-neg20.3%
Simplified20.3%
Final simplification20.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 34800000000000.0) (* R (acos (+ (cos lambda1) (* phi1 phi2)))) (* R (acos (+ (cos lambda2) (* phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 34800000000000.0) {
tmp = R * acos((cos(lambda1) + (phi1 * phi2)));
} else {
tmp = R * acos((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 (lambda2 <= 34800000000000.0d0) then
tmp = r * acos((cos(lambda1) + (phi1 * phi2)))
else
tmp = r * acos((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 (lambda2 <= 34800000000000.0) {
tmp = R * Math.acos((Math.cos(lambda1) + (phi1 * phi2)));
} else {
tmp = R * Math.acos((Math.cos(lambda2) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 34800000000000.0: tmp = R * math.acos((math.cos(lambda1) + (phi1 * phi2))) else: tmp = R * math.acos((math.cos(lambda2) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 34800000000000.0) tmp = Float64(R * acos(Float64(cos(lambda1) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(cos(lambda2) + Float64(phi1 * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 34800000000000.0) tmp = R * acos((cos(lambda1) + (phi1 * phi2))); else tmp = R * acos((cos(lambda2) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 34800000000000.0], N[(R * N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 34800000000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_2 + \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if lambda2 < 3.48e13Initial program 78.6%
*-commutative78.6%
*-commutative78.6%
+-commutative78.6%
*-commutative78.6%
associate-*l*78.7%
*-commutative78.7%
fma-define78.6%
Simplified78.6%
Taylor expanded in phi1 around 0 33.6%
Taylor expanded in phi2 around 0 19.5%
sub-neg19.5%
remove-double-neg19.5%
mul-1-neg19.5%
distribute-neg-in19.5%
+-commutative19.5%
cos-neg19.5%
mul-1-neg19.5%
unsub-neg19.5%
Simplified19.5%
Taylor expanded in phi2 around 0 18.3%
*-commutative18.3%
Simplified18.3%
Taylor expanded in lambda2 around 0 12.2%
cos-neg12.2%
Simplified12.2%
if 3.48e13 < lambda2 Initial program 59.5%
*-commutative59.5%
*-commutative59.5%
+-commutative59.5%
*-commutative59.5%
associate-*l*59.5%
*-commutative59.5%
fma-define59.5%
Simplified59.5%
Taylor expanded in phi1 around 0 35.1%
Taylor expanded in phi2 around 0 22.7%
sub-neg22.7%
remove-double-neg22.7%
mul-1-neg22.7%
distribute-neg-in22.7%
+-commutative22.7%
cos-neg22.7%
mul-1-neg22.7%
unsub-neg22.7%
Simplified22.7%
Taylor expanded in phi2 around 0 18.6%
*-commutative18.6%
Simplified18.6%
Taylor expanded in lambda1 around 0 18.7%
Final simplification14.0%
(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 73.6%
*-commutative73.6%
*-commutative73.6%
+-commutative73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
fma-define73.6%
Simplified73.6%
Taylor expanded in phi1 around 0 34.0%
Taylor expanded in phi2 around 0 20.3%
sub-neg20.3%
remove-double-neg20.3%
mul-1-neg20.3%
distribute-neg-in20.3%
+-commutative20.3%
cos-neg20.3%
mul-1-neg20.3%
unsub-neg20.3%
Simplified20.3%
Taylor expanded in phi2 around 0 18.4%
*-commutative18.4%
Simplified18.4%
Final simplification18.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos lambda1) (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos(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(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(lambda1) + (phi1 * phi2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos(lambda1) + (phi1 * phi2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(lambda1) + Float64(phi1 * phi2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos(lambda1) + (phi1 * phi2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \lambda_1 + \phi_1 \cdot \phi_2\right)
\end{array}
Initial program 73.6%
*-commutative73.6%
*-commutative73.6%
+-commutative73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
fma-define73.6%
Simplified73.6%
Taylor expanded in phi1 around 0 34.0%
Taylor expanded in phi2 around 0 20.3%
sub-neg20.3%
remove-double-neg20.3%
mul-1-neg20.3%
distribute-neg-in20.3%
+-commutative20.3%
cos-neg20.3%
mul-1-neg20.3%
unsub-neg20.3%
Simplified20.3%
Taylor expanded in phi2 around 0 18.4%
*-commutative18.4%
Simplified18.4%
Taylor expanded in lambda2 around 0 10.3%
cos-neg10.3%
Simplified10.3%
Final simplification10.3%
herbie shell --seed 2024078
(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))