
(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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 27 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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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
(let* ((t_0 (* (cos phi1) (cos phi2))))
(*
(acos
(fma
(sin phi1)
(sin phi2)
(fma
t_0
(* (cos lambda1) (cos lambda2))
(* t_0 (* (sin lambda1) (sin lambda2))))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
return acos(fma(sin(phi1), sin(phi2), fma(t_0, (cos(lambda1) * cos(lambda2)), (t_0 * (sin(lambda1) * sin(lambda2)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) return Float64(acos(fma(sin(phi1), sin(phi2), fma(t_0, Float64(cos(lambda1) * cos(lambda2)), Float64(t_0 * Float64(sin(lambda1) * sin(lambda2)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \mathsf{fma}\left(t\_0, \cos \lambda_1 \cdot \cos \lambda_2, t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)\right) \cdot R
\end{array}
\end{array}
Initial program 76.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6493.7
Applied rewrites93.7%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
distribute-lft-inN/A
lower-+.f64N/A
Applied rewrites93.7%
Applied rewrites93.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin 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) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))) * R;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) * cos(lambda2)) + (sin(lambda1) * sin(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) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(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) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2)))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $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 \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R
\end{array}
Initial program 76.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6493.7
Applied rewrites93.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(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[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $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 \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R
\end{array}
Initial program 76.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6493.7
Applied rewrites93.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -2e-7) (not (<= phi1 1e-7)))
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R)
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -2e-7) || !(phi1 <= 1e-7)) {
tmp = acos(fma(sin(phi2), sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
} else {
tmp = acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -2e-7) || !(phi1 <= 1e-7)) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R); else tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -2e-7], N[Not[LessEqual[phi1, 1e-7]], $MachinePrecision]], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -2 \cdot 10^{-7} \lor \neg \left(\phi_1 \leq 10^{-7}\right):\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -1.9999999999999999e-7 or 9.9999999999999995e-8 < phi1 Initial program 81.6%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.6%
if -1.9999999999999999e-7 < phi1 < 9.9999999999999995e-8Initial program 70.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6487.7
Applied rewrites87.7%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
sin-cos-mult-revN/A
lift-cos.f6487.7
Applied rewrites87.7%
Final simplification84.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -0.0017) (not (<= phi1 0.00022)))
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R)
(*
(acos
(+
(* phi1 (sin phi2))
(*
(* (fma (* phi1 phi1) -0.5 1.0) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -0.0017) || !(phi1 <= 0.00022)) {
tmp = acos(fma(sin(phi2), sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
} else {
tmp = acos(((phi1 * sin(phi2)) + ((fma((phi1 * phi1), -0.5, 1.0) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -0.0017) || !(phi1 <= 0.00022)) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R); else tmp = Float64(acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -0.0017], N[Not[LessEqual[phi1, 0.00022]], $MachinePrecision]], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.0017 \lor \neg \left(\phi_1 \leq 0.00022\right):\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -0.00169999999999999991 or 2.20000000000000008e-4 < phi1 Initial program 81.9%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.0%
if -0.00169999999999999991 < phi1 < 2.20000000000000008e-4Initial program 70.2%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6470.2
Applied rewrites70.2%
Taylor expanded in phi1 around 0
Applied rewrites70.0%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6487.7
Applied rewrites87.7%
Final simplification84.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -5.8e-11) (not (<= phi1 2.3e-9)))
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R)
(*
(acos
(fma
(cos lambda1)
(* (cos lambda2) (cos phi2))
(* (cos phi2) (* (sin lambda1) (sin lambda2)))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -5.8e-11) || !(phi1 <= 2.3e-9)) {
tmp = acos(fma(sin(phi2), sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
} else {
tmp = acos(fma(cos(lambda1), (cos(lambda2) * cos(phi2)), (cos(phi2) * (sin(lambda1) * sin(lambda2))))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -5.8e-11) || !(phi1 <= 2.3e-9)) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R); else tmp = Float64(acos(fma(cos(lambda1), Float64(cos(lambda2) * cos(phi2)), Float64(cos(phi2) * Float64(sin(lambda1) * sin(lambda2))))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -5.8e-11], N[Not[LessEqual[phi1, 2.3e-9]], $MachinePrecision]], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -5.8 \cdot 10^{-11} \lor \neg \left(\phi_1 \leq 2.3 \cdot 10^{-9}\right):\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2 \cdot \cos \phi_2, \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -5.8e-11 or 2.2999999999999999e-9 < phi1 Initial program 81.6%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.6%
if -5.8e-11 < phi1 < 2.2999999999999999e-9Initial program 70.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6487.7
Applied rewrites87.7%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
distribute-lft-inN/A
lower-+.f64N/A
Applied rewrites87.7%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6487.5
Applied rewrites87.5%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.3e-8) (not (<= phi2 3.8e-6)))
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R)
(*
(acos
(fma
(cos lambda1)
(* (cos lambda2) (cos phi1))
(* (cos phi1) (* (sin lambda1) (sin lambda2)))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.3e-8) || !(phi2 <= 3.8e-6)) {
tmp = acos(fma(sin(phi2), sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
} else {
tmp = acos(fma(cos(lambda1), (cos(lambda2) * cos(phi1)), (cos(phi1) * (sin(lambda1) * sin(lambda2))))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.3e-8) || !(phi2 <= 3.8e-6)) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R); else tmp = Float64(acos(fma(cos(lambda1), Float64(cos(lambda2) * cos(phi1)), Float64(cos(phi1) * Float64(sin(lambda1) * sin(lambda2))))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.3e-8], N[Not[LessEqual[phi2, 3.8e-6]], $MachinePrecision]], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.3 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 3.8 \cdot 10^{-6}\right):\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2 \cdot \cos \phi_1, \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -1.3000000000000001e-8 or 3.8e-6 < phi2 Initial program 81.3%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.3%
if -1.3000000000000001e-8 < phi2 < 3.8e-6Initial program 70.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6488.1
Applied rewrites88.1%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
distribute-lft-inN/A
lower-+.f64N/A
Applied rewrites88.1%
Taylor expanded in phi2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6487.8
Applied rewrites87.8%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda1 -0.00155) (not (<= lambda1 1.9e-8)))
(*
(acos
(fma (cos lambda1) (* (cos phi2) (cos phi1)) (* (sin phi2) (sin phi1))))
R)
(*
(acos
(fma (sin phi2) (sin phi1) (* (* (cos phi1) (cos phi2)) (cos lambda2))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -0.00155) || !(lambda1 <= 1.9e-8)) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), (sin(phi2) * sin(phi1)))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), ((cos(phi1) * cos(phi2)) * cos(lambda2)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -0.00155) || !(lambda1 <= 1.9e-8)) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), Float64(sin(phi2) * sin(phi1)))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -0.00155], N[Not[LessEqual[lambda1, 1.9e-8]], $MachinePrecision]], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.00155 \lor \neg \left(\lambda_1 \leq 1.9 \cdot 10^{-8}\right):\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -0.00154999999999999995 or 1.90000000000000014e-8 < lambda1 Initial program 64.0%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6464.1
Applied rewrites64.1%
if -0.00154999999999999995 < lambda1 < 1.90000000000000014e-8Initial program 88.1%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.1%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
associate-*r*N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f6487.9
Applied rewrites87.9%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (sin phi1))))
(if (or (<= lambda1 -0.00155) (not (<= lambda1 1.9e-8)))
(* (acos (fma (cos lambda1) (* (cos phi2) (cos phi1)) t_0)) R)
(* (acos (fma (* (cos lambda2) (cos phi2)) (cos phi1) t_0)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * sin(phi1);
double tmp;
if ((lambda1 <= -0.00155) || !(lambda1 <= 1.9e-8)) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), t_0)) * R;
} else {
tmp = acos(fma((cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -0.00155) || !(lambda1 <= 1.9e-8)) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), t_0)) * R); else tmp = Float64(acos(fma(Float64(cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.00155], N[Not[LessEqual[lambda1, 1.9e-8]], $MachinePrecision]], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -0.00155 \lor \neg \left(\lambda_1 \leq 1.9 \cdot 10^{-8}\right):\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, t\_0\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \phi_2, \cos \phi_1, t\_0\right)\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -0.00154999999999999995 or 1.90000000000000014e-8 < lambda1 Initial program 64.0%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6464.1
Applied rewrites64.1%
if -0.00154999999999999995 < lambda1 < 1.90000000000000014e-8Initial program 88.1%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6487.8
Applied rewrites87.8%
Final simplification76.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.5e-51) (not (<= phi2 8e+20)))
(*
(acos
(fma (cos lambda1) (* (cos phi2) (cos phi1)) (* (sin phi2) (sin phi1))))
R)
(*
(acos
(fma
phi2
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.5e-51) || !(phi2 <= 8e+20)) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), (sin(phi2) * sin(phi1)))) * R;
} else {
tmp = acos(fma(phi2, sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.5e-51) || !(phi2 <= 8e+20)) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), Float64(sin(phi2) * sin(phi1)))) * R); else tmp = Float64(acos(fma(phi2, sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.5e-51], N[Not[LessEqual[phi2, 8e+20]], $MachinePrecision]], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(phi2 * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.5 \cdot 10^{-51} \lor \neg \left(\phi_2 \leq 8 \cdot 10^{+20}\right):\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\phi_2, \sin \phi_1, \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -1.50000000000000001e-51 or 8e20 < phi2 Initial program 79.6%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6465.3
Applied rewrites65.3%
if -1.50000000000000001e-51 < phi2 < 8e20Initial program 72.6%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.6%
Taylor expanded in phi2 around 0
Applied rewrites70.9%
Final simplification68.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.00155)
(*
(acos
(fma (cos lambda1) (* (cos phi2) (cos phi1)) (* (sin phi2) (sin phi1))))
R)
(if (<= lambda1 1.9e-8)
(*
(acos
(fma (sin phi2) (sin phi1) (* (* (cos phi1) (cos phi2)) (cos lambda2))))
R)
(*
(acos
(fma (sin phi2) (sin phi1) (* (* (cos lambda1) (cos phi2)) (cos phi1))))
R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.00155) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), (sin(phi2) * sin(phi1)))) * R;
} else if (lambda1 <= 1.9e-8) {
tmp = acos(fma(sin(phi2), sin(phi1), ((cos(phi1) * cos(phi2)) * cos(lambda2)))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), ((cos(lambda1) * cos(phi2)) * cos(phi1)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.00155) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), Float64(sin(phi2) * sin(phi1)))) * R); elseif (lambda1 <= 1.9e-8) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2)))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(lambda1) * cos(phi2)) * cos(phi1)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.00155], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda1, 1.9e-8], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.00155:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq 1.9 \cdot 10^{-8}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -0.00154999999999999995Initial program 63.4%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6463.3
Applied rewrites63.3%
if -0.00154999999999999995 < lambda1 < 1.90000000000000014e-8Initial program 88.1%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.1%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
associate-*r*N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f6487.9
Applied rewrites87.9%
if 1.90000000000000014e-8 < lambda1 Initial program 64.5%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.6%
Taylor expanded in lambda1 around inf
Applied rewrites64.9%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(sin(phi2), sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R
\end{array}
Initial program 76.3%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -2.3)
(* (- (/ PI 2.0) (asin (* t_0 (cos phi1)))) R)
(if (<= phi1 3.55)
(*
(acos
(fma
(sin phi2)
(*
phi1
(fma
(* phi1 phi1)
(- (* 0.008333333333333333 (* phi1 phi1)) 0.16666666666666666)
1.0))
(* (* t_0 (cos phi2)) (cos phi1))))
R)
(*
(acos (fma 1.0 (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2))))
R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.3) {
tmp = ((((double) M_PI) / 2.0) - asin((t_0 * cos(phi1)))) * R;
} else if (phi1 <= 3.55) {
tmp = acos(fma(sin(phi2), (phi1 * fma((phi1 * phi1), ((0.008333333333333333 * (phi1 * phi1)) - 0.16666666666666666), 1.0)), ((t_0 * cos(phi2)) * cos(phi1)))) * R;
} else {
tmp = acos(fma(1.0, (cos(phi1) * cos(phi2)), (sin(phi1) * sin(phi2)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -2.3) tmp = Float64(Float64(Float64(pi / 2.0) - asin(Float64(t_0 * cos(phi1)))) * R); elseif (phi1 <= 3.55) tmp = Float64(acos(fma(sin(phi2), Float64(phi1 * fma(Float64(phi1 * phi1), Float64(Float64(0.008333333333333333 * Float64(phi1 * phi1)) - 0.16666666666666666), 1.0)), Float64(Float64(t_0 * cos(phi2)) * cos(phi1)))) * R); else tmp = Float64(acos(fma(1.0, Float64(cos(phi1) * cos(phi2)), Float64(sin(phi1) * sin(phi2)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.3], N[(N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 3.55], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[(phi1 * N[(N[(phi1 * phi1), $MachinePrecision] * N[(N[(0.008333333333333333 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(1.0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.3:\\
\;\;\;\;\left(\frac{\pi}{2} - \sin^{-1} \left(t\_0 \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 3.55:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \phi_1 \cdot \mathsf{fma}\left(\phi_1 \cdot \phi_1, 0.008333333333333333 \cdot \left(\phi_1 \cdot \phi_1\right) - 0.16666666666666666, 1\right), \left(t\_0 \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(1, \cos \phi_1 \cdot \cos \phi_2, \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -2.2999999999999998Initial program 83.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6453.3
Applied rewrites53.3%
lift-acos.f64N/A
acos-asinN/A
lift-/.f64N/A
lift-PI.f64N/A
lower--.f64N/A
lower-asin.f6453.3
Applied rewrites53.3%
if -2.2999999999999998 < phi1 < 3.5499999999999998Initial program 70.4%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6470.4
Applied rewrites70.4%
if 3.5499999999999998 < phi1 Initial program 80.3%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6465.4
Applied rewrites65.4%
Taylor expanded in lambda1 around 0
Applied rewrites46.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.12)
(* (- (/ PI 2.0) (asin (* t_0 (cos phi1)))) R)
(if (<= phi1 0.105)
(*
(acos
(fma
(sin phi2)
(sin phi1)
(*
(* t_0 (cos phi2))
(fma
(* phi1 phi1)
(- (* 0.041666666666666664 (* phi1 phi1)) 0.5)
1.0))))
R)
(*
(acos (fma 1.0 (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2))))
R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.12) {
tmp = ((((double) M_PI) / 2.0) - asin((t_0 * cos(phi1)))) * R;
} else if (phi1 <= 0.105) {
tmp = acos(fma(sin(phi2), sin(phi1), ((t_0 * cos(phi2)) * fma((phi1 * phi1), ((0.041666666666666664 * (phi1 * phi1)) - 0.5), 1.0)))) * R;
} else {
tmp = acos(fma(1.0, (cos(phi1) * cos(phi2)), (sin(phi1) * sin(phi2)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.12) tmp = Float64(Float64(Float64(pi / 2.0) - asin(Float64(t_0 * cos(phi1)))) * R); elseif (phi1 <= 0.105) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(t_0 * cos(phi2)) * fma(Float64(phi1 * phi1), Float64(Float64(0.041666666666666664 * Float64(phi1 * phi1)) - 0.5), 1.0)))) * R); else tmp = Float64(acos(fma(1.0, Float64(cos(phi1) * cos(phi2)), Float64(sin(phi1) * sin(phi2)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.12], N[(N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 0.105], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(phi1 * phi1), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(1.0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.12:\\
\;\;\;\;\left(\frac{\pi}{2} - \sin^{-1} \left(t\_0 \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 0.105:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(t\_0 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\phi_1 \cdot \phi_1, 0.041666666666666664 \cdot \left(\phi_1 \cdot \phi_1\right) - 0.5, 1\right)\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(1, \cos \phi_1 \cdot \cos \phi_2, \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -0.12Initial program 83.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6453.3
Applied rewrites53.3%
lift-acos.f64N/A
acos-asinN/A
lift-/.f64N/A
lift-PI.f64N/A
lower--.f64N/A
lower-asin.f6453.3
Applied rewrites53.3%
if -0.12 < phi1 < 0.104999999999999996Initial program 70.2%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.2%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6470.2
Applied rewrites70.2%
if 0.104999999999999996 < phi1 Initial program 80.6%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.7%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6465.8
Applied rewrites65.8%
Taylor expanded in lambda1 around 0
Applied rewrites45.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= phi1 -2.3)
(* (- (/ PI 2.0) (asin (* t_0 (cos phi1)))) R)
(if (<= phi1 3.55)
(*
(acos
(+
(* (* (fma (* phi1 phi1) -0.16666666666666666 1.0) phi1) (sin phi2))
(* t_1 t_0)))
R)
(* (acos (fma 1.0 t_1 (* (sin phi1) (sin phi2)))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (phi1 <= -2.3) {
tmp = ((((double) M_PI) / 2.0) - asin((t_0 * cos(phi1)))) * R;
} else if (phi1 <= 3.55) {
tmp = acos((((fma((phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * sin(phi2)) + (t_1 * t_0))) * R;
} else {
tmp = acos(fma(1.0, t_1, (sin(phi1) * sin(phi2)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -2.3) tmp = Float64(Float64(Float64(pi / 2.0) - asin(Float64(t_0 * cos(phi1)))) * R); elseif (phi1 <= 3.55) tmp = Float64(acos(Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * sin(phi2)) + Float64(t_1 * t_0))) * R); else tmp = Float64(acos(fma(1.0, t_1, Float64(sin(phi1) * sin(phi2)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.3], N[(N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 3.55], N[(N[ArcCos[N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi1), $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(1.0 * t$95$1 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -2.3:\\
\;\;\;\;\left(\frac{\pi}{2} - \sin^{-1} \left(t\_0 \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 3.55:\\
\;\;\;\;\cos^{-1} \left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot \phi_1\right) \cdot \sin \phi_2 + t\_1 \cdot t\_0\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(1, t\_1, \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -2.2999999999999998Initial program 83.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6453.3
Applied rewrites53.3%
lift-acos.f64N/A
acos-asinN/A
lift-/.f64N/A
lift-PI.f64N/A
lower--.f64N/A
lower-asin.f6453.3
Applied rewrites53.3%
if -2.2999999999999998 < phi1 < 3.5499999999999998Initial program 70.4%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6470.4
Applied rewrites70.4%
if 3.5499999999999998 < phi1 Initial program 80.3%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6465.4
Applied rewrites65.4%
Taylor expanded in lambda1 around 0
Applied rewrites46.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -2.3)
(* (- (/ PI 2.0) (asin (* t_0 (cos phi1)))) R)
(if (<= phi1 3.55)
(*
(acos
(fma
(sin phi2)
(* phi1 (fma -0.16666666666666666 (* phi1 phi1) 1.0))
(* (* t_0 (cos phi2)) (cos phi1))))
R)
(*
(acos (fma 1.0 (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2))))
R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.3) {
tmp = ((((double) M_PI) / 2.0) - asin((t_0 * cos(phi1)))) * R;
} else if (phi1 <= 3.55) {
tmp = acos(fma(sin(phi2), (phi1 * fma(-0.16666666666666666, (phi1 * phi1), 1.0)), ((t_0 * cos(phi2)) * cos(phi1)))) * R;
} else {
tmp = acos(fma(1.0, (cos(phi1) * cos(phi2)), (sin(phi1) * sin(phi2)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -2.3) tmp = Float64(Float64(Float64(pi / 2.0) - asin(Float64(t_0 * cos(phi1)))) * R); elseif (phi1 <= 3.55) tmp = Float64(acos(fma(sin(phi2), Float64(phi1 * fma(-0.16666666666666666, Float64(phi1 * phi1), 1.0)), Float64(Float64(t_0 * cos(phi2)) * cos(phi1)))) * R); else tmp = Float64(acos(fma(1.0, Float64(cos(phi1) * cos(phi2)), Float64(sin(phi1) * sin(phi2)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.3], N[(N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 3.55], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[(phi1 * N[(-0.16666666666666666 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(1.0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.3:\\
\;\;\;\;\left(\frac{\pi}{2} - \sin^{-1} \left(t\_0 \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 3.55:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \phi_1 \cdot \mathsf{fma}\left(-0.16666666666666666, \phi_1 \cdot \phi_1, 1\right), \left(t\_0 \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(1, \cos \phi_1 \cdot \cos \phi_2, \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -2.2999999999999998Initial program 83.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6453.3
Applied rewrites53.3%
lift-acos.f64N/A
acos-asinN/A
lift-/.f64N/A
lift-PI.f64N/A
lower--.f64N/A
lower-asin.f6453.3
Applied rewrites53.3%
if -2.2999999999999998 < phi1 < 3.5499999999999998Initial program 70.4%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6470.4
Applied rewrites70.4%
if 3.5499999999999998 < phi1 Initial program 80.3%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6465.4
Applied rewrites65.4%
Taylor expanded in lambda1 around 0
Applied rewrites46.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -8e-5)
(* (acos (fma 1.0 (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2)))) R)
(if (<= phi2 8e-6)
(* (acos (* t_0 (cos phi1))) R)
(* (acos (* t_0 (cos phi2))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -8e-5) {
tmp = acos(fma(1.0, (cos(phi1) * cos(phi2)), (sin(phi1) * sin(phi2)))) * R;
} else if (phi2 <= 8e-6) {
tmp = acos((t_0 * cos(phi1))) * R;
} else {
tmp = acos((t_0 * cos(phi2))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -8e-5) tmp = Float64(acos(fma(1.0, Float64(cos(phi1) * cos(phi2)), Float64(sin(phi1) * sin(phi2)))) * R); elseif (phi2 <= 8e-6) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); else tmp = Float64(acos(Float64(t_0 * cos(phi2))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -8e-5], N[(N[ArcCos[N[(1.0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 8e-6], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -8 \cdot 10^{-5}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(1, \cos \phi_1 \cdot \cos \phi_2, \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 8 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -8.00000000000000065e-5Initial program 83.0%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.0%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6467.9
Applied rewrites67.9%
Taylor expanded in lambda1 around 0
Applied rewrites46.7%
if -8.00000000000000065e-5 < phi2 < 7.99999999999999964e-6Initial program 70.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6470.9
Applied rewrites70.9%
if 7.99999999999999964e-6 < phi2 Initial program 79.2%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6452.0
Applied rewrites52.0%
Final simplification59.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 0.0002)
(* (acos (fma (sin phi2) (sin phi1) (* t_0 (cos phi1)))) R)
(* (acos (* t_0 (cos phi2))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.0002) {
tmp = acos(fma(sin(phi2), sin(phi1), (t_0 * cos(phi1)))) * R;
} else {
tmp = acos((t_0 * cos(phi2))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.0002) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(t_0 * cos(phi1)))) * R); else tmp = Float64(acos(Float64(t_0 * cos(phi2))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.0002], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 0.0002:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, t\_0 \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 2.0000000000000001e-4Initial program 75.4%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6450.6
Applied rewrites50.6%
if 2.0000000000000001e-4 < phi2 Initial program 79.2%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6452.0
Applied rewrites52.0%
Final simplification50.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -0.00155) (not (<= lambda1 1.85e-8))) (* (acos (* (cos lambda1) (cos phi1))) R) (* (acos (* (cos phi1) (cos lambda2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -0.00155) || !(lambda1 <= 1.85e-8)) {
tmp = acos((cos(lambda1) * cos(phi1))) * R;
} else {
tmp = acos((cos(phi1) * cos(lambda2))) * R;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda1 <= (-0.00155d0)) .or. (.not. (lambda1 <= 1.85d-8))) then
tmp = acos((cos(lambda1) * cos(phi1))) * r
else
tmp = acos((cos(phi1) * cos(lambda2))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -0.00155) || !(lambda1 <= 1.85e-8)) {
tmp = Math.acos((Math.cos(lambda1) * Math.cos(phi1))) * R;
} else {
tmp = Math.acos((Math.cos(phi1) * Math.cos(lambda2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -0.00155) or not (lambda1 <= 1.85e-8): tmp = math.acos((math.cos(lambda1) * math.cos(phi1))) * R else: tmp = math.acos((math.cos(phi1) * math.cos(lambda2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -0.00155) || !(lambda1 <= 1.85e-8)) tmp = Float64(acos(Float64(cos(lambda1) * cos(phi1))) * R); else tmp = Float64(acos(Float64(cos(phi1) * cos(lambda2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -0.00155) || ~((lambda1 <= 1.85e-8))) tmp = acos((cos(lambda1) * cos(phi1))) * R; else tmp = acos((cos(phi1) * cos(lambda2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -0.00155], N[Not[LessEqual[lambda1, 1.85e-8]], $MachinePrecision]], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.00155 \lor \neg \left(\lambda_1 \leq 1.85 \cdot 10^{-8}\right):\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -0.00154999999999999995 or 1.85e-8 < lambda1 Initial program 64.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.6
Applied rewrites42.6%
Taylor expanded in lambda1 around inf
Applied rewrites42.5%
if -0.00154999999999999995 < lambda1 < 1.85e-8Initial program 88.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6444.3
Applied rewrites44.3%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6444.1
Applied rewrites44.1%
Final simplification43.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 8e-6)
(* (acos (* t_0 (cos phi1))) R)
(* (acos (* t_0 (cos phi2))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 8e-6) {
tmp = acos((t_0 * cos(phi1))) * R;
} else {
tmp = acos((t_0 * cos(phi2))) * R;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (phi2 <= 8d-6) then
tmp = acos((t_0 * cos(phi1))) * r
else
tmp = acos((t_0 * cos(phi2))) * 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((lambda1 - lambda2));
double tmp;
if (phi2 <= 8e-6) {
tmp = Math.acos((t_0 * Math.cos(phi1))) * R;
} else {
tmp = Math.acos((t_0 * Math.cos(phi2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 8e-6: tmp = math.acos((t_0 * math.cos(phi1))) * R else: tmp = math.acos((t_0 * math.cos(phi2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 8e-6) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); else tmp = Float64(acos(Float64(t_0 * cos(phi2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 8e-6) tmp = acos((t_0 * cos(phi1))) * R; else tmp = acos((t_0 * cos(phi2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 8e-6], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 8 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 7.99999999999999964e-6Initial program 75.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6451.2
Applied rewrites51.2%
if 7.99999999999999964e-6 < phi2 Initial program 79.2%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6452.0
Applied rewrites52.0%
Final simplification51.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 7.2e-12) (* (acos (* (cos (- lambda1 lambda2)) (cos phi1))) R) (* (acos (* (cos lambda1) (cos phi2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 7.2e-12) {
tmp = acos((cos((lambda1 - lambda2)) * cos(phi1))) * R;
} else {
tmp = acos((cos(lambda1) * cos(phi2))) * R;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 7.2d-12) then
tmp = acos((cos((lambda1 - lambda2)) * cos(phi1))) * r
else
tmp = acos((cos(lambda1) * 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 (phi2 <= 7.2e-12) {
tmp = Math.acos((Math.cos((lambda1 - lambda2)) * Math.cos(phi1))) * R;
} else {
tmp = Math.acos((Math.cos(lambda1) * Math.cos(phi2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 7.2e-12: tmp = math.acos((math.cos((lambda1 - lambda2)) * math.cos(phi1))) * R else: tmp = math.acos((math.cos(lambda1) * math.cos(phi2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 7.2e-12) tmp = Float64(acos(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi1))) * R); else tmp = Float64(acos(Float64(cos(lambda1) * cos(phi2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 7.2e-12) tmp = acos((cos((lambda1 - lambda2)) * cos(phi1))) * R; else tmp = acos((cos(lambda1) * cos(phi2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 7.2e-12], N[(N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 7.2 \cdot 10^{-12}:\\
\;\;\;\;\cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 7.2e-12Initial program 75.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6451.1
Applied rewrites51.1%
if 7.2e-12 < phi2 Initial program 78.6%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.7%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6460.3
Applied rewrites60.3%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6441.4
Applied rewrites41.4%
Final simplification48.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (cos (- lambda1 lambda2)))) (if (<= t_0 0.9999) (* (acos t_0) R) (* (acos (cos (- phi1 phi2))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (t_0 <= 0.9999) {
tmp = acos(t_0) * R;
} else {
tmp = acos(cos((phi1 - phi2))) * R;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (t_0 <= 0.9999d0) then
tmp = acos(t_0) * r
else
tmp = acos(cos((phi1 - phi2))) * 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((lambda1 - lambda2));
double tmp;
if (t_0 <= 0.9999) {
tmp = Math.acos(t_0) * R;
} else {
tmp = Math.acos(Math.cos((phi1 - phi2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if t_0 <= 0.9999: tmp = math.acos(t_0) * R else: tmp = math.acos(math.cos((phi1 - phi2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (t_0 <= 0.9999) tmp = Float64(acos(t_0) * R); else tmp = Float64(acos(cos(Float64(phi1 - phi2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (t_0 <= 0.9999) tmp = acos(t_0) * R; else tmp = acos(cos((phi1 - phi2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.9999], N[(N[ArcCos[t$95$0], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;t\_0 \leq 0.9999:\\
\;\;\;\;\cos^{-1} t\_0 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \left(\phi_1 - \phi_2\right) \cdot R\\
\end{array}
\end{array}
if (cos.f64 (-.f64 lambda1 lambda2)) < 0.99990000000000001Initial program 74.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6446.8
Applied rewrites46.8%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f6431.6
Applied rewrites31.6%
if 0.99990000000000001 < (cos.f64 (-.f64 lambda1 lambda2)) Initial program 81.6%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.7%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6480.9
Applied rewrites80.9%
Taylor expanded in lambda1 around 0
cos-diff-revN/A
lower-cos.f64N/A
lower--.f6453.0
Applied rewrites53.0%
Final simplification38.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -255000000000.0) (* (acos (* (cos phi1) (cos lambda2))) R) (* (acos (* (cos lambda1) (cos phi2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -255000000000.0) {
tmp = acos((cos(phi1) * cos(lambda2))) * R;
} else {
tmp = acos((cos(lambda1) * cos(phi2))) * R;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 <= (-255000000000.0d0)) then
tmp = acos((cos(phi1) * cos(lambda2))) * r
else
tmp = acos((cos(lambda1) * 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 <= -255000000000.0) {
tmp = Math.acos((Math.cos(phi1) * Math.cos(lambda2))) * R;
} else {
tmp = Math.acos((Math.cos(lambda1) * Math.cos(phi2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -255000000000.0: tmp = math.acos((math.cos(phi1) * math.cos(lambda2))) * R else: tmp = math.acos((math.cos(lambda1) * math.cos(phi2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -255000000000.0) tmp = Float64(acos(Float64(cos(phi1) * cos(lambda2))) * R); else tmp = Float64(acos(Float64(cos(lambda1) * cos(phi2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -255000000000.0) tmp = acos((cos(phi1) * cos(lambda2))) * R; else tmp = acos((cos(lambda1) * cos(phi2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -255000000000.0], N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -255000000000:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -2.55e11Initial program 84.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6455.3
Applied rewrites55.3%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6443.8
Applied rewrites43.8%
if -2.55e11 < phi1 Initial program 74.1%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.1%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6456.2
Applied rewrites56.2%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6436.4
Applied rewrites36.4%
Final simplification38.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -0.00175) (not (<= lambda1 1.26e-8))) (* (acos (cos lambda1)) R) (* (acos (cos lambda2)) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -0.00175) || !(lambda1 <= 1.26e-8)) {
tmp = acos(cos(lambda1)) * R;
} else {
tmp = acos(cos(lambda2)) * R;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda1 <= (-0.00175d0)) .or. (.not. (lambda1 <= 1.26d-8))) then
tmp = acos(cos(lambda1)) * r
else
tmp = acos(cos(lambda2)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -0.00175) || !(lambda1 <= 1.26e-8)) {
tmp = Math.acos(Math.cos(lambda1)) * R;
} else {
tmp = Math.acos(Math.cos(lambda2)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -0.00175) or not (lambda1 <= 1.26e-8): tmp = math.acos(math.cos(lambda1)) * R else: tmp = math.acos(math.cos(lambda2)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -0.00175) || !(lambda1 <= 1.26e-8)) tmp = Float64(acos(cos(lambda1)) * R); else tmp = Float64(acos(cos(lambda2)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -0.00175) || ~((lambda1 <= 1.26e-8))) tmp = acos(cos(lambda1)) * R; else tmp = acos(cos(lambda2)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -0.00175], N[Not[LessEqual[lambda1, 1.26e-8]], $MachinePrecision]], N[(N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.00175 \lor \neg \left(\lambda_1 \leq 1.26 \cdot 10^{-8}\right):\\
\;\;\;\;\cos^{-1} \cos \lambda_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \lambda_2 \cdot R\\
\end{array}
\end{array}
if lambda1 < -0.00175000000000000004 or 1.26e-8 < lambda1 Initial program 64.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.6
Applied rewrites42.6%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f6429.9
Applied rewrites29.9%
Taylor expanded in lambda1 around inf
Applied rewrites29.9%
if -0.00175000000000000004 < lambda1 < 1.26e-8Initial program 88.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6444.3
Applied rewrites44.3%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f6419.5
Applied rewrites19.5%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6419.5
Applied rewrites19.5%
Final simplification24.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (cos (- lambda1 lambda2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(cos((lambda1 - lambda2))) * R;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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((lambda1 - lambda2))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(Math.cos((lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(math.cos((lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(cos(Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(cos((lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \cos \left(\lambda_1 - \lambda_2\right) \cdot R
\end{array}
Initial program 76.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6443.5
Applied rewrites43.5%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f6424.6
Applied rewrites24.6%
Final simplification24.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (cos lambda2)) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(cos(lambda2)) * R;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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(lambda2)) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(Math.cos(lambda2)) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(math.cos(lambda2)) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(cos(lambda2)) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(cos(lambda2)) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \cos \lambda_2 \cdot R
\end{array}
Initial program 76.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6443.5
Applied rewrites43.5%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f6424.6
Applied rewrites24.6%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6415.1
Applied rewrites15.1%
Final simplification15.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos 1.0) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(1.0) * R;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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(1.0d0) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(1.0) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(1.0) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(1.0) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(1.0) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[1.0], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} 1 \cdot R
\end{array}
Initial program 76.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6443.5
Applied rewrites43.5%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f6424.6
Applied rewrites24.6%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6415.1
Applied rewrites15.1%
Taylor expanded in lambda2 around 0
Applied rewrites4.8%
Final simplification4.8%
herbie shell --seed 2025080
(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))