
(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
(if (<=
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
0.0)
(* (fabs (remainder (- lambda1 lambda2) (* 2.0 PI))) R)
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) <= 0.0) {
tmp = fabs(remainder((lambda1 - lambda2), (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))));
}
return tmp;
}
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[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], 0.0], N[(N[Abs[N[With[{TMP1 = N[(lambda1 - lambda2), $MachinePrecision], TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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) \leq 0:\\
\;\;\;\;\left|\left(\left(\lambda_1 - \lambda_2\right) \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right)\right)\\
\end{array}
\end{array}
if (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) < 0.0Initial program 9.6%
add-cube-cbrt9.6%
pow39.6%
Applied egg-rr9.6%
Taylor expanded in phi2 around 0 9.6%
Taylor expanded in phi1 around 0 9.6%
acos-cos64.2%
Applied egg-rr64.2%
if 0.0 < (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) Initial program 82.0%
Simplified82.0%
cos-diff99.2%
+-commutative99.2%
Applied egg-rr99.2%
Final simplification97.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= (acos (+ t_0 (* t_1 (cos (- lambda1 lambda2))))) 0.0)
(* (fabs (remainder (- lambda1 lambda2) (* 2.0 PI))) R)
(*
R
(acos
(+
t_0
(*
t_1
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (acos((t_0 + (t_1 * cos((lambda1 - lambda2))))) <= 0.0) {
tmp = fabs(remainder((lambda1 - lambda2), (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos((t_0 + (t_1 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
}
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 (Math.acos((t_0 + (t_1 * Math.cos((lambda1 - lambda2))))) <= 0.0) {
tmp = Math.abs(Math.IEEEremainder((lambda1 - lambda2), (2.0 * Math.PI))) * R;
} else {
tmp = R * Math.acos((t_0 + (t_1 * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = math.cos(phi1) * math.cos(phi2) tmp = 0 if math.acos((t_0 + (t_1 * math.cos((lambda1 - lambda2))))) <= 0.0: tmp = math.fabs(math.remainder((lambda1 - lambda2), (2.0 * math.pi))) * R else: tmp = R * math.acos((t_0 + (t_1 * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))) return tmp
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[N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], N[(N[Abs[N[With[{TMP1 = N[(lambda1 - lambda2), $MachinePrecision], TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\cos^{-1} \left(t\_0 + t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \leq 0:\\
\;\;\;\;\left|\left(\left(\lambda_1 - \lambda_2\right) \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + t\_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) < 0.0Initial program 9.6%
add-cube-cbrt9.6%
pow39.6%
Applied egg-rr9.6%
Taylor expanded in phi2 around 0 9.6%
Taylor expanded in phi1 around 0 9.6%
acos-cos64.2%
Applied egg-rr64.2%
if 0.0 < (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) Initial program 82.0%
cos-diff99.2%
+-commutative99.2%
Applied egg-rr99.2%
Final simplification97.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -4.2e-7)
(*
R
(-
(/ PI 2.0)
(asin (fma (sin phi2) (sin phi1) (* (cos phi1) (* (cos phi2) t_0))))))
(if (<= phi2 1.12e-35)
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) t_0)
(* (sin phi1) (log (exp (sin phi2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -4.2e-7) {
tmp = R * ((((double) M_PI) / 2.0) - asin(fma(sin(phi2), sin(phi1), (cos(phi1) * (cos(phi2) * t_0)))));
} else if (phi2 <= 1.12e-35) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos((((cos(phi1) * cos(phi2)) * t_0) + (sin(phi1) * log(exp(sin(phi2))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -4.2e-7) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(fma(sin(phi2), sin(phi1), Float64(cos(phi1) * Float64(cos(phi2) * t_0)))))); elseif (phi2 <= 1.12e-35) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) + Float64(sin(phi1) * log(exp(sin(phi2))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.2e-7], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.12e-35], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Log[N[Exp[N[Sin[phi2], $MachinePrecision]], $MachinePrecision]], $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 -4.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.12 \cdot 10^{-35}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0 + \sin \phi_1 \cdot \log \left(e^{\sin \phi_2}\right)\right)\\
\end{array}
\end{array}
if phi2 < -4.2e-7Initial program 86.6%
add-cube-cbrt86.3%
pow386.3%
Applied egg-rr86.3%
rem-cube-cbrt86.6%
+-commutative86.6%
fma-undefine86.6%
acos-asin86.5%
*-commutative86.5%
*-commutative86.5%
Applied egg-rr86.5%
fma-undefine86.4%
*-commutative86.4%
associate-*r*86.4%
+-commutative86.4%
fma-undefine86.6%
Simplified86.6%
if -4.2e-7 < phi2 < 1.12e-35Initial program 69.7%
cos-diff87.9%
+-commutative87.9%
Applied egg-rr87.9%
Taylor expanded in phi2 around 0 87.9%
if 1.12e-35 < phi2 Initial program 82.8%
add-log-exp82.9%
Applied egg-rr82.9%
Final simplification86.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -2e-8)
(*
R
(-
(/ PI 2.0)
(asin (fma (sin phi2) (sin phi1) (* (cos phi1) (* (cos phi2) t_0))))))
(if (<= phi2 1.12e-35)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) t_0)
(* (sin phi1) (log (exp (sin phi2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -2e-8) {
tmp = R * ((((double) M_PI) / 2.0) - asin(fma(sin(phi2), sin(phi1), (cos(phi1) * (cos(phi2) * t_0)))));
} else if (phi2 <= 1.12e-35) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos((((cos(phi1) * cos(phi2)) * t_0) + (sin(phi1) * log(exp(sin(phi2))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -2e-8) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(fma(sin(phi2), sin(phi1), Float64(cos(phi1) * Float64(cos(phi2) * t_0)))))); elseif (phi2 <= 1.12e-35) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) + Float64(sin(phi1) * log(exp(sin(phi2))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2e-8], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.12e-35], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Log[N[Exp[N[Sin[phi2], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.12 \cdot 10^{-35}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0 + \sin \phi_1 \cdot \log \left(e^{\sin \phi_2}\right)\right)\\
\end{array}
\end{array}
if phi2 < -2e-8Initial program 86.6%
add-cube-cbrt86.3%
pow386.3%
Applied egg-rr86.3%
rem-cube-cbrt86.6%
+-commutative86.6%
fma-undefine86.6%
acos-asin86.5%
*-commutative86.5%
*-commutative86.5%
Applied egg-rr86.5%
fma-undefine86.4%
*-commutative86.4%
associate-*r*86.4%
+-commutative86.4%
fma-undefine86.6%
Simplified86.6%
if -2e-8 < phi2 < 1.12e-35Initial program 69.7%
add-cube-cbrt69.7%
pow369.7%
Applied egg-rr69.7%
Taylor expanded in phi2 around 0 69.7%
cos-diff87.9%
+-commutative87.9%
Applied egg-rr87.9%
if 1.12e-35 < phi2 Initial program 82.8%
add-log-exp82.9%
Applied egg-rr82.9%
Final simplification86.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.2e-9) (not (<= phi2 1.12e-35)))
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(* (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.2e-9) || !(phi2 <= 1.12e-35)) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.2e-9) || !(phi2 <= 1.12e-35)) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))); else tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.2e-9], N[Not[LessEqual[phi2, 1.12e-35]], $MachinePrecision]], 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], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{-9} \lor \neg \left(\phi_2 \leq 1.12 \cdot 10^{-35}\right):\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.2e-9 or 1.12e-35 < phi2 Initial program 84.7%
Simplified84.8%
if -1.2e-9 < phi2 < 1.12e-35Initial program 69.4%
add-cube-cbrt69.4%
pow369.4%
Applied egg-rr69.4%
Taylor expanded in phi2 around 0 69.4%
cos-diff87.8%
+-commutative87.8%
Applied egg-rr87.8%
Final simplification86.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(if (<= phi2 -2.8e-11)
(* R (- (/ PI 2.0) (asin (fma (sin phi2) (sin phi1) t_0))))
(if (<= phi2 1.12e-35)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(* R (acos (fma (sin phi1) (sin phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (cos(phi2) * cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -2.8e-11) {
tmp = R * ((((double) M_PI) / 2.0) - asin(fma(sin(phi2), sin(phi1), t_0)));
} else if (phi2 <= 1.12e-35) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), t_0));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi2 <= -2.8e-11) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(fma(sin(phi2), sin(phi1), t_0)))); elseif (phi2 <= 1.12e-35) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), t_0))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.8e-11], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.12e-35], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{if}\;\phi_2 \leq -2.8 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, t\_0\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.12 \cdot 10^{-35}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t\_0\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.8e-11Initial program 85.8%
add-cube-cbrt85.6%
pow385.6%
Applied egg-rr85.6%
rem-cube-cbrt85.8%
+-commutative85.8%
fma-undefine85.9%
acos-asin85.7%
*-commutative85.7%
*-commutative85.7%
Applied egg-rr85.7%
fma-undefine85.7%
*-commutative85.7%
associate-*r*85.7%
+-commutative85.7%
fma-undefine85.9%
Simplified85.9%
if -2.8e-11 < phi2 < 1.12e-35Initial program 69.8%
add-cube-cbrt69.8%
pow369.8%
Applied egg-rr69.8%
Taylor expanded in phi2 around 0 69.8%
cos-diff87.7%
+-commutative87.7%
Applied egg-rr87.7%
if 1.12e-35 < phi2 Initial program 82.8%
Simplified82.8%
Final simplification85.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.9e-11) (not (<= phi2 1.12e-35)))
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.9e-11) || !(phi2 <= 1.12e-35)) {
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
} else {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi2 <= (-1.9d-11)) .or. (.not. (phi2 <= 1.12d-35))) then
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
else
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.9e-11) || !(phi2 <= 1.12e-35)) {
tmp = Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
} else {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -1.9e-11) or not (phi2 <= 1.12e-35): tmp = math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R else: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.9e-11) || !(phi2 <= 1.12e-35)) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R); else tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -1.9e-11) || ~((phi2 <= 1.12e-35))) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; else tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.9e-11], N[Not[LessEqual[phi2, 1.12e-35]], $MachinePrecision]], 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], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.9 \cdot 10^{-11} \lor \neg \left(\phi_2 \leq 1.12 \cdot 10^{-35}\right):\\
\;\;\;\;\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\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.8999999999999999e-11 or 1.12e-35 < phi2 Initial program 84.3%
if -1.8999999999999999e-11 < phi2 < 1.12e-35Initial program 69.8%
add-cube-cbrt69.8%
pow369.8%
Applied egg-rr69.8%
Taylor expanded in phi2 around 0 69.8%
cos-diff87.7%
+-commutative87.7%
Applied egg-rr87.7%
Final simplification85.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda2 -3.5e-10)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(if (<= lambda2 1.65e-12)
(* 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 (lambda2 <= -3.5e-10) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else if (lambda2 <= 1.65e-12) {
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 (lambda2 <= (-3.5d-10)) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else if (lambda2 <= 1.65d-12) 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 (lambda2 <= -3.5e-10) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else if (lambda2 <= 1.65e-12) {
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 lambda2 <= -3.5e-10: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) elif lambda2 <= 1.65e-12: 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 (lambda2 <= -3.5e-10) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); elseif (lambda2 <= 1.65e-12) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= -3.5e-10) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); elseif (lambda2 <= 1.65e-12) 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[lambda2, -3.5e-10], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 1.65e-12], 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -3.5 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{elif}\;\lambda_2 \leq 1.65 \cdot 10^{-12}:\\
\;\;\;\;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 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < -3.4999999999999998e-10Initial program 62.9%
add-cube-cbrt62.9%
pow362.9%
Applied egg-rr62.9%
Taylor expanded in phi2 around 0 45.3%
cos-diff99.2%
+-commutative99.2%
Applied egg-rr61.7%
if -3.4999999999999998e-10 < lambda2 < 1.65e-12Initial program 90.2%
Taylor expanded in lambda2 around 0 90.2%
associate-*r*90.1%
*-commutative90.1%
*-commutative90.1%
Simplified90.1%
if 1.65e-12 < lambda2 Initial program 58.2%
Taylor expanded in lambda1 around 0 55.3%
cos-neg55.3%
Simplified55.3%
Final simplification76.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi2 -7.2e-5)
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi2) (* (cos phi1) (cos lambda1))))))
(if (<= phi2 2.8e-34)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi2 <= -7.2e-5) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1)))));
} else if (phi2 <= 2.8e-34) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((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 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi2 <= (-7.2d-5)) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1)))))
else if (phi2 <= 2.8d-34) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi2 <= -7.2e-5) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda1)))));
} else if (phi2 <= 2.8e-34) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi2 <= -7.2e-5: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda1))))) elif phi2 <= 2.8e-34: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi2 <= -7.2e-5) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda1)))))); elseif (phi2 <= 2.8e-34) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi2 <= -7.2e-5) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1))))); elseif (phi2 <= 2.8e-34) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((cos(phi2) * t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7.2e-5], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 2.8e-34], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_2 \leq -7.2 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 2.8 \cdot 10^{-34}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < -7.20000000000000018e-5Initial program 86.6%
Taylor expanded in lambda2 around 0 71.6%
associate-*r*71.6%
*-commutative71.6%
*-commutative71.6%
Simplified71.6%
if -7.20000000000000018e-5 < phi2 < 2.79999999999999997e-34Initial program 69.9%
add-cube-cbrt69.9%
pow369.9%
Applied egg-rr69.9%
Taylor expanded in phi2 around 0 69.9%
cos-diff87.9%
+-commutative87.9%
Applied egg-rr87.9%
if 2.79999999999999997e-34 < phi2 Initial program 82.6%
Simplified82.6%
cos-diff99.0%
+-commutative99.0%
Applied egg-rr99.0%
add-log-exp99.0%
Applied egg-rr99.0%
Taylor expanded in phi1 around 0 66.8%
Final simplification77.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -1.02e-5)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 0.000118)
(* R (acos (* (cos phi2) t_0)))
(* R (acos (fma (cos phi1) (cos phi2) (* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi1 <= -1.02e-5) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 0.000118) {
tmp = R * acos((cos(phi2) * t_0));
} else {
tmp = R * acos(fma(cos(phi1), cos(phi2), (sin(phi1) * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi1 <= -1.02e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 0.000118) tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); else tmp = Float64(R * acos(fma(cos(phi1), cos(phi2), Float64(sin(phi1) * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.02e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.000118], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -1.02 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.000118:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -1.0200000000000001e-5Initial program 81.5%
add-cube-cbrt81.3%
pow381.3%
Applied egg-rr81.3%
Taylor expanded in phi2 around 0 48.6%
cos-diff99.2%
+-commutative99.2%
Applied egg-rr60.5%
if -1.0200000000000001e-5 < phi1 < 1.18e-4Initial program 71.5%
Simplified71.5%
cos-diff88.9%
+-commutative88.9%
Applied egg-rr88.9%
add-log-exp88.8%
Applied egg-rr88.8%
Taylor expanded in phi1 around 0 88.6%
if 1.18e-4 < phi1 Initial program 86.3%
add-cube-cbrt86.0%
pow386.0%
Applied egg-rr86.0%
Taylor expanded in lambda1 around 0 66.4%
+-commutative66.4%
*-commutative66.4%
fma-define66.4%
cos-neg66.4%
associate-*r*66.4%
*-commutative66.4%
associate-*l*66.4%
Simplified66.4%
Taylor expanded in lambda2 around 0 51.5%
fma-define51.5%
Simplified51.5%
Final simplification72.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -2.4e-10)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 0.00235)
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2)))))
(* R (acos (fma (cos phi1) (cos phi2) (* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.4e-10) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 0.00235) {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
} else {
tmp = R * acos(fma(cos(phi1), cos(phi2), (sin(phi1) * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -2.4e-10) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 0.00235) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(fma(cos(phi1), cos(phi2), Float64(sin(phi1) * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.4e-10], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00235], 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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * 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_1 \leq -2.4 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00235:\\
\;\;\;\;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(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.4e-10Initial program 81.5%
add-cube-cbrt81.3%
pow381.3%
Applied egg-rr81.3%
Taylor expanded in phi2 around 0 48.6%
if -2.4e-10 < phi1 < 0.00235000000000000009Initial program 71.5%
Simplified71.5%
Taylor expanded in phi1 around 0 71.5%
if 0.00235000000000000009 < phi1 Initial program 86.3%
add-cube-cbrt86.0%
pow386.0%
Applied egg-rr86.0%
Taylor expanded in lambda1 around 0 66.4%
+-commutative66.4%
*-commutative66.4%
fma-define66.4%
cos-neg66.4%
associate-*r*66.4%
*-commutative66.4%
associate-*l*66.4%
Simplified66.4%
Taylor expanded in lambda2 around 0 51.5%
fma-define51.5%
Simplified51.5%
Final simplification60.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 2.8e-34)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(* R (acos (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.8e-34) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos((cos(phi2) * cos((lambda1 - lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 2.8d-34) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else
tmp = r * acos((cos(phi2) * cos((lambda1 - lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.8e-34) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos((lambda1 - lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 2.8e-34: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) else: tmp = R * math.acos((math.cos(phi2) * math.cos((lambda1 - lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 2.8e-34) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 2.8e-34) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos((cos(phi2) * cos((lambda1 - lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.8e-34], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.8 \cdot 10^{-34}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < 2.79999999999999997e-34Initial program 75.9%
add-cube-cbrt75.8%
pow375.8%
Applied egg-rr75.8%
Taylor expanded in phi2 around 0 51.5%
cos-diff92.1%
+-commutative92.1%
Applied egg-rr63.1%
if 2.79999999999999997e-34 < phi2 Initial program 82.6%
add-cube-cbrt82.4%
pow382.4%
Applied egg-rr82.4%
Taylor expanded in phi1 around 0 57.9%
Final simplification61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -2.4e-10)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 0.00068)
(* 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 <= -2.4e-10) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 0.00068) {
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 <= (-2.4d-10)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 0.00068d0) 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 <= -2.4e-10) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 0.00068) {
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 <= -2.4e-10: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 0.00068: 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 <= -2.4e-10) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 0.00068) 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 <= -2.4e-10) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 0.00068) 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, -2.4e-10], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00068], 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 -2.4 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00068:\\
\;\;\;\;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 < -2.4e-10Initial program 81.5%
add-cube-cbrt81.3%
pow381.3%
Applied egg-rr81.3%
Taylor expanded in phi2 around 0 48.6%
if -2.4e-10 < phi1 < 6.8e-4Initial program 71.5%
Simplified71.5%
Taylor expanded in phi1 around 0 71.5%
if 6.8e-4 < phi1 Initial program 86.3%
Taylor expanded in lambda1 around 0 59.8%
cos-neg59.8%
mul-1-neg59.8%
distribute-rgt-neg-in59.8%
sin-neg59.8%
remove-double-neg59.8%
Simplified59.8%
Taylor expanded in lambda2 around 0 51.5%
*-commutative51.5%
Simplified51.5%
Final simplification60.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= t_0 0.998)
(* R (acos t_0))
(* (fabs (remainder (- lambda1 lambda2) (* 2.0 PI))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (t_0 <= 0.998) {
tmp = R * acos(t_0);
} else {
tmp = fabs(remainder((lambda1 - lambda2), (2.0 * ((double) M_PI)))) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (t_0 <= 0.998) {
tmp = R * Math.acos(t_0);
} else {
tmp = Math.abs(Math.IEEEremainder((lambda1 - lambda2), (2.0 * Math.PI))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if t_0 <= 0.998: tmp = R * math.acos(t_0) else: tmp = math.fabs(math.remainder((lambda1 - lambda2), (2.0 * math.pi))) * R return tmp
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.998], N[(R * N[ArcCos[t$95$0], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[With[{TMP1 = N[(lambda1 - lambda2), $MachinePrecision], TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;t\_0 \leq 0.998:\\
\;\;\;\;R \cdot \cos^{-1} t\_0\\
\mathbf{else}:\\
\;\;\;\;\left|\left(\left(\lambda_1 - \lambda_2\right) \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\end{array}
\end{array}
if (cos.f64 (-.f64 lambda1 lambda2)) < 0.998Initial program 76.2%
add-cube-cbrt76.2%
pow376.2%
Applied egg-rr76.2%
Taylor expanded in phi2 around 0 47.6%
Taylor expanded in phi1 around 0 34.7%
if 0.998 < (cos.f64 (-.f64 lambda1 lambda2)) Initial program 81.1%
add-cube-cbrt80.9%
pow380.9%
Applied egg-rr80.9%
Taylor expanded in phi2 around 0 34.7%
Taylor expanded in phi1 around 0 5.7%
acos-cos18.0%
Applied egg-rr18.0%
Final simplification29.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 2.8e-34)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 2.8e-34) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((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 (phi2 <= 2.8d-34) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((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 (phi2 <= 2.8e-34) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 2.8e-34: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 2.8e-34) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(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 (phi2 <= 2.8e-34) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((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[phi2, 2.8e-34], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 2.8 \cdot 10^{-34}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 2.79999999999999997e-34Initial program 75.9%
add-cube-cbrt75.8%
pow375.8%
Applied egg-rr75.8%
Taylor expanded in phi2 around 0 51.5%
if 2.79999999999999997e-34 < phi2 Initial program 82.6%
add-cube-cbrt82.4%
pow382.4%
Applied egg-rr82.4%
Taylor expanded in phi1 around 0 57.9%
Final simplification53.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 2.9e-15) (* R (acos (* (cos phi1) (cos (- lambda1 lambda2))))) (* R (acos (* (cos phi2) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.9e-15) {
tmp = R * acos((cos(phi1) * cos((lambda1 - lambda2))));
} else {
tmp = R * acos((cos(phi2) * cos(lambda2)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 2.9d-15) then
tmp = r * acos((cos(phi1) * cos((lambda1 - lambda2))))
else
tmp = r * acos((cos(phi2) * cos(lambda2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.9e-15) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos((lambda1 - lambda2))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 2.9e-15: tmp = R * math.acos((math.cos(phi1) * math.cos((lambda1 - lambda2)))) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 2.9e-15) tmp = Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 2.9e-15) tmp = R * acos((cos(phi1) * cos((lambda1 - lambda2)))); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.9e-15], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.9 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < 2.90000000000000019e-15Initial program 76.4%
add-cube-cbrt76.3%
pow376.3%
Applied egg-rr76.3%
Taylor expanded in phi2 around 0 52.5%
if 2.90000000000000019e-15 < phi2 Initial program 81.7%
add-cube-cbrt81.4%
pow381.4%
Applied egg-rr81.4%
Taylor expanded in lambda1 around 0 62.2%
+-commutative62.2%
*-commutative62.2%
fma-define62.2%
cos-neg62.2%
associate-*r*62.2%
*-commutative62.2%
associate-*l*62.2%
Simplified62.2%
Taylor expanded in phi1 around 0 44.1%
Final simplification50.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 2.9e-15) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (* (cos phi2) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.9e-15) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos((cos(phi2) * cos(lambda2)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 2.9d-15) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos((cos(phi2) * cos(lambda2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.9e-15) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 2.9e-15: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 2.9e-15) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 2.9e-15) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.9e-15], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.9 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < 2.90000000000000019e-15Initial program 76.4%
add-cube-cbrt76.3%
pow376.3%
Applied egg-rr76.3%
Taylor expanded in phi2 around 0 52.5%
Taylor expanded in lambda2 around 0 41.4%
*-commutative41.4%
Simplified41.4%
if 2.90000000000000019e-15 < phi2 Initial program 81.7%
add-cube-cbrt81.4%
pow381.4%
Applied egg-rr81.4%
Taylor expanded in lambda1 around 0 62.2%
+-commutative62.2%
*-commutative62.2%
fma-define62.2%
cos-neg62.2%
associate-*r*62.2%
*-commutative62.2%
associate-*l*62.2%
Simplified62.2%
Taylor expanded in phi1 around 0 44.1%
Final simplification42.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -45.0) (* R (acos (cos lambda1))) (* R (acos (* (cos phi2) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -45.0) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * acos((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 <= (-45.0d0)) then
tmp = r * acos(cos(lambda1))
else
tmp = r * acos((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 <= -45.0) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -45.0: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -45.0) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -45.0) tmp = R * acos(cos(lambda1)); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -45.0], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -45:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -45Initial program 63.4%
add-cube-cbrt63.3%
pow363.3%
Applied egg-rr63.3%
Taylor expanded in phi2 around 0 42.4%
Taylor expanded in phi1 around 0 33.1%
Taylor expanded in lambda2 around 0 33.3%
if -45 < lambda1 Initial program 82.2%
add-cube-cbrt82.1%
pow382.1%
Applied egg-rr82.1%
Taylor expanded in lambda1 around 0 63.3%
+-commutative63.3%
*-commutative63.3%
fma-define63.3%
cos-neg63.3%
associate-*r*63.3%
*-commutative63.3%
associate-*l*63.3%
Simplified63.3%
Taylor expanded in phi1 around 0 33.9%
Final simplification33.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -1.5e-9) (* R (acos (cos lambda1))) (* R (acos (cos lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.5e-9) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * acos(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 <= (-1.5d-9)) then
tmp = r * acos(cos(lambda1))
else
tmp = r * acos(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 <= -1.5e-9) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -1.5e-9: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -1.5e-9) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -1.5e-9) tmp = R * acos(cos(lambda1)); else tmp = R * acos(cos(lambda2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1.5e-9], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.5 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda1 < -1.49999999999999999e-9Initial program 64.3%
add-cube-cbrt64.2%
pow364.2%
Applied egg-rr64.2%
Taylor expanded in phi2 around 0 42.2%
Taylor expanded in phi1 around 0 32.1%
Taylor expanded in lambda2 around 0 32.2%
if -1.49999999999999999e-9 < lambda1 Initial program 82.3%
add-cube-cbrt82.2%
pow382.2%
Applied egg-rr82.2%
Taylor expanded in phi2 around 0 44.1%
Taylor expanded in phi1 around 0 23.6%
Taylor expanded in lambda1 around 0 15.0%
cos-neg63.7%
Simplified15.0%
Final simplification19.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda1 lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(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(cos((lambda1 - lambda2)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda1 - lambda2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda1 - lambda2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda1 - lambda2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos((lambda1 - lambda2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \left(\lambda_1 - \lambda_2\right)
\end{array}
Initial program 77.7%
add-cube-cbrt77.6%
pow377.6%
Applied egg-rr77.6%
Taylor expanded in phi2 around 0 43.6%
Taylor expanded in phi1 around 0 25.8%
Final simplification25.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos lambda1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(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(cos(lambda1))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos(lambda1));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos(lambda1))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(lambda1))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos(lambda1)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \lambda_1
\end{array}
Initial program 77.7%
add-cube-cbrt77.6%
pow377.6%
Applied egg-rr77.6%
Taylor expanded in phi2 around 0 43.6%
Taylor expanded in phi1 around 0 25.8%
Taylor expanded in lambda2 around 0 19.1%
Final simplification19.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* lambda1 R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 * 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 = lambda1 * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return lambda1 * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(lambda1 * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = lambda1 * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 * R), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 \cdot R
\end{array}
Initial program 77.7%
add-cube-cbrt77.6%
pow377.6%
Applied egg-rr77.6%
Taylor expanded in phi2 around 0 43.6%
Taylor expanded in phi1 around 0 25.8%
Taylor expanded in lambda1 around inf 5.9%
herbie shell --seed 2024144
(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))