
(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 29 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
(*
R
(acos
(fma
(* (cos phi1) (cos phi2))
(fma
(cos lambda2)
(cos lambda1)
(expm1 (log1p (* (sin lambda2) (sin lambda1)))))
(* (sin phi1) (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma((cos(phi1) * cos(phi2)), fma(cos(lambda2), cos(lambda1), expm1(log1p((sin(lambda2) * sin(lambda1))))), (sin(phi1) * sin(phi2))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), fma(cos(lambda2), cos(lambda1), expm1(log1p(Float64(sin(lambda2) * sin(lambda1))))), Float64(sin(phi1) * sin(phi2))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(Exp[N[Log[1 + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \lambda_2 \cdot \sin \lambda_1\right)\right)\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)
\end{array}
Initial program 75.3%
Simplified75.3%
cos-diff96.1%
*-commutative96.1%
*-commutative96.1%
Applied egg-rr96.1%
*-commutative96.1%
fma-undefine96.1%
*-commutative96.1%
Simplified96.1%
expm1-log1p-u96.1%
Applied egg-rr96.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(fma
(* (cos phi1) (cos phi2))
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1)))
(* (sin phi1) (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma((cos(phi1) * cos(phi2)), fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1))), (sin(phi1) * sin(phi2))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1))), Float64(sin(phi1) * sin(phi2))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)
\end{array}
Initial program 75.3%
Simplified75.3%
cos-diff96.1%
*-commutative96.1%
*-commutative96.1%
Applied egg-rr96.1%
*-commutative96.1%
fma-undefine96.1%
*-commutative96.1%
Simplified96.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1))))))))
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(lambda2) * sin(lambda1))))));
}
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(lambda2) * sin(lambda1))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)\right)
\end{array}
Initial program 75.3%
cos-diff96.1%
distribute-lft-in96.1%
Applied egg-rr96.1%
distribute-lft-out96.1%
*-commutative96.1%
fma-undefine96.1%
*-commutative96.1%
Simplified96.1%
Final simplification96.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(fma
(* (cos phi1) (cos phi2))
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))
(* (sin phi1) (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma((cos(phi1) * cos(phi2)), ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))), (sin(phi1) * sin(phi2))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))), Float64(sin(phi1) * sin(phi2))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1, \sin \phi_1 \cdot \sin \phi_2\right)\right)
\end{array}
Initial program 75.3%
Simplified75.3%
cos-diff96.1%
+-commutative96.1%
*-commutative96.1%
*-commutative96.1%
Applied egg-rr96.1%
Final simplification96.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))))
(if (<= phi1 -1e-5)
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(* (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
(if (<= phi1 0.0054)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
t_0
(fma
(sin lambda2)
(sin lambda1)
(* (cos lambda2) (cos lambda1)))))))
(*
R
(-
(* 0.5 PI)
(asin
(fma t_0 (cos (- lambda2 lambda1)) (* (sin phi1) (sin phi2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double tmp;
if (phi1 <= -1e-5) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else if (phi1 <= 0.0054) {
tmp = R * acos(((phi1 * sin(phi2)) + (t_0 * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * ((0.5 * ((double) M_PI)) - asin(fma(t_0, cos((lambda2 - lambda1)), (sin(phi1) * sin(phi2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -1e-5) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))); elseif (phi1 <= 0.0054) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(t_0 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * Float64(Float64(0.5 * pi) - asin(fma(t_0, cos(Float64(lambda2 - lambda1)), Float64(sin(phi1) * sin(phi2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1e-5], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.0054], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(0.5 * Pi), $MachinePrecision] - N[ArcSin[N[(t$95$0 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.0054:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + t\_0 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(0.5 \cdot \pi - \sin^{-1} \left(\mathsf{fma}\left(t\_0, \cos \left(\lambda_2 - \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -1.00000000000000008e-5Initial program 77.3%
Simplified77.5%
if -1.00000000000000008e-5 < phi1 < 0.0054000000000000003Initial program 71.3%
Taylor expanded in phi1 around 0 71.3%
cos-diff92.7%
distribute-lft-in92.7%
Applied egg-rr92.3%
distribute-lft-out92.3%
+-commutative92.3%
*-commutative92.3%
fma-define92.3%
*-commutative92.3%
Simplified92.3%
if 0.0054000000000000003 < phi1 Initial program 80.4%
Simplified80.4%
cos-diff99.2%
*-commutative99.2%
*-commutative99.2%
cos-diff80.4%
fma-define80.4%
+-commutative80.4%
acos-asin80.3%
sub-neg80.3%
div-inv80.3%
metadata-eval80.3%
+-commutative80.3%
Applied egg-rr80.3%
sub-neg80.3%
*-commutative80.3%
fma-define80.3%
associate-*r*80.3%
fma-define80.3%
Simplified80.3%
Final simplification85.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1)))))))
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(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $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_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)
\end{array}
Initial program 75.3%
Simplified75.3%
cos-diff96.1%
*-commutative96.1%
*-commutative96.1%
Applied egg-rr96.1%
*-commutative96.1%
fma-undefine96.1%
*-commutative96.1%
Simplified96.1%
Taylor expanded in phi1 around 0 96.1%
Final simplification96.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -4.8e-6)
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(* (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
(if (<= phi1 0.00135)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(+ 1.0 (+ (* (sin lambda2) (sin lambda1)) -1.0)))))))
(*
R
(-
(* 0.5 PI)
(asin
(fma
(* (cos phi1) (cos phi2))
(cos (- lambda2 lambda1))
(* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -4.8e-6) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else if (phi1 <= 0.00135) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (1.0 + ((sin(lambda2) * sin(lambda1)) + -1.0))))));
} else {
tmp = R * ((0.5 * ((double) M_PI)) - asin(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), (sin(phi1) * sin(phi2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -4.8e-6) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))); elseif (phi1 <= 0.00135) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(1.0 + Float64(Float64(sin(lambda2) * sin(lambda1)) + -1.0))))))); else tmp = Float64(R * Float64(Float64(0.5 * pi) - asin(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), Float64(sin(phi1) * sin(phi2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -4.8e-6], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00135], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(0.5 * Pi), $MachinePrecision] - N[ArcSin[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -4.8 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00135:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \left(1 + \left(\sin \lambda_2 \cdot \sin \lambda_1 + -1\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(0.5 \cdot \pi - \sin^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -4.7999999999999998e-6Initial program 77.3%
Simplified77.5%
if -4.7999999999999998e-6 < phi1 < 0.0013500000000000001Initial program 71.7%
Simplified71.7%
cos-diff92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-commutative92.6%
fma-undefine92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in phi1 around 0 92.0%
*-commutative92.0%
expm1-log1p-u92.0%
expm1-undefine92.0%
log1p-expm1-u92.0%
log1p-undefine92.0%
rem-exp-log92.0%
expm1-log1p-u92.0%
Applied egg-rr92.0%
associate--l+92.0%
*-commutative92.0%
Simplified92.0%
if 0.0013500000000000001 < phi1 Initial program 79.5%
Simplified79.5%
cos-diff99.2%
*-commutative99.2%
*-commutative99.2%
cos-diff79.5%
fma-define79.5%
+-commutative79.5%
acos-asin79.4%
sub-neg79.4%
div-inv79.4%
metadata-eval79.4%
+-commutative79.4%
Applied egg-rr79.4%
sub-neg79.4%
*-commutative79.4%
fma-define79.4%
associate-*r*79.4%
fma-define79.4%
Simplified79.4%
Final simplification84.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -7.5e-7)
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(* (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
(if (<= phi1 0.00135)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(*
R
(-
(* 0.5 PI)
(asin
(fma
(* (cos phi1) (cos phi2))
(cos (- lambda2 lambda1))
(* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7.5e-7) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else if (phi1 <= 0.00135) {
tmp = R * acos(((cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * ((0.5 * ((double) M_PI)) - asin(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), (sin(phi1) * sin(phi2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7.5e-7) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))); elseif (phi1 <= 0.00135) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * Float64(Float64(0.5 * pi) - asin(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), Float64(sin(phi1) * sin(phi2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7.5e-7], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00135], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(0.5 * Pi), $MachinePrecision] - N[ArcSin[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00135:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(0.5 \cdot \pi - \sin^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.5000000000000002e-7Initial program 77.3%
Simplified77.5%
if -7.5000000000000002e-7 < phi1 < 0.0013500000000000001Initial program 71.7%
Simplified71.7%
cos-diff92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-commutative92.6%
fma-undefine92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in phi1 around 0 92.0%
if 0.0013500000000000001 < phi1 Initial program 79.5%
Simplified79.5%
cos-diff99.2%
*-commutative99.2%
*-commutative99.2%
cos-diff79.5%
fma-define79.5%
+-commutative79.5%
acos-asin79.4%
sub-neg79.4%
div-inv79.4%
metadata-eval79.4%
+-commutative79.4%
Applied egg-rr79.4%
sub-neg79.4%
*-commutative79.4%
fma-define79.4%
associate-*r*79.4%
fma-define79.4%
Simplified79.4%
Final simplification84.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -6.8e-7)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))
(if (<= phi1 0.00135)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -6.8e-7) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
} else if (phi1 <= 0.00135) {
tmp = R * acos(((cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -6.8e-7) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); elseif (phi1 <= 0.00135) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6.8e-7], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00135], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -6.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00135:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -6.79999999999999948e-7Initial program 77.3%
Simplified77.5%
if -6.79999999999999948e-7 < phi1 < 0.0013500000000000001Initial program 71.7%
Simplified71.7%
cos-diff92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-commutative92.6%
fma-undefine92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in phi1 around 0 92.0%
if 0.0013500000000000001 < phi1 Initial program 79.5%
Final simplification84.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -9e-9) (not (<= phi1 0.00135)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi2)
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -9e-9) || !(phi1 <= 0.00135)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi2) * fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -9e-9) || !(phi1 <= 0.00135)) 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(phi2) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -9e-9], N[Not[LessEqual[phi1, 0.00135]], $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[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -9 \cdot 10^{-9} \lor \neg \left(\phi_1 \leq 0.00135\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_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -8.99999999999999953e-9 or 0.0013500000000000001 < phi1 Initial program 78.4%
if -8.99999999999999953e-9 < phi1 < 0.0013500000000000001Initial program 71.7%
Simplified71.7%
cos-diff92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-commutative92.6%
fma-undefine92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in phi1 around 0 91.3%
cos-neg91.3%
*-commutative91.3%
*-commutative91.3%
fma-undefine91.3%
cos-neg91.3%
*-commutative91.3%
Simplified91.3%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -5e-9)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))
(if (<= phi1 0.00135)
(*
R
(acos
(*
(cos phi2)
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -5e-9) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
} else if (phi1 <= 0.00135) {
tmp = R * acos((cos(phi2) * fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -5e-9) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); elseif (phi1 <= 0.00135) tmp = Float64(R * acos(Float64(cos(phi2) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e-9], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00135], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00135:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -5.0000000000000001e-9Initial program 77.3%
Simplified77.5%
if -5.0000000000000001e-9 < phi1 < 0.0013500000000000001Initial program 71.7%
Simplified71.7%
cos-diff92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-commutative92.6%
fma-undefine92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in phi1 around 0 91.3%
cos-neg91.3%
*-commutative91.3%
*-commutative91.3%
fma-undefine91.3%
cos-neg91.3%
*-commutative91.3%
Simplified91.3%
if 0.0013500000000000001 < phi1 Initial program 79.5%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -1.7e-7)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 0.00135)
(*
R
(acos
(*
(cos phi2)
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) (sin lambda1))))))
(* R (acos (+ t_1 (* (* (cos phi1) (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 <= -1.7e-7) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 0.00135) {
tmp = R * acos((cos(phi2) * fma(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(lambda1)))));
} else {
tmp = R * acos((t_1 + ((cos(phi1) * 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 <= -1.7e-7) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 0.00135) tmp = Float64(R * acos(Float64(cos(phi2) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(lambda1)))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); 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[phi1, -1.7e-7], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00135], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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 -1.7 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00135:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -1.69999999999999987e-7Initial program 77.3%
Simplified77.4%
if -1.69999999999999987e-7 < phi1 < 0.0013500000000000001Initial program 71.7%
Simplified71.7%
cos-diff92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-commutative92.6%
fma-undefine92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in phi1 around 0 91.3%
cos-neg91.3%
*-commutative91.3%
*-commutative91.3%
fma-undefine91.3%
cos-neg91.3%
*-commutative91.3%
Simplified91.3%
if 0.0013500000000000001 < phi1 Initial program 79.5%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
R
(acos
(*
(cos phi2)
(+
(* (sin lambda2) (sin lambda1))
(* (cos lambda2) (cos lambda1)))))))
(t_1 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -1.45e+125)
t_0
(if (<= lambda1 -6.7e-6)
(* R (acos (+ t_1 (* (cos phi1) (* (cos phi2) (cos lambda1))))))
(if (<= lambda1 7.5e-39)
(* R (acos (+ t_1 (* (cos phi1) (* (cos phi2) (cos lambda2))))))
t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * acos((cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -1.45e+125) {
tmp = t_0;
} else if (lambda1 <= -6.7e-6) {
tmp = R * acos((t_1 + (cos(phi1) * (cos(phi2) * cos(lambda1)))));
} else if (lambda1 <= 7.5e-39) {
tmp = R * acos((t_1 + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
} 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(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))))
t_1 = sin(phi1) * sin(phi2)
if (lambda1 <= (-1.45d+125)) then
tmp = t_0
else if (lambda1 <= (-6.7d-6)) then
tmp = r * acos((t_1 + (cos(phi1) * (cos(phi2) * cos(lambda1)))))
else if (lambda1 <= 7.5d-39) then
tmp = r * acos((t_1 + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
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(phi2) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -1.45e+125) {
tmp = t_0;
} else if (lambda1 <= -6.7e-6) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda1)))));
} else if (lambda1 <= 7.5e-39) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = R * math.acos((math.cos(phi2) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1))))) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -1.45e+125: tmp = t_0 elif lambda1 <= -6.7e-6: tmp = R * math.acos((t_1 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda1))))) elif lambda1 <= 7.5e-39: tmp = R * math.acos((t_1 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) else: tmp = t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * acos(Float64(cos(phi2) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -1.45e+125) tmp = t_0; elseif (lambda1 <= -6.7e-6) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); elseif (lambda1 <= 7.5e-39) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = R * acos((cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -1.45e+125) tmp = t_0; elseif (lambda1 <= -6.7e-6) tmp = R * acos((t_1 + (cos(phi1) * (cos(phi2) * cos(lambda1))))); elseif (lambda1 <= 7.5e-39) tmp = R * acos((t_1 + (cos(phi1) * (cos(phi2) * cos(lambda2))))); 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[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.45e+125], t$95$0, If[LessEqual[lambda1, -6.7e-6], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 7.5e-39], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.45 \cdot 10^{+125}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq -6.7 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{elif}\;\lambda_1 \leq 7.5 \cdot 10^{-39}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -1.44999999999999997e125 or 7.49999999999999971e-39 < lambda1 Initial program 59.6%
Simplified59.6%
cos-diff99.3%
*-commutative99.3%
*-commutative99.3%
Applied egg-rr99.3%
*-commutative99.3%
fma-undefine99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in phi1 around 0 56.7%
if -1.44999999999999997e125 < lambda1 < -6.7e-6Initial program 69.1%
Taylor expanded in lambda2 around 0 69.6%
*-commutative69.6%
associate-*r*69.6%
Simplified69.6%
if -6.7e-6 < lambda1 < 7.49999999999999971e-39Initial program 92.3%
Taylor expanded in lambda1 around 0 92.3%
cos-neg92.3%
*-commutative92.3%
Simplified92.3%
Final simplification74.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 -3.8e+14)
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda2))))))
(if (<= phi2 3.35e-6)
(* R (acos (* (cos phi1) t_1)))
(if (<= phi2 4.5e+197)
(* R (acos (* (cos phi2) t_1)))
(* R (acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos lambda2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi2 <= -3.8e+14) {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
} else if (phi2 <= 3.35e-6) {
tmp = R * acos((cos(phi1) * t_1));
} else if (phi2 <= 4.5e+197) {
tmp = R * acos((cos(phi2) * t_1));
} else {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
t_1 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))
if (phi2 <= (-3.8d+14)) then
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
else if (phi2 <= 3.35d-6) then
tmp = r * acos((cos(phi1) * t_1))
else if (phi2 <= 4.5d+197) then
tmp = r * acos((cos(phi2) * t_1))
else
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = (Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi2 <= -3.8e+14) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
} else if (phi2 <= 3.35e-6) {
tmp = R * Math.acos((Math.cos(phi1) * t_1));
} else if (phi2 <= 4.5e+197) {
tmp = R * Math.acos((Math.cos(phi2) * t_1));
} else {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = (math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi2 <= -3.8e+14: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) elif phi2 <= 3.35e-6: tmp = R * math.acos((math.cos(phi1) * t_1)) elif phi2 <= 4.5e+197: tmp = R * math.acos((math.cos(phi2) * t_1)) else: tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi2 <= -3.8e+14) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); elseif (phi2 <= 3.35e-6) tmp = Float64(R * acos(Float64(cos(phi1) * t_1))); elseif (phi2 <= 4.5e+197) tmp = Float64(R * acos(Float64(cos(phi2) * t_1))); else tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)); tmp = 0.0; if (phi2 <= -3.8e+14) tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2))))); elseif (phi2 <= 3.35e-6) tmp = R * acos((cos(phi1) * t_1)); elseif (phi2 <= 4.5e+197) tmp = R * acos((cos(phi2) * t_1)); else tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.8e+14], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3.35e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.5e+197], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq -3.8 \cdot 10^{+14}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 3.35 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_1\right)\\
\mathbf{elif}\;\phi_2 \leq 4.5 \cdot 10^{+197}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < -3.8e14Initial program 74.2%
Taylor expanded in lambda1 around 0 61.8%
cos-neg61.8%
*-commutative61.8%
Simplified61.8%
if -3.8e14 < phi2 < 3.35e-6Initial program 73.5%
Simplified73.5%
Taylor expanded in phi2 around 0 70.2%
cos-diff93.8%
+-commutative93.8%
*-commutative93.8%
*-commutative93.8%
Applied egg-rr89.7%
if 3.35e-6 < phi2 < 4.5000000000000003e197Initial program 79.6%
Simplified79.6%
cos-diff99.2%
*-commutative99.2%
*-commutative99.2%
Applied egg-rr99.2%
*-commutative99.2%
fma-undefine99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in phi1 around 0 63.5%
if 4.5000000000000003e197 < phi2 Initial program 83.8%
Taylor expanded in lambda1 around 0 64.8%
cos-neg64.8%
associate-*r*64.8%
*-commutative64.8%
Simplified64.8%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda2))))))
(t_1
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 -3.8e+14)
t_0
(if (<= phi2 6.9e-6)
(* R (acos (* (cos phi1) t_1)))
(if (<= phi2 1.4e+196) (* 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(lambda2))));
double t_1 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi2 <= -3.8e+14) {
tmp = t_0;
} else if (phi2 <= 6.9e-6) {
tmp = R * acos((cos(phi1) * t_1));
} else if (phi2 <= 1.4e+196) {
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(lambda2))))
t_1 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))
if (phi2 <= (-3.8d+14)) then
tmp = t_0
else if (phi2 <= 6.9d-6) then
tmp = r * acos((cos(phi1) * t_1))
else if (phi2 <= 1.4d+196) 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(lambda2))));
double t_1 = (Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi2 <= -3.8e+14) {
tmp = t_0;
} else if (phi2 <= 6.9e-6) {
tmp = R * Math.acos((Math.cos(phi1) * t_1));
} else if (phi2 <= 1.4e+196) {
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(lambda2)))) t_1 = (math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi2 <= -3.8e+14: tmp = t_0 elif phi2 <= 6.9e-6: tmp = R * math.acos((math.cos(phi1) * t_1)) elif phi2 <= 1.4e+196: 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(lambda2))))) t_1 = Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi2 <= -3.8e+14) tmp = t_0; elseif (phi2 <= 6.9e-6) tmp = Float64(R * acos(Float64(cos(phi1) * t_1))); elseif (phi2 <= 1.4e+196) 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(lambda2)))); t_1 = (sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)); tmp = 0.0; if (phi2 <= -3.8e+14) tmp = t_0; elseif (phi2 <= 6.9e-6) tmp = R * acos((cos(phi1) * t_1)); elseif (phi2 <= 1.4e+196) 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[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.8e+14], t$95$0, If[LessEqual[phi2, 6.9e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.4e+196], 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_2\right)\\
t_1 := \sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq -3.8 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 6.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_1\right)\\
\mathbf{elif}\;\phi_2 \leq 1.4 \cdot 10^{+196}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -3.8e14 or 1.4000000000000001e196 < phi2 Initial program 76.5%
Taylor expanded in lambda1 around 0 62.5%
cos-neg62.5%
associate-*r*62.5%
*-commutative62.5%
Simplified62.5%
if -3.8e14 < phi2 < 6.9e-6Initial program 73.5%
Simplified73.5%
Taylor expanded in phi2 around 0 70.2%
cos-diff93.8%
+-commutative93.8%
*-commutative93.8%
*-commutative93.8%
Applied egg-rr89.7%
if 6.9e-6 < phi2 < 1.4000000000000001e196Initial program 79.6%
Simplified79.6%
cos-diff99.2%
*-commutative99.2%
*-commutative99.2%
Applied egg-rr99.2%
*-commutative99.2%
fma-undefine99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in phi1 around 0 63.5%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.1e-8) (not (<= phi1 0.00135)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi2)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.1e-8) || !(phi1 <= 0.00135)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * 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 ((phi1 <= (-1.1d-8)) .or. (.not. (phi1 <= 0.00135d0))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * 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 ((phi1 <= -1.1e-8) || !(phi1 <= 0.00135)) {
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(phi2) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -1.1e-8) or not (phi1 <= 0.00135): 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(phi2) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1.1e-8) || !(phi1 <= 0.00135)) 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(phi2) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -1.1e-8) || ~((phi1 <= 0.00135))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = R * acos((cos(phi2) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1.1e-8], N[Not[LessEqual[phi1, 0.00135]], $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[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.1 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 0.00135\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_2 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -1.0999999999999999e-8 or 0.0013500000000000001 < phi1 Initial program 78.4%
if -1.0999999999999999e-8 < phi1 < 0.0013500000000000001Initial program 71.7%
Simplified71.7%
cos-diff92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
*-commutative92.6%
fma-undefine92.6%
*-commutative92.6%
Simplified92.6%
Taylor expanded in phi1 around 0 91.3%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 6.9e-6)
(* 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(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi2 <= 6.9e-6) {
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(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))
if (phi2 <= 6.9d-6) 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(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi2 <= 6.9e-6) {
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(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi2 <= 6.9e-6: 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(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi2 <= 6.9e-6) 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(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)); tmp = 0.0; if (phi2 <= 6.9e-6) 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[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 6.9e-6], 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_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq 6.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 6.9e-6Initial program 73.7%
Simplified73.7%
Taylor expanded in phi2 around 0 54.4%
cos-diff95.3%
+-commutative95.3%
*-commutative95.3%
*-commutative95.3%
Applied egg-rr68.0%
if 6.9e-6 < phi2 Initial program 81.1%
Simplified81.1%
cos-diff99.1%
*-commutative99.1%
*-commutative99.1%
Applied egg-rr99.1%
*-commutative99.1%
fma-undefine99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in phi1 around 0 56.1%
Final simplification65.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 2.75e-5)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda2) (sin lambda1)) (* (cos lambda2) (cos lambda1))))))
(* R (acos (* (cos phi2) (cos (- lambda2 lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.75e-5) {
tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos((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 <= 2.75d-5) then
tmp = r * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1)))))
else
tmp = r * acos((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 <= 2.75e-5) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda2) * Math.sin(lambda1)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos((lambda2 - lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 2.75e-5: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda2) * math.sin(lambda1)) + (math.cos(lambda2) * math.cos(lambda1))))) else: tmp = R * math.acos((math.cos(phi2) * math.cos((lambda2 - lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 2.75e-5) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda2) * sin(lambda1)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(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 <= 2.75e-5) tmp = R * acos((cos(phi1) * ((sin(lambda2) * sin(lambda1)) + (cos(lambda2) * cos(lambda1))))); else tmp = R * acos((cos(phi2) * cos((lambda2 - lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.75e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.75 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < 2.7500000000000001e-5Initial program 73.7%
Simplified73.7%
Taylor expanded in phi2 around 0 54.4%
cos-diff95.3%
+-commutative95.3%
*-commutative95.3%
*-commutative95.3%
Applied egg-rr68.0%
if 2.7500000000000001e-5 < phi2 Initial program 81.1%
Simplified81.1%
Taylor expanded in phi1 around 0 50.1%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi2 3.6e-5)
(* R (log1p (expm1 (acos (* (cos phi1) t_0)))))
(* R (acos (* (cos phi2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 3.6e-5) {
tmp = R * log1p(expm1(acos((cos(phi1) * t_0))));
} else {
tmp = R * acos((cos(phi2) * t_0));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 3.6e-5) {
tmp = R * Math.log1p(Math.expm1(Math.acos((Math.cos(phi1) * t_0))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= 3.6e-5: tmp = R * math.log1p(math.expm1(math.acos((math.cos(phi1) * t_0)))) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 3.6e-5) tmp = Float64(R * log1p(expm1(acos(Float64(cos(phi1) * t_0))))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 3.6e-5], N[(R * N[Log[1 + N[(Exp[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq 3.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 3.60000000000000009e-5Initial program 73.7%
Simplified73.7%
Taylor expanded in phi2 around 0 54.4%
log1p-expm1-u54.4%
Applied egg-rr54.4%
if 3.60000000000000009e-5 < phi2 Initial program 81.1%
Simplified81.1%
Taylor expanded in phi1 around 0 50.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi2 2.25e-6)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 2.25e-6) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((cos(phi2) * t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
if (phi2 <= 2.25d-6) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((cos(phi2) * t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 2.25e-6) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= 2.25e-6: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 2.25e-6) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi2 <= 2.25e-6) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((cos(phi2) * t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 2.25e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq 2.25 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 2.25000000000000006e-6Initial program 73.7%
Simplified73.7%
Taylor expanded in phi2 around 0 54.4%
if 2.25000000000000006e-6 < phi2 Initial program 81.1%
Simplified81.1%
Taylor expanded in phi1 around 0 50.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 2.3) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (* (cos phi1) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.3) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos((cos(phi1) * 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 (lambda2 <= 2.3d0) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos((cos(phi1) * 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 (lambda2 <= 2.3) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 2.3: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 2.3) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 2.3) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos((cos(phi1) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 2.3], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 2.3:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 2.2999999999999998Initial program 80.0%
Simplified80.0%
Taylor expanded in phi2 around 0 49.4%
Taylor expanded in lambda2 around 0 40.9%
cos-neg40.9%
Simplified40.9%
if 2.2999999999999998 < lambda2 Initial program 60.9%
Simplified60.9%
Taylor expanded in phi2 around 0 38.3%
Taylor expanded in lambda1 around 0 38.4%
*-commutative38.4%
Simplified38.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 6.8) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (cos lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 6.8) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos(cos(lambda2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 6.8d0) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos(cos(lambda2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 6.8) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 6.8: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 6.8) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 6.8) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos(cos(lambda2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 6.8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 6.8:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda2 < 6.79999999999999982Initial program 79.7%
Simplified79.7%
Taylor expanded in phi2 around 0 49.2%
Taylor expanded in lambda2 around 0 40.8%
cos-neg40.8%
Simplified40.8%
if 6.79999999999999982 < lambda2 Initial program 61.5%
Simplified61.5%
Taylor expanded in phi2 around 0 38.6%
Taylor expanded in phi1 around 0 28.0%
Taylor expanded in lambda1 around 0 28.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* (cos phi1) (cos (- lambda2 lambda1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos(phi1) * 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(phi1) * 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(phi1) * Math.cos((lambda2 - lambda1))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)
\end{array}
Initial program 75.3%
Simplified75.3%
Taylor expanded in phi2 around 0 46.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 6e-14) (* R (acos (cos lambda1))) (* R (acos (cos lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 6e-14) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * acos(cos(lambda2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 6d-14) then
tmp = r * acos(cos(lambda1))
else
tmp = r * acos(cos(lambda2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 6e-14) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 6e-14: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 6e-14) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 6e-14) tmp = R * acos(cos(lambda1)); else tmp = R * acos(cos(lambda2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 6e-14], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 6 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda2 < 5.9999999999999997e-14Initial program 80.5%
Simplified80.5%
Taylor expanded in phi2 around 0 49.3%
Taylor expanded in phi1 around 0 28.3%
Taylor expanded in lambda2 around 0 21.8%
cos-neg21.8%
Simplified21.8%
if 5.9999999999999997e-14 < lambda2 Initial program 61.3%
Simplified61.3%
Taylor expanded in phi2 around 0 39.4%
Taylor expanded in phi1 around 0 27.6%
Taylor expanded in lambda1 around 0 26.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -0.165) (* R (acos (cos lambda1))) (* R (- lambda2 lambda1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.165) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * (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 (lambda1 <= (-0.165d0)) then
tmp = r * acos(cos(lambda1))
else
tmp = r * (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 (lambda1 <= -0.165) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * (lambda2 - lambda1);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -0.165: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * (lambda2 - lambda1) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.165) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * Float64(lambda2 - lambda1)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -0.165) tmp = R * acos(cos(lambda1)); else tmp = R * (lambda2 - lambda1); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.165], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.165:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\
\end{array}
\end{array}
if lambda1 < -0.165000000000000008Initial program 59.5%
Simplified59.5%
Taylor expanded in phi2 around 0 41.7%
Taylor expanded in phi1 around 0 28.0%
Taylor expanded in lambda2 around 0 28.5%
cos-neg28.5%
Simplified28.5%
if -0.165000000000000008 < lambda1 Initial program 80.9%
Simplified80.9%
Taylor expanded in phi2 around 0 48.4%
Taylor expanded in phi1 around 0 28.1%
Taylor expanded in lambda2 around 0 5.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda2 lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos((lambda2 - lambda1)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(cos((lambda2 - lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda2 - lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda2 - lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda2 - lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos((lambda2 - lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 75.3%
Simplified75.3%
Taylor expanded in phi2 around 0 46.6%
Taylor expanded in phi1 around 0 28.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (- lambda2 lambda1)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (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 * (lambda2 - lambda1)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (lambda2 - lambda1);
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (lambda2 - lambda1)
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(lambda2 - lambda1)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (lambda2 - lambda1); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 75.3%
Simplified75.3%
Taylor expanded in phi2 around 0 46.6%
Taylor expanded in phi1 around 0 28.1%
Taylor expanded in lambda2 around 0 5.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (- lambda1)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * -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 * -lambda1
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * -lambda1;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * -lambda1
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(-lambda1)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * -lambda1; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * (-lambda1)), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(-\lambda_1\right)
\end{array}
Initial program 75.3%
Simplified75.3%
Taylor expanded in phi2 around 0 46.6%
Taylor expanded in phi1 around 0 28.1%
Taylor expanded in lambda2 around 0 5.6%
associate-*r*5.6%
mul-1-neg5.6%
Simplified5.6%
Final simplification5.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R lambda2))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * 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 * lambda2
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * lambda2;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * lambda2
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * lambda2) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * lambda2; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * lambda2), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \lambda_2
\end{array}
Initial program 75.3%
Simplified75.3%
Taylor expanded in phi2 around 0 46.6%
Taylor expanded in phi1 around 0 28.1%
Taylor expanded in lambda2 around inf 5.7%
*-commutative5.7%
Simplified5.7%
Final simplification5.7%
herbie shell --seed 2024110
(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))