
(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}
Herbie found 32 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
(*
(acos
(fma
(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(fma(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(fma(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[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $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(\mathsf{fma}\left(\sin \phi_1, \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)\right) \cdot R
\end{array}
Initial program 73.8%
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.f6494.1
Applied rewrites94.1%
Applied rewrites94.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(cos phi1)
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))
(* (sin phi1) (sin phi2))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(cos(phi1), (cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))), (sin(phi1) * sin(phi2)))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(cos(phi1), Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))), Float64(sin(phi1) * sin(phi2)))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right), \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R
\end{array}
Initial program 73.8%
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.f6494.1
Applied rewrites94.1%
Taylor expanded in lambda1 around inf
lower-fma.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6494.1
Applied rewrites94.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(acos
(fma
(cos lambda1)
(* (cos phi2) (cos phi1))
(* (sin phi2) (sin phi1))))
R))
(t_1
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))
(if (<= lambda1 -1.2e+111)
(* (acos (* (cos phi2) t_1)) R)
(if (<= lambda1 -1.02e-5)
t_0
(if (<= lambda1 8.5e-29)
(*
(acos
(fma
(sin phi1)
(sin phi2)
(* (* (cos phi1) (cos phi2)) (cos lambda2))))
R)
(if (<= lambda1 1.8e+153) t_0 (* (acos (* (cos phi1) t_1)) R)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), (sin(phi2) * sin(phi1)))) * R;
double t_1 = fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)));
double tmp;
if (lambda1 <= -1.2e+111) {
tmp = acos((cos(phi2) * t_1)) * R;
} else if (lambda1 <= -1.02e-5) {
tmp = t_0;
} else if (lambda1 <= 8.5e-29) {
tmp = acos(fma(sin(phi1), sin(phi2), ((cos(phi1) * cos(phi2)) * cos(lambda2)))) * R;
} else if (lambda1 <= 1.8e+153) {
tmp = t_0;
} else {
tmp = acos((cos(phi1) * t_1)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), Float64(sin(phi2) * sin(phi1)))) * R) t_1 = fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))) tmp = 0.0 if (lambda1 <= -1.2e+111) tmp = Float64(acos(Float64(cos(phi2) * t_1)) * R); elseif (lambda1 <= -1.02e-5) tmp = t_0; elseif (lambda1 <= 8.5e-29) tmp = Float64(acos(fma(sin(phi1), sin(phi2), Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2)))) * R); elseif (lambda1 <= 1.8e+153) tmp = t_0; else tmp = Float64(acos(Float64(cos(phi1) * t_1)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.2e+111], N[(N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda1, -1.02e-5], t$95$0, If[LessEqual[lambda1, 8.5e-29], N[(N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda1, 1.8e+153], t$95$0, N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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\\
t_1 := \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -1.2 \cdot 10^{+111}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_2 \cdot t\_1\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq -1.02 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 8.5 \cdot 10^{-29}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq 1.8 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot t\_1\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -1.20000000000000003e111Initial program 59.0%
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.f6499.2
Applied rewrites99.2%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6460.5
Applied rewrites60.5%
if -1.20000000000000003e111 < lambda1 < -1.0200000000000001e-5 or 8.5000000000000001e-29 < lambda1 < 1.8e153Initial program 61.1%
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.f6457.7
Applied rewrites57.7%
if -1.0200000000000001e-5 < lambda1 < 8.5000000000000001e-29Initial program 88.7%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6488.7
Applied rewrites88.7%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f6488.7
Applied rewrites88.7%
if 1.8e153 < lambda1 Initial program 60.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.f6499.2
Applied rewrites99.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6458.8
Applied rewrites58.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))
(t_1 (* (sin phi2) (sin phi1)))
(t_2 (* (acos (fma (cos lambda1) (* (cos phi2) (cos phi1)) t_1)) R)))
(if (<= lambda1 -1.2e+111)
(* (acos (* (cos phi2) t_0)) R)
(if (<= lambda1 -1.02e-5)
t_2
(if (<= lambda1 9e-12)
(* (acos (fma (* (cos lambda2) (cos phi2)) (cos phi1) t_1)) R)
(if (<= lambda1 1.8e+153) t_2 (* (acos (* (cos phi1) t_0)) R)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)));
double t_1 = sin(phi2) * sin(phi1);
double t_2 = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), t_1)) * R;
double tmp;
if (lambda1 <= -1.2e+111) {
tmp = acos((cos(phi2) * t_0)) * R;
} else if (lambda1 <= -1.02e-5) {
tmp = t_2;
} else if (lambda1 <= 9e-12) {
tmp = acos(fma((cos(lambda2) * cos(phi2)), cos(phi1), t_1)) * R;
} else if (lambda1 <= 1.8e+153) {
tmp = t_2;
} else {
tmp = acos((cos(phi1) * t_0)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))) t_1 = Float64(sin(phi2) * sin(phi1)) t_2 = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), t_1)) * R) tmp = 0.0 if (lambda1 <= -1.2e+111) tmp = Float64(acos(Float64(cos(phi2) * t_0)) * R); elseif (lambda1 <= -1.02e-5) tmp = t_2; elseif (lambda1 <= 9e-12) tmp = Float64(acos(fma(Float64(cos(lambda2) * cos(phi2)), cos(phi1), t_1)) * R); elseif (lambda1 <= 1.8e+153) tmp = t_2; else tmp = Float64(acos(Float64(cos(phi1) * t_0)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[lambda1, -1.2e+111], N[(N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda1, -1.02e-5], t$95$2, If[LessEqual[lambda1, 9e-12], N[(N[ArcCos[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda1, 1.8e+153], t$95$2, N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\\
t_1 := \sin \phi_2 \cdot \sin \phi_1\\
t_2 := \cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, t\_1\right)\right) \cdot R\\
\mathbf{if}\;\lambda_1 \leq -1.2 \cdot 10^{+111}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_2 \cdot t\_0\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq -1.02 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-12}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \phi_2, \cos \phi_1, t\_1\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq 1.8 \cdot 10^{+153}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot t\_0\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -1.20000000000000003e111Initial program 59.0%
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.f6499.2
Applied rewrites99.2%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6460.5
Applied rewrites60.5%
if -1.20000000000000003e111 < lambda1 < -1.0200000000000001e-5 or 8.99999999999999962e-12 < lambda1 < 1.8e153Initial program 59.9%
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.f6458.7
Applied rewrites58.7%
if -1.0200000000000001e-5 < lambda1 < 8.99999999999999962e-12Initial program 88.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6488.5
Applied rewrites88.5%
if 1.8e153 < lambda1 Initial program 60.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.f6499.2
Applied rewrites99.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6458.8
Applied rewrites58.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (sin phi1)))
(t_1 (* (acos (fma (cos lambda1) (* (cos phi2) (cos phi1)) t_0)) R)))
(if (<= lambda1 -1.02e-5)
t_1
(if (<= lambda1 9e-12)
(* (acos (fma (* (cos lambda2) (cos phi2)) (cos phi1) t_0)) R)
(if (<= lambda1 1.8e+153)
t_1
(*
(acos
(*
(cos phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))
R))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * sin(phi1);
double t_1 = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), t_0)) * R;
double tmp;
if (lambda1 <= -1.02e-5) {
tmp = t_1;
} else if (lambda1 <= 9e-12) {
tmp = acos(fma((cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R;
} else if (lambda1 <= 1.8e+153) {
tmp = t_1;
} else {
tmp = acos((cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * sin(phi1)) t_1 = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), t_0)) * R) tmp = 0.0 if (lambda1 <= -1.02e-5) tmp = t_1; elseif (lambda1 <= 9e-12) tmp = Float64(acos(fma(Float64(cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R); elseif (lambda1 <= 1.8e+153) tmp = t_1; else tmp = Float64(acos(Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))) * 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]}, Block[{t$95$1 = 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]}, If[LessEqual[lambda1, -1.02e-5], t$95$1, If[LessEqual[lambda1, 9e-12], 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], If[LessEqual[lambda1, 1.8e+153], t$95$1, N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \sin \phi_1\\
t_1 := \cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, t\_0\right)\right) \cdot R\\
\mathbf{if}\;\lambda_1 \leq -1.02 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-12}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \phi_2, \cos \phi_1, t\_0\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq 1.8 \cdot 10^{+153}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \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 lambda1 < -1.0200000000000001e-5 or 8.99999999999999962e-12 < lambda1 < 1.8e153Initial program 59.5%
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.f6458.8
Applied rewrites58.8%
if -1.0200000000000001e-5 < lambda1 < 8.99999999999999962e-12Initial program 88.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6488.5
Applied rewrites88.5%
if 1.8e153 < lambda1 Initial program 60.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.f6499.2
Applied rewrites99.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6458.8
Applied rewrites58.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -7e-9)
(*
(acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0)))
R)
(if (<= phi2 9.5e-14)
(*
(acos
(*
(cos phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))
R)
(*
(acos (fma (sin phi2) (sin phi1) (* (* t_0 (cos phi2)) (cos phi1))))
R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -7e-9) {
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0))) * R;
} else if (phi2 <= 9.5e-14) {
tmp = acos((cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), ((t_0 * cos(phi2)) * cos(phi1)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -7e-9) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) * R); elseif (phi2 <= 9.5e-14) tmp = Float64(acos(Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(t_0 * cos(phi2)) * cos(phi1)))) * 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, -7e-9], 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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 9.5e-14], N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $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 -7 \cdot 10^{-9}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 9.5 \cdot 10^{-14}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(t\_0 \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -6.9999999999999998e-9Initial program 79.8%
if -6.9999999999999998e-9 < phi2 < 9.4999999999999999e-14Initial program 68.5%
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.9
Applied rewrites88.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6488.7
Applied rewrites88.7%
if 9.4999999999999999e-14 < phi2 Initial program 77.7%
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 rewrites77.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -7e-9)
(* (acos (fma (* (cos phi2) (cos phi1)) t_0 (* (sin phi2) (sin phi1)))) R)
(if (<= phi2 9.5e-14)
(*
(acos
(*
(cos phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))
R)
(*
(acos (fma (sin phi2) (sin phi1) (* (* t_0 (cos phi2)) (cos phi1))))
R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -7e-9) {
tmp = acos(fma((cos(phi2) * cos(phi1)), t_0, (sin(phi2) * sin(phi1)))) * R;
} else if (phi2 <= 9.5e-14) {
tmp = acos((cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), ((t_0 * cos(phi2)) * cos(phi1)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -7e-9) tmp = Float64(acos(fma(Float64(cos(phi2) * cos(phi1)), t_0, Float64(sin(phi2) * sin(phi1)))) * R); elseif (phi2 <= 9.5e-14) tmp = Float64(acos(Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(t_0 * cos(phi2)) * cos(phi1)))) * 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, -7e-9], N[(N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0 + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 9.5e-14], N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $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 -7 \cdot 10^{-9}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, t\_0, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 9.5 \cdot 10^{-14}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(t\_0 \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -6.9999999999999998e-9Initial program 79.8%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6479.8
Applied rewrites79.8%
if -6.9999999999999998e-9 < phi2 < 9.4999999999999999e-14Initial program 68.5%
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.9
Applied rewrites88.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6488.7
Applied rewrites88.7%
if 9.4999999999999999e-14 < phi2 Initial program 77.7%
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 rewrites77.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R)))
(if (<= phi2 -7e-9)
t_0
(if (<= phi2 9.5e-14)
(*
(acos
(*
(cos phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))
R)
t_0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos(fma(sin(phi2), sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
double tmp;
if (phi2 <= -7e-9) {
tmp = t_0;
} else if (phi2 <= 9.5e-14) {
tmp = acos((cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))) * R;
} else {
tmp = t_0;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R) tmp = 0.0 if (phi2 <= -7e-9) tmp = t_0; elseif (phi2 <= 9.5e-14) tmp = Float64(acos(Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))) * R); else tmp = t_0; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, -7e-9], t$95$0, If[LessEqual[phi2, 9.5e-14], N[(N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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{if}\;\phi_2 \leq -7 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 9.5 \cdot 10^{-14}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -6.9999999999999998e-9 or 9.4999999999999999e-14 < phi2 Initial program 78.8%
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.8%
if -6.9999999999999998e-9 < phi2 < 9.4999999999999999e-14Initial program 68.5%
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.9
Applied rewrites88.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6488.7
Applied rewrites88.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (sin phi1)))
(t_1 (* (acos (fma (* (cos lambda2) (cos phi2)) (cos phi1) t_0)) R)))
(if (<= lambda2 -1.16e-6)
t_1
(if (<= lambda2 3.5e-6)
(* (acos (fma (cos lambda1) (* (cos phi2) (cos phi1)) t_0)) R)
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * sin(phi1);
double t_1 = acos(fma((cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R;
double tmp;
if (lambda2 <= -1.16e-6) {
tmp = t_1;
} else if (lambda2 <= 3.5e-6) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), t_0)) * R;
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * sin(phi1)) t_1 = Float64(acos(fma(Float64(cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R) tmp = 0.0 if (lambda2 <= -1.16e-6) tmp = t_1; elseif (lambda2 <= 3.5e-6) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), t_0)) * R); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[lambda2, -1.16e-6], t$95$1, If[LessEqual[lambda2, 3.5e-6], 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], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \sin \phi_1\\
t_1 := \cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \phi_2, \cos \phi_1, t\_0\right)\right) \cdot R\\
\mathbf{if}\;\lambda_2 \leq -1.16 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 3.5 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, t\_0\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -1.1599999999999999e-6 or 3.49999999999999995e-6 < lambda2 Initial program 59.2%
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.f6458.8
Applied rewrites58.8%
if -1.1599999999999999e-6 < lambda2 < 3.49999999999999995e-6Initial program 88.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.f6488.6
Applied rewrites88.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(acos
(fma
(cos lambda1)
(* (cos phi2) (cos phi1))
(* (sin phi2) (sin phi1))))
R)))
(if (<= phi2 -0.045)
t_0
(if (<= phi2 1.85e-48)
(*
(acos
(+
(* (sin phi1) phi2)
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R)
t_0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), (sin(phi2) * sin(phi1)))) * R;
double tmp;
if (phi2 <= -0.045) {
tmp = t_0;
} else if (phi2 <= 1.85e-48) {
tmp = acos(((sin(phi1) * phi2) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
} else {
tmp = t_0;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), Float64(sin(phi2) * sin(phi1)))) * R) tmp = 0.0 if (phi2 <= -0.045) tmp = t_0; elseif (phi2 <= 1.85e-48) tmp = Float64(acos(Float64(Float64(sin(phi1) * phi2) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R); else tmp = t_0; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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[phi2, -0.045], t$95$0, If[LessEqual[phi2, 1.85e-48], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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{if}\;\phi_2 \leq -0.045:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 1.85 \cdot 10^{-48}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -0.044999999999999998 or 1.8499999999999999e-48 < phi2 Initial program 78.3%
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.f6459.4
Applied rewrites59.4%
if -0.044999999999999998 < phi2 < 1.8499999999999999e-48Initial program 68.5%
Taylor expanded in phi2 around 0
Applied rewrites68.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 -1.3)
(*
(acos (+ (* (sin phi1) (sin phi2)) (* t_0 (* lambda2 (/ 1.0 lambda2)))))
R)
(if (<= phi2 3.6)
(*
(acos
(+
(*
(sin phi1)
(*
(fma
(-
(*
(fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
(* phi2 phi2))
0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))
(* t_0 t_1)))
R)
(* (acos (fma (sin phi2) (sin phi1) (* (cos phi2) t_1))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.3) {
tmp = acos(((sin(phi1) * sin(phi2)) + (t_0 * (lambda2 * (1.0 / lambda2))))) * R;
} else if (phi2 <= 3.6) {
tmp = acos(((sin(phi1) * (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2)) + (t_0 * t_1))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), (cos(phi2) * t_1))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.3) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * Float64(lambda2 * Float64(1.0 / lambda2))))) * R); elseif (phi2 <= 3.6) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)) + Float64(t_0 * t_1))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(phi2) * t_1))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.3], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(lambda2 * N[(1.0 / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.6], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.3:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \left(\lambda_2 \cdot \frac{1}{\lambda_2}\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.6:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2\right) + t\_0 \cdot t\_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_2 \cdot t\_1\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -1.30000000000000004Initial program 80.0%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6453.4
Applied rewrites53.4%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lift-cos.f6453.4
Applied rewrites53.4%
Taylor expanded in lambda1 around 0
lower-/.f6441.4
Applied rewrites41.4%
if -1.30000000000000004 < phi2 < 3.60000000000000009Initial program 68.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites68.4%
if 3.60000000000000009 < phi2 Initial program 78.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 rewrites78.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6448.5
Applied rewrites48.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 -1.3)
(*
(acos (+ (* (sin phi1) (sin phi2)) (* t_0 (* lambda2 (/ 1.0 lambda2)))))
R)
(if (<= phi2 3.2)
(*
(acos
(+
(*
(sin phi1)
(*
(fma
(- (* (* phi2 phi2) 0.008333333333333333) 0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))
(* t_0 t_1)))
R)
(* (acos (fma (sin phi2) (sin phi1) (* (cos phi2) t_1))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.3) {
tmp = acos(((sin(phi1) * sin(phi2)) + (t_0 * (lambda2 * (1.0 / lambda2))))) * R;
} else if (phi2 <= 3.2) {
tmp = acos(((sin(phi1) * (fma((((phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2)) + (t_0 * t_1))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), (cos(phi2) * t_1))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.3) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * Float64(lambda2 * Float64(1.0 / lambda2))))) * R); elseif (phi2 <= 3.2) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(Float64(Float64(phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)) + Float64(t_0 * t_1))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(phi2) * t_1))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.3], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(lambda2 * N[(1.0 / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.2], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.3:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \left(\lambda_2 \cdot \frac{1}{\lambda_2}\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.2:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2\right) + t\_0 \cdot t\_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_2 \cdot t\_1\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -1.30000000000000004Initial program 80.0%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6453.4
Applied rewrites53.4%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lift-cos.f6453.4
Applied rewrites53.4%
Taylor expanded in lambda1 around 0
lower-/.f6441.4
Applied rewrites41.4%
if -1.30000000000000004 < phi2 < 3.2000000000000002Initial program 68.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.4
Applied rewrites68.4%
if 3.2000000000000002 < phi2 Initial program 78.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 rewrites78.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6448.5
Applied rewrites48.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.232)
(*
(acos (+ t_1 (* (* (cos phi1) (cos phi2)) (* lambda2 (/ 1.0 lambda2)))))
R)
(if (<= phi2 9.5e-14)
(*
(acos
(+
t_1
(*
(*
(cos phi1)
(fma
(- (* (* phi2 phi2) 0.041666666666666664) 0.5)
(* phi2 phi2)
1.0))
t_0)))
R)
(* (acos (fma (sin phi2) (sin phi1) (* (cos phi2) t_0))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.232) {
tmp = acos((t_1 + ((cos(phi1) * cos(phi2)) * (lambda2 * (1.0 / lambda2))))) * R;
} else if (phi2 <= 9.5e-14) {
tmp = acos((t_1 + ((cos(phi1) * fma((((phi2 * phi2) * 0.041666666666666664) - 0.5), (phi2 * phi2), 1.0)) * t_0))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), (cos(phi2) * t_0))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.232) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(lambda2 * Float64(1.0 / lambda2))))) * R); elseif (phi2 <= 9.5e-14) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * fma(Float64(Float64(Float64(phi2 * phi2) * 0.041666666666666664) - 0.5), Float64(phi2 * phi2), 1.0)) * t_0))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(phi2) * t_0))) * 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[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.232], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(lambda2 * N[(1.0 / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 9.5e-14], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.232:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\lambda_2 \cdot \frac{1}{\lambda_2}\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 9.5 \cdot 10^{-14}:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.041666666666666664 - 0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot t\_0\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_2 \cdot t\_0\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -0.232000000000000012Initial program 80.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6453.5
Applied rewrites53.5%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lift-cos.f6453.4
Applied rewrites53.4%
Taylor expanded in lambda1 around 0
lower-/.f6441.4
Applied rewrites41.4%
if -0.232000000000000012 < phi2 < 9.4999999999999999e-14Initial program 68.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.4
Applied rewrites68.4%
if 9.4999999999999999e-14 < phi2 Initial program 77.7%
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 rewrites77.7%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6448.1
Applied rewrites48.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 -1.28)
(*
(acos (+ (* (sin phi1) (sin phi2)) (* t_0 (* lambda2 (/ 1.0 lambda2)))))
R)
(if (<= phi2 3.35e+15)
(*
(acos
(+
(* (sin phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(* t_0 t_1)))
R)
(* (acos (fma (sin phi2) (sin phi1) (* (cos phi2) t_1))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.28) {
tmp = acos(((sin(phi1) * sin(phi2)) + (t_0 * (lambda2 * (1.0 / lambda2))))) * R;
} else if (phi2 <= 3.35e+15) {
tmp = acos(((sin(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) + (t_0 * t_1))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), (cos(phi2) * t_1))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.28) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * Float64(lambda2 * Float64(1.0 / lambda2))))) * R); elseif (phi2 <= 3.35e+15) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) + Float64(t_0 * t_1))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(phi2) * t_1))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.28], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(lambda2 * N[(1.0 / lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.35e+15], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.28:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \left(\lambda_2 \cdot \frac{1}{\lambda_2}\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.35 \cdot 10^{+15}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) + t\_0 \cdot t\_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_2 \cdot t\_1\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -1.28000000000000003Initial program 80.0%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6453.4
Applied rewrites53.4%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lift-cos.f6453.4
Applied rewrites53.4%
Taylor expanded in lambda1 around 0
lower-/.f6441.4
Applied rewrites41.4%
if -1.28000000000000003 < phi2 < 3.35e15Initial program 68.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6467.4
Applied rewrites67.4%
if 3.35e15 < phi2 Initial program 78.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 rewrites78.2%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6448.8
Applied rewrites48.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -1.2e-6)
(* (acos (* t_0 (cos phi1))) R)
(if (<= phi1 -1.1e-87)
(*
(acos
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
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 (phi1 <= -1.2e-6) {
tmp = acos((t_0 * cos(phi1))) * R;
} else if (phi1 <= -1.1e-87) {
tmp = acos(((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) * 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 (phi1 <= (-1.2d-6)) then
tmp = acos((t_0 * cos(phi1))) * r
else if (phi1 <= (-1.1d-87)) then
tmp = acos(((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) * 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 (phi1 <= -1.2e-6) {
tmp = Math.acos((t_0 * Math.cos(phi1))) * R;
} else if (phi1 <= -1.1e-87) {
tmp = Math.acos(((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2)))) * 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 phi1 <= -1.2e-6: tmp = math.acos((t_0 * math.cos(phi1))) * R elif phi1 <= -1.1e-87: tmp = math.acos(((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2)))) * 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 (phi1 <= -1.2e-6) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); elseif (phi1 <= -1.1e-87) tmp = Float64(acos(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) * 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 (phi1 <= -1.2e-6) tmp = acos((t_0 * cos(phi1))) * R; elseif (phi1 <= -1.1e-87) tmp = acos(((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) * 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[phi1, -1.2e-6], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -1.1e-87], N[(N[ArcCos[N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $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_1 \leq -1.2 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -1.1 \cdot 10^{-87}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -1.1999999999999999e-6Initial program 78.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6446.7
Applied rewrites46.7%
if -1.1999999999999999e-6 < phi1 < -1.09999999999999994e-87Initial program 69.1%
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.0
Applied rewrites88.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6487.8
Applied rewrites87.8%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6447.5
Applied rewrites47.5%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-+.f6447.5
Applied rewrites47.5%
if -1.09999999999999994e-87 < phi1 Initial program 72.5%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6450.3
Applied rewrites50.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -1.2e-6)
(* (acos (* t_0 (cos phi1))) R)
(if (<= phi1 -1.1e-87)
(*
(acos
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))
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 (phi1 <= -1.2e-6) {
tmp = acos((t_0 * cos(phi1))) * R;
} else if (phi1 <= -1.1e-87) {
tmp = acos(fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))) * 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 (phi1 <= -1.2e-6) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); elseif (phi1 <= -1.1e-87) tmp = Float64(acos(fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))) * 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[phi1, -1.2e-6], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -1.1e-87], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $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_1 \leq -1.2 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -1.1 \cdot 10^{-87}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -1.1999999999999999e-6Initial program 78.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6446.7
Applied rewrites46.7%
if -1.1999999999999999e-6 < phi1 < -1.09999999999999994e-87Initial program 69.1%
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.0
Applied rewrites88.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6487.8
Applied rewrites87.8%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-cos.f64N/A
lift-cos.f6447.5
Applied rewrites47.5%
if -1.09999999999999994e-87 < phi1 Initial program 72.5%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6450.3
Applied rewrites50.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 9.5e-14)
(* (acos (fma (sin phi2) (sin phi1) (* t_0 (cos phi1)))) R)
(* (acos (fma (sin phi2) (sin phi1) (* (cos phi2) t_0))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 9.5e-14) {
tmp = acos(fma(sin(phi2), sin(phi1), (t_0 * cos(phi1)))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), (cos(phi2) * t_0))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 9.5e-14) tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(t_0 * cos(phi1)))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(phi2) * t_0))) * 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, 9.5e-14], 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[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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 9.5 \cdot 10^{-14}:\\
\;\;\;\;\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(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_2 \cdot t\_0\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 9.4999999999999999e-14Initial program 72.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 rewrites72.4%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6450.7
Applied rewrites50.7%
if 9.4999999999999999e-14 < phi2 Initial program 77.7%
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 rewrites77.7%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6448.1
Applied rewrites48.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.00093)
(* (acos (* t_0 (cos phi1))) R)
(* (acos (fma (sin phi2) (sin phi1) (* (cos phi2) t_0))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.00093) {
tmp = acos((t_0 * cos(phi1))) * R;
} else {
tmp = acos(fma(sin(phi2), sin(phi1), (cos(phi2) * t_0))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.00093) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); else tmp = Float64(acos(fma(sin(phi2), sin(phi1), Float64(cos(phi2) * t_0))) * 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.00093], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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.00093:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \cos \phi_2 \cdot t\_0\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -9.3000000000000005e-4Initial program 78.6%
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%
if -9.3000000000000005e-4 < phi1 Initial program 72.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 rewrites72.2%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6451.8
Applied rewrites51.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -8e-6)
(* (acos (* t_0 (cos phi1))) R)
(* (acos (* phi1 (/ (* (cos phi2) t_0) phi1))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -8e-6) {
tmp = acos((t_0 * cos(phi1))) * R;
} else {
tmp = acos((phi1 * ((cos(phi2) * t_0) / phi1))) * 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 (phi1 <= (-8d-6)) then
tmp = acos((t_0 * cos(phi1))) * r
else
tmp = acos((phi1 * ((cos(phi2) * t_0) / phi1))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -8e-6) {
tmp = Math.acos((t_0 * Math.cos(phi1))) * R;
} else {
tmp = Math.acos((phi1 * ((Math.cos(phi2) * t_0) / phi1))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -8e-6: tmp = math.acos((t_0 * math.cos(phi1))) * R else: tmp = math.acos((phi1 * ((math.cos(phi2) * t_0) / phi1))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -8e-6) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); else tmp = Float64(acos(Float64(phi1 * Float64(Float64(cos(phi2) * t_0) / phi1))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -8e-6) tmp = acos((t_0 * cos(phi1))) * R; else tmp = acos((phi1 * ((cos(phi2) * t_0) / phi1))) * 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[phi1, -8e-6], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(phi1 * N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / phi1), $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 -8 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \frac{\cos \phi_2 \cdot t\_0}{\phi_1}\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -7.99999999999999964e-6Initial program 78.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6446.7
Applied rewrites46.7%
if -7.99999999999999964e-6 < phi1 Initial program 72.2%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6447.7
Applied rewrites47.7%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6447.6
Applied rewrites47.6%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6451.9
Applied rewrites51.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.00126)
(* (acos (* (cos lambda2) (cos phi1))) R)
(if (<= phi1 -1.2e-285)
(* (acos (* phi1 (/ (cos (- lambda1 lambda2)) phi1))) R)
(* (acos (* (cos lambda2) (cos phi2))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00126) {
tmp = acos((cos(lambda2) * cos(phi1))) * R;
} else if (phi1 <= -1.2e-285) {
tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * R;
} else {
tmp = acos((cos(lambda2) * 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 <= (-0.00126d0)) then
tmp = acos((cos(lambda2) * cos(phi1))) * r
else if (phi1 <= (-1.2d-285)) then
tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * r
else
tmp = acos((cos(lambda2) * 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 <= -0.00126) {
tmp = Math.acos((Math.cos(lambda2) * Math.cos(phi1))) * R;
} else if (phi1 <= -1.2e-285) {
tmp = Math.acos((phi1 * (Math.cos((lambda1 - lambda2)) / phi1))) * R;
} else {
tmp = Math.acos((Math.cos(lambda2) * Math.cos(phi2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00126: tmp = math.acos((math.cos(lambda2) * math.cos(phi1))) * R elif phi1 <= -1.2e-285: tmp = math.acos((phi1 * (math.cos((lambda1 - lambda2)) / phi1))) * R else: tmp = math.acos((math.cos(lambda2) * math.cos(phi2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00126) tmp = Float64(acos(Float64(cos(lambda2) * cos(phi1))) * R); elseif (phi1 <= -1.2e-285) tmp = Float64(acos(Float64(phi1 * Float64(cos(Float64(lambda1 - lambda2)) / phi1))) * R); else tmp = Float64(acos(Float64(cos(lambda2) * cos(phi2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.00126) tmp = acos((cos(lambda2) * cos(phi1))) * R; elseif (phi1 <= -1.2e-285) tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * R; else tmp = acos((cos(lambda2) * cos(phi2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00126], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, -1.2e-285], N[(N[ArcCos[N[(phi1 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00126:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq -1.2 \cdot 10^{-285}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right)}{\phi_1}\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -0.00126000000000000005Initial program 78.6%
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.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6437.9
Applied rewrites37.9%
if -0.00126000000000000005 < phi1 < -1.2e-285Initial program 69.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6469.3
Applied rewrites69.3%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6469.2
Applied rewrites69.2%
Taylor expanded in phi2 around 0
lower-/.f64N/A
lift-cos.f64N/A
lift--.f6437.5
Applied rewrites37.5%
if -1.2e-285 < phi1 Initial program 73.3%
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.f6452.9
Applied rewrites52.9%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f6432.1
Applied rewrites32.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -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 (phi1 <= -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 (phi1 <= (-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 (phi1 <= -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 phi1 <= -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 (phi1 <= -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 (phi1 <= -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[phi1, -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_1 \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 phi1 < -7.99999999999999964e-6Initial program 78.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6446.7
Applied rewrites46.7%
if -7.99999999999999964e-6 < phi1 Initial program 72.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%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 9.5e-14) (* (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 <= 9.5e-14) {
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 <= 9.5d-14) 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 <= 9.5e-14) {
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 <= 9.5e-14: 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 <= 9.5e-14) 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 <= 9.5e-14) 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, 9.5e-14], 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 9.5 \cdot 10^{-14}:\\
\;\;\;\;\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 < 9.4999999999999999e-14Initial program 72.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6451.0
Applied rewrites51.0%
if 9.4999999999999999e-14 < phi2 Initial program 77.7%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6448.7
Applied rewrites48.7%
Taylor expanded in lambda1 around inf
Applied rewrites38.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -5.8e-13) (* (acos (* (cos 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 (phi1 <= -5.8e-13) {
tmp = acos((cos(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 (phi1 <= (-5.8d-13)) then
tmp = acos((cos(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 (phi1 <= -5.8e-13) {
tmp = Math.acos((Math.cos(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 phi1 <= -5.8e-13: tmp = math.acos((math.cos(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 (phi1 <= -5.8e-13) tmp = Float64(acos(Float64(cos(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 (phi1 <= -5.8e-13) tmp = acos((cos(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[phi1, -5.8e-13], N[(N[ArcCos[N[(N[Cos[lambda2], $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_1 \leq -5.8 \cdot 10^{-13}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \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 phi1 < -5.7999999999999995e-13Initial program 78.3%
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.f6459.0
Applied rewrites59.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6437.7
Applied rewrites37.7%
if -5.7999999999999995e-13 < phi1 Initial program 72.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%
Taylor expanded in lambda1 around inf
Applied rewrites36.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.00126)
(* (acos (* (cos lambda2) (cos phi1))) R)
(if (<= phi1 1.65e-214)
(* (acos (* phi1 (/ (cos (- lambda1 lambda2)) phi1))) R)
(* (acos (cos phi2)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00126) {
tmp = acos((cos(lambda2) * cos(phi1))) * R;
} else if (phi1 <= 1.65e-214) {
tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * R;
} else {
tmp = acos(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 <= (-0.00126d0)) then
tmp = acos((cos(lambda2) * cos(phi1))) * r
else if (phi1 <= 1.65d-214) then
tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * r
else
tmp = acos(cos(phi2)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00126) {
tmp = Math.acos((Math.cos(lambda2) * Math.cos(phi1))) * R;
} else if (phi1 <= 1.65e-214) {
tmp = Math.acos((phi1 * (Math.cos((lambda1 - lambda2)) / phi1))) * R;
} else {
tmp = Math.acos(Math.cos(phi2)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00126: tmp = math.acos((math.cos(lambda2) * math.cos(phi1))) * R elif phi1 <= 1.65e-214: tmp = math.acos((phi1 * (math.cos((lambda1 - lambda2)) / phi1))) * R else: tmp = math.acos(math.cos(phi2)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00126) tmp = Float64(acos(Float64(cos(lambda2) * cos(phi1))) * R); elseif (phi1 <= 1.65e-214) tmp = Float64(acos(Float64(phi1 * Float64(cos(Float64(lambda1 - lambda2)) / phi1))) * R); else tmp = Float64(acos(cos(phi2)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.00126) tmp = acos((cos(lambda2) * cos(phi1))) * R; elseif (phi1 <= 1.65e-214) tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * R; else tmp = acos(cos(phi2)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00126], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 1.65e-214], N[(N[ArcCos[N[(phi1 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00126:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{elif}\;\phi_1 \leq 1.65 \cdot 10^{-214}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right)}{\phi_1}\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\end{array}
if phi1 < -0.00126000000000000005Initial program 78.6%
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.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6437.9
Applied rewrites37.9%
if -0.00126000000000000005 < phi1 < 1.6499999999999999e-214Initial program 69.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6469.5
Applied rewrites69.5%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6469.2
Applied rewrites69.2%
Taylor expanded in phi2 around 0
lower-/.f64N/A
lift-cos.f64N/A
lift--.f6437.5
Applied rewrites37.5%
if 1.6499999999999999e-214 < phi1 Initial program 74.1%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
associate-*r*N/A
flip-+N/A
Applied rewrites74.1%
Taylor expanded in lambda2 around 0
Applied rewrites47.1%
Taylor expanded in lambda1 around 0
Applied rewrites33.9%
Taylor expanded in phi1 around 0
lift-cos.f6416.4
Applied rewrites16.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.14)
(* (acos (cos phi1)) R)
(if (<= phi1 1.65e-214)
(* (acos (* phi1 (/ (cos (- lambda1 lambda2)) phi1))) R)
(* (acos (cos phi2)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.14) {
tmp = acos(cos(phi1)) * R;
} else if (phi1 <= 1.65e-214) {
tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * R;
} else {
tmp = acos(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 <= (-0.14d0)) then
tmp = acos(cos(phi1)) * r
else if (phi1 <= 1.65d-214) then
tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * r
else
tmp = acos(cos(phi2)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.14) {
tmp = Math.acos(Math.cos(phi1)) * R;
} else if (phi1 <= 1.65e-214) {
tmp = Math.acos((phi1 * (Math.cos((lambda1 - lambda2)) / phi1))) * R;
} else {
tmp = Math.acos(Math.cos(phi2)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.14: tmp = math.acos(math.cos(phi1)) * R elif phi1 <= 1.65e-214: tmp = math.acos((phi1 * (math.cos((lambda1 - lambda2)) / phi1))) * R else: tmp = math.acos(math.cos(phi2)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.14) tmp = Float64(acos(cos(phi1)) * R); elseif (phi1 <= 1.65e-214) tmp = Float64(acos(Float64(phi1 * Float64(cos(Float64(lambda1 - lambda2)) / phi1))) * R); else tmp = Float64(acos(cos(phi2)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.14) tmp = acos(cos(phi1)) * R; elseif (phi1 <= 1.65e-214) tmp = acos((phi1 * (cos((lambda1 - lambda2)) / phi1))) * R; else tmp = acos(cos(phi2)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.14], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 1.65e-214], N[(N[ArcCos[N[(phi1 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.14:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{elif}\;\phi_1 \leq 1.65 \cdot 10^{-214}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right)}{\phi_1}\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\end{array}
if phi1 < -0.14000000000000001Initial program 78.6%
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.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6438.0
Applied rewrites38.0%
Taylor expanded in lambda2 around 0
lift-cos.f6429.4
Applied rewrites29.4%
if -0.14000000000000001 < phi1 < 1.6499999999999999e-214Initial program 69.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6469.2
Applied rewrites69.2%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6469.0
Applied rewrites69.0%
Taylor expanded in phi2 around 0
lower-/.f64N/A
lift-cos.f64N/A
lift--.f6437.4
Applied rewrites37.4%
if 1.6499999999999999e-214 < phi1 Initial program 74.1%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
associate-*r*N/A
flip-+N/A
Applied rewrites74.1%
Taylor expanded in lambda2 around 0
Applied rewrites47.1%
Taylor expanded in lambda1 around 0
Applied rewrites33.9%
Taylor expanded in phi1 around 0
lift-cos.f6416.4
Applied rewrites16.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.14)
(* (acos (cos phi1)) R)
(if (<= phi1 1.65e-214)
(* (acos (* phi2 (/ (cos (- lambda1 lambda2)) phi2))) R)
(* (acos (cos phi2)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.14) {
tmp = acos(cos(phi1)) * R;
} else if (phi1 <= 1.65e-214) {
tmp = acos((phi2 * (cos((lambda1 - lambda2)) / phi2))) * R;
} else {
tmp = acos(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 <= (-0.14d0)) then
tmp = acos(cos(phi1)) * r
else if (phi1 <= 1.65d-214) then
tmp = acos((phi2 * (cos((lambda1 - lambda2)) / phi2))) * r
else
tmp = acos(cos(phi2)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.14) {
tmp = Math.acos(Math.cos(phi1)) * R;
} else if (phi1 <= 1.65e-214) {
tmp = Math.acos((phi2 * (Math.cos((lambda1 - lambda2)) / phi2))) * R;
} else {
tmp = Math.acos(Math.cos(phi2)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.14: tmp = math.acos(math.cos(phi1)) * R elif phi1 <= 1.65e-214: tmp = math.acos((phi2 * (math.cos((lambda1 - lambda2)) / phi2))) * R else: tmp = math.acos(math.cos(phi2)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.14) tmp = Float64(acos(cos(phi1)) * R); elseif (phi1 <= 1.65e-214) tmp = Float64(acos(Float64(phi2 * Float64(cos(Float64(lambda1 - lambda2)) / phi2))) * R); else tmp = Float64(acos(cos(phi2)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.14) tmp = acos(cos(phi1)) * R; elseif (phi1 <= 1.65e-214) tmp = acos((phi2 * (cos((lambda1 - lambda2)) / phi2))) * R; else tmp = acos(cos(phi2)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.14], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 1.65e-214], N[(N[ArcCos[N[(phi2 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.14:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{elif}\;\phi_1 \leq 1.65 \cdot 10^{-214}:\\
\;\;\;\;\cos^{-1} \left(\phi_2 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right)}{\phi_2}\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\end{array}
if phi1 < -0.14000000000000001Initial program 78.6%
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.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6438.0
Applied rewrites38.0%
Taylor expanded in lambda2 around 0
lift-cos.f6429.4
Applied rewrites29.4%
if -0.14000000000000001 < phi1 < 1.6499999999999999e-214Initial program 69.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6434.2
Applied rewrites34.2%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower-+.f64N/A
lift-sin.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6434.0
Applied rewrites34.0%
Taylor expanded in phi1 around 0
lower-/.f64N/A
lift-cos.f64N/A
lift--.f6437.3
Applied rewrites37.3%
if 1.6499999999999999e-214 < phi1 Initial program 74.1%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
associate-*r*N/A
flip-+N/A
Applied rewrites74.1%
Taylor expanded in lambda2 around 0
Applied rewrites47.1%
Taylor expanded in lambda1 around 0
Applied rewrites33.9%
Taylor expanded in phi1 around 0
lift-cos.f6416.4
Applied rewrites16.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.14)
(* (acos (cos phi1)) R)
(if (<= phi1 1.65e-214)
(* (acos (cos (- lambda1 lambda2))) R)
(* (acos (cos phi2)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.14) {
tmp = acos(cos(phi1)) * R;
} else if (phi1 <= 1.65e-214) {
tmp = acos(cos((lambda1 - lambda2))) * R;
} else {
tmp = acos(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 <= (-0.14d0)) then
tmp = acos(cos(phi1)) * r
else if (phi1 <= 1.65d-214) then
tmp = acos(cos((lambda1 - lambda2))) * r
else
tmp = acos(cos(phi2)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.14) {
tmp = Math.acos(Math.cos(phi1)) * R;
} else if (phi1 <= 1.65e-214) {
tmp = Math.acos(Math.cos((lambda1 - lambda2))) * R;
} else {
tmp = Math.acos(Math.cos(phi2)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.14: tmp = math.acos(math.cos(phi1)) * R elif phi1 <= 1.65e-214: tmp = math.acos(math.cos((lambda1 - lambda2))) * R else: tmp = math.acos(math.cos(phi2)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.14) tmp = Float64(acos(cos(phi1)) * R); elseif (phi1 <= 1.65e-214) tmp = Float64(acos(cos(Float64(lambda1 - lambda2))) * R); else tmp = Float64(acos(cos(phi2)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.14) tmp = acos(cos(phi1)) * R; elseif (phi1 <= 1.65e-214) tmp = acos(cos((lambda1 - lambda2))) * R; else tmp = acos(cos(phi2)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.14], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 1.65e-214], N[(N[ArcCos[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.14:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{elif}\;\phi_1 \leq 1.65 \cdot 10^{-214}:\\
\;\;\;\;\cos^{-1} \cos \left(\lambda_1 - \lambda_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\end{array}
if phi1 < -0.14000000000000001Initial program 78.6%
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.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6438.0
Applied rewrites38.0%
Taylor expanded in lambda2 around 0
lift-cos.f6429.4
Applied rewrites29.4%
if -0.14000000000000001 < phi1 < 1.6499999999999999e-214Initial program 69.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6469.2
Applied rewrites69.2%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6437.4
Applied rewrites37.4%
if 1.6499999999999999e-214 < phi1 Initial program 74.1%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
associate-*r*N/A
flip-+N/A
Applied rewrites74.1%
Taylor expanded in lambda2 around 0
Applied rewrites47.1%
Taylor expanded in lambda1 around 0
Applied rewrites33.9%
Taylor expanded in phi1 around 0
lift-cos.f6416.4
Applied rewrites16.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.021)
(* (acos (cos phi1)) R)
(if (<= phi1 1.05e-278)
(* (acos (cos lambda1)) R)
(* (acos (cos phi2)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.021) {
tmp = acos(cos(phi1)) * R;
} else if (phi1 <= 1.05e-278) {
tmp = acos(cos(lambda1)) * R;
} else {
tmp = acos(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 <= (-0.021d0)) then
tmp = acos(cos(phi1)) * r
else if (phi1 <= 1.05d-278) then
tmp = acos(cos(lambda1)) * r
else
tmp = acos(cos(phi2)) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.021) {
tmp = Math.acos(Math.cos(phi1)) * R;
} else if (phi1 <= 1.05e-278) {
tmp = Math.acos(Math.cos(lambda1)) * R;
} else {
tmp = Math.acos(Math.cos(phi2)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.021: tmp = math.acos(math.cos(phi1)) * R elif phi1 <= 1.05e-278: tmp = math.acos(math.cos(lambda1)) * R else: tmp = math.acos(math.cos(phi2)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.021) tmp = Float64(acos(cos(phi1)) * R); elseif (phi1 <= 1.05e-278) tmp = Float64(acos(cos(lambda1)) * R); else tmp = Float64(acos(cos(phi2)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.021) tmp = acos(cos(phi1)) * R; elseif (phi1 <= 1.05e-278) tmp = acos(cos(lambda1)) * R; else tmp = acos(cos(phi2)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.021], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi1, 1.05e-278], N[(N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.021:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{elif}\;\phi_1 \leq 1.05 \cdot 10^{-278}:\\
\;\;\;\;\cos^{-1} \cos \lambda_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\end{array}
if phi1 < -0.0210000000000000013Initial program 78.6%
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.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6437.9
Applied rewrites37.9%
Taylor expanded in lambda2 around 0
lift-cos.f6429.3
Applied rewrites29.3%
if -0.0210000000000000013 < phi1 < 1.05000000000000007e-278Initial program 69.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6469.2
Applied rewrites69.2%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in lambda2 around 0
lift-cos.f6423.2
Applied rewrites23.2%
if 1.05000000000000007e-278 < phi1 Initial program 73.7%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
associate-*r*N/A
flip-+N/A
Applied rewrites73.6%
Taylor expanded in lambda2 around 0
Applied rewrites46.6%
Taylor expanded in lambda1 around 0
Applied rewrites32.9%
Taylor expanded in phi1 around 0
lift-cos.f6417.4
Applied rewrites17.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.021) (* (acos (cos phi1)) R) (* (acos (cos lambda1)) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.021) {
tmp = acos(cos(phi1)) * R;
} else {
tmp = acos(cos(lambda1)) * 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 <= (-0.021d0)) then
tmp = acos(cos(phi1)) * r
else
tmp = acos(cos(lambda1)) * 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 <= -0.021) {
tmp = Math.acos(Math.cos(phi1)) * R;
} else {
tmp = Math.acos(Math.cos(lambda1)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.021: tmp = math.acos(math.cos(phi1)) * R else: tmp = math.acos(math.cos(lambda1)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.021) tmp = Float64(acos(cos(phi1)) * R); else tmp = Float64(acos(cos(lambda1)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.021) tmp = acos(cos(phi1)) * R; else tmp = acos(cos(lambda1)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.021], N[(N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.021:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \lambda_1 \cdot R\\
\end{array}
\end{array}
if phi1 < -0.0210000000000000013Initial program 78.6%
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.f6459.3
Applied rewrites59.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6437.9
Applied rewrites37.9%
Taylor expanded in lambda2 around 0
lift-cos.f6429.3
Applied rewrites29.3%
if -0.0210000000000000013 < phi1 Initial program 72.2%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6447.6
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6430.1
Applied rewrites30.1%
Taylor expanded in lambda2 around 0
lift-cos.f6419.1
Applied rewrites19.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (cos lambda1)) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(cos(lambda1)) * 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)) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(Math.cos(lambda1)) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(math.cos(lambda1)) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(cos(lambda1)) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(cos(lambda1)) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \cos \lambda_1 \cdot R
\end{array}
Initial program 73.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6436.7
Applied rewrites36.7%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6426.6
Applied rewrites26.6%
Taylor expanded in lambda2 around 0
lift-cos.f6417.4
Applied rewrites17.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (* phi1 phi2)) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos((phi1 * phi2)) * 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((phi1 * phi2)) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos((phi1 * phi2)) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos((phi1 * phi2)) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(phi1 * phi2)) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos((phi1 * phi2)) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(phi1 * phi2), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\phi_1 \cdot \phi_2\right) \cdot R
\end{array}
Initial program 73.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6436.7
Applied rewrites36.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lower-*.f6418.5
Applied rewrites18.5%
Taylor expanded in phi1 around inf
lift-*.f649.7
Applied rewrites9.7%
(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 73.8%
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.f6453.4
Applied rewrites53.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6431.0
Applied rewrites31.0%
Taylor expanded in lambda2 around 0
lift-cos.f6417.4
Applied rewrites17.4%
Taylor expanded in phi1 around 0
Applied rewrites4.4%
herbie shell --seed 2025092
(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))