
(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 23 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
(fma
(sin phi1)
(sin phi2)
(*
(* (cos phi1) (cos phi2))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(sin(phi1), sin(phi2), ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(sin(phi1), sin(phi2), Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right) \cdot R
\end{array}
Initial program 71.1%
Simplified71.1%
cos-diff93.4%
+-commutative93.4%
Applied egg-rr93.4%
Final simplification93.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), 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[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)
\end{array}
Initial program 71.1%
cos-diff93.4%
Applied egg-rr93.4%
cos-neg93.4%
*-commutative93.4%
fma-def93.4%
cos-neg93.4%
Simplified93.4%
Final simplification93.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(*
(* (cos phi1) (cos phi2))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* (sin phi1) (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (sin(phi1) * sin(phi2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos((((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (sin(phi1) * sin(phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((((Math.cos(phi1) * Math.cos(phi2)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))) + (Math.sin(phi1) * Math.sin(phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((((math.cos(phi1) * math.cos(phi2)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))) + (math.sin(phi1) * math.sin(phi2))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(sin(phi1) * sin(phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (sin(phi1) * sin(phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) + \sin \phi_1 \cdot \sin \phi_2\right)
\end{array}
Initial program 71.1%
cos-diff93.4%
+-commutative93.4%
Applied egg-rr93.4%
Final simplification93.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -2.05e-6)
(* R (acos (+ t_2 (cbrt (pow (* t_0 t_1) 3.0)))))
(if (<= phi2 1.05e-8)
(*
R
(acos
(+
(* (sin phi1) phi2)
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (acos (fma t_0 (log (exp t_1)) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -2.05e-6) {
tmp = R * acos((t_2 + cbrt(pow((t_0 * t_1), 3.0))));
} else if (phi2 <= 1.05e-8) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos(fma(t_0, log(exp(t_1)), t_2));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -2.05e-6) tmp = Float64(R * acos(Float64(t_2 + cbrt((Float64(t_0 * t_1) ^ 3.0))))); elseif (phi2 <= 1.05e-8) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(fma(t_0, log(exp(t_1)), t_2))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.05e-6], N[(R * N[ArcCos[N[(t$95$2 + N[Power[N[Power[N[(t$95$0 * t$95$1), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.05e-8], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $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[(t$95$0 * N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.05 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_2 + \sqrt[3]{{\left(t_0 \cdot t_1\right)}^{3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.05 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \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(\mathsf{fma}\left(t_0, \log \left(e^{t_1}\right), t_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.0499999999999999e-6Initial program 70.2%
add-cbrt-cube70.1%
pow370.2%
*-commutative70.2%
Applied egg-rr70.2%
if -2.0499999999999999e-6 < phi2 < 1.04999999999999997e-8Initial program 70.3%
Simplified70.3%
cos-diff88.4%
+-commutative88.4%
Applied egg-rr88.4%
Taylor expanded in phi2 around 0 88.4%
if 1.04999999999999997e-8 < phi2 Initial program 73.9%
Simplified73.9%
add-log-exp73.9%
Applied egg-rr73.9%
Final simplification80.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1.1e-5)
(* R (acos (+ t_2 (cbrt (pow (* t_0 t_1) 3.0)))))
(if (<= phi2 1.05e-8)
(*
R
(acos
(+
(* (sin phi1) phi2)
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (- (* PI 0.5) (asin (fma t_1 t_0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -1.1e-5) {
tmp = R * acos((t_2 + cbrt(pow((t_0 * t_1), 3.0))));
} else if (phi2 <= 1.05e-8) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin(fma(t_1, t_0, t_2)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -1.1e-5) tmp = Float64(R * acos(Float64(t_2 + cbrt((Float64(t_0 * t_1) ^ 3.0))))); elseif (phi2 <= 1.05e-8) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(fma(t_1, t_0, t_2)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.1e-5], N[(R * N[ArcCos[N[(t$95$2 + N[Power[N[Power[N[(t$95$0 * t$95$1), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.05e-8], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $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[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$1 * t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_2 + \sqrt[3]{{\left(t_0 \cdot t_1\right)}^{3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.05 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \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 \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(t_1, t_0, t_2\right)\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.1e-5Initial program 71.0%
add-cbrt-cube70.9%
pow371.0%
*-commutative71.0%
Applied egg-rr71.0%
if -1.1e-5 < phi2 < 1.04999999999999997e-8Initial program 69.9%
Simplified69.9%
cos-diff88.4%
+-commutative88.4%
Applied egg-rr88.4%
Taylor expanded in phi2 around 0 88.2%
if 1.04999999999999997e-8 < phi2 Initial program 73.9%
acos-asin73.9%
+-commutative73.9%
fma-udef74.0%
div-inv74.0%
metadata-eval74.0%
fma-udef73.9%
*-commutative73.9%
fma-def74.0%
Applied egg-rr74.0%
Final simplification80.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= phi2 -7e-7)
(* R (acos (+ (* (sin phi1) (sin phi2)) (cbrt (pow t_0 3.0)))))
(if (<= phi2 1.05e-8)
(*
R
(acos
(+
(* (sin phi1) phi2)
(*
(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 <= -7e-7) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + cbrt(pow(t_0, 3.0))));
} else if (phi2 <= 1.05e-8) {
tmp = R * acos(((sin(phi1) * phi2) + (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(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= -7e-7) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + cbrt((t_0 ^ 3.0))))); elseif (phi2 <= 1.05e-8) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7e-7], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[t$95$0, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.05e-8], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $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[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -7 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \sqrt[3]{{t_0}^{3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.05 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \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(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0\right)\right)\\
\end{array}
\end{array}
if phi2 < -6.99999999999999968e-7Initial program 70.2%
add-cbrt-cube70.1%
pow370.2%
*-commutative70.2%
Applied egg-rr70.2%
if -6.99999999999999968e-7 < phi2 < 1.04999999999999997e-8Initial program 70.3%
Simplified70.3%
cos-diff88.4%
+-commutative88.4%
Applied egg-rr88.4%
Taylor expanded in phi2 around 0 88.4%
if 1.04999999999999997e-8 < phi2 Initial program 73.9%
Simplified73.9%
Final simplification80.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(t_1
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -5.8e+111)
t_0
(if (<= phi1 -1.7e-5)
(* R (acos (* (cos phi1) t_1)))
(if (<= phi1 3e-6)
(* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) t_1))))
t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * acos(fma(sin(phi1), sin(phi2), ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi1 <= -5.8e+111) {
tmp = t_0;
} else if (phi1 <= -1.7e-5) {
tmp = R * acos((cos(phi1) * t_1));
} else if (phi1 <= 3e-6) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_1)));
} else {
tmp = t_0;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))) t_1 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi1 <= -5.8e+111) tmp = t_0; elseif (phi1 <= -1.7e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_1))); elseif (phi1 <= 3e-6) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * t_1)))); else tmp = t_0; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{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]}, If[LessEqual[phi1, -5.8e+111], t$95$0, If[LessEqual[phi1, -1.7e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3e-6], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -5.8 \cdot 10^{+111}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_1 \leq -1.7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_1\right)\\
\mathbf{elif}\;\phi_1 \leq 3 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if phi1 < -5.7999999999999999e111 or 3.0000000000000001e-6 < phi1 Initial program 81.8%
Simplified81.9%
if -5.7999999999999999e111 < phi1 < -1.7e-5Initial program 72.9%
Simplified72.9%
cos-diff98.7%
+-commutative98.7%
Applied egg-rr98.6%
Taylor expanded in phi2 around 0 72.2%
if -1.7e-5 < phi1 < 3.0000000000000001e-6Initial program 63.2%
Simplified63.2%
Taylor expanded in phi1 around 0 62.9%
cos-diff88.6%
+-commutative88.6%
Applied egg-rr88.2%
Final simplification84.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -3.5e-6) (not (<= phi2 1.05e-8)))
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(+
(* (sin phi1) phi2)
(*
(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 <= -3.5e-6) || !(phi2 <= 1.05e-8)) {
tmp = R * acos(fma(sin(phi1), sin(phi2), ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -3.5e-6) || !(phi2 <= 1.05e-8)) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + 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, -3.5e-6], N[Not[LessEqual[phi2, 1.05e-8]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -3.5 \cdot 10^{-6} \lor \neg \left(\phi_2 \leq 1.05 \cdot 10^{-8}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \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 < -3.49999999999999995e-6 or 1.04999999999999997e-8 < phi2 Initial program 72.4%
Simplified72.4%
if -3.49999999999999995e-6 < phi2 < 1.04999999999999997e-8Initial program 69.9%
Simplified69.9%
cos-diff88.4%
+-commutative88.4%
Applied egg-rr88.4%
Taylor expanded in phi2 around 0 88.2%
Final simplification80.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -2.7e-12) (not (<= phi2 8.5e-9)))
(*
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 <= -2.7e-12) || !(phi2 <= 8.5e-9)) {
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 <= -2.7e-12) || !(phi2 <= 8.5e-9)) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(Float64(cos(phi1) * 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, -2.7e-12], N[Not[LessEqual[phi2, 8.5e-9]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[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 -2.7 \cdot 10^{-12} \lor \neg \left(\phi_2 \leq 8.5 \cdot 10^{-9}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\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 < -2.6999999999999998e-12 or 8.5e-9 < phi2 Initial program 72.4%
Simplified72.4%
if -2.6999999999999998e-12 < phi2 < 8.5e-9Initial program 69.8%
Simplified69.8%
cos-diff88.1%
+-commutative88.1%
Applied egg-rr88.1%
Taylor expanded in phi2 around 0 88.1%
Final simplification80.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda1))))))
(t_1
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -7.8e+152)
t_0
(if (<= phi1 -1.05e-5)
(* R (acos (* (cos phi1) t_1)))
(if (<= phi1 3.9e-10) (* R (acos (* (cos phi2) t_1))) t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
double t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi1 <= -7.8e+152) {
tmp = t_0;
} else if (phi1 <= -1.05e-5) {
tmp = R * acos((cos(phi1) * t_1));
} else if (phi1 <= 3.9e-10) {
tmp = R * acos((cos(phi2) * t_1));
} else {
tmp = 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 = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi1 <= (-7.8d+152)) then
tmp = t_0
else if (phi1 <= (-1.05d-5)) then
tmp = r * acos((cos(phi1) * t_1))
else if (phi1 <= 3.9d-10) then
tmp = r * acos((cos(phi2) * t_1))
else
tmp = 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 = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
double t_1 = (Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi1 <= -7.8e+152) {
tmp = t_0;
} else if (phi1 <= -1.05e-5) {
tmp = R * Math.acos((Math.cos(phi1) * t_1));
} else if (phi1 <= 3.9e-10) {
tmp = R * Math.acos((Math.cos(phi2) * t_1));
} else {
tmp = t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) t_1 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi1 <= -7.8e+152: tmp = t_0 elif phi1 <= -1.05e-5: tmp = R * math.acos((math.cos(phi1) * t_1)) elif phi1 <= 3.9e-10: tmp = R * math.acos((math.cos(phi2) * t_1)) else: tmp = t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))) t_1 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi1 <= -7.8e+152) tmp = t_0; elseif (phi1 <= -1.05e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_1))); elseif (phi1 <= 3.9e-10) tmp = Float64(R * acos(Float64(cos(phi2) * t_1))); else tmp = t_0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi1 <= -7.8e+152) tmp = t_0; elseif (phi1 <= -1.05e-5) tmp = R * acos((cos(phi1) * t_1)); elseif (phi1 <= 3.9e-10) tmp = R * acos((cos(phi2) * t_1)); else tmp = t_0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{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]}, If[LessEqual[phi1, -7.8e+152], t$95$0, If[LessEqual[phi1, -1.05e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.9e-10], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -7.8 \cdot 10^{+152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_1 \leq -1.05 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_1\right)\\
\mathbf{elif}\;\phi_1 \leq 3.9 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if phi1 < -7.80000000000000022e152 or 3.9e-10 < phi1 Initial program 82.5%
Taylor expanded in lambda2 around 0 62.8%
if -7.80000000000000022e152 < phi1 < -1.04999999999999994e-5Initial program 71.6%
Simplified71.6%
cos-diff98.8%
+-commutative98.8%
Applied egg-rr98.8%
Taylor expanded in phi2 around 0 74.9%
if -1.04999999999999994e-5 < phi1 < 3.9e-10Initial program 62.7%
Simplified62.7%
cos-diff88.3%
+-commutative88.3%
Applied egg-rr88.3%
Taylor expanded in phi1 around 0 87.8%
Final simplification77.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -3.2e-12) (not (<= phi2 1.05e-8)))
(*
R
(acos
(+
(* (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 <= -3.2e-12) || !(phi2 <= 1.05e-8)) {
tmp = R * acos(((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;
}
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 <= (-3.2d-12)) .or. (.not. (phi2 <= 1.05d-8))) then
tmp = r * acos(((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)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -3.2e-12) || !(phi2 <= 1.05e-8)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * 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 <= -3.2e-12) or not (phi2 <= 1.05e-8): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * 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 <= -3.2e-12) || !(phi2 <= 1.05e-8)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * 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
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -3.2e-12) || ~((phi2 <= 1.05e-8))) tmp = R * acos(((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))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -3.2e-12], N[Not[LessEqual[phi2, 1.05e-8]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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 -3.2 \cdot 10^{-12} \lor \neg \left(\phi_2 \leq 1.05 \cdot 10^{-8}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\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 < -3.2000000000000001e-12 or 1.04999999999999997e-8 < phi2 Initial program 72.4%
if -3.2000000000000001e-12 < phi2 < 1.04999999999999997e-8Initial program 69.8%
Simplified69.8%
cos-diff88.1%
+-commutative88.1%
Applied egg-rr88.1%
Taylor expanded in phi2 around 0 88.1%
Final simplification80.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -2.8e-5)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 3.9e-10)
(* R (acos (* (cos phi2) t_0)))
(* R (acos (+ (* (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 <= -2.8e-5) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 3.9e-10) {
tmp = R * acos((cos(phi2) * t_0));
} else {
tmp = R * acos(((cos(phi1) * cos(phi2)) + (sin(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 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi1 <= (-2.8d-5)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 3.9d-10) then
tmp = r * acos((cos(phi2) * t_0))
else
tmp = r * acos(((cos(phi1) * cos(phi2)) + (sin(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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi1 <= -2.8e-5) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 3.9e-10) {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
} else {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos(phi2)) + (Math.sin(phi1) * Math.sin(phi2))));
}
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 <= -2.8e-5: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 3.9e-10: tmp = R * math.acos((math.cos(phi2) * t_0)) else: tmp = R * math.acos(((math.cos(phi1) * math.cos(phi2)) + (math.sin(phi1) * math.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 <= -2.8e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 3.9e-10) tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(phi2)) + Float64(sin(phi1) * sin(phi2))))); 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 <= -2.8e-5) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 3.9e-10) tmp = R * acos((cos(phi2) * t_0)); else tmp = R * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2)))); 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, -2.8e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.9e-10], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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 -2.8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_0\right)\\
\mathbf{elif}\;\phi_1 \leq 3.9 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \phi_2 + \sin \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -2.79999999999999996e-5Initial program 80.0%
Simplified80.0%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.0%
Taylor expanded in phi2 around 0 54.7%
if -2.79999999999999996e-5 < phi1 < 3.9e-10Initial program 62.7%
Simplified62.7%
cos-diff88.3%
+-commutative88.3%
Applied egg-rr88.3%
Taylor expanded in phi1 around 0 87.8%
if 3.9e-10 < phi1 Initial program 81.3%
Taylor expanded in lambda2 around 0 50.8%
Taylor expanded in lambda1 around 0 46.2%
Final simplification70.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 1.05e-8)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (cos phi2) (cos (- lambda2 lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.05e-8) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 1.05d-8) 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((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.05e-8) {
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((lambda2 - lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.05e-8: 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((lambda2 - lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.05e-8) 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(lambda2 - lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1.05e-8) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.05e-8], 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[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.05 \cdot 10^{-8}:\\
\;\;\;\;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_2 - \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < 1.04999999999999997e-8Initial program 70.3%
Simplified70.3%
cos-diff92.0%
+-commutative92.0%
Applied egg-rr92.0%
Taylor expanded in phi2 around 0 64.9%
if 1.04999999999999997e-8 < phi2 Initial program 73.9%
Taylor expanded in phi1 around 0 51.7%
sub-neg51.7%
neg-mul-151.7%
neg-mul-151.7%
remove-double-neg51.7%
mul-1-neg51.7%
distribute-neg-in51.7%
+-commutative51.7%
cos-neg51.7%
mul-1-neg51.7%
unsub-neg51.7%
Simplified51.7%
Final simplification61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* R (acos (+ (* (cos phi1) (cos phi2)) t_0))))
(t_2 (cos (- lambda2 lambda1))))
(if (<= phi1 -4.6e+222)
t_1
(if (<= phi1 -0.042)
(* R (acos (+ t_0 (* (cos phi1) t_2))))
(if (<= phi1 1.9e-6)
(*
R
(acos
(+
(* phi1 (sin phi2))
(* (* (cos phi2) t_2) (+ (* -0.5 (pow phi1 2.0)) 1.0)))))
t_1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = R * acos(((cos(phi1) * cos(phi2)) + t_0));
double t_2 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -4.6e+222) {
tmp = t_1;
} else if (phi1 <= -0.042) {
tmp = R * acos((t_0 + (cos(phi1) * t_2)));
} else if (phi1 <= 1.9e-6) {
tmp = R * acos(((phi1 * sin(phi2)) + ((cos(phi2) * t_2) * ((-0.5 * pow(phi1, 2.0)) + 1.0))));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
t_1 = r * acos(((cos(phi1) * cos(phi2)) + t_0))
t_2 = cos((lambda2 - lambda1))
if (phi1 <= (-4.6d+222)) then
tmp = t_1
else if (phi1 <= (-0.042d0)) then
tmp = r * acos((t_0 + (cos(phi1) * t_2)))
else if (phi1 <= 1.9d-6) then
tmp = r * acos(((phi1 * sin(phi2)) + ((cos(phi2) * t_2) * (((-0.5d0) * (phi1 ** 2.0d0)) + 1.0d0))))
else
tmp = t_1
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 t_1 = R * Math.acos(((Math.cos(phi1) * Math.cos(phi2)) + t_0));
double t_2 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -4.6e+222) {
tmp = t_1;
} else if (phi1 <= -0.042) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * t_2)));
} else if (phi1 <= 1.9e-6) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + ((Math.cos(phi2) * t_2) * ((-0.5 * Math.pow(phi1, 2.0)) + 1.0))));
} else {
tmp = t_1;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = R * math.acos(((math.cos(phi1) * math.cos(phi2)) + t_0)) t_2 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -4.6e+222: tmp = t_1 elif phi1 <= -0.042: tmp = R * math.acos((t_0 + (math.cos(phi1) * t_2))) elif phi1 <= 1.9e-6: tmp = R * math.acos(((phi1 * math.sin(phi2)) + ((math.cos(phi2) * t_2) * ((-0.5 * math.pow(phi1, 2.0)) + 1.0)))) else: tmp = t_1 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(R * acos(Float64(Float64(cos(phi1) * cos(phi2)) + t_0))) t_2 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -4.6e+222) tmp = t_1; elseif (phi1 <= -0.042) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * t_2)))); elseif (phi1 <= 1.9e-6) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(cos(phi2) * t_2) * Float64(Float64(-0.5 * (phi1 ^ 2.0)) + 1.0))))); else tmp = t_1; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = R * acos(((cos(phi1) * cos(phi2)) + t_0)); t_2 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi1 <= -4.6e+222) tmp = t_1; elseif (phi1 <= -0.042) tmp = R * acos((t_0 + (cos(phi1) * t_2))); elseif (phi1 <= 1.9e-6) tmp = R * acos(((phi1 * sin(phi2)) + ((cos(phi2) * t_2) * ((-0.5 * (phi1 ^ 2.0)) + 1.0)))); else tmp = t_1; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -4.6e+222], t$95$1, If[LessEqual[phi1, -0.042], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-6], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] * N[(N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \phi_2 + t_0\right)\\
t_2 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -4.6 \cdot 10^{+222}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\phi_1 \leq -0.042:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot t_2\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot t_2\right) \cdot \left(-0.5 \cdot {\phi_1}^{2} + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if phi1 < -4.60000000000000021e222 or 1.9e-6 < phi1 Initial program 79.5%
Taylor expanded in lambda2 around 0 52.3%
Taylor expanded in lambda1 around 0 43.3%
if -4.60000000000000021e222 < phi1 < -0.0420000000000000026Initial program 81.7%
Taylor expanded in phi2 around 0 56.8%
sub-neg56.8%
remove-double-neg56.8%
mul-1-neg56.8%
distribute-neg-in56.8%
+-commutative56.8%
cos-neg56.8%
mul-1-neg56.8%
unsub-neg56.8%
Simplified56.8%
if -0.0420000000000000026 < phi1 < 1.9e-6Initial program 63.5%
Simplified63.5%
Taylor expanded in phi1 around 0 63.5%
+-commutative63.5%
associate-+r+63.5%
Simplified63.5%
Final simplification56.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* R (acos (+ (* (cos phi1) (cos phi2)) t_0))))
(t_2 (cos (- lambda2 lambda1))))
(if (<= phi1 -5.6e+222)
t_1
(if (<= phi1 -1.05e-5)
(* R (acos (+ t_0 (* (cos phi1) t_2))))
(if (<= phi1 1.9e-6) (* R (acos (+ t_0 (* (cos phi2) t_2)))) t_1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = R * acos(((cos(phi1) * cos(phi2)) + t_0));
double t_2 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -5.6e+222) {
tmp = t_1;
} else if (phi1 <= -1.05e-5) {
tmp = R * acos((t_0 + (cos(phi1) * t_2)));
} else if (phi1 <= 1.9e-6) {
tmp = R * acos((t_0 + (cos(phi2) * t_2)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
t_1 = r * acos(((cos(phi1) * cos(phi2)) + t_0))
t_2 = cos((lambda2 - lambda1))
if (phi1 <= (-5.6d+222)) then
tmp = t_1
else if (phi1 <= (-1.05d-5)) then
tmp = r * acos((t_0 + (cos(phi1) * t_2)))
else if (phi1 <= 1.9d-6) then
tmp = r * acos((t_0 + (cos(phi2) * t_2)))
else
tmp = t_1
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 t_1 = R * Math.acos(((Math.cos(phi1) * Math.cos(phi2)) + t_0));
double t_2 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -5.6e+222) {
tmp = t_1;
} else if (phi1 <= -1.05e-5) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * t_2)));
} else if (phi1 <= 1.9e-6) {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * t_2)));
} else {
tmp = t_1;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = R * math.acos(((math.cos(phi1) * math.cos(phi2)) + t_0)) t_2 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -5.6e+222: tmp = t_1 elif phi1 <= -1.05e-5: tmp = R * math.acos((t_0 + (math.cos(phi1) * t_2))) elif phi1 <= 1.9e-6: tmp = R * math.acos((t_0 + (math.cos(phi2) * t_2))) else: tmp = t_1 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(R * acos(Float64(Float64(cos(phi1) * cos(phi2)) + t_0))) t_2 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -5.6e+222) tmp = t_1; elseif (phi1 <= -1.05e-5) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * t_2)))); elseif (phi1 <= 1.9e-6) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * t_2)))); else tmp = t_1; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = R * acos(((cos(phi1) * cos(phi2)) + t_0)); t_2 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi1 <= -5.6e+222) tmp = t_1; elseif (phi1 <= -1.05e-5) tmp = R * acos((t_0 + (cos(phi1) * t_2))); elseif (phi1 <= 1.9e-6) tmp = R * acos((t_0 + (cos(phi2) * t_2))); else tmp = t_1; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5.6e+222], t$95$1, If[LessEqual[phi1, -1.05e-5], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-6], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \phi_2 + t_0\right)\\
t_2 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -5.6 \cdot 10^{+222}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\phi_1 \leq -1.05 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot t_2\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot t_2\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if phi1 < -5.6000000000000003e222 or 1.9e-6 < phi1 Initial program 79.5%
Taylor expanded in lambda2 around 0 52.3%
Taylor expanded in lambda1 around 0 43.3%
if -5.6000000000000003e222 < phi1 < -1.04999999999999994e-5Initial program 81.7%
Taylor expanded in phi2 around 0 56.8%
sub-neg56.8%
remove-double-neg56.8%
mul-1-neg56.8%
distribute-neg-in56.8%
+-commutative56.8%
cos-neg56.8%
mul-1-neg56.8%
unsub-neg56.8%
Simplified56.8%
if -1.04999999999999994e-5 < phi1 < 1.9e-6Initial program 63.5%
Taylor expanded in phi1 around 0 63.2%
sub-neg63.2%
neg-mul-163.2%
neg-mul-163.2%
remove-double-neg63.2%
mul-1-neg63.2%
distribute-neg-in63.2%
+-commutative63.2%
cos-neg63.2%
mul-1-neg63.2%
unsub-neg63.2%
Simplified63.2%
Final simplification56.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(* R (acos (+ (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2))))))
(t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -5e+222)
t_0
(if (<= phi1 -3.1e-5)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_1))))
(if (<= phi1 1.9e-6)
(* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) t_1))))
t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2))));
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -5e+222) {
tmp = t_0;
} else if (phi1 <= -3.1e-5) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1)));
} else if (phi1 <= 1.9e-6) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_1)));
} else {
tmp = 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 = r * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2))))
t_1 = cos((lambda1 - lambda2))
if (phi1 <= (-5d+222)) then
tmp = t_0
else if (phi1 <= (-3.1d-5)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1)))
else if (phi1 <= 1.9d-6) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_1)))
else
tmp = 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 = R * Math.acos(((Math.cos(phi1) * Math.cos(phi2)) + (Math.sin(phi1) * Math.sin(phi2))));
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -5e+222) {
tmp = t_0;
} else if (phi1 <= -3.1e-5) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_1)));
} else if (phi1 <= 1.9e-6) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * t_1)));
} else {
tmp = t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = R * math.acos(((math.cos(phi1) * math.cos(phi2)) + (math.sin(phi1) * math.sin(phi2)))) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -5e+222: tmp = t_0 elif phi1 <= -3.1e-5: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_1))) elif phi1 <= 1.9e-6: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * t_1))) else: tmp = t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * acos(Float64(Float64(cos(phi1) * cos(phi2)) + Float64(sin(phi1) * sin(phi2))))) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -5e+222) tmp = t_0; elseif (phi1 <= -3.1e-5) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_1)))); elseif (phi1 <= 1.9e-6) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * t_1)))); else tmp = t_0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = R * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2)))); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -5e+222) tmp = t_0; elseif (phi1 <= -3.1e-5) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1))); elseif (phi1 <= 1.9e-6) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_1))); else tmp = t_0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e+222], t$95$0, If[LessEqual[phi1, -3.1e-5], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-6], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \phi_2 + \sin \phi_1 \cdot \sin \phi_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{+222}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_1 \leq -3.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t_1\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if phi1 < -5.00000000000000023e222 or 1.9e-6 < phi1 Initial program 79.5%
Taylor expanded in lambda2 around 0 52.3%
Taylor expanded in lambda1 around 0 43.3%
if -5.00000000000000023e222 < phi1 < -3.10000000000000014e-5Initial program 81.7%
Simplified81.7%
Taylor expanded in phi2 around 0 49.1%
if -3.10000000000000014e-5 < phi1 < 1.9e-6Initial program 63.5%
Simplified63.5%
Taylor expanded in phi1 around 0 63.2%
Final simplification54.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* R (acos (+ (* (cos phi1) (cos phi2)) t_0)))))
(if (<= phi1 -5.9e+221)
t_1
(if (<= phi1 -2.75e-5)
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1))))))
(if (<= phi1 1.9e-6)
(*
R
(acos
(+ (* phi1 (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2))))))
t_1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = R * acos(((cos(phi1) * cos(phi2)) + t_0));
double tmp;
if (phi1 <= -5.9e+221) {
tmp = t_1;
} else if (phi1 <= -2.75e-5) {
tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))));
} else if (phi1 <= 1.9e-6) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
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 = sin(phi1) * sin(phi2)
t_1 = r * acos(((cos(phi1) * cos(phi2)) + t_0))
if (phi1 <= (-5.9d+221)) then
tmp = t_1
else if (phi1 <= (-2.75d-5)) then
tmp = r * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))
else if (phi1 <= 1.9d-6) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))))
else
tmp = t_1
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 t_1 = R * Math.acos(((Math.cos(phi1) * Math.cos(phi2)) + t_0));
double tmp;
if (phi1 <= -5.9e+221) {
tmp = t_1;
} else if (phi1 <= -2.75e-5) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (phi1 <= 1.9e-6) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = R * math.acos(((math.cos(phi1) * math.cos(phi2)) + t_0)) tmp = 0 if phi1 <= -5.9e+221: tmp = t_1 elif phi1 <= -2.75e-5: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) elif phi1 <= 1.9e-6: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) else: tmp = t_1 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(R * acos(Float64(Float64(cos(phi1) * cos(phi2)) + t_0))) tmp = 0.0 if (phi1 <= -5.9e+221) tmp = t_1; elseif (phi1 <= -2.75e-5) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); elseif (phi1 <= 1.9e-6) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = t_1; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = R * acos(((cos(phi1) * cos(phi2)) + t_0)); tmp = 0.0; if (phi1 <= -5.9e+221) tmp = t_1; elseif (phi1 <= -2.75e-5) tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))); elseif (phi1 <= 1.9e-6) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); else tmp = t_1; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5.9e+221], t$95$1, If[LessEqual[phi1, -2.75e-5], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-6], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \phi_2 + t_0\right)\\
\mathbf{if}\;\phi_1 \leq -5.9 \cdot 10^{+221}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\phi_1 \leq -2.75 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if phi1 < -5.9e221 or 1.9e-6 < phi1 Initial program 79.5%
Taylor expanded in lambda2 around 0 52.3%
Taylor expanded in lambda1 around 0 43.3%
if -5.9e221 < phi1 < -2.7500000000000001e-5Initial program 81.7%
Taylor expanded in phi2 around 0 56.8%
sub-neg56.8%
remove-double-neg56.8%
mul-1-neg56.8%
distribute-neg-in56.8%
+-commutative56.8%
cos-neg56.8%
mul-1-neg56.8%
unsub-neg56.8%
Simplified56.8%
if -2.7500000000000001e-5 < phi1 < 1.9e-6Initial program 63.5%
Simplified63.5%
Taylor expanded in phi1 around 0 63.2%
Final simplification56.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -7800000.0)
(* R (acos (cos (- lambda2 lambda1))))
(*
R
(acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7800000.0) {
tmp = R * acos(cos((lambda2 - lambda1)));
} else {
tmp = R * acos(((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 (phi1 <= (-7800000.0d0)) then
tmp = r * acos(cos((lambda2 - lambda1)))
else
tmp = r * acos(((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 (phi1 <= -7800000.0) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -7800000.0: tmp = R * math.acos(math.cos((lambda2 - lambda1))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7800000.0) tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); else tmp = Float64(R * acos(Float64(Float64(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 (phi1 <= -7800000.0) tmp = R * acos(cos((lambda2 - lambda1))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7800000.0], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7800000:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.8e6Initial program 80.0%
Simplified80.0%
Taylor expanded in phi1 around 0 6.5%
Taylor expanded in phi2 around 0 6.5%
sub-neg6.5%
remove-double-neg6.5%
mul-1-neg6.5%
distribute-neg-in6.5%
+-commutative6.5%
cos-neg6.5%
mul-1-neg6.5%
sub-neg6.5%
Simplified6.5%
Taylor expanded in phi2 around 0 6.5%
Taylor expanded in phi1 around 0 17.4%
if -7.8e6 < phi1 Initial program 68.7%
Simplified68.7%
Taylor expanded in phi1 around 0 45.7%
Final simplification39.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 1.05e-8)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.05e-8) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (phi2 <= 1.05d-8) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.05e-8) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 1.05e-8: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 1.05e-8) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 1.05e-8) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 1.05e-8], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 1.05 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t_0\right)\\
\end{array}
\end{array}
if phi2 < 1.04999999999999997e-8Initial program 70.3%
Simplified70.3%
Taylor expanded in phi2 around 0 47.7%
if 1.04999999999999997e-8 < phi2 Initial program 73.9%
Simplified73.9%
Taylor expanded in phi1 around 0 45.4%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 0.155) (* R (acos (cos (- lambda2 lambda1)))) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.155) {
tmp = R * acos(cos((lambda2 - lambda1)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 0.155d0) then
tmp = r * acos(cos((lambda2 - lambda1)))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.155) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.155: tmp = R * math.acos(math.cos((lambda2 - lambda1))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.155) tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.155) tmp = R * acos(cos((lambda2 - lambda1))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.155], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.155:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < 0.154999999999999999Initial program 70.2%
Simplified70.2%
Taylor expanded in phi1 around 0 34.8%
Taylor expanded in phi2 around 0 26.9%
sub-neg26.9%
remove-double-neg26.9%
mul-1-neg26.9%
distribute-neg-in26.9%
+-commutative26.9%
cos-neg26.9%
mul-1-neg26.9%
sub-neg26.9%
Simplified26.9%
Taylor expanded in phi2 around 0 25.4%
Taylor expanded in phi1 around 0 31.5%
if 0.154999999999999999 < phi2 Initial program 74.3%
Simplified74.4%
Taylor expanded in phi1 around 0 45.0%
Taylor expanded in lambda2 around 0 34.9%
*-commutative34.9%
Simplified34.9%
Final simplification32.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda1 -180000.0)
(* R (acos (+ t_0 (* (cos phi2) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi2) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda1 <= -180000.0) {
tmp = R * acos((t_0 + (cos(phi2) * cos(lambda1))));
} else {
tmp = R * acos((t_0 + (cos(phi2) * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = phi1 * sin(phi2)
if (lambda1 <= (-180000.0d0)) then
tmp = r * acos((t_0 + (cos(phi2) * cos(lambda1))))
else
tmp = r * acos((t_0 + (cos(phi2) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * Math.sin(phi2);
double tmp;
if (lambda1 <= -180000.0) {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi2) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda1 <= -180000.0: tmp = R * math.acos((t_0 + (math.cos(phi2) * math.cos(lambda1)))) else: tmp = R * math.acos((t_0 + (math.cos(phi2) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda1 <= -180000.0) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda1 <= -180000.0) tmp = R * acos((t_0 + (cos(phi2) * cos(lambda1)))); else tmp = R * acos((t_0 + (cos(phi2) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -180000.0], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -180000:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -1.8e5Initial program 63.1%
Simplified63.1%
Taylor expanded in phi1 around 0 35.3%
Taylor expanded in lambda2 around 0 35.3%
*-commutative35.3%
Simplified35.3%
if -1.8e5 < lambda1 Initial program 73.5%
Simplified73.5%
Taylor expanded in phi1 around 0 37.7%
Taylor expanded in lambda1 around 0 27.8%
cos-neg27.8%
Simplified27.8%
Final simplification29.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda2 lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos((lambda2 - lambda1)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(cos((lambda2 - lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda2 - lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda2 - lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda2 - lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos((lambda2 - lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 71.1%
Simplified71.1%
Taylor expanded in phi1 around 0 37.2%
Taylor expanded in phi2 around 0 23.2%
sub-neg23.2%
remove-double-neg23.2%
mul-1-neg23.2%
distribute-neg-in23.2%
+-commutative23.2%
cos-neg23.2%
mul-1-neg23.2%
sub-neg23.2%
Simplified23.2%
Taylor expanded in phi2 around 0 20.8%
Taylor expanded in phi1 around 0 27.8%
Final simplification27.8%
(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.1%
Simplified71.1%
Taylor expanded in phi1 around 0 37.2%
Taylor expanded in phi2 around 0 23.2%
sub-neg23.2%
remove-double-neg23.2%
mul-1-neg23.2%
distribute-neg-in23.2%
+-commutative23.2%
cos-neg23.2%
mul-1-neg23.2%
sub-neg23.2%
Simplified23.2%
Taylor expanded in phi2 around 0 20.8%
Taylor expanded in phi1 around inf 10.4%
Final simplification10.4%
herbie shell --seed 2023306
(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))