
(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 22 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R
\end{array}
Initial program 74.0%
cos-diff96.2%
Applied egg-rr96.2%
cos-neg96.2%
*-commutative96.2%
fma-define96.2%
cos-neg96.2%
Simplified96.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi1 -1.3e+35)
(* R (- (* PI 0.5) (asin (+ t_0 (* (cos phi1) (* (cos phi2) t_2))))))
(if (<= phi1 2.35e-23)
(*
R
(acos
(+
(*
t_1
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))
(* phi1 (sin phi2)))))
(* R (acos (+ t_0 (cbrt (pow (* t_1 t_2) 3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.3e+35) {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_0 + (cos(phi1) * (cos(phi2) * t_2)))));
} else if (phi1 <= 2.35e-23) {
tmp = R * acos(((t_1 * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_0 + cbrt(pow((t_1 * t_2), 3.0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.3e+35) tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * t_2)))))); elseif (phi1 <= 2.35e-23) tmp = Float64(R * acos(Float64(Float64(t_1 * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_0 + cbrt((Float64(t_1 * t_2) ^ 3.0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.3e+35], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.35e-23], N[(R * N[ArcCos[N[(N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[Power[N[Power[N[(t$95$1 * t$95$2), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.3 \cdot 10^{+35}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_2\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 2.35 \cdot 10^{-23}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \sqrt[3]{{\left(t\_1 \cdot t\_2\right)}^{3}}\right)\\
\end{array}
\end{array}
if phi1 < -1.30000000000000003e35Initial program 80.9%
acos-asin81.0%
div-inv81.0%
metadata-eval81.0%
+-commutative81.0%
*-commutative81.0%
fma-define81.0%
Applied egg-rr81.0%
Taylor expanded in lambda1 around 0 80.9%
if -1.30000000000000003e35 < phi1 < 2.35e-23Initial program 68.5%
cos-diff94.4%
Applied egg-rr94.4%
cos-neg94.4%
*-commutative94.4%
fma-define94.4%
cos-neg94.4%
Simplified94.4%
Taylor expanded in phi1 around 0 92.3%
if 2.35e-23 < phi1 Initial program 79.7%
add-cbrt-cube79.6%
pow379.6%
Applied egg-rr79.6%
add-cbrt-cube79.5%
cbrt-unprod79.6%
pow379.5%
unpow-prod-down79.6%
Applied egg-rr79.6%
Final simplification86.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)
\end{array}
Initial program 74.0%
cos-diff96.2%
+-commutative96.2%
Applied egg-rr96.2%
Final simplification96.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.000155)
(* R (- (* PI 0.5) (asin (+ t_0 (* (cos phi1) (* (cos phi2) t_1))))))
(if (<= phi1 2.35e-23)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi2)
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda1) (sin lambda2)))))))
(*
R
(acos (+ t_0 (cbrt (pow (* (* (cos phi1) (cos phi2)) t_1) 3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.000155) {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_0 + (cos(phi1) * (cos(phi2) * t_1)))));
} else if (phi1 <= 2.35e-23) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_0 + cbrt(pow(((cos(phi1) * cos(phi2)) * t_1), 3.0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.000155) tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * t_1)))))); elseif (phi1 <= 2.35e-23) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(Float64(t_0 + cbrt((Float64(Float64(cos(phi1) * cos(phi2)) * t_1) ^ 3.0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.000155], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.35e-23], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[Power[N[Power[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.000155:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 2.35 \cdot 10^{-23}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \sqrt[3]{{\left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)}^{3}}\right)\\
\end{array}
\end{array}
if phi1 < -1.55e-4Initial program 77.9%
acos-asin77.9%
div-inv77.9%
metadata-eval77.9%
+-commutative77.9%
*-commutative77.9%
fma-define77.9%
Applied egg-rr77.9%
Taylor expanded in lambda1 around 0 77.9%
if -1.55e-4 < phi1 < 2.35e-23Initial program 69.1%
Simplified69.1%
Taylor expanded in phi1 around 0 68.9%
cos-diff94.1%
Applied egg-rr93.8%
cos-neg94.1%
*-commutative94.1%
fma-define94.1%
cos-neg94.1%
Simplified93.8%
if 2.35e-23 < phi1 Initial program 79.7%
add-cbrt-cube79.6%
pow379.6%
Applied egg-rr79.6%
add-cbrt-cube79.5%
cbrt-unprod79.6%
pow379.5%
unpow-prod-down79.6%
Applied egg-rr79.6%
Final simplification86.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -9.5e-6)
(* R (- (* PI 0.5) (asin (+ t_0 (* (cos phi1) (* (cos phi2) t_1))))))
(if (<= phi1 1.6e-54)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi2)
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (+ t_0 (* (* (cos phi1) (cos phi2)) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -9.5e-6) {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_0 + (cos(phi1) * (cos(phi2) * t_1)))));
} else if (phi1 <= 1.6e-54) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * t_1)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -9.5e-6) tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * t_1)))))); elseif (phi1 <= 1.6e-54) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -9.5e-6], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.6e-54], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.6 \cdot 10^{-54}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
\end{array}
\end{array}
if phi1 < -9.5000000000000005e-6Initial program 77.9%
acos-asin77.9%
div-inv77.9%
metadata-eval77.9%
+-commutative77.9%
*-commutative77.9%
fma-define77.9%
Applied egg-rr77.9%
Taylor expanded in lambda1 around 0 77.9%
if -9.5000000000000005e-6 < phi1 < 1.59999999999999999e-54Initial program 69.0%
Simplified69.0%
Taylor expanded in phi1 around 0 68.7%
cos-diff93.8%
Applied egg-rr93.4%
cos-neg93.8%
*-commutative93.8%
fma-define93.8%
cos-neg93.8%
Simplified93.5%
if 1.59999999999999999e-54 < phi1 Initial program 78.9%
Final simplification85.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -1e-5)
(* R (- (* PI 0.5) (asin (+ t_0 (* (cos phi1) (* (cos phi2) t_1))))))
(if (<= phi1 1.6e-54)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(* R (acos (+ t_0 (* (* (cos phi1) (cos phi2)) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -1e-5) {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_0 + (cos(phi1) * (cos(phi2) * t_1)))));
} else if (phi1 <= 1.6e-54) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * t_1)));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -1e-5) {
tmp = R * ((Math.PI * 0.5) - Math.asin((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * t_1)))));
} else if (phi1 <= 1.6e-54) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
} else {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * t_1)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -1e-5: tmp = R * ((math.pi * 0.5) - math.asin((t_0 + (math.cos(phi1) * (math.cos(phi2) * t_1))))) elif phi1 <= 1.6e-54: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) else: tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * t_1))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1e-5) tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * t_1)))))); elseif (phi1 <= 1.6e-54) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -1e-5) tmp = R * ((pi * 0.5) - asin((t_0 + (cos(phi1) * (cos(phi2) * t_1))))); elseif (phi1 <= 1.6e-54) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); else tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * t_1))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1e-5], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.6e-54], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.6 \cdot 10^{-54}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
\end{array}
\end{array}
if phi1 < -1.00000000000000008e-5Initial program 77.9%
acos-asin77.9%
div-inv77.9%
metadata-eval77.9%
+-commutative77.9%
*-commutative77.9%
fma-define77.9%
Applied egg-rr77.9%
Taylor expanded in lambda1 around 0 77.9%
if -1.00000000000000008e-5 < phi1 < 1.59999999999999999e-54Initial program 69.0%
Simplified69.0%
Taylor expanded in phi1 around 0 68.7%
cos-diff93.8%
+-commutative93.8%
Applied egg-rr93.4%
if 1.59999999999999999e-54 < phi1 Initial program 78.9%
Final simplification85.6%
(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 74.0%
Simplified74.0%
Final simplification74.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -1.65e-5)
(* R (acos (+ t_1 (* t_0 (cos lambda1)))))
(* R (acos (+ t_1 (* t_0 (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -1.65e-5) {
tmp = R * acos((t_1 + (t_0 * cos(lambda1))));
} else {
tmp = R * acos((t_1 + (t_0 * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(phi1) * sin(phi2)
if (lambda1 <= (-1.65d-5)) then
tmp = r * acos((t_1 + (t_0 * cos(lambda1))))
else
tmp = r * acos((t_1 + (t_0 * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -1.65e-5) {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -1.65e-5: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda1)))) else: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -1.65e-5) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -1.65e-5) tmp = R * acos((t_1 + (t_0 * cos(lambda1)))); else tmp = R * acos((t_1 + (t_0 * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.65e-5], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.65 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -1.6500000000000001e-5Initial program 56.6%
Taylor expanded in lambda2 around 0 57.4%
if -1.6500000000000001e-5 < lambda1 Initial program 79.8%
Taylor expanded in lambda1 around 0 68.7%
cos-neg68.7%
Simplified68.7%
Final simplification65.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda2 1.6e-12)
(* R (acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi2) (cos (- lambda1 lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= 1.6e-12) {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (lambda2 <= 1.6d-12) then
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
else
tmp = r * acos((t_0 + (cos(phi2) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= 1.6e-12) {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 1.6e-12: tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= 1.6e-12) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 1.6e-12) tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = R * acos((t_0 + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 1.6e-12], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 1.6 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda2 < 1.6e-12Initial program 79.6%
Taylor expanded in lambda2 around 0 61.2%
if 1.6e-12 < lambda2 Initial program 60.8%
add-cbrt-cube60.6%
pow360.7%
Applied egg-rr60.7%
Taylor expanded in phi1 around 0 40.2%
Final simplification54.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 74.0%
Final simplification74.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= phi1 -23.0)
(*
R
(- (* PI 0.5) (asin (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1)))))))
(if (<= phi1 100.0)
(* R (acos (+ (* phi1 (sin phi2)) (* t_1 (cos (- lambda1 lambda2))))))
(* R (acos (+ t_0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (phi1 <= -23.0) {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))));
} else if (phi1 <= 100.0) {
tmp = R * acos(((phi1 * sin(phi2)) + (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((t_0 + t_1));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (phi1 <= -23.0) {
tmp = R * ((Math.PI * 0.5) - Math.asin((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1))))));
} else if (phi1 <= 100.0) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (t_1 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos((t_0 + t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = math.cos(phi1) * math.cos(phi2) tmp = 0 if phi1 <= -23.0: tmp = R * ((math.pi * 0.5) - math.asin((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1)))))) elif phi1 <= 100.0: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (t_1 * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos((t_0 + t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -23.0) tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))))); elseif (phi1 <= 100.0) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(t_1 * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(t_0 + t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = cos(phi1) * cos(phi2); tmp = 0.0; if (phi1 <= -23.0) tmp = R * ((pi * 0.5) - asin((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))); elseif (phi1 <= 100.0) tmp = R * acos(((phi1 * sin(phi2)) + (t_1 * cos((lambda1 - lambda2))))); else tmp = R * acos((t_0 + t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -23.0], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 100.0], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -23:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 100:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + t\_1\right)\\
\end{array}
\end{array}
if phi1 < -23Initial program 77.9%
acos-asin77.9%
div-inv77.9%
metadata-eval77.9%
+-commutative77.9%
*-commutative77.9%
fma-define77.9%
Applied egg-rr77.9%
Taylor expanded in lambda1 around 0 77.9%
Taylor expanded in phi2 around 0 49.1%
sub-neg49.1%
remove-double-neg49.1%
mul-1-neg49.1%
distribute-neg-in49.1%
+-commutative49.1%
cos-neg49.1%
mul-1-neg49.1%
unsub-neg49.1%
Simplified49.1%
if -23 < phi1 < 100Initial program 69.4%
Taylor expanded in phi1 around 0 69.0%
if 100 < phi1 Initial program 79.7%
log1p-expm1-u79.7%
log1p-undefine79.7%
Applied egg-rr79.7%
Taylor expanded in lambda1 around 0 51.6%
+-commutative51.6%
mul-1-neg51.6%
distribute-rgt-neg-in51.6%
sin-neg51.6%
remove-double-neg51.6%
cos-neg51.6%
Simplified51.6%
Taylor expanded in lambda2 around 0 37.9%
Final simplification56.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin phi1) (sin phi2)))
(t_2 (* (cos phi1) (cos phi2))))
(if (<= phi1 -23.0)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 3900.0)
(* R (acos (+ (* phi1 (sin phi2)) (* t_2 t_0))))
(* R (acos (+ t_1 t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if (phi1 <= -23.0) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 3900.0) {
tmp = R * acos(((phi1 * sin(phi2)) + (t_2 * t_0)));
} else {
tmp = R * acos((t_1 + t_2));
}
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((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
t_2 = cos(phi1) * cos(phi2)
if (phi1 <= (-23.0d0)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 3900.0d0) then
tmp = r * acos(((phi1 * sin(phi2)) + (t_2 * t_0)))
else
tmp = r * acos((t_1 + t_2))
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 t_1 = Math.sin(phi1) * Math.sin(phi2);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (phi1 <= -23.0) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 3900.0) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (t_2 * t_0)));
} else {
tmp = R * Math.acos((t_1 + t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if phi1 <= -23.0: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 3900.0: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (t_2 * t_0))) else: tmp = R * math.acos((t_1 + t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -23.0) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 3900.0) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(t_2 * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if (phi1 <= -23.0) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 3900.0) tmp = R * acos(((phi1 * sin(phi2)) + (t_2 * t_0))); else tmp = R * acos((t_1 + t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -23.0], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3900.0], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -23:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 3900:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + t\_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_2\right)\\
\end{array}
\end{array}
if phi1 < -23Initial program 77.9%
add-cbrt-cube77.9%
pow377.9%
Applied egg-rr77.9%
Taylor expanded in phi2 around 0 49.1%
if -23 < phi1 < 3900Initial program 69.1%
Taylor expanded in phi1 around 0 68.6%
if 3900 < phi1 Initial program 80.6%
log1p-expm1-u80.6%
log1p-undefine80.6%
Applied egg-rr80.6%
Taylor expanded in lambda1 around 0 52.4%
+-commutative52.4%
mul-1-neg52.4%
distribute-rgt-neg-in52.4%
sin-neg52.4%
remove-double-neg52.4%
cos-neg52.4%
Simplified52.4%
Taylor expanded in lambda2 around 0 38.2%
Final simplification56.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -3.5e-8)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 680000.0)
(* 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((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -3.5e-8) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 680000.0) {
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((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-3.5d-8)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 680000.0d0) 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((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -3.5e-8) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 680000.0) {
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((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -3.5e-8: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 680000.0: 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(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -3.5e-8) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 680000.0) 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((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -3.5e-8) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 680000.0) 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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.5e-8], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 680000.0], 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_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -3.5 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 680000:\\
\;\;\;\;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 < -3.50000000000000024e-8Initial program 76.0%
add-cbrt-cube76.0%
pow376.0%
Applied egg-rr76.0%
Taylor expanded in phi2 around 0 48.2%
if -3.50000000000000024e-8 < phi1 < 6.8e5Initial program 69.7%
add-cbrt-cube69.5%
pow369.5%
Applied egg-rr69.5%
Taylor expanded in phi1 around 0 68.6%
if 6.8e5 < phi1 Initial program 80.6%
log1p-expm1-u80.6%
log1p-undefine80.6%
Applied egg-rr80.6%
Taylor expanded in lambda1 around 0 52.4%
+-commutative52.4%
mul-1-neg52.4%
distribute-rgt-neg-in52.4%
sin-neg52.4%
remove-double-neg52.4%
cos-neg52.4%
Simplified52.4%
Taylor expanded in lambda2 around 0 38.2%
Final simplification56.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -3.5e-8)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 1.0)
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2)))))
(* R (acos (+ t_1 (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -3.5e-8) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 1.0) {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
} 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((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-3.5d-8)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 1.0d0) then
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))))
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((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -3.5e-8) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 1.0) {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
} 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((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -3.5e-8: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 1.0: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) 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(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -3.5e-8) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 1.0) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); 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((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -3.5e-8) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 1.0) tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); 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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.5e-8], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.0], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $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_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -3.5 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -3.50000000000000024e-8Initial program 76.0%
add-cbrt-cube76.0%
pow376.0%
Applied egg-rr76.0%
Taylor expanded in phi2 around 0 48.2%
if -3.50000000000000024e-8 < phi1 < 1Initial program 70.1%
Simplified70.1%
Taylor expanded in phi1 around 0 69.0%
if 1 < phi1 Initial program 79.7%
log1p-expm1-u79.7%
log1p-undefine79.7%
Applied egg-rr79.7%
Taylor expanded in lambda1 around 0 51.6%
+-commutative51.6%
mul-1-neg51.6%
distribute-rgt-neg-in51.6%
sin-neg51.6%
remove-double-neg51.6%
cos-neg51.6%
Simplified51.6%
Taylor expanded in lambda2 around 0 37.9%
Final simplification56.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -3.5e-8)
(* R (acos (+ (* (cos phi1) t_0) (* (sin phi1) phi2))))
(if (<= phi1 1.0)
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2)))))
(* 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 <= -3.5e-8) {
tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)));
} else if (phi1 <= 1.0) {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
} 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 <= (-3.5d-8)) then
tmp = r * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)))
else if (phi1 <= 1.0d0) then
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))))
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 <= -3.5e-8) {
tmp = R * Math.acos(((Math.cos(phi1) * t_0) + (Math.sin(phi1) * phi2)));
} else if (phi1 <= 1.0) {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
} 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 <= -3.5e-8: tmp = R * math.acos(((math.cos(phi1) * t_0) + (math.sin(phi1) * phi2))) elif phi1 <= 1.0: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) 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 <= -3.5e-8) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * t_0) + Float64(sin(phi1) * phi2)))); elseif (phi1 <= 1.0) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); 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 <= -3.5e-8) tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2))); elseif (phi1 <= 1.0) tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); 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, -3.5e-8], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.0], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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[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 -3.5 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0 + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{elif}\;\phi_1 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \sin \phi_2\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 < -3.50000000000000024e-8Initial program 76.0%
Simplified76.0%
Taylor expanded in phi2 around 0 39.5%
if -3.50000000000000024e-8 < phi1 < 1Initial program 70.1%
Simplified70.1%
Taylor expanded in phi1 around 0 69.0%
if 1 < phi1 Initial program 79.7%
log1p-expm1-u79.7%
log1p-undefine79.7%
Applied egg-rr79.7%
Taylor expanded in lambda1 around 0 51.6%
+-commutative51.6%
mul-1-neg51.6%
distribute-rgt-neg-in51.6%
sin-neg51.6%
remove-double-neg51.6%
cos-neg51.6%
Simplified51.6%
Taylor expanded in lambda2 around 0 37.9%
Final simplification54.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 4e-5)
(* R (acos (cos (- lambda2 lambda1))))
(if (<= phi2 5.8e+98)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* 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 <= 4e-5) {
tmp = R * acos(cos((lambda2 - lambda1)));
} else if (phi2 <= 5.8e+98) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (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 <= 4d-5) then
tmp = r * acos(cos((lambda2 - lambda1)))
else if (phi2 <= 5.8d+98) then
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (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 <= 4e-5) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} else if (phi2 <= 5.8e+98) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (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 <= 4e-5: tmp = R * math.acos(math.cos((lambda2 - lambda1))) elif phi2 <= 5.8e+98: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (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 <= 4e-5) tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); elseif (phi2 <= 5.8e+98) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + 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 <= 4e-5) tmp = R * acos(cos((lambda2 - lambda1))); elseif (phi2 <= 5.8e+98) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (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, 4e-5], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 5.8e+98], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 4 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{elif}\;\phi_2 \leq 5.8 \cdot 10^{+98}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\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 < 4.00000000000000033e-5Initial program 73.6%
Simplified73.6%
Taylor expanded in phi1 around 0 36.7%
Taylor expanded in phi2 around 0 26.0%
sub-neg26.0%
remove-double-neg26.0%
mul-1-neg26.0%
distribute-neg-in26.0%
+-commutative26.0%
cos-neg26.0%
mul-1-neg26.0%
sub-neg26.0%
Simplified26.0%
Taylor expanded in phi2 around 0 24.5%
Taylor expanded in phi1 around 0 30.6%
if 4.00000000000000033e-5 < phi2 < 5.8000000000000002e98Initial program 77.7%
Simplified77.8%
Taylor expanded in phi1 around 0 50.3%
Taylor expanded in phi2 around 0 46.2%
if 5.8000000000000002e98 < phi2 Initial program 73.1%
Simplified73.1%
Taylor expanded in phi1 around 0 35.4%
Taylor expanded in lambda2 around 0 24.1%
*-commutative24.1%
Simplified24.1%
Final simplification31.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 0.0007)
(* R (acos (+ (* (cos phi1) t_0) (* (sin phi1) phi2))))
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.0007) {
tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)));
} else {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (phi2 <= 0.0007d0) then
tmp = r * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)))
else
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.0007) {
tmp = R * Math.acos(((Math.cos(phi1) * t_0) + (Math.sin(phi1) * phi2)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 0.0007: tmp = R * math.acos(((math.cos(phi1) * t_0) + (math.sin(phi1) * phi2))) else: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.0007) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * t_0) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 0.0007) tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2))); else tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.0007], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 0.0007:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0 + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi2 < 6.99999999999999993e-4Initial program 73.6%
Simplified73.6%
Taylor expanded in phi2 around 0 48.6%
if 6.99999999999999993e-4 < phi2 Initial program 74.8%
Simplified74.8%
Taylor expanded in phi1 around 0 40.9%
Final simplification46.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -23.0)
(* R (acos (cos (- lambda2 lambda1))))
(*
R
(acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -23.0) {
tmp = R * acos(cos((lambda2 - lambda1)));
} else {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi1 <= (-23.0d0)) then
tmp = r * acos(cos((lambda2 - lambda1)))
else
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -23.0) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -23.0: tmp = R * math.acos(math.cos((lambda2 - lambda1))) else: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -23.0) tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -23.0) tmp = R * acos(cos((lambda2 - lambda1))); else tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -23.0], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -23:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -23Initial program 77.9%
Simplified77.9%
Taylor expanded in phi1 around 0 5.5%
Taylor expanded in phi2 around 0 5.5%
sub-neg5.5%
remove-double-neg5.5%
mul-1-neg5.5%
distribute-neg-in5.5%
+-commutative5.5%
cos-neg5.5%
mul-1-neg5.5%
sub-neg5.5%
Simplified5.5%
Taylor expanded in phi2 around 0 5.5%
Taylor expanded in phi1 around 0 17.1%
if -23 < phi1 Initial program 72.9%
Simplified72.9%
Taylor expanded in phi1 around 0 46.9%
Final simplification40.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda1 -0.24)
(* 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.24) {
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.24d0)) 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.24) {
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.24: 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.24) 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.24) 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.24], 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.24:\\
\;\;\;\;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.23999999999999999Initial program 55.9%
Simplified56.0%
Taylor expanded in phi1 around 0 31.5%
Taylor expanded in lambda2 around 0 32.0%
*-commutative32.0%
Simplified32.0%
if -0.23999999999999999 < lambda1 Initial program 79.9%
Simplified79.9%
Taylor expanded in phi1 around 0 40.1%
Taylor expanded in lambda1 around 0 34.3%
cos-neg34.3%
Simplified34.3%
Final simplification33.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= phi1 -3.6e-8) (not (<= phi1 9.4e-88))) (* R (acos (cos (- lambda2 lambda1)))) (* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3.6e-8) || !(phi1 <= 9.4e-88)) {
tmp = R * acos(cos((lambda2 - lambda1)));
} else {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-3.6d-8)) .or. (.not. (phi1 <= 9.4d-88))) then
tmp = r * acos(cos((lambda2 - lambda1)))
else
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3.6e-8) || !(phi1 <= 9.4e-88)) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -3.6e-8) or not (phi1 <= 9.4e-88): tmp = R * math.acos(math.cos((lambda2 - lambda1))) else: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -3.6e-8) || !(phi1 <= 9.4e-88)) tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -3.6e-8) || ~((phi1 <= 9.4e-88))) tmp = R * acos(cos((lambda2 - lambda1))); else tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -3.6e-8], N[Not[LessEqual[phi1, 9.4e-88]], $MachinePrecision]], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 9.4 \cdot 10^{-88}\right):\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -3.59999999999999981e-8 or 9.4e-88 < phi1 Initial program 77.1%
Simplified77.1%
Taylor expanded in phi1 around 0 12.0%
Taylor expanded in phi2 around 0 9.5%
sub-neg9.5%
remove-double-neg9.5%
mul-1-neg9.5%
distribute-neg-in9.5%
+-commutative9.5%
cos-neg9.5%
mul-1-neg9.5%
sub-neg9.5%
Simplified9.5%
Taylor expanded in phi2 around 0 8.6%
Taylor expanded in phi1 around 0 19.7%
if -3.59999999999999981e-8 < phi1 < 9.4e-88Initial program 70.1%
Simplified70.1%
Taylor expanded in phi1 around 0 69.9%
Taylor expanded in phi2 around 0 53.4%
Final simplification34.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda2 lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos((lambda2 - lambda1)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(cos((lambda2 - lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda2 - lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda2 - lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda2 - lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos((lambda2 - lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 74.0%
Simplified74.0%
Taylor expanded in phi1 around 0 38.0%
Taylor expanded in phi2 around 0 21.0%
sub-neg21.0%
remove-double-neg21.0%
mul-1-neg21.0%
distribute-neg-in21.0%
+-commutative21.0%
cos-neg21.0%
mul-1-neg21.0%
sub-neg21.0%
Simplified21.0%
Taylor expanded in phi2 around 0 18.9%
Taylor expanded in phi1 around 0 26.6%
Final simplification26.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((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((phi1 * phi2))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((phi1 * phi2));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((phi1 * phi2))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(phi1 * phi2))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((phi1 * phi2)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(phi1 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2\right)
\end{array}
Initial program 74.0%
Simplified74.0%
Taylor expanded in phi1 around 0 38.0%
Taylor expanded in phi2 around 0 21.0%
sub-neg21.0%
remove-double-neg21.0%
mul-1-neg21.0%
distribute-neg-in21.0%
+-commutative21.0%
cos-neg21.0%
mul-1-neg21.0%
sub-neg21.0%
Simplified21.0%
Taylor expanded in phi2 around 0 18.9%
Taylor expanded in phi1 around inf 11.0%
Final simplification11.0%
herbie shell --seed 2024131
(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))