
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(* (cos lambda1) (* (cos phi2) (cos phi1)))
(cos lambda2)
(fma
(* (* (sin lambda1) (sin lambda2)) (cos phi1))
(cos phi2)
(* (sin phi2) (sin phi1)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma((cos(lambda1) * (cos(phi2) * cos(phi1))), cos(lambda2), fma(((sin(lambda1) * sin(lambda2)) * cos(phi1)), cos(phi2), (sin(phi2) * sin(phi1))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(Float64(cos(lambda1) * Float64(cos(phi2) * cos(phi1))), cos(lambda2), fma(Float64(Float64(sin(lambda1) * sin(lambda2)) * cos(phi1)), cos(phi2), Float64(sin(phi2) * sin(phi1))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right), \cos \lambda_2, \mathsf{fma}\left(\left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_1, \cos \phi_2, \sin \phi_2 \cdot \sin \phi_1\right)\right)\right) \cdot R
\end{array}
Initial program 73.0%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.4
Applied rewrites94.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-inN/A
associate-+l+N/A
Applied rewrites94.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(*
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1)))
(cos phi2))
(cos phi1)
(* (sin phi2) (sin phi1))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma((fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))) * cos(phi2)), cos(phi1), (sin(phi2) * sin(phi1)))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(Float64(fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))) * cos(phi2)), cos(phi1), Float64(sin(phi2) * sin(phi1)))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2, \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R
\end{array}
Initial program 73.0%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.4
Applied rewrites94.4%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites94.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda2 lambda1)) (cos phi1)) (cos phi2))))
R))
(t_1 (fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))
(t_2 (* (acos (* t_1 (cos phi2))) R)))
(if (<= phi2 -7000000000000.0)
t_0
(if (<= phi2 5.6e-33)
(* (acos (* t_1 (cos phi1))) R)
(if (<= phi2 6.5e+17)
t_2
(if (<= phi2 4.2e+247)
t_0
(if (<= phi2 2.1e+255)
t_2
(if (<= phi2 1.1e+301) t_0 (* (acos (cos phi1)) R)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos(fma(sin(phi2), sin(phi1), ((cos((lambda2 - lambda1)) * cos(phi1)) * cos(phi2)))) * R;
double t_1 = fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)));
double t_2 = acos((t_1 * cos(phi2))) * R;
double tmp;
if (phi2 <= -7000000000000.0) {
tmp = t_0;
} else if (phi2 <= 5.6e-33) {
tmp = acos((t_1 * cos(phi1))) * R;
} else if (phi2 <= 6.5e+17) {
tmp = t_2;
} else if (phi2 <= 4.2e+247) {
tmp = t_0;
} else if (phi2 <= 2.1e+255) {
tmp = t_2;
} else if (phi2 <= 1.1e+301) {
tmp = t_0;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda2 - lambda1)) * cos(phi1)) * cos(phi2)))) * R) t_1 = fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))) t_2 = Float64(acos(Float64(t_1 * cos(phi2))) * R) tmp = 0.0 if (phi2 <= -7000000000000.0) tmp = t_0; elseif (phi2 <= 5.6e-33) tmp = Float64(acos(Float64(t_1 * cos(phi1))) * R); elseif (phi2 <= 6.5e+17) tmp = t_2; elseif (phi2 <= 4.2e+247) tmp = t_0; elseif (phi2 <= 2.1e+255) tmp = t_2; elseif (phi2 <= 1.1e+301) tmp = t_0; else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[ArcCos[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, -7000000000000.0], t$95$0, If[LessEqual[phi2, 5.6e-33], N[(N[ArcCos[N[(t$95$1 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 6.5e+17], t$95$2, If[LessEqual[phi2, 4.2e+247], t$95$0, If[LessEqual[phi2, 2.1e+255], t$95$2, If[LessEqual[phi2, 1.1e+301], t$95$0, N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \cos \phi_1\right) \cdot \cos \phi_2\right)\right) \cdot R\\
t_1 := \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\\
t_2 := \cos^{-1} \left(t\_1 \cdot \cos \phi_2\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq -7000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-33}:\\
\;\;\;\;\cos^{-1} \left(t\_1 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{+17}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 4.2 \cdot 10^{+247}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 2.1 \cdot 10^{+255}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 1.1 \cdot 10^{+301}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if phi2 < -7e12 or 6.5e17 < phi2 < 4.2e247 or 2.1e255 < phi2 < 1.1e301Initial program 77.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6477.1
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6477.1
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
*-commutativeN/A
cos-diff-revN/A
lower-cos.f64N/A
lower--.f6477.1
Applied rewrites77.1%
if -7e12 < phi2 < 5.6e-33Initial program 69.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6490.2
Applied rewrites90.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6488.0
Applied rewrites88.0%
if 5.6e-33 < phi2 < 6.5e17 or 4.2e247 < phi2 < 2.1e255Initial program 67.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6492.1
Applied rewrites92.1%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6473.5
Applied rewrites73.5%
if 1.1e301 < phi2 Initial program 66.3%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6467.7
Applied rewrites67.7%
Taylor expanded in lambda1 around 0
Applied rewrites26.8%
Applied rewrites19.6%
Taylor expanded in phi2 around 0
Applied rewrites18.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(acos
(*
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1)))
(cos phi1)))
R))
(t_1
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (cos lambda1) (* (cos phi2) (cos phi1)))))
R)))
(if (<= lambda1 -1.25e-7)
t_1
(if (<= lambda1 7.8e-26)
(*
(acos
(fma
(* (cos lambda2) (cos phi2))
(cos phi1)
(* (sin phi2) (sin phi1))))
R)
(if (<= lambda1 2.6e+40)
t_0
(if (<= lambda1 2.2e+237)
t_1
(if (<= lambda1 1.9e+252)
t_0
(if (<= lambda1 2.2e+306) t_1 (* (acos (cos phi1)) R)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos((fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))) * cos(phi1))) * R;
double t_1 = acos(fma(sin(phi2), sin(phi1), (cos(lambda1) * (cos(phi2) * cos(phi1))))) * R;
double tmp;
if (lambda1 <= -1.25e-7) {
tmp = t_1;
} else if (lambda1 <= 7.8e-26) {
tmp = acos(fma((cos(lambda2) * cos(phi2)), cos(phi1), (sin(phi2) * sin(phi1)))) * R;
} else if (lambda1 <= 2.6e+40) {
tmp = t_0;
} else if (lambda1 <= 2.2e+237) {
tmp = t_1;
} else if (lambda1 <= 1.9e+252) {
tmp = t_0;
} else if (lambda1 <= 2.2e+306) {
tmp = t_1;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(Float64(fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))) * cos(phi1))) * R) t_1 = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(lambda1) * Float64(cos(phi2) * cos(phi1))))) * R) tmp = 0.0 if (lambda1 <= -1.25e-7) tmp = t_1; elseif (lambda1 <= 7.8e-26) tmp = Float64(acos(fma(Float64(cos(lambda2) * cos(phi2)), cos(phi1), Float64(sin(phi2) * sin(phi1)))) * R); elseif (lambda1 <= 2.6e+40) tmp = t_0; elseif (lambda1 <= 2.2e+237) tmp = t_1; elseif (lambda1 <= 1.9e+252) tmp = t_0; elseif (lambda1 <= 2.2e+306) tmp = t_1; else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[lambda1, -1.25e-7], t$95$1, If[LessEqual[lambda1, 7.8e-26], N[(N[ArcCos[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda1, 2.6e+40], t$95$0, If[LessEqual[lambda1, 2.2e+237], t$95$1, If[LessEqual[lambda1, 1.9e+252], t$95$0, If[LessEqual[lambda1, 2.2e+306], t$95$1, N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(\mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_1\right) \cdot R\\
t_1 := \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right)\right) \cdot R\\
\mathbf{if}\;\lambda_1 \leq -1.25 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 7.8 \cdot 10^{-26}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \phi_2, \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq 2.6 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 2.2 \cdot 10^{+237}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 1.9 \cdot 10^{+252}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 2.2 \cdot 10^{+306}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if lambda1 < -1.24999999999999994e-7 or 2.6000000000000001e40 < lambda1 < 2.2e237 or 1.89999999999999986e252 < lambda1 < 2.2e306Initial program 62.9%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6462.8
Applied rewrites62.8%
Applied rewrites62.8%
if -1.24999999999999994e-7 < lambda1 < 7.79999999999999973e-26Initial program 87.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6487.6
Applied rewrites87.6%
if 7.79999999999999973e-26 < lambda1 < 2.6000000000000001e40 or 2.2e237 < lambda1 < 1.89999999999999986e252Initial program 67.1%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6499.2
Applied rewrites99.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6460.1
Applied rewrites60.1%
if 2.2e306 < lambda1 Initial program 60.0%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6461.0
Applied rewrites61.0%
Taylor expanded in lambda1 around 0
Applied rewrites25.8%
Applied rewrites19.3%
Taylor expanded in phi2 around 0
Applied rewrites19.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (cos lambda1) (* (cos phi2) (cos phi1)))))
R)))
(if (<= lambda1 -1.25e-7)
t_0
(if (<= lambda1 7.8e-26)
(*
(acos
(fma
(* (cos lambda2) (cos phi2))
(cos phi1)
(* (sin phi2) (sin phi1))))
R)
(if (<= lambda1 2.2e+306) t_0 (* (acos (cos phi1)) R))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos(fma(sin(phi2), sin(phi1), (cos(lambda1) * (cos(phi2) * cos(phi1))))) * R;
double tmp;
if (lambda1 <= -1.25e-7) {
tmp = t_0;
} else if (lambda1 <= 7.8e-26) {
tmp = acos(fma((cos(lambda2) * cos(phi2)), cos(phi1), (sin(phi2) * sin(phi1)))) * R;
} else if (lambda1 <= 2.2e+306) {
tmp = t_0;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(lambda1) * Float64(cos(phi2) * cos(phi1))))) * R) tmp = 0.0 if (lambda1 <= -1.25e-7) tmp = t_0; elseif (lambda1 <= 7.8e-26) tmp = Float64(acos(fma(Float64(cos(lambda2) * cos(phi2)), cos(phi1), Float64(sin(phi2) * sin(phi1)))) * R); elseif (lambda1 <= 2.2e+306) tmp = t_0; else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[lambda1, -1.25e-7], t$95$0, If[LessEqual[lambda1, 7.8e-26], N[(N[ArcCos[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda1, 2.2e+306], t$95$0, N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right)\right) \cdot R\\
\mathbf{if}\;\lambda_1 \leq -1.25 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 7.8 \cdot 10^{-26}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \phi_2, \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq 2.2 \cdot 10^{+306}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if lambda1 < -1.24999999999999994e-7 or 7.79999999999999973e-26 < lambda1 < 2.2e306Initial program 63.4%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6462.8
Applied rewrites62.8%
Applied rewrites62.8%
if -1.24999999999999994e-7 < lambda1 < 7.79999999999999973e-26Initial program 87.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6487.6
Applied rewrites87.6%
if 2.2e306 < lambda1 Initial program 60.0%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6461.0
Applied rewrites61.0%
Taylor expanded in lambda1 around 0
Applied rewrites25.8%
Applied rewrites19.3%
Taylor expanded in phi2 around 0
Applied rewrites19.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -0.00088)
(* (acos (* (cos (- lambda2 lambda1)) (cos phi1))) R)
(if (<= lambda2 2e-7)
(*
(acos
(fma (sin phi2) (sin phi1) (* (cos lambda1) (* (cos phi2) (cos phi1)))))
R)
(if (<= lambda2 1.95e+220)
(* (acos (* (cos lambda2) (cos phi1))) R)
(if (<= lambda2 7.5e+291)
(* (acos (* (cos lambda2) (cos phi2))) R)
(* (acos (cos phi1)) R))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -0.00088) {
tmp = acos((cos((lambda2 - lambda1)) * cos(phi1))) * R;
} else if (lambda2 <= 2e-7) {
tmp = acos(fma(sin(phi2), sin(phi1), (cos(lambda1) * (cos(phi2) * cos(phi1))))) * R;
} else if (lambda2 <= 1.95e+220) {
tmp = acos((cos(lambda2) * cos(phi1))) * R;
} else if (lambda2 <= 7.5e+291) {
tmp = acos((cos(lambda2) * cos(phi2))) * R;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -0.00088) tmp = Float64(acos(Float64(cos(Float64(lambda2 - lambda1)) * cos(phi1))) * R); elseif (lambda2 <= 2e-7) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(lambda1) * Float64(cos(phi2) * cos(phi1))))) * R); elseif (lambda2 <= 1.95e+220) tmp = Float64(acos(Float64(cos(lambda2) * cos(phi1))) * R); elseif (lambda2 <= 7.5e+291) tmp = Float64(acos(Float64(cos(lambda2) * cos(phi2))) * R); else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -0.00088], N[(N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda2, 2e-7], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda2, 1.95e+220], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda2, 7.5e+291], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -0.00088:\\
\;\;\;\;\cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 1.95 \cdot 10^{+220}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 7.5 \cdot 10^{+291}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if lambda2 < -8.80000000000000031e-4Initial program 50.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6435.3
Applied rewrites35.3%
if -8.80000000000000031e-4 < lambda2 < 1.9999999999999999e-7Initial program 89.1%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6489.1
Applied rewrites89.1%
Applied rewrites89.1%
if 1.9999999999999999e-7 < lambda2 < 1.95000000000000008e220Initial program 63.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6434.8
Applied rewrites34.8%
Taylor expanded in lambda1 around 0
Applied rewrites34.6%
if 1.95000000000000008e220 < lambda2 < 7.5000000000000001e291Initial program 57.4%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in phi1 around 0
lower-/.f64N/A
Applied rewrites44.2%
Taylor expanded in lambda1 around 0
Applied rewrites34.8%
if 7.5000000000000001e291 < lambda2 Initial program 44.0%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6422.8
Applied rewrites22.8%
Taylor expanded in lambda1 around 0
Applied rewrites9.4%
Applied rewrites9.4%
Taylor expanded in phi2 around 0
Applied rewrites3.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* t_0 (cos phi2))))
(if (<= phi1 -15.5)
(* (acos (* t_0 (cos phi1))) R)
(if (<= phi1 -2e-70)
(* (acos (fma (sin phi2) phi1 t_1)) R)
(if (<= phi1 0.0155) (* (acos t_1) R) (* (acos (cos phi1)) R))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = t_0 * cos(phi2);
double tmp;
if (phi1 <= -15.5) {
tmp = acos((t_0 * cos(phi1))) * R;
} else if (phi1 <= -2e-70) {
tmp = acos(fma(sin(phi2), phi1, t_1)) * R;
} else if (phi1 <= 0.0155) {
tmp = acos(t_1) * R;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(t_0 * cos(phi2)) tmp = 0.0 if (phi1 <= -15.5) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); elseif (phi1 <= -2e-70) tmp = Float64(acos(fma(sin(phi2), phi1, t_1)) * R); elseif (phi1 <= 0.0155) tmp = Float64(acos(t_1) * R); else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -15.5], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -2e-70], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * phi1 + t$95$1), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 0.0155], N[(N[ArcCos[t$95$1], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := t\_0 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -15.5:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -2 \cdot 10^{-70}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \phi_1, t\_1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 0.0155:\\
\;\;\;\;\cos^{-1} t\_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if phi1 < -15.5Initial program 84.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6447.0
Applied rewrites47.0%
if -15.5 < phi1 < -1.99999999999999999e-70Initial program 58.6%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6459.1
Applied rewrites59.1%
if -1.99999999999999999e-70 < phi1 < 0.0155Initial program 67.7%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6467.7
Applied rewrites67.7%
if 0.0155 < phi1 Initial program 74.5%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6456.1
Applied rewrites56.1%
Taylor expanded in lambda1 around 0
Applied rewrites27.9%
Applied rewrites22.3%
Taylor expanded in phi2 around 0
Applied rewrites22.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= (cos (- lambda1 lambda2)) 0.99998) (* (acos (* (cos (- lambda2 lambda1)) (cos phi1))) R) (* (acos (cos (- phi2 phi1))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (cos((lambda1 - lambda2)) <= 0.99998) {
tmp = acos((cos((lambda2 - lambda1)) * cos(phi1))) * R;
} else {
tmp = acos(cos((phi2 - phi1))) * R;
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (cos((lambda1 - lambda2)) <= 0.99998d0) then
tmp = acos((cos((lambda2 - lambda1)) * cos(phi1))) * r
else
tmp = acos(cos((phi2 - phi1))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (Math.cos((lambda1 - lambda2)) <= 0.99998) {
tmp = Math.acos((Math.cos((lambda2 - lambda1)) * Math.cos(phi1))) * R;
} else {
tmp = Math.acos(Math.cos((phi2 - phi1))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if math.cos((lambda1 - lambda2)) <= 0.99998: tmp = math.acos((math.cos((lambda2 - lambda1)) * math.cos(phi1))) * R else: tmp = math.acos(math.cos((phi2 - phi1))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (cos(Float64(lambda1 - lambda2)) <= 0.99998) tmp = Float64(acos(Float64(cos(Float64(lambda2 - lambda1)) * cos(phi1))) * R); else tmp = Float64(acos(cos(Float64(phi2 - phi1))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (cos((lambda1 - lambda2)) <= 0.99998) tmp = acos((cos((lambda2 - lambda1)) * cos(phi1))) * R; else tmp = acos(cos((phi2 - phi1))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision], 0.99998], N[(N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\lambda_1 - \lambda_2\right) \leq 0.99998:\\
\;\;\;\;\cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \left(\phi_2 - \phi_1\right) \cdot R\\
\end{array}
\end{array}
if (cos.f64 (-.f64 lambda1 lambda2)) < 0.99997999999999998Initial program 72.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6446.2
Applied rewrites46.2%
if 0.99997999999999998 < (cos.f64 (-.f64 lambda1 lambda2)) Initial program 76.6%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6476.6
Applied rewrites76.6%
Taylor expanded in lambda1 around 0
Applied rewrites73.4%
Applied rewrites51.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma -0.5 (* phi1 phi1) 1.0))
(t_1 (* (acos (* (cos lambda1) (cos phi2))) R))
(t_2 (* (acos (* t_0 (cos (- lambda1 lambda2)))) R)))
(if (<= phi1 -32500.0)
(* (acos (* (cos lambda2) (cos phi1))) R)
(if (<= phi1 -8e-47)
t_1
(if (<= phi1 -3.3e-63)
(* (acos (* t_0 (cos lambda2))) R)
(if (<= phi1 -1.9e-283)
t_1
(if (<= phi1 7.2e-308)
t_2
(if (<= phi1 2.35e-263)
t_1
(if (<= phi1 3.6e-239)
t_2
(if (<= phi1 2.1e-16) t_1 (* (acos (cos phi1)) R)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(-0.5, (phi1 * phi1), 1.0);
double t_1 = acos((cos(lambda1) * cos(phi2))) * R;
double t_2 = acos((t_0 * cos((lambda1 - lambda2)))) * R;
double tmp;
if (phi1 <= -32500.0) {
tmp = acos((cos(lambda2) * cos(phi1))) * R;
} else if (phi1 <= -8e-47) {
tmp = t_1;
} else if (phi1 <= -3.3e-63) {
tmp = acos((t_0 * cos(lambda2))) * R;
} else if (phi1 <= -1.9e-283) {
tmp = t_1;
} else if (phi1 <= 7.2e-308) {
tmp = t_2;
} else if (phi1 <= 2.35e-263) {
tmp = t_1;
} else if (phi1 <= 3.6e-239) {
tmp = t_2;
} else if (phi1 <= 2.1e-16) {
tmp = t_1;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(-0.5, Float64(phi1 * phi1), 1.0) t_1 = Float64(acos(Float64(cos(lambda1) * cos(phi2))) * R) t_2 = Float64(acos(Float64(t_0 * cos(Float64(lambda1 - lambda2)))) * R) tmp = 0.0 if (phi1 <= -32500.0) tmp = Float64(acos(Float64(cos(lambda2) * cos(phi1))) * R); elseif (phi1 <= -8e-47) tmp = t_1; elseif (phi1 <= -3.3e-63) tmp = Float64(acos(Float64(t_0 * cos(lambda2))) * R); elseif (phi1 <= -1.9e-283) tmp = t_1; elseif (phi1 <= 7.2e-308) tmp = t_2; elseif (phi1 <= 2.35e-263) tmp = t_1; elseif (phi1 <= 3.6e-239) tmp = t_2; elseif (phi1 <= 2.1e-16) tmp = t_1; else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, Block[{t$95$2 = N[(N[ArcCos[N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi1, -32500.0], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -8e-47], t$95$1, If[LessEqual[phi1, -3.3e-63], N[(N[ArcCos[N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -1.9e-283], t$95$1, If[LessEqual[phi1, 7.2e-308], t$95$2, If[LessEqual[phi1, 2.35e-263], t$95$1, If[LessEqual[phi1, 3.6e-239], t$95$2, If[LessEqual[phi1, 2.1e-16], t$95$1, N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right)\\
t_1 := \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot R\\
t_2 := \cos^{-1} \left(t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_1 \leq -32500:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -8 \cdot 10^{-47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq -3.3 \cdot 10^{-63}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \lambda_2\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -1.9 \cdot 10^{-283}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 7.2 \cdot 10^{-308}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 2.35 \cdot 10^{-263}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 3.6 \cdot 10^{-239}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if phi1 < -32500Initial program 84.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6447.0
Applied rewrites47.0%
Taylor expanded in lambda1 around 0
Applied rewrites33.2%
if -32500 < phi1 < -7.9999999999999998e-47 or -3.29999999999999994e-63 < phi1 < -1.9000000000000001e-283 or 7.1999999999999997e-308 < phi1 < 2.34999999999999985e-263 or 3.6000000000000001e-239 < phi1 < 2.1000000000000001e-16Initial program 65.9%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6450.1
Applied rewrites50.1%
Taylor expanded in phi1 around 0
Applied rewrites49.8%
if -7.9999999999999998e-47 < phi1 < -3.29999999999999994e-63Initial program 51.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6436.4
Applied rewrites36.4%
Taylor expanded in phi1 around 0
Applied rewrites36.4%
Taylor expanded in lambda1 around 0
Applied rewrites36.2%
if -1.9000000000000001e-283 < phi1 < 7.1999999999999997e-308 or 2.34999999999999985e-263 < phi1 < 3.6000000000000001e-239Initial program 72.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6454.1
Applied rewrites54.1%
Taylor expanded in phi1 around 0
Applied rewrites54.1%
if 2.1000000000000001e-16 < phi1 Initial program 75.2%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.4
Applied rewrites57.4%
Taylor expanded in lambda1 around 0
Applied rewrites27.4%
Applied rewrites22.0%
Taylor expanded in phi2 around 0
Applied rewrites21.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (acos (* (cos lambda1) (cos phi2))) R)))
(if (<= phi1 -15.5)
(* (acos (* (cos lambda1) (cos phi1))) R)
(if (<= phi1 -1.9e-283)
t_0
(if (<= phi1 7.2e-308)
(*
(acos (* (fma -0.5 (* phi1 phi1) 1.0) (cos (- lambda1 lambda2))))
R)
(if (<= phi1 2.35e-263)
t_0
(if (<= phi1 9.5e-216)
(* (acos (* (cos lambda2) (cos phi2))) R)
(if (<= phi1 0.0155) t_0 (* (acos (cos phi1)) R)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos((cos(lambda1) * cos(phi2))) * R;
double tmp;
if (phi1 <= -15.5) {
tmp = acos((cos(lambda1) * cos(phi1))) * R;
} else if (phi1 <= -1.9e-283) {
tmp = t_0;
} else if (phi1 <= 7.2e-308) {
tmp = acos((fma(-0.5, (phi1 * phi1), 1.0) * cos((lambda1 - lambda2)))) * R;
} else if (phi1 <= 2.35e-263) {
tmp = t_0;
} else if (phi1 <= 9.5e-216) {
tmp = acos((cos(lambda2) * cos(phi2))) * R;
} else if (phi1 <= 0.0155) {
tmp = t_0;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(Float64(cos(lambda1) * cos(phi2))) * R) tmp = 0.0 if (phi1 <= -15.5) tmp = Float64(acos(Float64(cos(lambda1) * cos(phi1))) * R); elseif (phi1 <= -1.9e-283) tmp = t_0; elseif (phi1 <= 7.2e-308) tmp = Float64(acos(Float64(fma(-0.5, Float64(phi1 * phi1), 1.0) * cos(Float64(lambda1 - lambda2)))) * R); elseif (phi1 <= 2.35e-263) tmp = t_0; elseif (phi1 <= 9.5e-216) tmp = Float64(acos(Float64(cos(lambda2) * cos(phi2))) * R); elseif (phi1 <= 0.0155) tmp = t_0; else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi1, -15.5], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -1.9e-283], t$95$0, If[LessEqual[phi1, 7.2e-308], N[(N[ArcCos[N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 2.35e-263], t$95$0, If[LessEqual[phi1, 9.5e-216], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 0.0155], t$95$0, N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot R\\
\mathbf{if}\;\phi_1 \leq -15.5:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -1.9 \cdot 10^{-283}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 7.2 \cdot 10^{-308}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 2.35 \cdot 10^{-263}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 9.5 \cdot 10^{-216}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_2\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 0.0155:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if phi1 < -15.5Initial program 84.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6447.0
Applied rewrites47.0%
Taylor expanded in lambda2 around 0
Applied rewrites41.7%
if -15.5 < phi1 < -1.9000000000000001e-283 or 7.1999999999999997e-308 < phi1 < 2.34999999999999985e-263 or 9.49999999999999943e-216 < phi1 < 0.0155Initial program 64.9%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6449.7
Applied rewrites49.7%
Taylor expanded in phi1 around 0
Applied rewrites49.3%
if -1.9000000000000001e-283 < phi1 < 7.1999999999999997e-308Initial program 83.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6468.6
Applied rewrites68.6%
Taylor expanded in phi1 around 0
Applied rewrites68.6%
if 2.34999999999999985e-263 < phi1 < 9.49999999999999943e-216Initial program 74.5%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in phi1 around 0
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in lambda1 around 0
Applied rewrites53.0%
if 0.0155 < phi1 Initial program 74.5%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6456.1
Applied rewrites56.1%
Taylor expanded in lambda1 around 0
Applied rewrites27.9%
Applied rewrites22.3%
Taylor expanded in phi2 around 0
Applied rewrites22.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (acos (* (cos lambda1) (cos phi2))) R))
(t_1
(*
(acos (* (fma -0.5 (* phi1 phi1) 1.0) (cos (- lambda1 lambda2))))
R)))
(if (<= phi1 -15.5)
(* (acos (* (cos lambda1) (cos phi1))) R)
(if (<= phi1 -1.9e-283)
t_0
(if (<= phi1 7.2e-308)
t_1
(if (<= phi1 2.35e-263)
t_0
(if (<= phi1 3.6e-239)
t_1
(if (<= phi1 2.1e-16) t_0 (* (acos (cos phi1)) R)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos((cos(lambda1) * cos(phi2))) * R;
double t_1 = acos((fma(-0.5, (phi1 * phi1), 1.0) * cos((lambda1 - lambda2)))) * R;
double tmp;
if (phi1 <= -15.5) {
tmp = acos((cos(lambda1) * cos(phi1))) * R;
} else if (phi1 <= -1.9e-283) {
tmp = t_0;
} else if (phi1 <= 7.2e-308) {
tmp = t_1;
} else if (phi1 <= 2.35e-263) {
tmp = t_0;
} else if (phi1 <= 3.6e-239) {
tmp = t_1;
} else if (phi1 <= 2.1e-16) {
tmp = t_0;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(Float64(cos(lambda1) * cos(phi2))) * R) t_1 = Float64(acos(Float64(fma(-0.5, Float64(phi1 * phi1), 1.0) * cos(Float64(lambda1 - lambda2)))) * R) tmp = 0.0 if (phi1 <= -15.5) tmp = Float64(acos(Float64(cos(lambda1) * cos(phi1))) * R); elseif (phi1 <= -1.9e-283) tmp = t_0; elseif (phi1 <= 7.2e-308) tmp = t_1; elseif (phi1 <= 2.35e-263) tmp = t_0; elseif (phi1 <= 3.6e-239) tmp = t_1; elseif (phi1 <= 2.1e-16) tmp = t_0; else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi1, -15.5], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -1.9e-283], t$95$0, If[LessEqual[phi1, 7.2e-308], t$95$1, If[LessEqual[phi1, 2.35e-263], t$95$0, If[LessEqual[phi1, 3.6e-239], t$95$1, If[LessEqual[phi1, 2.1e-16], t$95$0, N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot R\\
t_1 := \cos^{-1} \left(\mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_1 \leq -15.5:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -1.9 \cdot 10^{-283}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 7.2 \cdot 10^{-308}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 2.35 \cdot 10^{-263}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 3.6 \cdot 10^{-239}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if phi1 < -15.5Initial program 84.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6447.0
Applied rewrites47.0%
Taylor expanded in lambda2 around 0
Applied rewrites41.7%
if -15.5 < phi1 < -1.9000000000000001e-283 or 7.1999999999999997e-308 < phi1 < 2.34999999999999985e-263 or 3.6000000000000001e-239 < phi1 < 2.1000000000000001e-16Initial program 65.2%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6448.6
Applied rewrites48.6%
Taylor expanded in phi1 around 0
Applied rewrites48.3%
if -1.9000000000000001e-283 < phi1 < 7.1999999999999997e-308 or 2.34999999999999985e-263 < phi1 < 3.6000000000000001e-239Initial program 72.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6454.1
Applied rewrites54.1%
Taylor expanded in phi1 around 0
Applied rewrites54.1%
if 2.1000000000000001e-16 < phi1 Initial program 75.2%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.4
Applied rewrites57.4%
Taylor expanded in lambda1 around 0
Applied rewrites27.4%
Applied rewrites22.0%
Taylor expanded in phi2 around 0
Applied rewrites21.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -15.5)
(* (acos (* t_0 (cos phi1))) R)
(if (<= phi1 1.55e-27)
(* (acos (* t_0 (cos phi2))) R)
(* (acos (cos phi1)) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -15.5) {
tmp = acos((t_0 * cos(phi1))) * R;
} else if (phi1 <= 1.55e-27) {
tmp = acos((t_0 * cos(phi2))) * R;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
if (phi1 <= (-15.5d0)) then
tmp = acos((t_0 * cos(phi1))) * r
else if (phi1 <= 1.55d-27) then
tmp = acos((t_0 * cos(phi2))) * r
else
tmp = acos(cos(phi1)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -15.5) {
tmp = Math.acos((t_0 * Math.cos(phi1))) * R;
} else if (phi1 <= 1.55e-27) {
tmp = Math.acos((t_0 * Math.cos(phi2))) * R;
} else {
tmp = Math.acos(Math.cos(phi1)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -15.5: tmp = math.acos((t_0 * math.cos(phi1))) * R elif phi1 <= 1.55e-27: tmp = math.acos((t_0 * math.cos(phi2))) * R else: tmp = math.acos(math.cos(phi1)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -15.5) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); elseif (phi1 <= 1.55e-27) tmp = Float64(acos(Float64(t_0 * cos(phi2))) * R); else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi1 <= -15.5) tmp = acos((t_0 * cos(phi1))) * R; elseif (phi1 <= 1.55e-27) tmp = acos((t_0 * cos(phi2))) * R; else tmp = acos(cos(phi1)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -15.5], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 1.55e-27], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -15.5:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 1.55 \cdot 10^{-27}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if phi1 < -15.5Initial program 84.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6447.0
Applied rewrites47.0%
if -15.5 < phi1 < 1.5499999999999999e-27Initial program 65.4%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6465.2
Applied rewrites65.2%
if 1.5499999999999999e-27 < phi1 Initial program 75.9%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.2
Applied rewrites57.2%
Taylor expanded in lambda1 around 0
Applied rewrites26.7%
Applied rewrites21.5%
Taylor expanded in phi2 around 0
Applied rewrites21.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -32500.0)
(* (acos (* (cos lambda2) (cos phi1))) R)
(if (<= phi1 2.6e-127)
(* (acos (* (fma -0.5 (* phi1 phi1) 1.0) (cos (- lambda1 lambda2)))) R)
(* (acos (cos phi1)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -32500.0) {
tmp = acos((cos(lambda2) * cos(phi1))) * R;
} else if (phi1 <= 2.6e-127) {
tmp = acos((fma(-0.5, (phi1 * phi1), 1.0) * cos((lambda1 - lambda2)))) * R;
} else {
tmp = acos(cos(phi1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -32500.0) tmp = Float64(acos(Float64(cos(lambda2) * cos(phi1))) * R); elseif (phi1 <= 2.6e-127) tmp = Float64(acos(Float64(fma(-0.5, Float64(phi1 * phi1), 1.0) * cos(Float64(lambda1 - lambda2)))) * R); else tmp = Float64(acos(cos(phi1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -32500.0], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 2.6e-127], N[(N[ArcCos[N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -32500:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 2.6 \cdot 10^{-127}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\end{array}
\end{array}
if phi1 < -32500Initial program 84.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6447.0
Applied rewrites47.0%
Taylor expanded in lambda1 around 0
Applied rewrites33.2%
if -32500 < phi1 < 2.59999999999999991e-127Initial program 66.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6438.7
Applied rewrites38.7%
Taylor expanded in phi1 around 0
Applied rewrites38.5%
if 2.59999999999999991e-127 < phi1 Initial program 72.1%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6455.0
Applied rewrites55.0%
Taylor expanded in lambda1 around 0
Applied rewrites25.6%
Applied rewrites21.6%
Taylor expanded in phi2 around 0
Applied rewrites17.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma -0.5 (* phi1 phi1) 1.0)) (t_1 (* (acos (cos phi1)) R)))
(if (<= phi1 -0.54)
t_1
(if (<= phi1 6.2e-284)
(* (acos (* t_0 (cos lambda1))) R)
(if (<= phi1 4.6e-235)
(* (acos (* t_0 (cos lambda2))) R)
(if (<= phi1 1.05e-114) (* (acos (cos phi2)) R) t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(-0.5, (phi1 * phi1), 1.0);
double t_1 = acos(cos(phi1)) * R;
double tmp;
if (phi1 <= -0.54) {
tmp = t_1;
} else if (phi1 <= 6.2e-284) {
tmp = acos((t_0 * cos(lambda1))) * R;
} else if (phi1 <= 4.6e-235) {
tmp = acos((t_0 * cos(lambda2))) * R;
} else if (phi1 <= 1.05e-114) {
tmp = acos(cos(phi2)) * R;
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(-0.5, Float64(phi1 * phi1), 1.0) t_1 = Float64(acos(cos(phi1)) * R) tmp = 0.0 if (phi1 <= -0.54) tmp = t_1; elseif (phi1 <= 6.2e-284) tmp = Float64(acos(Float64(t_0 * cos(lambda1))) * R); elseif (phi1 <= 4.6e-235) tmp = Float64(acos(Float64(t_0 * cos(lambda2))) * R); elseif (phi1 <= 1.05e-114) tmp = Float64(acos(cos(phi2)) * R); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi1, -0.54], t$95$1, If[LessEqual[phi1, 6.2e-284], N[(N[ArcCos[N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 4.6e-235], N[(N[ArcCos[N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 1.05e-114], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right)\\
t_1 := \cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{if}\;\phi_1 \leq -0.54:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 6.2 \cdot 10^{-284}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \lambda_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{-235}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \lambda_2\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 1.05 \cdot 10^{-114}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -0.54000000000000004 or 1.04999999999999996e-114 < phi1 Initial program 76.5%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6460.3
Applied rewrites60.3%
Taylor expanded in lambda1 around 0
Applied rewrites32.5%
Applied rewrites24.0%
Taylor expanded in phi2 around 0
Applied rewrites22.2%
if -0.54000000000000004 < phi1 < 6.1999999999999996e-284Initial program 69.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6439.9
Applied rewrites39.9%
Taylor expanded in phi1 around 0
Applied rewrites39.9%
Taylor expanded in lambda2 around 0
Applied rewrites31.7%
if 6.1999999999999996e-284 < phi1 < 4.59999999999999995e-235Initial program 61.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6443.9
Applied rewrites43.9%
Taylor expanded in phi1 around 0
Applied rewrites43.9%
Taylor expanded in lambda1 around 0
Applied rewrites23.9%
if 4.59999999999999995e-235 < phi1 < 1.04999999999999996e-114Initial program 65.5%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6444.9
Applied rewrites44.9%
Taylor expanded in lambda1 around 0
Applied rewrites26.9%
Applied rewrites26.9%
Taylor expanded in phi1 around 0
Applied rewrites26.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= phi1 -32500.0) (not (<= phi1 1.32e-129))) (* (acos (cos phi1)) R) (* (acos (* (fma -0.5 (* phi1 phi1) 1.0) (cos (- lambda1 lambda2)))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -32500.0) || !(phi1 <= 1.32e-129)) {
tmp = acos(cos(phi1)) * R;
} else {
tmp = acos((fma(-0.5, (phi1 * phi1), 1.0) * cos((lambda1 - lambda2)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -32500.0) || !(phi1 <= 1.32e-129)) tmp = Float64(acos(cos(phi1)) * R); else tmp = Float64(acos(Float64(fma(-0.5, Float64(phi1 * phi1), 1.0) * cos(Float64(lambda1 - lambda2)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -32500.0], N[Not[LessEqual[phi1, 1.32e-129]], $MachinePrecision]], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -32500 \lor \neg \left(\phi_1 \leq 1.32 \cdot 10^{-129}\right):\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -32500 or 1.31999999999999992e-129 < phi1 Initial program 77.1%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6461.0
Applied rewrites61.0%
Taylor expanded in lambda1 around 0
Applied rewrites32.8%
Applied rewrites24.3%
Taylor expanded in phi2 around 0
Applied rewrites22.0%
if -32500 < phi1 < 1.31999999999999992e-129Initial program 66.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6438.7
Applied rewrites38.7%
Taylor expanded in phi1 around 0
Applied rewrites38.5%
Final simplification28.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (acos (cos phi1)) R)))
(if (<= phi1 -0.54)
t_0
(if (<= phi1 3.15e-217)
(* (acos (* (fma -0.5 (* phi1 phi1) 1.0) (cos lambda1))) R)
(if (<= phi1 3.4e-36) (* (acos (cos phi2)) R) t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos(cos(phi1)) * R;
double tmp;
if (phi1 <= -0.54) {
tmp = t_0;
} else if (phi1 <= 3.15e-217) {
tmp = acos((fma(-0.5, (phi1 * phi1), 1.0) * cos(lambda1))) * R;
} else if (phi1 <= 3.4e-36) {
tmp = acos(cos(phi2)) * R;
} else {
tmp = t_0;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(cos(phi1)) * R) tmp = 0.0 if (phi1 <= -0.54) tmp = t_0; elseif (phi1 <= 3.15e-217) tmp = Float64(acos(Float64(fma(-0.5, Float64(phi1 * phi1), 1.0) * cos(lambda1))) * R); elseif (phi1 <= 3.4e-36) tmp = Float64(acos(cos(phi2)) * R); else tmp = t_0; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi1, -0.54], t$95$0, If[LessEqual[phi1, 3.15e-217], N[(N[ArcCos[N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 3.4e-36], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{if}\;\phi_1 \leq -0.54:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 3.15 \cdot 10^{-217}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right) \cdot \cos \lambda_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 3.4 \cdot 10^{-36}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -0.54000000000000004 or 3.4000000000000003e-36 < phi1 Initial program 79.1%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6462.7
Applied rewrites62.7%
Taylor expanded in lambda1 around 0
Applied rewrites34.2%
Applied rewrites24.6%
Taylor expanded in phi2 around 0
Applied rewrites24.2%
if -0.54000000000000004 < phi1 < 3.14999999999999999e-217Initial program 69.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
mul-1-negN/A
lower-cos.f64N/A
remove-double-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6439.9
Applied rewrites39.9%
Taylor expanded in phi1 around 0
Applied rewrites39.9%
Taylor expanded in lambda2 around 0
Applied rewrites30.5%
if 3.14999999999999999e-217 < phi1 < 3.4000000000000003e-36Initial program 58.1%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6443.2
Applied rewrites43.2%
Taylor expanded in lambda1 around 0
Applied rewrites21.6%
Applied rewrites21.6%
Taylor expanded in phi1 around 0
Applied rewrites21.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= phi1 -15.5) (not (<= phi1 3e-158))) (* (acos (cos phi1)) R) (* (acos (cos phi2)) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -15.5) || !(phi1 <= 3e-158)) {
tmp = acos(cos(phi1)) * R;
} else {
tmp = acos(cos(phi2)) * R;
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-15.5d0)) .or. (.not. (phi1 <= 3d-158))) then
tmp = acos(cos(phi1)) * r
else
tmp = acos(cos(phi2)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -15.5) || !(phi1 <= 3e-158)) {
tmp = Math.acos(Math.cos(phi1)) * R;
} else {
tmp = Math.acos(Math.cos(phi2)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -15.5) or not (phi1 <= 3e-158): tmp = math.acos(math.cos(phi1)) * R else: tmp = math.acos(math.cos(phi2)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -15.5) || !(phi1 <= 3e-158)) tmp = Float64(acos(cos(phi1)) * R); else tmp = Float64(acos(cos(phi2)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -15.5) || ~((phi1 <= 3e-158))) tmp = acos(cos(phi1)) * R; else tmp = acos(cos(phi2)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -15.5], N[Not[LessEqual[phi1, 3e-158]], $MachinePrecision]], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -15.5 \lor \neg \left(\phi_1 \leq 3 \cdot 10^{-158}\right):\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\end{array}
if phi1 < -15.5 or 3e-158 < phi1 Initial program 75.5%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6459.1
Applied rewrites59.1%
Taylor expanded in lambda1 around 0
Applied rewrites31.3%
Applied rewrites23.3%
Taylor expanded in phi2 around 0
Applied rewrites21.0%
if -15.5 < phi1 < 3e-158Initial program 68.5%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6450.8
Applied rewrites50.8%
Taylor expanded in lambda1 around 0
Applied rewrites23.4%
Applied rewrites23.0%
Taylor expanded in phi1 around 0
Applied rewrites22.8%
Final simplification21.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (cos (- phi2 phi1))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(cos((phi2 - phi1))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(cos((phi2 - phi1))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(Math.cos((phi2 - phi1))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(math.cos((phi2 - phi1))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(cos(Float64(phi2 - phi1))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(cos((phi2 - phi1))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \cos \left(\phi_2 - \phi_1\right) \cdot R
\end{array}
Initial program 73.0%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6456.1
Applied rewrites56.1%
Taylor expanded in lambda1 around 0
Applied rewrites28.5%
Applied rewrites23.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (cos phi1)) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(cos(phi1)) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(cos(phi1)) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(Math.cos(phi1)) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(math.cos(phi1)) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(cos(phi1)) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(cos(phi1)) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \cos \phi_1 \cdot R
\end{array}
Initial program 73.0%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6456.1
Applied rewrites56.1%
Taylor expanded in lambda1 around 0
Applied rewrites28.5%
Applied rewrites23.2%
Taylor expanded in phi2 around 0
Applied rewrites15.8%
herbie shell --seed 2024338
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Spherical law of cosines"
:precision binary64
(* (acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))) R))