
(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 25 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
(+
(log1p (expm1 (* (sin phi1) (sin phi2))))
(*
(* (cos phi2) (cos phi1))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos((log1p(expm1((sin(phi1) * sin(phi2)))) + ((cos(phi2) * cos(phi1)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(log1p(expm1(Float64(sin(phi1) * sin(phi2)))) + Float64(Float64(cos(phi2) * cos(phi1)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Log[1 + N[(Exp[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{log1p}\left(\mathsf{expm1}\left(\sin \phi_1 \cdot \sin \phi_2\right)\right) + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R
\end{array}
Initial program 71.5%
cos-diff91.6%
distribute-lft-in91.6%
Applied egg-rr91.6%
distribute-lft-out91.6%
*-commutative91.6%
fma-define91.6%
Simplified91.6%
log1p-expm1-u91.6%
Applied egg-rr91.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right)\right)
\end{array}
Initial program 71.5%
Simplified71.5%
cos-diff91.6%
+-commutative91.6%
Applied egg-rr91.6%
*-commutative91.6%
fma-define91.6%
Applied egg-rr91.6%
Final simplification91.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(+
(* 0.5 PI)
(-
(acos
(fma
(* (cos phi2) (cos phi1))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))
(* (sin phi1) (sin phi2))))
(/ PI 2.0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * ((0.5 * ((double) M_PI)) + (acos(fma((cos(phi2) * cos(phi1)), ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))), (sin(phi1) * sin(phi2)))) - (((double) M_PI) / 2.0)));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(Float64(0.5 * pi) + Float64(acos(fma(Float64(cos(phi2) * cos(phi1)), Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))), Float64(sin(phi1) * sin(phi2)))) - Float64(pi / 2.0)))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(N[(0.5 * Pi), $MachinePrecision] + N[(N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(0.5 \cdot \pi + \left(\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2, \sin \phi_1 \cdot \sin \phi_2\right)\right) - \frac{\pi}{2}\right)\right)
\end{array}
Initial program 71.5%
Simplified71.6%
acos-asin71.4%
fma-undefine71.4%
associate-*r*71.4%
+-commutative71.4%
sub-neg71.4%
div-inv71.4%
metadata-eval71.4%
+-commutative71.4%
fma-define71.4%
Applied egg-rr71.4%
sub-neg71.4%
*-commutative71.4%
fma-undefine71.4%
*-commutative71.4%
associate-*r*71.4%
+-commutative71.4%
*-commutative71.4%
fma-define71.4%
*-commutative71.4%
associate-*r*71.4%
*-commutative71.4%
associate-*l*71.5%
Simplified71.5%
asin-acos71.6%
fma-undefine71.6%
*-commutative71.6%
*-commutative71.6%
cos-diff91.6%
fma-undefine91.6%
+-commutative91.6%
fma-undefine91.6%
cos-diff71.6%
fma-define71.6%
*-commutative71.6%
Applied egg-rr71.6%
cos-diff91.6%
+-commutative91.6%
Applied egg-rr91.6%
Final simplification91.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi2) (cos phi1))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi2) * cos(phi1)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi2) * cos(phi1)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)
\end{array}
Initial program 71.5%
cos-diff91.6%
distribute-lft-in91.6%
Applied egg-rr91.6%
distribute-lft-out91.6%
*-commutative91.6%
fma-define91.6%
Simplified91.6%
Final simplification91.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.0065)
(*
R
(-
(* 0.5 PI)
(asin
(fma
(sin phi2)
(sin phi1)
(* t_0 (* (cos phi1) (log1p (expm1 (cos phi2)))))))))
(if (<= phi2 0.88)
(*
R
(acos
(+
(*
(* (cos phi2) (cos phi1))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))
(* (sin phi1) phi2))))
(*
R
(acos
(fma (cos phi1) (* (cos phi2) t_0) (* (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 (phi2 <= -0.0065) {
tmp = R * ((0.5 * ((double) M_PI)) - asin(fma(sin(phi2), sin(phi1), (t_0 * (cos(phi1) * log1p(expm1(cos(phi2))))))));
} else if (phi2 <= 0.88) {
tmp = R * acos((((cos(phi2) * cos(phi1)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))) + (sin(phi1) * phi2)));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), (sin(phi1) * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.0065) tmp = Float64(R * Float64(Float64(0.5 * pi) - asin(fma(sin(phi2), sin(phi1), Float64(t_0 * Float64(cos(phi1) * log1p(expm1(cos(phi2))))))))); elseif (phi2 <= 0.88) tmp = Float64(R * acos(Float64(Float64(Float64(cos(phi2) * cos(phi1)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), 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[phi2, -0.0065], N[(R * N[(N[(0.5 * Pi), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Log[1 + N[(Exp[N[Cos[phi2], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.88], N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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_2 \leq -0.0065:\\
\;\;\;\;R \cdot \left(0.5 \cdot \pi - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, t\_0 \cdot \left(\cos \phi_1 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_2\right)\right)\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 0.88:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right) + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -0.0064999999999999997Initial program 81.3%
Simplified81.2%
acos-asin81.1%
fma-undefine81.2%
associate-*r*81.2%
+-commutative81.2%
sub-neg81.2%
div-inv81.2%
metadata-eval81.2%
+-commutative81.2%
fma-define81.2%
Applied egg-rr81.2%
sub-neg81.2%
*-commutative81.2%
fma-undefine81.2%
*-commutative81.2%
associate-*r*81.2%
+-commutative81.2%
*-commutative81.2%
fma-define81.2%
*-commutative81.2%
associate-*r*81.2%
*-commutative81.2%
associate-*l*81.2%
Simplified81.2%
log1p-expm1-u81.1%
Applied egg-rr81.1%
if -0.0064999999999999997 < phi2 < 0.880000000000000004Initial program 67.8%
cos-diff85.6%
distribute-lft-in85.5%
Applied egg-rr85.5%
distribute-lft-out85.6%
*-commutative85.6%
fma-define85.6%
Simplified85.6%
Taylor expanded in phi2 around 0 85.2%
if 0.880000000000000004 < phi2 Initial program 71.8%
Simplified71.9%
Final simplification81.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos phi1))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.0026)
(* R (- (* 0.5 PI) (asin (fma (sin phi2) (sin phi1) (* t_0 t_1)))))
(if (<= phi2 0.88)
(*
R
(acos
(+
(*
t_0
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))
(* (sin phi1) phi2))))
(*
R
(acos
(fma (cos phi1) (* (cos phi2) t_1) (* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * cos(phi1);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.0026) {
tmp = R * ((0.5 * ((double) M_PI)) - asin(fma(sin(phi2), sin(phi1), (t_0 * t_1))));
} else if (phi2 <= 0.88) {
tmp = R * acos(((t_0 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))) + (sin(phi1) * phi2)));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_1), (sin(phi1) * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(phi1)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.0026) tmp = Float64(R * Float64(Float64(0.5 * pi) - asin(fma(sin(phi2), sin(phi1), Float64(t_0 * t_1))))); elseif (phi2 <= 0.88) tmp = Float64(R * acos(Float64(Float64(t_0 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_1), Float64(sin(phi1) * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.0026], N[(R * N[(N[(0.5 * Pi), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.88], N[(R * N[ArcCos[N[(N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.0026:\\
\;\;\;\;R \cdot \left(0.5 \cdot \pi - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, t\_0 \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 0.88:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right) + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_1, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -0.0025999999999999999Initial program 81.3%
Simplified81.2%
acos-asin81.1%
fma-undefine81.2%
associate-*r*81.2%
+-commutative81.2%
sub-neg81.2%
div-inv81.2%
metadata-eval81.2%
+-commutative81.2%
fma-define81.2%
Applied egg-rr81.2%
sub-neg81.2%
*-commutative81.2%
fma-undefine81.2%
*-commutative81.2%
associate-*r*81.2%
+-commutative81.2%
*-commutative81.2%
fma-define81.2%
*-commutative81.2%
associate-*r*81.2%
*-commutative81.2%
associate-*l*81.2%
Simplified81.2%
if -0.0025999999999999999 < phi2 < 0.880000000000000004Initial program 67.8%
cos-diff85.6%
distribute-lft-in85.5%
Applied egg-rr85.5%
distribute-lft-out85.6%
*-commutative85.6%
fma-define85.6%
Simplified85.6%
Taylor expanded in phi2 around 0 85.2%
if 0.880000000000000004 < phi2 Initial program 71.8%
Simplified71.9%
Final simplification81.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi2) (cos phi1))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi2) * cos(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi2) * cos(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi2) * Math.cos(phi1)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi2) * math.cos(phi1)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi2) * cos(phi1)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi2) * cos(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)
\end{array}
Initial program 71.5%
cos-diff91.6%
+-commutative91.6%
Applied egg-rr91.6%
Final simplification91.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[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}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right)
\end{array}
Initial program 71.5%
cos-diff91.6%
distribute-lft-in91.6%
Applied egg-rr91.6%
distribute-lft-out91.6%
*-commutative91.6%
fma-define91.6%
Simplified91.6%
Taylor expanded in phi2 around inf 91.6%
Final simplification91.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 -5.8e-7)
(*
R
(-
(* 0.5 PI)
(asin (fma (sin phi2) (sin phi1) (* (* (cos phi2) (cos phi1)) t_1)))))
(if (<= phi2 880.0)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (acos (fma (cos phi1) (* (cos phi2) t_1) t_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 (phi2 <= -5.8e-7) {
tmp = R * ((0.5 * ((double) M_PI)) - asin(fma(sin(phi2), sin(phi1), ((cos(phi2) * cos(phi1)) * t_1))));
} else if (phi2 <= 880.0) {
tmp = R * acos((t_0 + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_1), t_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 (phi2 <= -5.8e-7) tmp = Float64(R * Float64(Float64(0.5 * pi) - asin(fma(sin(phi2), sin(phi1), Float64(Float64(cos(phi2) * cos(phi1)) * t_1))))); elseif (phi2 <= 880.0) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_1), t_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[phi2, -5.8e-7], N[(R * N[(N[(0.5 * Pi), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 880.0], N[(R * N[ArcCos[N[(t$95$0 + 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[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + t$95$0), $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_2 \leq -5.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(0.5 \cdot \pi - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 880:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \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(\cos \phi_1, \cos \phi_2 \cdot t\_1, t\_0\right)\right)\\
\end{array}
\end{array}
if phi2 < -5.7999999999999995e-7Initial program 81.3%
Simplified81.2%
acos-asin81.1%
fma-undefine81.2%
associate-*r*81.2%
+-commutative81.2%
sub-neg81.2%
div-inv81.2%
metadata-eval81.2%
+-commutative81.2%
fma-define81.2%
Applied egg-rr81.2%
sub-neg81.2%
*-commutative81.2%
fma-undefine81.2%
*-commutative81.2%
associate-*r*81.2%
+-commutative81.2%
*-commutative81.2%
fma-define81.2%
*-commutative81.2%
associate-*r*81.2%
*-commutative81.2%
associate-*l*81.2%
Simplified81.2%
if -5.7999999999999995e-7 < phi2 < 880Initial program 67.5%
cos-diff85.7%
distribute-lft-in85.6%
Applied egg-rr85.6%
distribute-lft-out85.7%
*-commutative85.7%
fma-define85.7%
Simplified85.7%
Taylor expanded in phi2 around 0 84.1%
if 880 < phi2 Initial program 72.6%
Simplified72.8%
Final simplification80.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -2.6e-6)
(*
R
(-
(* 0.5 PI)
(asin (fma (sin phi2) (sin phi1) (* (* (cos phi2) (cos phi1)) t_0)))))
(if (<= phi2 0.00088)
(*
R
(acos
(+
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* (sin phi1) phi2))))
(*
R
(acos
(fma (cos phi1) (* (cos phi2) t_0) (* (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 (phi2 <= -2.6e-6) {
tmp = R * ((0.5 * ((double) M_PI)) - asin(fma(sin(phi2), sin(phi1), ((cos(phi2) * cos(phi1)) * t_0))));
} else if (phi2 <= 0.00088) {
tmp = R * acos(((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (sin(phi1) * phi2)));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), (sin(phi1) * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -2.6e-6) tmp = Float64(R * Float64(Float64(0.5 * pi) - asin(fma(sin(phi2), sin(phi1), Float64(Float64(cos(phi2) * cos(phi1)) * t_0))))); elseif (phi2 <= 0.00088) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), 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[phi2, -2.6e-6], N[(R * N[(N[(0.5 * Pi), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00088], N[(R * N[ArcCos[N[(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] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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_2 \leq -2.6 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(0.5 \cdot \pi - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t\_0\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00088:\\
\;\;\;\;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) + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.60000000000000009e-6Initial program 81.3%
Simplified81.2%
acos-asin81.1%
fma-undefine81.2%
associate-*r*81.2%
+-commutative81.2%
sub-neg81.2%
div-inv81.2%
metadata-eval81.2%
+-commutative81.2%
fma-define81.2%
Applied egg-rr81.2%
sub-neg81.2%
*-commutative81.2%
fma-undefine81.2%
*-commutative81.2%
associate-*r*81.2%
+-commutative81.2%
*-commutative81.2%
fma-define81.2%
*-commutative81.2%
associate-*r*81.2%
*-commutative81.2%
associate-*l*81.2%
Simplified81.2%
if -2.60000000000000009e-6 < phi2 < 8.80000000000000031e-4Initial program 67.6%
cos-diff85.5%
distribute-lft-in85.4%
Applied egg-rr85.4%
distribute-lft-out85.5%
*-commutative85.5%
fma-define85.5%
Simplified85.5%
log1p-expm1-u85.5%
Applied egg-rr85.5%
Taylor expanded in phi2 around 0 84.8%
if 8.80000000000000031e-4 < phi2 Initial program 72.2%
Simplified72.3%
Final simplification81.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -4.8e-7)
(* R (acos (+ t_1 (* (* (cos phi2) (cos phi1)) t_0))))
(if (<= phi2 0.00088)
(*
R
(acos
(+
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* (sin phi1) phi2))))
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))))
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 (phi2 <= -4.8e-7) {
tmp = R * acos((t_1 + ((cos(phi2) * cos(phi1)) * t_0)));
} else if (phi2 <= 0.00088) {
tmp = R * acos(((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (sin(phi1) * phi2)));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
}
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 (phi2 <= -4.8e-7) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi2) * cos(phi1)) * t_0)))); elseif (phi2 <= 0.00088) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -4.8e-7], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00088], N[(R * N[ArcCos[N[(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] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $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_2 \leq -4.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t\_0\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00088:\\
\;\;\;\;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) + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -4.79999999999999957e-7Initial program 81.3%
if -4.79999999999999957e-7 < phi2 < 8.80000000000000031e-4Initial program 67.6%
cos-diff85.5%
distribute-lft-in85.4%
Applied egg-rr85.4%
distribute-lft-out85.5%
*-commutative85.5%
fma-define85.5%
Simplified85.5%
log1p-expm1-u85.5%
Applied egg-rr85.5%
Taylor expanded in phi2 around 0 84.8%
if 8.80000000000000031e-4 < phi2 Initial program 72.2%
Simplified72.3%
Final simplification81.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -3.9e-8)
(* R (acos (+ t_1 (* (* (cos phi2) (cos phi1)) t_0))))
(if (<= phi2 6.5e-31)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))))
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 (phi2 <= -3.9e-8) {
tmp = R * acos((t_1 + ((cos(phi2) * cos(phi1)) * t_0)));
} else if (phi2 <= 6.5e-31) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
}
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 (phi2 <= -3.9e-8) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi2) * cos(phi1)) * t_0)))); elseif (phi2 <= 6.5e-31) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.9e-8], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.5e-31], 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[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $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_2 \leq -3.9 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t\_0\right)\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{-31}:\\
\;\;\;\;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(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -3.89999999999999985e-8Initial program 81.5%
if -3.89999999999999985e-8 < phi2 < 6.49999999999999967e-31Initial program 67.8%
cos-diff86.1%
distribute-lft-in86.1%
Applied egg-rr86.1%
distribute-lft-out86.1%
*-commutative86.1%
fma-define86.1%
Simplified86.1%
log1p-expm1-u86.1%
Applied egg-rr86.1%
Taylor expanded in phi2 around 0 86.1%
if 6.49999999999999967e-31 < phi2 Initial program 71.0%
Simplified71.1%
Final simplification81.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -5.7e-8) (not (<= phi2 6.5e-31)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi2) (cos phi1)) (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 <= -5.7e-8) || !(phi2 <= 6.5e-31)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi2) * cos(phi1)) * cos((lambda1 - lambda2)))));
} 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 <= (-5.7d-8)) .or. (.not. (phi2 <= 6.5d-31))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi2) * cos(phi1)) * cos((lambda1 - lambda2)))))
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 <= -5.7e-8) || !(phi2 <= 6.5e-31)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi2) * Math.cos(phi1)) * Math.cos((lambda1 - lambda2)))));
} 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 <= -5.7e-8) or not (phi2 <= 6.5e-31): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi2) * math.cos(phi1)) * math.cos((lambda1 - lambda2))))) 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 <= -5.7e-8) || !(phi2 <= 6.5e-31)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi2) * cos(phi1)) * 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
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -5.7e-8) || ~((phi2 <= 6.5e-31))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi2) * cos(phi1)) * cos((lambda1 - lambda2))))); 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, -5.7e-8], N[Not[LessEqual[phi2, 6.5e-31]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $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 -5.7 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 6.5 \cdot 10^{-31}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\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 < -5.70000000000000009e-8 or 6.49999999999999967e-31 < phi2 Initial program 75.5%
if -5.70000000000000009e-8 < phi2 < 6.49999999999999967e-31Initial program 68.0%
cos-diff86.2%
distribute-lft-in86.2%
Applied egg-rr86.2%
distribute-lft-out86.2%
*-commutative86.2%
fma-define86.2%
Simplified86.2%
log1p-expm1-u86.2%
Applied egg-rr86.2%
Taylor expanded in phi2 around 0 86.1%
Final simplification81.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -5.2e-8)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 8e-7)
(* R (acos (* (cos phi2) t_0)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi2) (* (cos phi1) (cos lambda1))))))))))
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 <= -5.2e-8) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 8e-7) {
tmp = R * acos((cos(phi2) * t_0));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi1 <= (-5.2d-8)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 8d-7) then
tmp = r * acos((cos(phi2) * t_0))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi1 <= -5.2e-8) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 8e-7) {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda1)))));
}
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 phi1 <= -5.2e-8: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 8e-7: tmp = R * math.acos((math.cos(phi2) * t_0)) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda1))))) 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 <= -5.2e-8) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 8e-7) tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda1)))))); 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 (phi1 <= -5.2e-8) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 8e-7) tmp = R * acos((cos(phi2) * t_0)); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * (cos(phi1) * cos(lambda1))))); 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[phi1, -5.2e-8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 8e-7], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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]]]]
\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 -5.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;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)\\
\end{array}
\end{array}
if phi1 < -5.2000000000000002e-8Initial program 78.3%
cos-diff98.9%
distribute-lft-in98.8%
Applied egg-rr98.8%
distribute-lft-out98.9%
*-commutative98.9%
fma-define98.8%
Simplified98.8%
log1p-expm1-u98.9%
Applied egg-rr98.9%
Taylor expanded in phi2 around 0 63.1%
if -5.2000000000000002e-8 < phi1 < 7.9999999999999996e-7Initial program 67.0%
cos-diff84.3%
distribute-lft-in84.3%
Applied egg-rr84.3%
distribute-lft-out84.3%
*-commutative84.3%
fma-define84.3%
Simplified84.3%
log1p-expm1-u84.3%
Applied egg-rr84.3%
Taylor expanded in phi1 around 0 83.8%
if 7.9999999999999996e-7 < phi1 Initial program 74.0%
Taylor expanded in lambda2 around 0 54.8%
*-commutative54.8%
*-commutative54.8%
associate-*l*54.8%
Simplified54.8%
Final simplification71.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -5.5e-8)
(* 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 (phi1 <= -5.5e-8) {
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 (phi1 <= (-5.5d-8)) 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 (phi1 <= -5.5e-8) {
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 phi1 <= -5.5e-8: 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 (phi1 <= -5.5e-8) 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 (phi1 <= -5.5e-8) 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[phi1, -5.5e-8], 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_1 \leq -5.5 \cdot 10^{-8}:\\
\;\;\;\;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 phi1 < -5.5000000000000003e-8Initial program 78.3%
cos-diff98.9%
distribute-lft-in98.8%
Applied egg-rr98.8%
distribute-lft-out98.9%
*-commutative98.9%
fma-define98.8%
Simplified98.8%
log1p-expm1-u98.9%
Applied egg-rr98.9%
Taylor expanded in phi2 around 0 63.1%
if -5.5000000000000003e-8 < phi1 Initial program 69.3%
cos-diff89.2%
distribute-lft-in89.2%
Applied egg-rr89.2%
distribute-lft-out89.2%
*-commutative89.2%
fma-define89.2%
Simplified89.2%
log1p-expm1-u89.3%
Applied egg-rr89.3%
Taylor expanded in phi1 around 0 62.1%
Final simplification62.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.005)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.005) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (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 <= 0.005d0) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (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 <= 0.005) {
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.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.005: 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.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.005) 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(sin(phi1) * sin(phi2)) + 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 <= 0.005) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.005], 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[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.005:\\
\;\;\;\;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(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < 0.0050000000000000001Initial program 71.3%
cos-diff89.2%
distribute-lft-in89.2%
Applied egg-rr89.2%
distribute-lft-out89.2%
*-commutative89.2%
fma-define89.2%
Simplified89.2%
log1p-expm1-u89.2%
Applied egg-rr89.2%
Taylor expanded in phi2 around 0 66.7%
if 0.0050000000000000001 < phi2 Initial program 72.2%
Taylor expanded in phi1 around 0 44.1%
Final simplification61.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -5.5e-8)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(* R (acos (+ t_1 (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -5.5e-8) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-5.5d-8)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else
tmp = r * acos((t_1 + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -5.5e-8) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -5.5e-8: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -5.5e-8) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -5.5e-8) tmp = R * acos((t_1 + (cos(phi1) * t_0))); else tmp = R * acos((t_1 + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5.5e-8], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -5.5 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -5.5000000000000003e-8Initial program 78.3%
Taylor expanded in phi2 around 0 49.5%
*-commutative49.5%
Simplified49.5%
if -5.5000000000000003e-8 < phi1 Initial program 69.3%
Taylor expanded in phi1 around 0 50.8%
Final simplification50.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 0.000155)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.000155) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (phi2 <= 0.000155d0) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.000155) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 0.000155: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.000155) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 0.000155) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.000155], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 0.000155:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 1.55e-4Initial program 71.6%
Simplified71.6%
Taylor expanded in phi2 around 0 50.9%
if 1.55e-4 < phi2 Initial program 71.4%
Taylor expanded in phi1 around 0 43.7%
Final simplification49.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 0.00043)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(* 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.00043) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} 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.00043d0) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
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.00043) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} 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.00043: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) 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.00043) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); 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.00043) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); 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.00043], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(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.00043:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi2 < 4.29999999999999989e-4Initial program 71.6%
Simplified71.6%
Taylor expanded in phi2 around 0 50.9%
if 4.29999999999999989e-4 < phi2 Initial program 71.4%
Simplified71.5%
Taylor expanded in phi1 around 0 33.2%
Final simplification46.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -1.55)
(* R (acos t_0))
(* 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 (phi1 <= -1.55) {
tmp = R * acos(t_0);
} 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 (phi1 <= (-1.55d0)) then
tmp = r * acos(t_0)
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 (phi1 <= -1.55) {
tmp = R * Math.acos(t_0);
} 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 phi1 <= -1.55: tmp = R * math.acos(t_0) 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 (phi1 <= -1.55) tmp = Float64(R * acos(t_0)); 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 (phi1 <= -1.55) tmp = R * acos(t_0); 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[phi1, -1.55], N[(R * N[ArcCos[t$95$0], $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_1 \leq -1.55:\\
\;\;\;\;R \cdot \cos^{-1} t\_0\\
\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 phi1 < -1.55000000000000004Initial program 78.3%
Simplified78.3%
Taylor expanded in phi1 around 0 4.9%
Taylor expanded in phi2 around 0 4.9%
Taylor expanded in phi2 around 0 4.9%
Taylor expanded in phi1 around 0 14.7%
if -1.55000000000000004 < phi1 Initial program 69.3%
Simplified69.3%
Taylor expanded in phi1 around 0 46.5%
Final simplification38.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda2 3.9e-7)
(* 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 (lambda2 <= 3.9e-7) {
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 (lambda2 <= 3.9d-7) 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 (lambda2 <= 3.9e-7) {
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 lambda2 <= 3.9e-7: 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 (lambda2 <= 3.9e-7) 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 (lambda2 <= 3.9e-7) 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[lambda2, 3.9e-7], 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_2 \leq 3.9 \cdot 10^{-7}:\\
\;\;\;\;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 lambda2 < 3.90000000000000025e-7Initial program 78.2%
Simplified78.2%
Taylor expanded in phi1 around 0 38.5%
Taylor expanded in lambda2 around 0 32.8%
if 3.90000000000000025e-7 < lambda2 Initial program 51.2%
Simplified51.2%
Taylor expanded in phi1 around 0 29.3%
Taylor expanded in lambda1 around 0 29.3%
cos-neg29.3%
Simplified29.3%
Final simplification31.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 9.8e-8) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos lambda1))))) (* R (acos (cos (- lambda1 lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 9.8e-8) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))));
} else {
tmp = R * acos(cos((lambda1 - lambda2)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 9.8d-8) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))))
else
tmp = r * acos(cos((lambda1 - lambda2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 9.8e-8) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(Math.cos((lambda1 - lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 9.8e-8: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos(lambda1)))) else: tmp = R * math.acos(math.cos((lambda1 - lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 9.8e-8) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(lambda1))))); else tmp = Float64(R * acos(cos(Float64(lambda1 - lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 9.8e-8) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1)))); else tmp = R * acos(cos((lambda1 - lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 9.8e-8], 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], N[(R * N[ArcCos[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 9.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_1 - \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 9.8000000000000004e-8Initial program 78.2%
Simplified78.2%
Taylor expanded in phi1 around 0 38.5%
Taylor expanded in lambda2 around 0 32.8%
if 9.8000000000000004e-8 < lambda2 Initial program 51.2%
Simplified51.2%
Taylor expanded in phi1 around 0 29.3%
Taylor expanded in phi2 around 0 23.9%
Taylor expanded in phi2 around 0 21.8%
Taylor expanded in phi1 around 0 30.8%
Final simplification32.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -1.35e-93) (not (<= phi1 3.7e-103)))
(* R (acos t_0))
(* R (acos (+ (* (cos phi2) t_0) (* phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.35e-93) || !(phi1 <= 3.7e-103)) {
tmp = R * acos(t_0);
} else {
tmp = R * acos(((cos(phi2) * t_0) + (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) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if ((phi1 <= (-1.35d-93)) .or. (.not. (phi1 <= 3.7d-103))) then
tmp = r * acos(t_0)
else
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * 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 <= -1.35e-93) || !(phi1 <= 3.7e-103)) {
tmp = R * Math.acos(t_0);
} else {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1.35e-93) or not (phi1 <= 3.7e-103): tmp = R * math.acos(t_0) else: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -1.35e-93) || !(phi1 <= 3.7e-103)) tmp = Float64(R * acos(t_0)); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1.35e-93) || ~((phi1 <= 3.7e-103))) tmp = R * acos(t_0); else tmp = R * acos(((cos(phi2) * t_0) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.35e-93], N[Not[LessEqual[phi1, 3.7e-103]], $MachinePrecision]], N[(R * N[ArcCos[t$95$0], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.35 \cdot 10^{-93} \lor \neg \left(\phi_1 \leq 3.7 \cdot 10^{-103}\right):\\
\;\;\;\;R \cdot \cos^{-1} t\_0\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -1.3500000000000001e-93 or 3.6999999999999999e-103 < phi1 Initial program 71.8%
Simplified71.8%
Taylor expanded in phi1 around 0 14.6%
Taylor expanded in phi2 around 0 10.9%
Taylor expanded in phi2 around 0 9.7%
Taylor expanded in phi1 around 0 19.7%
if -1.3500000000000001e-93 < phi1 < 3.6999999999999999e-103Initial program 71.2%
Simplified71.2%
Taylor expanded in phi1 around 0 71.2%
Taylor expanded in phi2 around 0 56.8%
Final simplification33.9%
(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 71.5%
Simplified71.6%
Taylor expanded in phi1 around 0 36.3%
Taylor expanded in phi2 around 0 21.9%
Taylor expanded in phi2 around 0 20.3%
Taylor expanded in phi1 around 0 27.3%
Final simplification27.3%
(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 71.5%
Simplified71.6%
Taylor expanded in phi1 around 0 36.3%
Taylor expanded in phi2 around 0 21.9%
Taylor expanded in phi2 around 0 20.3%
Taylor expanded in phi1 around inf 10.0%
Final simplification10.0%
herbie shell --seed 2024145
(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))