
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(*
(cos phi2)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))
(sqrt
(-
1.0
(fma
(* (cos phi2) (cos phi1))
(* t_0 t_0)
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((cos(phi2) * (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))) + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))), sqrt((1.0 - fma((cos(phi2) * cos(phi1)), (t_0 * t_0), pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))), sqrt(Float64(1.0 - fma(Float64(cos(phi2) * cos(phi1)), Float64(t_0 * t_0), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, t_0 \cdot t_0, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 65.8%
Simplified65.8%
expm1-log1p-u65.8%
div-inv65.8%
metadata-eval65.8%
Applied egg-rr65.8%
metadata-eval65.8%
div-inv65.8%
div-sub65.8%
sin-diff66.7%
Applied egg-rr66.7%
fma-neg66.7%
distribute-rgt-neg-in66.7%
Simplified66.7%
Taylor expanded in phi1 around inf 66.8%
Final simplification66.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi2) (cos phi1)) t_0)))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi2) * cos(phi1)) * t_0));
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi2) * cos(phi1)) * t_0))
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi2) * Math.cos(phi1)) * t_0));
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi2) * math.cos(phi1)) * t_0)) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi2) * cos(phi1)) * t_0))) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi2) * cos(phi1)) * t_0)); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
Initial program 65.8%
Final simplification65.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi2) (cos phi1))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_0))))
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi2) * cos(phi1);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (pow(sin((0.5 * (lambda1 - lambda2))), 2.0) * t_1)))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi2) * cos(phi1)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_1 * t_0)))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - ((sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0) * t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi2) * Math.cos(phi1);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0) * t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi2) * math.cos(phi1) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) * t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi2) * cos(phi1)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_0)))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0) * t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi2) * cos(phi1); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_1 * t_0)))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - ((sin((0.5 * (lambda1 - lambda2))) ^ 2.0) * t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_2 \cdot \cos \phi_1\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_0\right)}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} \cdot t_1}}\right)
\end{array}
\end{array}
Initial program 65.8%
associate--r+65.8%
associate-*r*65.8%
cancel-sign-sub-inv65.8%
div-inv65.8%
metadata-eval65.8%
pow265.8%
div-inv65.8%
metadata-eval65.8%
Applied egg-rr65.8%
Final simplification65.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= phi2 1.15e-17)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi2) (cos phi1)) t_1))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2))))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)
(cos phi2)
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (fma t_0 t_0 (* (cos phi2) (- t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 1.15e-17) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((cos(phi2) * cos(phi1)) * t_1)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(pow(sin((0.5 * (lambda1 - lambda2))), 2.0), cos(phi2), pow(sin((phi2 * -0.5)), 2.0))), sqrt(fma(t_0, t_0, (cos(phi2) * -t_2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (phi2 <= 1.15e-17) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(cos(phi2) * cos(phi1)) * t_1)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0), cos(phi2), (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(fma(t_0, t_0, Float64(cos(phi2) * Float64(-t_2))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, 1.15e-17], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$0 * t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * (-t$95$2)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq 1.15 \cdot 10^{-17}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_1\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{\mathsf{fma}\left(t_0, t_0, \cos \phi_2 \cdot \left(-t_2\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < 1.15000000000000004e-17Initial program 70.5%
Taylor expanded in phi2 around 0 61.3%
associate--r+61.3%
unpow261.3%
1-sub-sin61.3%
unpow261.3%
*-commutative61.3%
unpow261.3%
associate-*r*61.3%
Simplified61.3%
if 1.15000000000000004e-17 < phi2 Initial program 53.4%
Taylor expanded in phi1 around 0 51.9%
associate--r+51.9%
unpow251.9%
1-sub-sin52.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
associate-*r*52.0%
*-commutative52.0%
sub-neg52.0%
mul-1-neg52.0%
distribute-lft-in52.0%
metadata-eval52.0%
associate-*r*52.0%
associate-*r*52.0%
metadata-eval52.0%
distribute-lft-in52.0%
+-commutative52.0%
mul-1-neg52.0%
sub-neg52.0%
Simplified52.0%
Taylor expanded in phi1 around 0 52.5%
Taylor expanded in phi1 around 0 53.0%
+-commutative53.0%
*-commutative53.0%
fma-def53.0%
Simplified53.0%
pow253.0%
cancel-sign-sub-inv53.0%
unpow253.0%
fma-def53.0%
*-commutative53.0%
*-commutative53.0%
pow253.0%
Applied egg-rr53.0%
Final simplification59.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= phi2 1.15e-17)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi2) (cos phi1)) t_0))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)
(cos phi2)
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 1.15e-17) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi2) * cos(phi1)) * t_0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(pow(sin((0.5 * (lambda1 - lambda2))), 2.0), cos(phi2), pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (phi2 <= 1.15e-17) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi2) * cos(phi1)) * t_0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0), cos(phi2), (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, 1.15e-17], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq 1.15 \cdot 10^{-17}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < 1.15000000000000004e-17Initial program 70.5%
Taylor expanded in phi2 around 0 61.3%
associate--r+61.3%
unpow261.3%
1-sub-sin61.3%
unpow261.3%
*-commutative61.3%
unpow261.3%
associate-*r*61.3%
Simplified61.3%
if 1.15000000000000004e-17 < phi2 Initial program 53.4%
Taylor expanded in phi1 around 0 51.9%
associate--r+51.9%
unpow251.9%
1-sub-sin52.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
associate-*r*52.0%
*-commutative52.0%
sub-neg52.0%
mul-1-neg52.0%
distribute-lft-in52.0%
metadata-eval52.0%
associate-*r*52.0%
associate-*r*52.0%
metadata-eval52.0%
distribute-lft-in52.0%
+-commutative52.0%
mul-1-neg52.0%
sub-neg52.0%
Simplified52.0%
Taylor expanded in phi1 around 0 52.5%
Taylor expanded in phi1 around 0 53.0%
+-commutative53.0%
*-commutative53.0%
fma-def53.0%
Simplified53.0%
Final simplification59.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi2) (cos phi1)) t_0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi2) * cos(phi1)) * t_0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi2) * cos(phi1)) * t_0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi2) * Math.cos(phi1)) * t_0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi2) * math.cos(phi1)) * t_0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi2) * cos(phi1)) * t_0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi2) * cos(phi1)) * t_0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 65.8%
Taylor expanded in phi1 around 0 51.5%
associate--r+51.4%
unpow251.4%
1-sub-sin51.5%
unpow251.5%
*-commutative51.5%
unpow251.5%
associate-*r*51.5%
*-commutative51.5%
sub-neg51.5%
mul-1-neg51.5%
distribute-lft-in51.5%
metadata-eval51.5%
associate-*r*51.5%
associate-*r*51.5%
metadata-eval51.5%
distribute-lft-in51.5%
+-commutative51.5%
mul-1-neg51.5%
sub-neg51.5%
Simplified51.5%
Final simplification51.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= phi2 1.15e-17)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi2) (cos phi1)) t_0))
(pow
(+ (sin (* phi1 0.5)) (* -0.5 (* phi2 (cos (* phi1 0.5)))))
2.0)))
(sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)
(cos phi2)
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 1.15e-17) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi2) * cos(phi1)) * t_0)) + pow((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))), 2.0))), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(pow(sin((0.5 * (lambda1 - lambda2))), 2.0), cos(phi2), pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (phi2 <= 1.15e-17) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi2) * cos(phi1)) * t_0)) + (Float64(sin(Float64(phi1 * 0.5)) + Float64(-0.5 * Float64(phi2 * cos(Float64(phi1 * 0.5))))) ^ 2.0))), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0), cos(phi2), (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, 1.15e-17], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq 1.15 \cdot 10^{-17}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_0\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}}}{\sqrt{1 - t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < 1.15000000000000004e-17Initial program 70.5%
Taylor expanded in phi1 around 0 51.3%
associate--r+51.3%
unpow251.3%
1-sub-sin51.3%
unpow251.3%
*-commutative51.3%
unpow251.3%
associate-*r*51.3%
*-commutative51.3%
sub-neg51.3%
mul-1-neg51.3%
distribute-lft-in51.3%
metadata-eval51.3%
associate-*r*51.3%
associate-*r*51.3%
metadata-eval51.3%
distribute-lft-in51.3%
+-commutative51.3%
mul-1-neg51.3%
sub-neg51.3%
Simplified51.3%
Taylor expanded in phi2 around 0 42.1%
Taylor expanded in phi2 around 0 41.5%
if 1.15000000000000004e-17 < phi2 Initial program 53.4%
Taylor expanded in phi1 around 0 51.9%
associate--r+51.9%
unpow251.9%
1-sub-sin52.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
associate-*r*52.0%
*-commutative52.0%
sub-neg52.0%
mul-1-neg52.0%
distribute-lft-in52.0%
metadata-eval52.0%
associate-*r*52.0%
associate-*r*52.0%
metadata-eval52.0%
distribute-lft-in52.0%
+-commutative52.0%
mul-1-neg52.0%
sub-neg52.0%
Simplified52.0%
Taylor expanded in phi1 around 0 52.5%
Taylor expanded in phi1 around 0 53.0%
+-commutative53.0%
*-commutative53.0%
fma-def53.0%
Simplified53.0%
Final simplification44.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= phi2 1.15e-17)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi2) (cos phi1)) t_0))
(pow
(+ (sin (* phi1 0.5)) (* -0.5 (* phi2 (cos (* phi1 0.5)))))
2.0)))
(sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 1.15e-17) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi2) * cos(phi1)) * t_0)) + pow((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))), 2.0))), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * 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(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if (phi2 <= 1.15d-17) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi2) * cos(phi1)) * t_0)) + ((sin((phi1 * 0.5d0)) + ((-0.5d0) * (phi2 * cos((phi1 * 0.5d0))))) ** 2.0d0))), sqrt((1.0d0 - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * 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(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 1.15e-17) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi2) * Math.cos(phi1)) * t_0)) + Math.pow((Math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * Math.cos((phi1 * 0.5))))), 2.0))), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if phi2 <= 1.15e-17: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi2) * math.cos(phi1)) * t_0)) + math.pow((math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * math.cos((phi1 * 0.5))))), 2.0))), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (phi2 <= 1.15e-17) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi2) * cos(phi1)) * t_0)) + (Float64(sin(Float64(phi1 * 0.5)) + Float64(-0.5 * Float64(phi2 * cos(Float64(phi1 * 0.5))))) ^ 2.0))), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if (phi2 <= 1.15e-17) tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi2) * cos(phi1)) * t_0)) + ((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))) ^ 2.0))), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, 1.15e-17], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq 1.15 \cdot 10^{-17}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_0\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}}}{\sqrt{1 - t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < 1.15000000000000004e-17Initial program 70.5%
Taylor expanded in phi1 around 0 51.3%
associate--r+51.3%
unpow251.3%
1-sub-sin51.3%
unpow251.3%
*-commutative51.3%
unpow251.3%
associate-*r*51.3%
*-commutative51.3%
sub-neg51.3%
mul-1-neg51.3%
distribute-lft-in51.3%
metadata-eval51.3%
associate-*r*51.3%
associate-*r*51.3%
metadata-eval51.3%
distribute-lft-in51.3%
+-commutative51.3%
mul-1-neg51.3%
sub-neg51.3%
Simplified51.3%
Taylor expanded in phi2 around 0 42.1%
Taylor expanded in phi2 around 0 41.5%
if 1.15000000000000004e-17 < phi2 Initial program 53.4%
Taylor expanded in phi1 around 0 51.9%
associate--r+51.9%
unpow251.9%
1-sub-sin52.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
associate-*r*52.0%
*-commutative52.0%
sub-neg52.0%
mul-1-neg52.0%
distribute-lft-in52.0%
metadata-eval52.0%
associate-*r*52.0%
associate-*r*52.0%
metadata-eval52.0%
distribute-lft-in52.0%
+-commutative52.0%
mul-1-neg52.0%
sub-neg52.0%
Simplified52.0%
Taylor expanded in phi1 around 0 52.5%
Taylor expanded in phi1 around 0 53.0%
*-commutative53.0%
Simplified53.0%
Final simplification44.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= phi2 0.045)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi2) (cos phi1)) t_0))
(pow
(+ (sin (* phi1 0.5)) (* -0.5 (* phi2 (cos (* phi1 0.5)))))
2.0)))
(sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 0.045) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi2) * cos(phi1)) * t_0)) + pow((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))), 2.0))), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * 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(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if (phi2 <= 0.045d0) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi2) * cos(phi1)) * t_0)) + ((sin((phi1 * 0.5d0)) + ((-0.5d0) * (phi2 * cos((phi1 * 0.5d0))))) ** 2.0d0))), sqrt((1.0d0 - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * 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(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 0.045) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi2) * Math.cos(phi1)) * t_0)) + Math.pow((Math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * Math.cos((phi1 * 0.5))))), 2.0))), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if phi2 <= 0.045: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi2) * math.cos(phi1)) * t_0)) + math.pow((math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * math.cos((phi1 * 0.5))))), 2.0))), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (phi2 <= 0.045) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi2) * cos(phi1)) * t_0)) + (Float64(sin(Float64(phi1 * 0.5)) + Float64(-0.5 * Float64(phi2 * cos(Float64(phi1 * 0.5))))) ^ 2.0))), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if (phi2 <= 0.045) tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi2) * cos(phi1)) * t_0)) + ((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))) ^ 2.0))), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, 0.045], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq 0.045:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_0\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}}}{\sqrt{1 - t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < 0.044999999999999998Initial program 70.7%
Taylor expanded in phi1 around 0 51.4%
associate--r+51.4%
unpow251.4%
1-sub-sin51.4%
unpow251.4%
*-commutative51.4%
unpow251.4%
associate-*r*51.4%
*-commutative51.4%
sub-neg51.4%
mul-1-neg51.4%
distribute-lft-in51.4%
metadata-eval51.4%
associate-*r*51.4%
associate-*r*51.4%
metadata-eval51.4%
distribute-lft-in51.4%
+-commutative51.4%
mul-1-neg51.4%
sub-neg51.4%
Simplified51.4%
Taylor expanded in phi2 around 0 42.4%
Taylor expanded in phi2 around 0 41.9%
if 0.044999999999999998 < phi2 Initial program 51.9%
Taylor expanded in phi1 around 0 51.5%
associate--r+51.5%
unpow251.5%
1-sub-sin51.6%
unpow251.6%
*-commutative51.6%
unpow251.6%
associate-*r*51.6%
*-commutative51.6%
sub-neg51.6%
mul-1-neg51.6%
distribute-lft-in51.6%
metadata-eval51.6%
associate-*r*51.6%
associate-*r*51.6%
metadata-eval51.6%
distribute-lft-in51.6%
+-commutative51.6%
mul-1-neg51.6%
sub-neg51.6%
Simplified51.6%
Taylor expanded in phi1 around 0 52.2%
Taylor expanded in phi1 around 0 52.7%
+-commutative52.7%
*-commutative52.7%
fma-def52.7%
Simplified52.7%
Taylor expanded in lambda1 around 0 39.7%
Final simplification41.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi2 -0.5)) 2.0))
(t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(if (<= lambda2 0.00106)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double tmp;
if (lambda2 <= 0.00106) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0)))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0)))), 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((phi2 * (-0.5d0))) ** 2.0d0
t_1 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))
if (lambda2 <= 0.00106d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0)))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), 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.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_1 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double tmp;
if (lambda2 <= 0.00106) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0)))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_1 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))) tmp = 0 if lambda2 <= 0.00106: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) tmp = 0.0 if (lambda2 <= 0.00106) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0)))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi2 * -0.5)) ^ 2.0; t_1 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))); tmp = 0.0; if (lambda2 <= 0.00106) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 0.00106], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq 0.00106:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{t_1}\right)\\
\end{array}
\end{array}
if lambda2 < 0.00105999999999999996Initial program 69.4%
Taylor expanded in phi1 around 0 52.9%
associate--r+52.9%
unpow252.9%
1-sub-sin53.0%
unpow253.0%
*-commutative53.0%
unpow253.0%
associate-*r*53.0%
*-commutative53.0%
sub-neg53.0%
mul-1-neg53.0%
distribute-lft-in53.0%
metadata-eval53.0%
associate-*r*53.0%
associate-*r*53.0%
metadata-eval53.0%
distribute-lft-in53.0%
+-commutative53.0%
mul-1-neg53.0%
sub-neg53.0%
Simplified53.0%
Taylor expanded in phi1 around 0 52.3%
Taylor expanded in phi1 around 0 49.5%
+-commutative49.5%
*-commutative49.5%
fma-def49.5%
Simplified49.5%
Taylor expanded in lambda2 around 0 40.6%
*-commutative40.6%
Simplified40.6%
if 0.00105999999999999996 < lambda2 Initial program 53.6%
Taylor expanded in phi1 around 0 46.3%
associate--r+46.3%
unpow246.3%
1-sub-sin46.3%
unpow246.3%
*-commutative46.3%
unpow246.3%
associate-*r*46.3%
*-commutative46.3%
sub-neg46.3%
mul-1-neg46.3%
distribute-lft-in46.3%
metadata-eval46.3%
associate-*r*46.3%
associate-*r*46.3%
metadata-eval46.3%
distribute-lft-in46.3%
+-commutative46.3%
mul-1-neg46.3%
sub-neg46.3%
Simplified46.3%
Taylor expanded in phi1 around 0 46.2%
Taylor expanded in phi1 around 0 47.0%
+-commutative47.0%
*-commutative47.0%
fma-def47.0%
Simplified47.0%
Taylor expanded in lambda1 around 0 46.9%
Final simplification42.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (cos (* phi2 -0.5))))
(if (<= (- lambda1 lambda2) -5e-73)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi2) (cos phi1)) t_1))))
(sqrt (- 1.0 t_0)))))
(*
R
(*
2.0
(atan2
(- (* -0.5 (* phi1 t_2)) (sin (* phi2 -0.5)))
(sqrt (- (pow t_2 2.0) (* (cos phi2) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos((phi2 * -0.5));
double tmp;
if ((lambda1 - lambda2) <= -5e-73) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((cos(phi2) * cos(phi1)) * t_1)))), sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(((-0.5 * (phi1 * t_2)) - sin((phi2 * -0.5))), sqrt((pow(t_2, 2.0) - (cos(phi2) * t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos((phi2 * (-0.5d0)))
if ((lambda1 - lambda2) <= (-5d-73)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * ((cos(phi2) * cos(phi1)) * t_1)))), sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2((((-0.5d0) * (phi1 * t_2)) - sin((phi2 * (-0.5d0)))), sqrt(((t_2 ** 2.0d0) - (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.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos((phi2 * -0.5));
double tmp;
if ((lambda1 - lambda2) <= -5e-73) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((Math.cos(phi2) * Math.cos(phi1)) * t_1)))), Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(((-0.5 * (phi1 * t_2)) - Math.sin((phi2 * -0.5))), Math.sqrt((Math.pow(t_2, 2.0) - (Math.cos(phi2) * t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos((phi2 * -0.5)) tmp = 0 if (lambda1 - lambda2) <= -5e-73: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((math.cos(phi2) * math.cos(phi1)) * t_1)))), math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2(((-0.5 * (phi1 * t_2)) - math.sin((phi2 * -0.5))), math.sqrt((math.pow(t_2, 2.0) - (math.cos(phi2) * t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = cos(Float64(phi2 * -0.5)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -5e-73) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(cos(phi2) * cos(phi1)) * t_1)))), sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(-0.5 * Float64(phi1 * t_2)) - sin(Float64(phi2 * -0.5))), sqrt(Float64((t_2 ^ 2.0) - Float64(cos(phi2) * t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos((phi2 * -0.5)); tmp = 0.0; if ((lambda1 - lambda2) <= -5e-73) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * ((cos(phi2) * cos(phi1)) * t_1)))), sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2(((-0.5 * (phi1 * t_2)) - sin((phi2 * -0.5))), sqrt(((t_2 ^ 2.0) - (cos(phi2) * t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -5e-73], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(-0.5 * N[(phi1 * t$95$2), $MachinePrecision]), $MachinePrecision] - N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$2, 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \left(\phi_2 \cdot -0.5\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-73}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_1\right)}}{\sqrt{1 - t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot t_2\right) - \sin \left(\phi_2 \cdot -0.5\right)}{\sqrt{{t_2}^{2} - \cos \phi_2 \cdot t_0}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -4.9999999999999998e-73Initial program 66.1%
Taylor expanded in phi1 around 0 51.2%
associate--r+51.2%
unpow251.2%
1-sub-sin51.2%
unpow251.2%
*-commutative51.2%
unpow251.2%
associate-*r*51.2%
*-commutative51.2%
sub-neg51.2%
mul-1-neg51.2%
distribute-lft-in51.2%
metadata-eval51.2%
associate-*r*51.2%
associate-*r*51.2%
metadata-eval51.2%
distribute-lft-in51.2%
+-commutative51.2%
mul-1-neg51.2%
sub-neg51.2%
Simplified51.2%
Taylor expanded in phi2 around 0 35.8%
if -4.9999999999999998e-73 < (-.f64 lambda1 lambda2) Initial program 65.7%
Taylor expanded in phi1 around 0 51.6%
associate--r+51.6%
unpow251.6%
1-sub-sin51.6%
unpow251.6%
*-commutative51.6%
unpow251.6%
associate-*r*51.6%
*-commutative51.6%
sub-neg51.6%
mul-1-neg51.6%
distribute-lft-in51.6%
metadata-eval51.6%
associate-*r*51.6%
associate-*r*51.6%
metadata-eval51.6%
distribute-lft-in51.6%
+-commutative51.6%
mul-1-neg51.6%
sub-neg51.6%
Simplified51.6%
Taylor expanded in phi1 around 0 51.2%
Taylor expanded in phi1 around -inf 19.2%
+-commutative19.2%
mul-1-neg19.2%
unsub-neg19.2%
*-commutative19.2%
Simplified19.2%
Final simplification26.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi2 -0.5)))
(t_1 (cos (* phi2 -0.5)))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= (- lambda1 lambda2) -5e-73)
(*
R
(*
2.0
(atan2
(sqrt
(fma
(pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)
(cos phi2)
(pow t_0 2.0)))
(sqrt (- 1.0 t_2)))))
(*
R
(*
2.0
(atan2
(- (* -0.5 (* phi1 t_1)) t_0)
(sqrt (- (pow t_1 2.0) (* (cos phi2) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi2 * -0.5));
double t_1 = cos((phi2 * -0.5));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -5e-73) {
tmp = R * (2.0 * atan2(sqrt(fma(pow(sin((0.5 * (lambda1 - lambda2))), 2.0), cos(phi2), pow(t_0, 2.0))), sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * atan2(((-0.5 * (phi1 * t_1)) - t_0), sqrt((pow(t_1, 2.0) - (cos(phi2) * t_2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) t_1 = cos(Float64(phi2 * -0.5)) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (Float64(lambda1 - lambda2) <= -5e-73) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0), cos(phi2), (t_0 ^ 2.0))), sqrt(Float64(1.0 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(-0.5 * Float64(phi1 * t_1)) - t_0), sqrt(Float64((t_1 ^ 2.0) - Float64(cos(phi2) * t_2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -5e-73], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(-0.5 * N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$1, 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_2 \cdot -0.5\right)\\
t_1 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-73}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_2, {t_0}^{2}\right)}}{\sqrt{1 - t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot t_1\right) - t_0}{\sqrt{{t_1}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -4.9999999999999998e-73Initial program 66.1%
Taylor expanded in phi1 around 0 51.2%
associate--r+51.2%
unpow251.2%
1-sub-sin51.2%
unpow251.2%
*-commutative51.2%
unpow251.2%
associate-*r*51.2%
*-commutative51.2%
sub-neg51.2%
mul-1-neg51.2%
distribute-lft-in51.2%
metadata-eval51.2%
associate-*r*51.2%
associate-*r*51.2%
metadata-eval51.2%
distribute-lft-in51.2%
+-commutative51.2%
mul-1-neg51.2%
sub-neg51.2%
Simplified51.2%
Taylor expanded in phi1 around 0 50.6%
Taylor expanded in phi1 around 0 51.2%
+-commutative51.2%
*-commutative51.2%
fma-def51.2%
Simplified51.2%
Taylor expanded in phi2 around 0 35.7%
if -4.9999999999999998e-73 < (-.f64 lambda1 lambda2) Initial program 65.7%
Taylor expanded in phi1 around 0 51.6%
associate--r+51.6%
unpow251.6%
1-sub-sin51.6%
unpow251.6%
*-commutative51.6%
unpow251.6%
associate-*r*51.6%
*-commutative51.6%
sub-neg51.6%
mul-1-neg51.6%
distribute-lft-in51.6%
metadata-eval51.6%
associate-*r*51.6%
associate-*r*51.6%
metadata-eval51.6%
distribute-lft-in51.6%
+-commutative51.6%
mul-1-neg51.6%
sub-neg51.6%
Simplified51.6%
Taylor expanded in phi1 around 0 51.2%
Taylor expanded in phi1 around -inf 19.2%
+-commutative19.2%
mul-1-neg19.2%
unsub-neg19.2%
*-commutative19.2%
Simplified19.2%
Final simplification26.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5)))
(t_1 (* phi1 t_0))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= phi2 950.0)
(* R (* 2.0 (atan2 (* -0.5 t_1) (sqrt (- 1.0 t_2)))))
(*
R
(*
2.0
(atan2
(+ (sin (* phi2 -0.5)) (* 0.5 t_1))
(sqrt (- (pow t_0 2.0) (* (cos phi2) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double t_1 = phi1 * t_0;
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 950.0) {
tmp = R * (2.0 * atan2((-0.5 * t_1), sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * atan2((sin((phi2 * -0.5)) + (0.5 * t_1)), sqrt((pow(t_0, 2.0) - (cos(phi2) * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0)))
t_1 = phi1 * t_0
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if (phi2 <= 950.0d0) then
tmp = r * (2.0d0 * atan2(((-0.5d0) * t_1), sqrt((1.0d0 - t_2))))
else
tmp = r * (2.0d0 * atan2((sin((phi2 * (-0.5d0))) + (0.5d0 * t_1)), sqrt(((t_0 ** 2.0d0) - (cos(phi2) * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 * -0.5));
double t_1 = phi1 * t_0;
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi2 <= 950.0) {
tmp = R * (2.0 * Math.atan2((-0.5 * t_1), Math.sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * Math.atan2((Math.sin((phi2 * -0.5)) + (0.5 * t_1)), Math.sqrt((Math.pow(t_0, 2.0) - (Math.cos(phi2) * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) t_1 = phi1 * t_0 t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if phi2 <= 950.0: tmp = R * (2.0 * math.atan2((-0.5 * t_1), math.sqrt((1.0 - t_2)))) else: tmp = R * (2.0 * math.atan2((math.sin((phi2 * -0.5)) + (0.5 * t_1)), math.sqrt((math.pow(t_0, 2.0) - (math.cos(phi2) * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) t_1 = Float64(phi1 * t_0) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (phi2 <= 950.0) tmp = Float64(R * Float64(2.0 * atan(Float64(-0.5 * t_1), sqrt(Float64(1.0 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(phi2 * -0.5)) + Float64(0.5 * t_1)), sqrt(Float64((t_0 ^ 2.0) - Float64(cos(phi2) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); t_1 = phi1 * t_0; t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if (phi2 <= 950.0) tmp = R * (2.0 * atan2((-0.5 * t_1), sqrt((1.0 - t_2)))); else tmp = R * (2.0 * atan2((sin((phi2 * -0.5)) + (0.5 * t_1)), sqrt(((t_0 ^ 2.0) - (cos(phi2) * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(phi1 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, 950.0], N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * t$95$1), $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \phi_1 \cdot t_0\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq 950:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot t_1}{\sqrt{1 - t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot t_1}{\sqrt{{t_0}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\end{array}
\end{array}
if phi2 < 950Initial program 70.8%
Taylor expanded in phi1 around 0 51.7%
associate--r+51.7%
unpow251.7%
1-sub-sin51.7%
unpow251.7%
*-commutative51.7%
unpow251.7%
associate-*r*51.7%
*-commutative51.7%
sub-neg51.7%
mul-1-neg51.7%
distribute-lft-in51.7%
metadata-eval51.7%
associate-*r*51.7%
associate-*r*51.7%
metadata-eval51.7%
distribute-lft-in51.7%
+-commutative51.7%
mul-1-neg51.7%
sub-neg51.7%
Simplified51.7%
Taylor expanded in phi1 around 0 50.7%
Taylor expanded in phi1 around -inf 11.0%
Taylor expanded in phi2 around 0 11.0%
if 950 < phi2 Initial program 51.2%
Taylor expanded in phi1 around 0 50.8%
associate--r+50.8%
unpow250.8%
1-sub-sin50.9%
unpow250.9%
*-commutative50.9%
unpow250.9%
associate-*r*50.9%
*-commutative50.9%
sub-neg50.9%
mul-1-neg50.9%
distribute-lft-in50.9%
metadata-eval50.9%
associate-*r*50.9%
associate-*r*50.9%
metadata-eval50.9%
distribute-lft-in50.9%
+-commutative50.9%
mul-1-neg50.9%
sub-neg50.9%
Simplified50.9%
Taylor expanded in phi1 around 0 51.5%
Taylor expanded in phi1 around inf 13.1%
Final simplification11.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5))))
(*
R
(*
2.0
(atan2
(- (* -0.5 (* phi1 t_0)) (sin (* phi2 -0.5)))
(sqrt
(-
(pow t_0 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
return R * (2.0 * atan2(((-0.5 * (phi1 * t_0)) - sin((phi2 * -0.5))), sqrt((pow(t_0, 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
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
t_0 = cos((phi2 * (-0.5d0)))
code = r * (2.0d0 * atan2((((-0.5d0) * (phi1 * t_0)) - sin((phi2 * (-0.5d0)))), sqrt(((t_0 ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 * -0.5));
return R * (2.0 * Math.atan2(((-0.5 * (phi1 * t_0)) - Math.sin((phi2 * -0.5))), Math.sqrt((Math.pow(t_0, 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) return R * (2.0 * math.atan2(((-0.5 * (phi1 * t_0)) - math.sin((phi2 * -0.5))), math.sqrt((math.pow(t_0, 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) return Float64(R * Float64(2.0 * atan(Float64(Float64(-0.5 * Float64(phi1 * t_0)) - sin(Float64(phi2 * -0.5))), sqrt(Float64((t_0 ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); tmp = R * (2.0 * atan2(((-0.5 * (phi1 * t_0)) - sin((phi2 * -0.5))), sqrt(((t_0 ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[(N[(-0.5 * N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision] - N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot t_0\right) - \sin \left(\phi_2 \cdot -0.5\right)}{\sqrt{{t_0}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 65.8%
Taylor expanded in phi1 around 0 51.5%
associate--r+51.4%
unpow251.4%
1-sub-sin51.5%
unpow251.5%
*-commutative51.5%
unpow251.5%
associate-*r*51.5%
*-commutative51.5%
sub-neg51.5%
mul-1-neg51.5%
distribute-lft-in51.5%
metadata-eval51.5%
associate-*r*51.5%
associate-*r*51.5%
metadata-eval51.5%
distribute-lft-in51.5%
+-commutative51.5%
mul-1-neg51.5%
sub-neg51.5%
Simplified51.5%
Taylor expanded in phi1 around 0 50.9%
Taylor expanded in phi1 around -inf 16.6%
+-commutative16.6%
mul-1-neg16.6%
unsub-neg16.6%
*-commutative16.6%
Simplified16.6%
Final simplification16.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* -0.5 (* phi1 (cos (* phi2 -0.5))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((-0.5 * (phi1 * cos((phi2 * -0.5)))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
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 * (2.0d0 * atan2(((-0.5d0) * (phi1 * cos((phi2 * (-0.5d0))))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((-0.5 * (phi1 * Math.cos((phi2 * -0.5)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((-0.5 * (phi1 * math.cos((phi2 * -0.5)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi1 * cos(Float64(phi2 * -0.5)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((-0.5 * (phi1 * cos((phi2 * -0.5)))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 65.8%
Taylor expanded in phi1 around 0 51.5%
associate--r+51.4%
unpow251.4%
1-sub-sin51.5%
unpow251.5%
*-commutative51.5%
unpow251.5%
associate-*r*51.5%
*-commutative51.5%
sub-neg51.5%
mul-1-neg51.5%
distribute-lft-in51.5%
metadata-eval51.5%
associate-*r*51.5%
associate-*r*51.5%
metadata-eval51.5%
distribute-lft-in51.5%
+-commutative51.5%
mul-1-neg51.5%
sub-neg51.5%
Simplified51.5%
Taylor expanded in phi1 around 0 50.9%
Taylor expanded in phi1 around -inf 9.9%
Taylor expanded in phi2 around 0 9.9%
Final simplification9.9%
herbie shell --seed 2023187
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Distance on a great circle"
:precision binary64
(* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))