
(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 14 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 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(* t_0 (* t_2 (log1p (expm1 (sin (* 0.5 (- lambda1 lambda2)))))))))
(sqrt (- (- 1.0 t_1) (* t_0 (* t_2 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * log1p(expm1(sin((0.5 * (lambda1 - lambda2))))))))), sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * Math.log1p(Math.expm1(Math.sin((0.5 * (lambda1 - lambda2))))))))), Math.sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * math.log1p(math.expm1(math.sin((0.5 * (lambda1 - lambda2))))))))), math.sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * log1p(expm1(sin(Float64(0.5 * Float64(lambda1 - lambda2))))))))), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * Float64(t_2 * t_2))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * N[Log[1 + N[(Exp[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\right)}}{\sqrt{\left(1 - t\_1\right) - t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}\right)
\end{array}
\end{array}
Initial program 66.4%
associate-*l*66.4%
Simplified66.4%
div-sub66.4%
sin-diff67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr67.2%
div-sub66.4%
sin-diff67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr82.3%
log1p-expm1-u82.3%
div-inv82.3%
metadata-eval82.3%
Applied egg-rr82.3%
Final simplification82.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_0 (* t_2 t_2)))
(t_4 (- 1.0 t_1)))
(if (or (<= lambda2 -5.4e-6) (not (<= lambda2 1.7e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 (sin (* lambda2 -0.5))))))
(sqrt (- t_4 t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_3))
(sqrt (- t_4 (* t_0 (* t_2 (sin (* 0.5 lambda1))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = 1.0 - t_1;
double tmp;
if ((lambda2 <= -5.4e-6) || !(lambda2 <= 1.7e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * sin((lambda2 * -0.5)))))), sqrt((t_4 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt((t_4 - (t_0 * (t_2 * sin((0.5 * lambda1))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_0 * (t_2 * t_2)
t_4 = 1.0d0 - t_1
if ((lambda2 <= (-5.4d-6)) .or. (.not. (lambda2 <= 1.7d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * sin((lambda2 * (-0.5d0))))))), sqrt((t_4 - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_3)), sqrt((t_4 - (t_0 * (t_2 * sin((0.5d0 * lambda1))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = 1.0 - t_1;
double tmp;
if ((lambda2 <= -5.4e-6) || !(lambda2 <= 1.7e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * Math.sin((lambda2 * -0.5)))))), Math.sqrt((t_4 - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_3)), Math.sqrt((t_4 - (t_0 * (t_2 * Math.sin((0.5 * lambda1))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_0 * (t_2 * t_2) t_4 = 1.0 - t_1 tmp = 0 if (lambda2 <= -5.4e-6) or not (lambda2 <= 1.7e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * math.sin((lambda2 * -0.5)))))), math.sqrt((t_4 - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_3)), math.sqrt((t_4 - (t_0 * (t_2 * math.sin((0.5 * lambda1)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_0 * Float64(t_2 * t_2)) t_4 = Float64(1.0 - t_1) tmp = 0.0 if ((lambda2 <= -5.4e-6) || !(lambda2 <= 1.7e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * sin(Float64(lambda2 * -0.5)))))), sqrt(Float64(t_4 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_3)), sqrt(Float64(t_4 - Float64(t_0 * Float64(t_2 * sin(Float64(0.5 * lambda1))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_0 * (t_2 * t_2); t_4 = 1.0 - t_1; tmp = 0.0; if ((lambda2 <= -5.4e-6) || ~((lambda2 <= 1.7e-5))) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * sin((lambda2 * -0.5)))))), sqrt((t_4 - t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt((t_4 - (t_0 * (t_2 * sin((0.5 * lambda1)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$1), $MachinePrecision]}, If[Or[LessEqual[lambda2, -5.4e-6], N[Not[LessEqual[lambda2, 1.7e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - N[(t$95$0 * N[(t$95$2 * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_0 \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := 1 - t\_1\\
\mathbf{if}\;\lambda_2 \leq -5.4 \cdot 10^{-6} \lor \neg \left(\lambda_2 \leq 1.7 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t\_4 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_3}}{\sqrt{t\_4 - t\_0 \cdot \left(t\_2 \cdot \sin \left(0.5 \cdot \lambda_1\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -5.39999999999999997e-6 or 1.7e-5 < lambda2 Initial program 51.0%
associate-*l*51.0%
Simplified51.0%
div-sub51.0%
sin-diff51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
Applied egg-rr52.1%
Taylor expanded in lambda1 around 0 51.0%
div-sub51.0%
sin-diff51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
Applied egg-rr62.1%
if -5.39999999999999997e-6 < lambda2 < 1.7e-5Initial program 79.3%
associate-*l*79.3%
Simplified79.3%
div-sub79.3%
sin-diff80.3%
div-inv80.3%
metadata-eval80.3%
div-inv80.3%
metadata-eval80.3%
div-inv80.3%
metadata-eval80.3%
div-inv80.3%
metadata-eval80.3%
Applied egg-rr80.3%
div-sub79.3%
sin-diff80.3%
div-inv80.3%
metadata-eval80.3%
div-inv80.3%
metadata-eval80.3%
div-inv80.3%
metadata-eval80.3%
div-inv80.3%
metadata-eval80.3%
Applied egg-rr98.2%
Taylor expanded in lambda2 around 0 98.2%
Final simplification81.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_1 (* t_2 t_2)))
(t_4 (* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
(t_5 (pow (- (* t_0 (cos (* 0.5 phi2))) t_4) 2.0))
(t_6 (sqrt (- (- 1.0 t_5) t_3))))
(if (or (<= lambda1 -3.8e-13) (not (<= lambda1 4.1e-53)))
(* R (* 2.0 (atan2 (sqrt (+ t_3 (pow (- t_0 t_4) 2.0))) t_6)))
(*
R
(*
2.0
(atan2 (sqrt (+ t_5 (* t_1 (* t_2 (sin (* lambda2 -0.5)))))) t_6))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double t_4 = cos((phi1 * 0.5)) * sin((0.5 * phi2));
double t_5 = pow(((t_0 * cos((0.5 * phi2))) - t_4), 2.0);
double t_6 = sqrt(((1.0 - t_5) - t_3));
double tmp;
if ((lambda1 <= -3.8e-13) || !(lambda1 <= 4.1e-53)) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow((t_0 - t_4), 2.0))), t_6));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 + (t_1 * (t_2 * sin((lambda2 * -0.5)))))), t_6));
}
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) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_1 * (t_2 * t_2)
t_4 = cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2))
t_5 = ((t_0 * cos((0.5d0 * phi2))) - t_4) ** 2.0d0
t_6 = sqrt(((1.0d0 - t_5) - t_3))
if ((lambda1 <= (-3.8d-13)) .or. (.not. (lambda1 <= 4.1d-53))) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + ((t_0 - t_4) ** 2.0d0))), t_6))
else
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (t_1 * (t_2 * sin((lambda2 * (-0.5d0))))))), t_6))
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 * 0.5));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double t_4 = Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2));
double t_5 = Math.pow(((t_0 * Math.cos((0.5 * phi2))) - t_4), 2.0);
double t_6 = Math.sqrt(((1.0 - t_5) - t_3));
double tmp;
if ((lambda1 <= -3.8e-13) || !(lambda1 <= 4.1e-53)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow((t_0 - t_4), 2.0))), t_6));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + (t_1 * (t_2 * Math.sin((lambda2 * -0.5)))))), t_6));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_1 * (t_2 * t_2) t_4 = math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)) t_5 = math.pow(((t_0 * math.cos((0.5 * phi2))) - t_4), 2.0) t_6 = math.sqrt(((1.0 - t_5) - t_3)) tmp = 0 if (lambda1 <= -3.8e-13) or not (lambda1 <= 4.1e-53): tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow((t_0 - t_4), 2.0))), t_6)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + (t_1 * (t_2 * math.sin((lambda2 * -0.5)))))), t_6)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_1 * Float64(t_2 * t_2)) t_4 = Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2))) t_5 = Float64(Float64(t_0 * cos(Float64(0.5 * phi2))) - t_4) ^ 2.0 t_6 = sqrt(Float64(Float64(1.0 - t_5) - t_3)) tmp = 0.0 if ((lambda1 <= -3.8e-13) || !(lambda1 <= 4.1e-53)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (Float64(t_0 - t_4) ^ 2.0))), t_6))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + Float64(t_1 * Float64(t_2 * sin(Float64(lambda2 * -0.5)))))), t_6))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_1 * (t_2 * t_2); t_4 = cos((phi1 * 0.5)) * sin((0.5 * phi2)); t_5 = ((t_0 * cos((0.5 * phi2))) - t_4) ^ 2.0; t_6 = sqrt(((1.0 - t_5) - t_3)); tmp = 0.0; if ((lambda1 <= -3.8e-13) || ~((lambda1 <= 4.1e-53))) tmp = R * (2.0 * atan2(sqrt((t_3 + ((t_0 - t_4) ^ 2.0))), t_6)); else tmp = R * (2.0 * atan2(sqrt((t_5 + (t_1 * (t_2 * sin((lambda2 * -0.5)))))), t_6)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Power[N[(N[(t$95$0 * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(N[(1.0 - t$95$5), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -3.8e-13], N[Not[LessEqual[lambda1, 4.1e-53]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[(t$95$0 - t$95$4), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[(t$95$1 * N[(t$95$2 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_1 \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\\
t_5 := {\left(t\_0 \cdot \cos \left(0.5 \cdot \phi_2\right) - t\_4\right)}^{2}\\
t_6 := \sqrt{\left(1 - t\_5\right) - t\_3}\\
\mathbf{if}\;\lambda_1 \leq -3.8 \cdot 10^{-13} \lor \neg \left(\lambda_1 \leq 4.1 \cdot 10^{-53}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\left(t\_0 - t\_4\right)}^{2}}}{t\_6}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + t\_1 \cdot \left(t\_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{t\_6}\right)\\
\end{array}
\end{array}
if lambda1 < -3.8e-13 or 4.1000000000000001e-53 < lambda1 Initial program 52.8%
associate-*l*52.8%
Simplified52.8%
div-sub52.8%
sin-diff53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
Applied egg-rr53.8%
div-sub52.8%
sin-diff53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
Applied egg-rr66.6%
Taylor expanded in phi2 around 0 54.7%
*-commutative54.7%
Simplified54.7%
if -3.8e-13 < lambda1 < 4.1000000000000001e-53Initial program 80.8%
associate-*l*80.8%
Simplified80.8%
div-sub80.8%
sin-diff81.4%
div-inv81.4%
metadata-eval81.4%
div-inv81.4%
metadata-eval81.4%
div-inv81.4%
metadata-eval81.4%
div-inv81.4%
metadata-eval81.4%
Applied egg-rr81.7%
Taylor expanded in lambda1 around 0 81.6%
div-sub80.8%
sin-diff81.4%
div-inv81.4%
metadata-eval81.4%
div-inv81.4%
metadata-eval81.4%
div-inv81.4%
metadata-eval81.4%
div-inv81.4%
metadata-eval81.4%
Applied egg-rr99.0%
Final simplification76.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_2)) (sqrt (- (- 1.0 t_0) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
return R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2))));
}
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
t_0 = ((sin((phi1 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
code = r * (2.0d0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0d0 - t_0) - t_2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt(((1.0 - t_0) - t_2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) return R * (2.0 * math.atan2(math.sqrt((t_0 + t_2)), math.sqrt(((1.0 - t_0) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(Float64(1.0 - t_0) - t_2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{\left(1 - t\_0\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 66.4%
associate-*l*66.4%
Simplified66.4%
div-sub66.4%
sin-diff67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr67.2%
div-sub66.4%
sin-diff67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr82.3%
Final simplification82.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (* phi1 0.5)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_3 (* (cos (* phi1 0.5)) (sin (* 0.5 phi2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (- t_1 t_3) 2.0)))
(sqrt (- (- 1.0 (pow (- (* t_1 (cos (* 0.5 phi2))) t_3) 2.0)) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sin((phi1 * 0.5));
double t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_3 = cos((phi1 * 0.5)) * sin((0.5 * phi2));
return R * (2.0 * atan2(sqrt((t_2 + pow((t_1 - t_3), 2.0))), sqrt(((1.0 - pow(((t_1 * cos((0.5 * phi2))) - t_3), 2.0)) - t_2))));
}
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) :: t_3
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((phi1 * 0.5d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_3 = cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2))
code = r * (2.0d0 * atan2(sqrt((t_2 + ((t_1 - t_3) ** 2.0d0))), sqrt(((1.0d0 - (((t_1 * cos((0.5d0 * phi2))) - t_3) ** 2.0d0)) - t_2))))
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.sin((phi1 * 0.5));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_3 = Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2));
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((t_1 - t_3), 2.0))), Math.sqrt(((1.0 - Math.pow(((t_1 * Math.cos((0.5 * phi2))) - t_3), 2.0)) - t_2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sin((phi1 * 0.5)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_3 = math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)) return R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((t_1 - t_3), 2.0))), math.sqrt(((1.0 - math.pow(((t_1 * math.cos((0.5 * phi2))) - t_3), 2.0)) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(phi1 * 0.5)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_3 = Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(t_1 - t_3) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(t_1 * cos(Float64(0.5 * phi2))) - t_3) ^ 2.0)) - t_2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((phi1 * 0.5)); t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_3 = cos((phi1 * 0.5)) * sin((0.5 * phi2)); tmp = R * (2.0 * atan2(sqrt((t_2 + ((t_1 - t_3) ^ 2.0))), sqrt(((1.0 - (((t_1 * cos((0.5 * phi2))) - t_3) ^ 2.0)) - t_2)))); 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[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(t$95$1 - t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(t$95$1 * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$2), $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(\phi_1 \cdot 0.5\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
t_3 := \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(t\_1 - t\_3\right)}^{2}}}{\sqrt{\left(1 - {\left(t\_1 \cdot \cos \left(0.5 \cdot \phi_2\right) - t\_3\right)}^{2}\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 66.4%
associate-*l*66.4%
Simplified66.4%
div-sub66.4%
sin-diff67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr67.2%
div-sub66.4%
sin-diff67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr82.3%
Taylor expanded in phi2 around 0 68.0%
*-commutative68.0%
Simplified68.0%
Final simplification68.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
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(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 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(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 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(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - 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 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 66.4%
associate-*l*66.4%
Simplified66.4%
div-sub66.4%
sin-diff67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
div-inv67.2%
metadata-eval67.2%
Applied egg-rr67.3%
Final simplification67.3%
(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 phi1) (cos phi2)) t_0))))
(sqrt
(fabs
(-
1.0
(fma
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(cos phi1)
(pow (sin (* -0.5 (- phi2 phi1))) 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(phi1) * cos(phi2)) * t_0)))), sqrt(fabs((1.0 - fma((cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)), cos(phi1), pow(sin((-0.5 * (phi2 - phi1))), 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(phi1) * cos(phi2)) * t_0)))), sqrt(abs(Float64(1.0 - fma(Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)), cos(phi1), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 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[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 66.4%
add-sqr-sqrt66.4%
sqrt-unprod66.9%
pow266.9%
Applied egg-rr66.9%
Simplified66.9%
Final simplification66.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) 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(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - 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(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - 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(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - 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 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 66.4%
associate-*l*66.4%
Simplified66.4%
unpow266.4%
sin-mult66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
Applied egg-rr66.4%
div-sub66.4%
+-inverses66.4%
cos-066.4%
metadata-eval66.4%
distribute-lft-out66.4%
metadata-eval66.4%
*-rgt-identity66.4%
Simplified66.4%
Final simplification66.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0)))))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi1 -1.7e-6) (not (<= phi1 1.1e+16)))
(*
R
(*
2.0
(atan2 t_1 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -1.7e-6) || !(phi1 <= 1.1e+16)) {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 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 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))))
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi1 <= (-1.7d-6)) .or. (.not. (phi1 <= 1.1d+16))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_2)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi2 * (-0.5d0))) ** 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.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0))));
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -1.7e-6) || !(phi1 <= 1.1e+16)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi1 <= -1.7e-6) or not (phi1 <= 1.1e+16): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_2))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi1 <= -1.7e-6) || !(phi1 <= 1.1e+16)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi1 <= -1.7e-6) || ~((phi1 <= 1.1e+16))) tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_2))))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); 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[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[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.7e-6], N[Not[LessEqual[phi1, 1.1e+16]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / 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[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 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(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -1.7 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 1.1 \cdot 10^{+16}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\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{t\_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_2}}\right)\\
\end{array}
\end{array}
if phi1 < -1.70000000000000003e-6 or 1.1e16 < phi1 Initial program 44.1%
Taylor expanded in phi2 around 0 45.4%
+-commutative45.4%
associate--r+45.3%
unpow245.3%
1-sub-sin45.4%
unpow245.4%
sub-neg45.4%
mul-1-neg45.4%
distribute-lft-in45.4%
metadata-eval45.4%
associate-*r*45.4%
associate-*r*45.4%
metadata-eval45.4%
distribute-lft-in45.4%
+-commutative45.4%
Simplified45.4%
if -1.70000000000000003e-6 < phi1 < 1.1e16Initial program 82.4%
Taylor expanded in phi1 around 0 82.4%
+-commutative82.4%
associate--r+82.4%
unpow282.4%
1-sub-sin82.5%
unpow282.5%
sub-neg82.5%
mul-1-neg82.5%
distribute-lft-in82.5%
metadata-eval82.5%
associate-*r*82.5%
associate-*r*82.5%
metadata-eval82.5%
distribute-lft-in82.5%
+-commutative82.5%
Simplified82.5%
Final simplification67.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (* lambda2 -0.5)))
(t_2 (pow (cos (* phi2 -0.5)) 2.0))
(t_3 (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))))
(if (or (<= lambda1 -2.6e-6) (not (<= lambda1 7.5e-53)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (sin (* 0.5 lambda1)) t_3)))
(sqrt
(-
t_2
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 t_3)))
(sqrt (- t_2 (* (cos phi2) (pow t_1 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin((lambda2 * -0.5));
double t_2 = pow(cos((phi2 * -0.5)), 2.0);
double t_3 = (cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((lambda1 <= -2.6e-6) || !(lambda1 <= 7.5e-53)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((0.5 * lambda1)) * t_3))), sqrt((t_2 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt((t_2 - (cos(phi2) * pow(t_1, 2.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) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin((lambda2 * (-0.5d0)))
t_2 = cos((phi2 * (-0.5d0))) ** 2.0d0
t_3 = (cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0d0))
if ((lambda1 <= (-2.6d-6)) .or. (.not. (lambda1 <= 7.5d-53))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (sin((0.5d0 * lambda1)) * t_3))), sqrt((t_2 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt((t_2 - (cos(phi2) * (t_1 ** 2.0d0))))))
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(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin((lambda2 * -0.5));
double t_2 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((lambda1 <= -2.6e-6) || !(lambda1 <= 7.5e-53)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.sin((0.5 * lambda1)) * t_3))), Math.sqrt((t_2 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * t_3))), Math.sqrt((t_2 - (Math.cos(phi2) * Math.pow(t_1, 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin((lambda2 * -0.5)) t_2 = math.pow(math.cos((phi2 * -0.5)), 2.0) t_3 = (math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (lambda1 <= -2.6e-6) or not (lambda1 <= 7.5e-53): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.sin((0.5 * lambda1)) * t_3))), math.sqrt((t_2 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * t_3))), math.sqrt((t_2 - (math.cos(phi2) * math.pow(t_1, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(lambda2 * -0.5)) t_2 = cos(Float64(phi2 * -0.5)) ^ 2.0 t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) tmp = 0.0 if ((lambda1 <= -2.6e-6) || !(lambda1 <= 7.5e-53)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(sin(Float64(0.5 * lambda1)) * t_3))), sqrt(Float64(t_2 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * t_3))), sqrt(Float64(t_2 - Float64(cos(phi2) * (t_1 ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin((lambda2 * -0.5)); t_2 = cos((phi2 * -0.5)) ^ 2.0; t_3 = (cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((lambda1 <= -2.6e-6) || ~((lambda1 <= 7.5e-53))) tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((0.5 * lambda1)) * t_3))), sqrt((t_2 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt((t_2 - (cos(phi2) * (t_1 ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -2.6e-6], N[Not[LessEqual[lambda1, 7.5e-53]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\lambda_2 \cdot -0.5\right)\\
t_2 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 \leq -2.6 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 7.5 \cdot 10^{-53}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \sin \left(0.5 \cdot \lambda_1\right) \cdot t\_3}}{\sqrt{t\_2 - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_1 \cdot t\_3}}{\sqrt{t\_2 - \cos \phi_2 \cdot {t\_1}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -2.60000000000000009e-6 or 7.5000000000000001e-53 < lambda1 Initial program 52.8%
Taylor expanded in phi1 around 0 46.4%
+-commutative46.4%
associate--r+46.4%
unpow246.4%
1-sub-sin46.4%
unpow246.4%
sub-neg46.4%
mul-1-neg46.4%
distribute-lft-in46.4%
metadata-eval46.4%
associate-*r*46.4%
associate-*r*46.4%
metadata-eval46.4%
distribute-lft-in46.4%
+-commutative46.4%
Simplified46.4%
Taylor expanded in lambda2 around 0 45.0%
if -2.60000000000000009e-6 < lambda1 < 7.5000000000000001e-53Initial program 80.8%
Taylor expanded in phi1 around 0 67.3%
+-commutative67.3%
associate--r+67.3%
unpow267.3%
1-sub-sin67.4%
unpow267.4%
sub-neg67.4%
mul-1-neg67.4%
distribute-lft-in67.4%
metadata-eval67.4%
associate-*r*67.4%
associate-*r*67.4%
metadata-eval67.4%
distribute-lft-in67.4%
+-commutative67.4%
Simplified67.4%
Taylor expanded in lambda1 around 0 67.3%
Taylor expanded in lambda1 around 0 67.3%
Final simplification55.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))
(t_1 (sin (* lambda2 -0.5)))
(t_2 (* (cos phi1) (cos phi2))))
(if (or (<= phi2 -6.6e-74) (not (<= phi2 1.2e-46)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_1)) (pow (sin (* phi2 -0.5)) 2.0)))
t_0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(pow (sin (* phi1 0.5)) 2.0)))
t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_1 = sin((lambda2 * -0.5));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -6.6e-74) || !(phi2 <= 1.2e-46)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + pow(sin((phi2 * -0.5)), 2.0))), t_0));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * sin(((lambda1 - lambda2) / 2.0)))) + pow(sin((phi1 * 0.5)), 2.0))), 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 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))
t_1 = sin((lambda2 * (-0.5d0)))
t_2 = cos(phi1) * cos(phi2)
if ((phi2 <= (-6.6d-74)) .or. (.not. (phi2 <= 1.2d-46))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), t_0))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * sin(((lambda1 - lambda2) / 2.0d0)))) + (sin((phi1 * 0.5d0)) ** 2.0d0))), 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.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_1 = Math.sin((lambda2 * -0.5));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((phi2 <= -6.6e-74) || !(phi2 <= 1.2e-46)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_1)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), t_0));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * Math.sin(((lambda1 - lambda2) / 2.0)))) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): 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)))) t_1 = math.sin((lambda2 * -0.5)) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (phi2 <= -6.6e-74) or not (phi2 <= 1.2e-46): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_1)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), t_0)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * math.sin(((lambda1 - lambda2) / 2.0)))) + math.pow(math.sin((phi1 * 0.5)), 2.0))), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) t_1 = sin(Float64(lambda2 * -0.5)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -6.6e-74) || !(phi2 <= 1.2e-46)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_1)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), t_0))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * sin(Float64(Float64(lambda1 - lambda2) / 2.0)))) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))); t_1 = sin((lambda2 * -0.5)); t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if ((phi2 <= -6.6e-74) || ~((phi2 <= 1.2e-46))) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + (sin((phi2 * -0.5)) ^ 2.0))), t_0)); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * sin(((lambda1 - lambda2) / 2.0)))) + (sin((phi1 * 0.5)) ^ 2.0))), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -6.6e-74], N[Not[LessEqual[phi2, 1.2e-46]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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}}\\
t_1 := \sin \left(\lambda_2 \cdot -0.5\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -6.6 \cdot 10^{-74} \lor \neg \left(\phi_2 \leq 1.2 \cdot 10^{-46}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_1\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{t\_0}\right)\\
\end{array}
\end{array}
if phi2 < -6.59999999999999992e-74 or 1.20000000000000007e-46 < phi2 Initial program 56.6%
Taylor expanded in phi1 around 0 53.4%
+-commutative53.4%
associate--r+53.4%
unpow253.4%
1-sub-sin53.5%
unpow253.5%
sub-neg53.5%
mul-1-neg53.5%
distribute-lft-in53.5%
metadata-eval53.5%
associate-*r*53.5%
associate-*r*53.5%
metadata-eval53.5%
distribute-lft-in53.5%
+-commutative53.5%
Simplified53.5%
Taylor expanded in lambda1 around 0 41.0%
Taylor expanded in phi1 around 0 38.7%
Taylor expanded in lambda1 around 0 39.2%
if -6.59999999999999992e-74 < phi2 < 1.20000000000000007e-46Initial program 83.0%
Taylor expanded in phi1 around 0 61.8%
+-commutative61.8%
associate--r+61.8%
unpow261.8%
1-sub-sin61.8%
unpow261.8%
sub-neg61.8%
mul-1-neg61.8%
distribute-lft-in61.8%
metadata-eval61.8%
associate-*r*61.8%
associate-*r*61.8%
metadata-eval61.8%
distribute-lft-in61.8%
+-commutative61.8%
Simplified61.8%
Taylor expanded in lambda1 around 0 43.6%
Taylor expanded in phi2 around 0 43.6%
Final simplification40.8%
(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 phi1) (cos phi2)) 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(phi1) * cos(phi2)) * 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(phi1) * cos(phi2)) * 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(phi1) * Math.cos(phi2)) * 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(phi1) * math.cos(phi2)) * 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(phi1) * cos(phi2)) * 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(phi1) * cos(phi2)) * 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[phi1], $MachinePrecision] * N[Cos[phi2], $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_1 \cdot \cos \phi_2\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 66.4%
Taylor expanded in phi1 around 0 56.5%
+-commutative56.5%
associate--r+56.5%
unpow256.5%
1-sub-sin56.6%
unpow256.6%
sub-neg56.6%
mul-1-neg56.6%
distribute-lft-in56.6%
metadata-eval56.6%
associate-*r*56.6%
associate-*r*56.6%
metadata-eval56.6%
distribute-lft-in56.6%
+-commutative56.6%
Simplified56.6%
Final simplification56.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* lambda2 -0.5))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) 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((lambda2 * -0.5));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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((lambda2 * (-0.5d0)))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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((lambda2 * -0.5));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * 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((lambda2 * -0.5)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * 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(lambda2 * -0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * 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((lambda2 * -0.5)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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[(lambda2 * -0.5), $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[phi1], $MachinePrecision] * N[Cos[phi2], $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(\lambda_2 \cdot -0.5\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_1 \cdot \cos \phi_2\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 66.4%
Taylor expanded in phi1 around 0 56.5%
+-commutative56.5%
associate--r+56.5%
unpow256.5%
1-sub-sin56.6%
unpow256.6%
sub-neg56.6%
mul-1-neg56.6%
distribute-lft-in56.6%
metadata-eval56.6%
associate-*r*56.6%
associate-*r*56.6%
metadata-eval56.6%
distribute-lft-in56.6%
+-commutative56.6%
Simplified56.6%
Taylor expanded in lambda1 around 0 42.0%
Taylor expanded in lambda1 around 0 42.7%
Final simplification42.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* lambda2 -0.5))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (* phi2 -0.5)) 2.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((lambda2 * -0.5));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin((phi2 * -0.5)), 2.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((lambda2 * (-0.5d0)))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), 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((lambda2 * -0.5));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.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((lambda2 * -0.5)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin((phi2 * -0.5)), 2.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(lambda2 * -0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(phi2 * -0.5)) ^ 2.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((lambda2 * -0.5)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin((phi2 * -0.5)) ^ 2.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[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $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] * 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(\lambda_2 \cdot -0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\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 66.4%
Taylor expanded in phi1 around 0 56.5%
+-commutative56.5%
associate--r+56.5%
unpow256.5%
1-sub-sin56.6%
unpow256.6%
sub-neg56.6%
mul-1-neg56.6%
distribute-lft-in56.6%
metadata-eval56.6%
associate-*r*56.6%
associate-*r*56.6%
metadata-eval56.6%
distribute-lft-in56.6%
+-commutative56.6%
Simplified56.6%
Taylor expanded in lambda1 around 0 42.0%
Taylor expanded in phi1 around 0 35.3%
Taylor expanded in lambda1 around 0 36.2%
Final simplification36.2%
herbie shell --seed 2024111
(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))))))))))