
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 38 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (cos lambda2)))
(t_1 (* (sin lambda1) (sin lambda2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(/ (- (pow t_0 2.0) (pow t_1 2.0)) (- t_0 t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * cos(lambda2);
double t_1 = sin(lambda1) * sin(lambda2);
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * ((pow(t_0, 2.0) - pow(t_1, 2.0)) / (t_0 - t_1)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(lambda1) * cos(lambda2)
t_1 = sin(lambda1) * sin(lambda2)
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * (((t_0 ** 2.0d0) - (t_1 ** 2.0d0)) / (t_0 - t_1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.cos(lambda2);
double t_1 = Math.sin(lambda1) * Math.sin(lambda2);
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * ((Math.pow(t_0, 2.0) - Math.pow(t_1, 2.0)) / (t_0 - t_1)))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.cos(lambda2) t_1 = math.sin(lambda1) * math.sin(lambda2) return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * ((math.pow(t_0, 2.0) - math.pow(t_1, 2.0)) / (t_0 - t_1)))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * cos(lambda2)) t_1 = Float64(sin(lambda1) * sin(lambda2)) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * Float64(Float64((t_0 ^ 2.0) - (t_1 ^ 2.0)) / Float64(t_0 - t_1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * cos(lambda2); t_1 = sin(lambda1) * sin(lambda2); tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * (((t_0 ^ 2.0) - (t_1 ^ 2.0)) / (t_0 - t_1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \cos \lambda_2\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \frac{{t\_0}^{2} - {t\_1}^{2}}{t\_0 - t\_1}}
\end{array}
\end{array}
Initial program 81.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6491.3
Applied rewrites91.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.8%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
pow2N/A
lower-pow.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f6499.8
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
pow2N/A
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[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]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \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)}
\end{array}
Initial program 81.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6491.3
Applied rewrites91.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -1.3e-5) (not (<= phi2 4.7e-57)))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_0) (cos phi2))
(- t_1 (* t_2 (cos (- lambda1 lambda2)))))
(atan2
(- (* (cos lambda2) (sin lambda1)) t_0)
(-
t_1
(*
t_2
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -1.3e-5) || !(phi2 <= 4.7e-57)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (t_1 - (t_2 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - t_0), (t_1 - (t_2 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -1.3e-5) || !(phi2 <= 4.7e-57)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), Float64(t_1 - Float64(t_2 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - t_0), Float64(t_1 - Float64(t_2 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -1.3e-5], N[Not[LessEqual[phi2, 4.7e-57]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$1 - N[(t$95$2 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.3 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4.7 \cdot 10^{-57}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_0\right) \cdot \cos \phi_2}{t\_1 - t\_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - t\_0}{t\_1 - t\_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -1.29999999999999992e-5 or 4.6999999999999998e-57 < phi2 Initial program 78.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.8
Applied rewrites90.8%
if -1.29999999999999992e-5 < phi2 < 4.6999999999999998e-57Initial program 84.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.0
Applied rewrites92.0%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
sin-diff-revN/A
sin-+PI/2-revN/A
sin-mult-revN/A
lower--.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Final simplification94.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -1.3e-10) (not (<= lambda2 2.9e-16)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (* (cos phi1) (sin phi2)) (* t_0 (cos lambda2))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* (- (cos lambda1)) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -1.3e-10) || !(lambda2 <= 2.9e-16)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * cos(lambda2))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -1.3e-10) || !(lambda2 <= 2.9e-16)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * cos(lambda2)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.3e-10], N[Not[LessEqual[lambda2, 2.9e-16]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -1.3 \cdot 10^{-10} \lor \neg \left(\lambda_2 \leq 2.9 \cdot 10^{-16}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot t\_0\right)}\\
\end{array}
\end{array}
if lambda2 < -1.29999999999999991e-10 or 2.8999999999999998e-16 < lambda2 Initial program 63.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6483.4
Applied rewrites83.4%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6483.4
Applied rewrites83.4%
if -1.29999999999999991e-10 < lambda2 < 2.8999999999999998e-16Initial program 99.8%
Taylor expanded in lambda2 around 0
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
Final simplification91.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 81.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6491.3
Applied rewrites91.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2)))))
(t_3 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -6.4e-12)
(atan2 (* (- t_3 (sin lambda2)) (cos phi2)) t_2)
(if (<= phi1 4.4e-13)
(atan2 (* (- t_3 t_0) (cos phi2)) (- (sin phi2) (* t_1 (cos lambda2))))
(atan2 (* (- (sin lambda1) t_0) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = sin(phi1) * cos(phi2);
double t_2 = (cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)));
double t_3 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -6.4e-12) {
tmp = atan2(((t_3 - sin(lambda2)) * cos(phi2)), t_2);
} else if (phi1 <= 4.4e-13) {
tmp = atan2(((t_3 - t_0) * cos(phi2)), (sin(phi2) - (t_1 * cos(lambda2))));
} else {
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), t_2);
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = sin(phi1) * cos(phi2)
t_2 = (cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)))
t_3 = sin(lambda1) * cos(lambda2)
if (phi1 <= (-6.4d-12)) then
tmp = atan2(((t_3 - sin(lambda2)) * cos(phi2)), t_2)
else if (phi1 <= 4.4d-13) then
tmp = atan2(((t_3 - t_0) * cos(phi2)), (sin(phi2) - (t_1 * cos(lambda2))))
else
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), t_2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.sin(phi1) * Math.cos(phi2);
double t_2 = (Math.cos(phi1) * Math.sin(phi2)) - (t_1 * Math.cos((lambda1 - lambda2)));
double t_3 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if (phi1 <= -6.4e-12) {
tmp = Math.atan2(((t_3 - Math.sin(lambda2)) * Math.cos(phi2)), t_2);
} else if (phi1 <= 4.4e-13) {
tmp = Math.atan2(((t_3 - t_0) * Math.cos(phi2)), (Math.sin(phi2) - (t_1 * Math.cos(lambda2))));
} else {
tmp = Math.atan2(((Math.sin(lambda1) - t_0) * Math.cos(phi2)), t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.sin(phi1) * math.cos(phi2) t_2 = (math.cos(phi1) * math.sin(phi2)) - (t_1 * math.cos((lambda1 - lambda2))) t_3 = math.sin(lambda1) * math.cos(lambda2) tmp = 0 if phi1 <= -6.4e-12: tmp = math.atan2(((t_3 - math.sin(lambda2)) * math.cos(phi2)), t_2) elif phi1 <= 4.4e-13: tmp = math.atan2(((t_3 - t_0) * math.cos(phi2)), (math.sin(phi2) - (t_1 * math.cos(lambda2)))) else: tmp = math.atan2(((math.sin(lambda1) - t_0) * math.cos(phi2)), t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2)))) t_3 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -6.4e-12) tmp = atan(Float64(Float64(t_3 - sin(lambda2)) * cos(phi2)), t_2); elseif (phi1 <= 4.4e-13) tmp = atan(Float64(Float64(t_3 - t_0) * cos(phi2)), Float64(sin(phi2) - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(Float64(sin(lambda1) - t_0) * cos(phi2)), t_2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = sin(phi1) * cos(phi2); t_2 = (cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2))); t_3 = sin(lambda1) * cos(lambda2); tmp = 0.0; if (phi1 <= -6.4e-12) tmp = atan2(((t_3 - sin(lambda2)) * cos(phi2)), t_2); elseif (phi1 <= 4.4e-13) tmp = atan2(((t_3 - t_0) * cos(phi2)), (sin(phi2) - (t_1 * cos(lambda2)))); else tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), t_2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -6.4e-12], N[ArcTan[N[(N[(t$95$3 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 4.4e-13], N[ArcTan[N[(N[(t$95$3 - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -6.4 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_3 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 4.4 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_3 - t\_0\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_0\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi1 < -6.4000000000000002e-12Initial program 82.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6484.0
Applied rewrites84.0%
Taylor expanded in lambda1 around 0
lift-sin.f6482.7
Applied rewrites82.7%
if -6.4000000000000002e-12 < phi1 < 4.39999999999999993e-13Initial program 81.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6499.8
Applied rewrites99.8%
if 4.39999999999999993e-13 < phi1 Initial program 79.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6481.5
Applied rewrites81.5%
Taylor expanded in lambda2 around 0
lift-sin.f6480.9
Applied rewrites80.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos lambda1) (sin lambda2)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (* (sin phi1) (cos phi2))))
(if (<= phi1 -4.3e-6)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* t_2 (sin phi1)) (cos phi2))))
(if (<= phi1 4.4e-13)
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_1) (cos phi2))
(- (sin phi2) (* t_3 (cos lambda2))))
(atan2 (* (- (sin lambda1) t_1) (cos phi2)) (- t_0 (* t_3 t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(lambda1) * sin(lambda2);
double t_2 = cos((lambda1 - lambda2));
double t_3 = sin(phi1) * cos(phi2);
double tmp;
if (phi1 <= -4.3e-6) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_2 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 4.4e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (sin(phi2) - (t_3 * cos(lambda2))));
} else {
tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), (t_0 - (t_3 * t_2)));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(lambda1) * sin(lambda2)
t_2 = cos((lambda1 - lambda2))
t_3 = sin(phi1) * cos(phi2)
if (phi1 <= (-4.3d-6)) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_2 * sin(phi1)) * cos(phi2))))
else if (phi1 <= 4.4d-13) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (sin(phi2) - (t_3 * cos(lambda2))))
else
tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), (t_0 - (t_3 * t_2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(lambda1) * Math.sin(lambda2);
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if (phi1 <= -4.3e-6) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((t_2 * Math.sin(phi1)) * Math.cos(phi2))));
} else if (phi1 <= 4.4e-13) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_1) * Math.cos(phi2)), (Math.sin(phi2) - (t_3 * Math.cos(lambda2))));
} else {
tmp = Math.atan2(((Math.sin(lambda1) - t_1) * Math.cos(phi2)), (t_0 - (t_3 * t_2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(lambda1) * math.sin(lambda2) t_2 = math.cos((lambda1 - lambda2)) t_3 = math.sin(phi1) * math.cos(phi2) tmp = 0 if phi1 <= -4.3e-6: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((t_2 * math.sin(phi1)) * math.cos(phi2)))) elif phi1 <= 4.4e-13: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_1) * math.cos(phi2)), (math.sin(phi2) - (t_3 * math.cos(lambda2)))) else: tmp = math.atan2(((math.sin(lambda1) - t_1) * math.cos(phi2)), (t_0 - (t_3 * t_2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(lambda1) * sin(lambda2)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -4.3e-6) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(t_2 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 4.4e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), Float64(sin(phi2) - Float64(t_3 * cos(lambda2)))); else tmp = atan(Float64(Float64(sin(lambda1) - t_1) * cos(phi2)), Float64(t_0 - Float64(t_3 * t_2))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(lambda1) * sin(lambda2); t_2 = cos((lambda1 - lambda2)); t_3 = sin(phi1) * cos(phi2); tmp = 0.0; if (phi1 <= -4.3e-6) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_2 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 4.4e-13) tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (sin(phi2) - (t_3 * cos(lambda2)))); else tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), (t_0 - (t_3 * t_2))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.3e-6], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(t$95$2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.4e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$3 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -4.3 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(t\_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 4.4 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_1\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_3 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_1\right) \cdot \cos \phi_2}{t\_0 - t\_3 \cdot t\_2}\\
\end{array}
\end{array}
if phi1 < -4.30000000000000033e-6Initial program 82.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6482.9
Applied rewrites82.9%
if -4.30000000000000033e-6 < phi1 < 4.39999999999999993e-13Initial program 80.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.4
Applied rewrites99.4%
Taylor expanded in phi1 around 0
lift-sin.f6499.4
Applied rewrites99.4%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6499.4
Applied rewrites99.4%
if 4.39999999999999993e-13 < phi1 Initial program 79.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6481.5
Applied rewrites81.5%
Taylor expanded in lambda2 around 0
lift-sin.f6480.9
Applied rewrites80.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -4.3e-6)
(atan2
t_1
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(if (<= phi1 4.4e-13)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos lambda2))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (sin phi1)) (cos phi2)) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -4.3e-6) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 4.4e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-sin(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -4.3e-6) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 4.4e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-sin(phi1)) * cos(phi2)) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.3e-6], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.4e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -4.3 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 4.4 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\sin \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0\right)}\\
\end{array}
\end{array}
if phi1 < -4.30000000000000033e-6Initial program 82.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6482.9
Applied rewrites82.9%
if -4.30000000000000033e-6 < phi1 < 4.39999999999999993e-13Initial program 80.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.4
Applied rewrites99.4%
Taylor expanded in phi1 around 0
lift-sin.f6499.4
Applied rewrites99.4%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6499.4
Applied rewrites99.4%
if 4.39999999999999993e-13 < phi1 Initial program 79.4%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites79.4%
Final simplification90.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -5.8e-6)
(atan2
t_1
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(if (<= phi1 1.1e-12)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma (- phi1) (* (cos phi2) t_0) (sin phi2)))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (sin phi1)) (cos phi2)) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -5.8e-6) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 1.1e-12) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(-phi1, (cos(phi2) * t_0), sin(phi2)));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-sin(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -5.8e-6) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 1.1e-12) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-phi1), Float64(cos(phi2) * t_0), sin(phi2))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-sin(phi1)) * cos(phi2)) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5.8e-6], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.1e-12], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-phi1) * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -5.8 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 1.1 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, \cos \phi_2 \cdot t\_0, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\sin \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0\right)}\\
\end{array}
\end{array}
if phi1 < -5.8000000000000004e-6Initial program 82.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6482.9
Applied rewrites82.9%
if -5.8000000000000004e-6 < phi1 < 1.09999999999999996e-12Initial program 80.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.4
Applied rewrites99.4%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6499.4
Applied rewrites99.4%
if 1.09999999999999996e-12 < phi1 Initial program 79.4%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites79.4%
Final simplification90.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -5.8e-6)
(atan2
t_1
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(if (<= phi1 9e-13)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (sin phi1) t_0)))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (sin phi1)) (cos phi2)) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -5.8e-6) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 9e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-sin(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -5.8e-6) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 9e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-sin(phi1)) * cos(phi2)) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5.8e-6], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 9e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -5.8 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 9 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\sin \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0\right)}\\
\end{array}
\end{array}
if phi1 < -5.8000000000000004e-6Initial program 82.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6482.9
Applied rewrites82.9%
if -5.8000000000000004e-6 < phi1 < 9e-13Initial program 80.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.4
Applied rewrites99.4%
Taylor expanded in phi1 around 0
lift-sin.f6499.4
Applied rewrites99.4%
Taylor expanded in phi2 around 0
lift-sin.f6499.3
Applied rewrites99.3%
if 9e-13 < phi1 Initial program 79.4%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites79.4%
Final simplification90.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.9e-35) (not (<= phi1 3.9e-13)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (cos (- lambda1 lambda2)) (sin phi1)) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.9e-35) || !(phi1 <= 3.9e-13)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 <= (-1.9d-35)) .or. (.not. (phi1 <= 3.9d-13))) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.9e-35) || !(phi1 <= 3.9e-13)) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos((lambda1 - lambda2)) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -1.9e-35) or not (phi1 <= 3.9e-13): tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos((lambda1 - lambda2)) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1.9e-35) || !(phi1 <= 3.9e-13)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -1.9e-35) || ~((phi1 <= 3.9e-13))) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1.9e-35], N[Not[LessEqual[phi1, 3.9e-13]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.9 \cdot 10^{-35} \lor \neg \left(\phi_1 \leq 3.9 \cdot 10^{-13}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.9000000000000001e-35 or 3.90000000000000004e-13 < phi1 Initial program 80.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6480.9
Applied rewrites80.9%
if -1.9000000000000001e-35 < phi1 < 3.90000000000000004e-13Initial program 81.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6497.8
Applied rewrites97.8%
Final simplification89.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -1.9e-35)
(atan2
t_1
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(if (<= phi1 3.9e-13)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (sin phi1)) (cos phi2)) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -1.9e-35) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 3.9e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-sin(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -1.9e-35) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 3.9e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-sin(phi1)) * cos(phi2)) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.9e-35], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 3.9e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.9 \cdot 10^{-35}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 3.9 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\sin \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0\right)}\\
\end{array}
\end{array}
if phi1 < -1.9000000000000001e-35Initial program 82.4%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6482.4
Applied rewrites82.4%
if -1.9000000000000001e-35 < phi1 < 3.90000000000000004e-13Initial program 81.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6497.8
Applied rewrites97.8%
if 3.90000000000000004e-13 < phi1 Initial program 79.4%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites79.4%
Final simplification89.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -1.9e-35)
(atan2 t_2 (- t_0 (* (* t_1 (sin phi1)) (cos phi2))))
(if (<= phi1 3.9e-13)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_2 (- t_0 (* (sin phi1) (* t_1 (cos phi2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -1.9e-35) {
tmp = atan2(t_2, (t_0 - ((t_1 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 3.9e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_2, (t_0 - (sin(phi1) * (t_1 * cos(phi2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-1.9d-35)) then
tmp = atan2(t_2, (t_0 - ((t_1 * sin(phi1)) * cos(phi2))))
else if (phi1 <= 3.9d-13) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_2, (t_0 - (sin(phi1) * (t_1 * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -1.9e-35) {
tmp = Math.atan2(t_2, (t_0 - ((t_1 * Math.sin(phi1)) * Math.cos(phi2))));
} else if (phi1 <= 3.9e-13) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.sin(phi1) * (t_1 * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -1.9e-35: tmp = math.atan2(t_2, (t_0 - ((t_1 * math.sin(phi1)) * math.cos(phi2)))) elif phi1 <= 3.9e-13: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_2, (t_0 - (math.sin(phi1) * (t_1 * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -1.9e-35) tmp = atan(t_2, Float64(t_0 - Float64(Float64(t_1 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 3.9e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_2, Float64(t_0 - Float64(sin(phi1) * Float64(t_1 * cos(phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -1.9e-35) tmp = atan2(t_2, (t_0 - ((t_1 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 3.9e-13) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_2, (t_0 - (sin(phi1) * (t_1 * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.9e-35], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 3.9e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.9 \cdot 10^{-35}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \left(t\_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 3.9 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \sin \phi_1 \cdot \left(t\_1 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if phi1 < -1.9000000000000001e-35Initial program 82.4%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6482.4
Applied rewrites82.4%
if -1.9000000000000001e-35 < phi1 < 3.90000000000000004e-13Initial program 81.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6497.8
Applied rewrites97.8%
if 3.90000000000000004e-13 < phi1 Initial program 79.4%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6479.4
Applied rewrites79.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -5.5e-5) (not (<= lambda2 6.8e-10)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (cos lambda1)) (* (sin phi1) (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -5.5e-5) || !(lambda2 <= 6.8e-10)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * (sin(phi1) * cos(phi2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -5.5e-5) || !(lambda2 <= 6.8e-10)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * Float64(sin(phi1) * cos(phi2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -5.5e-5], N[Not[LessEqual[lambda2, 6.8e-10]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -5.5 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 6.8 \cdot 10^{-10}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)\right)}\\
\end{array}
\end{array}
if lambda2 < -5.5000000000000002e-5 or 6.8000000000000003e-10 < lambda2 Initial program 63.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6483.2
Applied rewrites83.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6459.8
Applied rewrites59.8%
if -5.5000000000000002e-5 < lambda2 < 6.8000000000000003e-10Initial program 99.8%
Taylor expanded in lambda2 around 0
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
Final simplification79.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (- (sin phi1)) (cos phi2))))
(if (<= lambda1 -0.0034)
(atan2
(* (sin lambda1) (cos phi2))
(fma (sin phi2) (cos phi1) (* t_0 (cos (- lambda1 lambda2)))))
(if (<= lambda1 0.0125)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* t_0 (cos lambda2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -sin(phi1) * cos(phi2);
double tmp;
if (lambda1 <= -0.0034) {
tmp = atan2((sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), (t_0 * cos((lambda1 - lambda2)))));
} else if (lambda1 <= 0.0125) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (t_0 * cos(lambda2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(-sin(phi1)) * cos(phi2)) tmp = 0.0 if (lambda1 <= -0.0034) tmp = atan(Float64(sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(t_0 * cos(Float64(lambda1 - lambda2))))); elseif (lambda1 <= 0.0125) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(t_0 * cos(lambda2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.0034], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.0125], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-\sin \phi_1\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.0034:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{elif}\;\lambda_1 \leq 0.0125:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, t\_0 \cdot \cos \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -0.00339999999999999981Initial program 65.0%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites65.0%
Taylor expanded in lambda1 around inf
Applied rewrites69.2%
if -0.00339999999999999981 < lambda1 < 0.012500000000000001Initial program 99.0%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6499.0
Applied rewrites99.0%
if 0.012500000000000001 < lambda1 Initial program 63.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.3
Applied rewrites80.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6470.4
Applied rewrites70.4%
Final simplification83.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.0034)
(atan2
(* (sin lambda1) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (* (- (sin phi1)) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= lambda1 0.0125)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (cos lambda2) (sin phi1)) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.0034) {
tmp = atan2((sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), ((-sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else if (lambda1 <= 0.0125) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.0034) tmp = atan(Float64(sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-sin(phi1)) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); elseif (lambda1 <= 0.0125) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.0034], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.0125], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.0034:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\sin \phi_1\right) \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{elif}\;\lambda_1 \leq 0.0125:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -0.00339999999999999981Initial program 65.0%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites65.0%
Taylor expanded in lambda1 around inf
Applied rewrites69.2%
if -0.00339999999999999981 < lambda1 < 0.012500000000000001Initial program 99.0%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6499.0
Applied rewrites99.0%
if 0.012500000000000001 < lambda1 Initial program 63.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.3
Applied rewrites80.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6470.4
Applied rewrites70.4%
Final simplification83.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= lambda1 -21.0)
(atan2
(* (sin lambda1) (cos phi2))
(fma (sin phi2) (cos phi1) (* (* (- (sin phi1)) (cos phi2)) t_0)))
(if (<= lambda1 0.86)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) t_0)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (lambda1 <= -21.0) {
tmp = atan2((sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), ((-sin(phi1) * cos(phi2)) * t_0)));
} else if (lambda1 <= 0.86) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (lambda1 <= -21.0) tmp = atan(Float64(sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-sin(phi1)) * cos(phi2)) * t_0))); elseif (lambda1 <= 0.86) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -21.0], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.86], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -21:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\sin \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0\right)}\\
\mathbf{elif}\;\lambda_1 \leq 0.86:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -21Initial program 66.0%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites66.0%
Taylor expanded in lambda1 around inf
Applied rewrites70.2%
if -21 < lambda1 < 0.859999999999999987Initial program 98.2%
Taylor expanded in phi2 around 0
lift-sin.f6480.1
Applied rewrites80.1%
if 0.859999999999999987 < lambda1 Initial program 63.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.3
Applied rewrites80.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6470.4
Applied rewrites70.4%
Final simplification75.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -21.0)
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* (* (sin phi1) (cos phi2)) t_0)))
(if (<= lambda1 0.86)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_1 (* (sin phi1) t_0)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -21.0) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * t_0)));
} else if (lambda1 <= 0.86) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (sin(phi1) * t_0)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
if (lambda1 <= (-21.0d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * t_0)))
else if (lambda1 <= 0.86d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (sin(phi1) * t_0)))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -21.0) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else if (lambda1 <= 0.86) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_1 - (Math.sin(phi1) * t_0)));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -21.0: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - ((math.sin(phi1) * math.cos(phi2)) * t_0))) elif lambda1 <= 0.86: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_1 - (math.sin(phi1) * t_0))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -21.0) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); elseif (lambda1 <= 0.86) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_1 - Float64(sin(phi1) * t_0))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -21.0) tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * t_0))); elseif (lambda1 <= 0.86) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (sin(phi1) * t_0))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -21.0], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.86], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -21:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{elif}\;\lambda_1 \leq 0.86:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - \sin \phi_1 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -21Initial program 66.0%
Taylor expanded in lambda1 around inf
Applied rewrites70.2%
if -21 < lambda1 < 0.859999999999999987Initial program 98.2%
Taylor expanded in phi2 around 0
lift-sin.f6480.1
Applied rewrites80.1%
if 0.859999999999999987 < lambda1 Initial program 63.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.3
Applied rewrites80.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6470.4
Applied rewrites70.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.9e-35) (not (<= phi1 3.9e-13)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (* (cos (- lambda1 lambda2)) (sin phi1)) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.9e-35) || !(phi1 <= 3.9e-13)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 <= (-1.9d-35)) .or. (.not. (phi1 <= 3.9d-13))) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.9e-35) || !(phi1 <= 3.9e-13)) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.cos((lambda1 - lambda2)) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -1.9e-35) or not (phi1 <= 3.9e-13): tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.cos((lambda1 - lambda2)) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1.9e-35) || !(phi1 <= 3.9e-13)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -1.9e-35) || ~((phi1 <= 3.9e-13))) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1.9e-35], N[Not[LessEqual[phi1, 3.9e-13]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.9 \cdot 10^{-35} \lor \neg \left(\phi_1 \leq 3.9 \cdot 10^{-13}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.9000000000000001e-35 or 3.90000000000000004e-13 < phi1 Initial program 80.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6480.9
Applied rewrites80.9%
Taylor expanded in phi1 around 0
lift-sin.f6452.2
Applied rewrites52.2%
if -1.9000000000000001e-35 < phi1 < 3.90000000000000004e-13Initial program 81.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6497.8
Applied rewrites97.8%
Final simplification74.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -620000000.0)
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin phi1) t_0)))
(if (<= phi1 3.9e-13)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_1 (- (sin phi2) (* (* t_0 (sin phi1)) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -620000000.0) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
} else if (phi1 <= 3.9e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, (sin(phi2) - ((t_0 * sin(phi1)) * cos(phi2))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-620000000.0d0)) then
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)))
else if (phi1 <= 3.9d-13) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_1, (sin(phi2) - ((t_0 * sin(phi1)) * cos(phi2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -620000000.0) {
tmp = Math.atan2(t_1, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * t_0)));
} else if (phi1 <= 3.9e-13) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_1, (Math.sin(phi2) - ((t_0 * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -620000000.0: tmp = math.atan2(t_1, ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * t_0))) elif phi1 <= 3.9e-13: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_1, (math.sin(phi2) - ((t_0 * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -620000000.0) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0))); elseif (phi1 <= 3.9e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, Float64(sin(phi2) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -620000000.0) tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0))); elseif (phi1 <= 3.9e-13) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_1, (sin(phi2) - ((t_0 * sin(phi1)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -620000000.0], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 3.9e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -620000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 3.9 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if phi1 < -6.2e8Initial program 86.3%
Taylor expanded in phi2 around 0
lift-sin.f6457.8
Applied rewrites57.8%
if -6.2e8 < phi1 < 3.90000000000000004e-13Initial program 79.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6497.6
Applied rewrites97.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6494.2
Applied rewrites94.2%
if 3.90000000000000004e-13 < phi1 Initial program 79.4%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6479.3
Applied rewrites79.3%
Taylor expanded in phi1 around 0
lift-sin.f6450.1
Applied rewrites50.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.35e-31) (not (<= phi2 2.3e+14)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
(*
(sin (- lambda1 lambda2))
(fma (* phi2 phi2) (- (* 0.041666666666666664 (* phi2 phi2)) 0.5) 1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.35e-31) || !(phi2 <= 2.3e+14)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * fma((phi2 * phi2), ((0.041666666666666664 * (phi2 * phi2)) - 0.5), 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.35e-31) || !(phi2 <= 2.3e+14)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * fma(Float64(phi2 * phi2), Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5), 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.35e-31], N[Not[LessEqual[phi2, 2.3e+14]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.35 \cdot 10^{-31} \lor \neg \left(\phi_2 \leq 2.3 \cdot 10^{+14}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, 0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -1.35000000000000007e-31 or 2.3e14 < phi2 Initial program 75.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.4
Applied rewrites90.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6462.6
Applied rewrites62.6%
if -1.35000000000000007e-31 < phi2 < 2.3e14Initial program 87.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6485.3
Applied rewrites85.3%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6485.4
Applied rewrites85.4%
Final simplification72.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -55000000000.0) (not (<= phi2 2.3e+14)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(*
t_0
(fma (* phi2 phi2) (- (* 0.041666666666666664 (* phi2 phi2)) 0.5) 1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -55000000000.0) || !(phi2 <= 2.3e+14)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_0 * fma((phi2 * phi2), ((0.041666666666666664 * (phi2 * phi2)) - 0.5), 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -55000000000.0) || !(phi2 <= 2.3e+14)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5), 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -55000000000.0], N[Not[LessEqual[phi2, 2.3e+14]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -55000000000 \lor \neg \left(\phi_2 \leq 2.3 \cdot 10^{+14}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, 0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -5.5e10 or 2.3e14 < phi2 Initial program 76.5%
Taylor expanded in phi1 around 0
lift-sin.f6448.8
Applied rewrites48.8%
if -5.5e10 < phi2 < 2.3e14Initial program 85.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.6
Applied rewrites82.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6482.8
Applied rewrites82.8%
Final simplification65.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -55000000000.0) (not (<= phi2 2.3e+14)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(*
t_0
(+
1.0
(* (* phi2 phi2) (- (* 0.041666666666666664 (* phi2 phi2)) 0.5))))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(* (sin phi1) (fma -0.5 (* phi2 phi2) 1.0))
(cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -55000000000.0) || !(phi2 <= 2.3e+14)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_0 * (1.0 + ((phi2 * phi2) * ((0.041666666666666664 * (phi2 * phi2)) - 0.5)))), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * fma(-0.5, (phi2 * phi2), 1.0)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -55000000000.0) || !(phi2 <= 2.3e+14)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_0 * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5)))), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * fma(-0.5, Float64(phi2 * phi2), 1.0)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -55000000000.0], N[Not[LessEqual[phi2, 2.3e+14]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -55000000000 \lor \neg \left(\phi_2 \leq 2.3 \cdot 10^{+14}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5\right)\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -5.5e10 or 2.3e14 < phi2 Initial program 76.5%
Taylor expanded in phi1 around 0
lift-sin.f6448.8
Applied rewrites48.8%
if -5.5e10 < phi2 < 2.3e14Initial program 85.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.6
Applied rewrites82.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6482.5
Applied rewrites82.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6482.7
Applied rewrites82.7%
Final simplification65.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -9000000.0) (not (<= phi2 0.245)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(* t_0 (+ 1.0 (* -0.5 (* phi2 phi2))))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(* (sin phi1) (fma -0.5 (* phi2 phi2) 1.0))
(cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -9000000.0) || !(phi2 <= 0.245)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * fma(-0.5, (phi2 * phi2), 1.0)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -9000000.0) || !(phi2 <= 0.245)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * fma(-0.5, Float64(phi2 * phi2), 1.0)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -9000000.0], N[Not[LessEqual[phi2, 0.245]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -9000000 \lor \neg \left(\phi_2 \leq 0.245\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -9e6 or 0.245 < phi2 Initial program 77.0%
Taylor expanded in phi1 around 0
lift-sin.f6448.1
Applied rewrites48.1%
if -9e6 < phi2 < 0.245Initial program 85.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.3
Applied rewrites84.3%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6484.2
Applied rewrites84.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.2
Applied rewrites84.2%
Final simplification65.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.00043) (not (<= phi2 0.245)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
t_0
(- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00043) || !(phi2 <= 0.245)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.00043d0)) .or. (.not. (phi2 <= 0.245d0))) then
tmp = atan2((t_0 * cos(phi2)), sin(phi2))
else
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00043) || !(phi2 <= 0.245)) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, ((phi2 * Math.cos(phi1)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.00043) or not (phi2 <= 0.245): tmp = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_0, ((phi2 * math.cos(phi1)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.00043) || !(phi2 <= 0.245)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(t_0, Float64(Float64(phi2 * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.00043) || ~((phi2 <= 0.245))) tmp = atan2((t_0 * cos(phi2)), sin(phi2)); else tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00043], N[Not[LessEqual[phi2, 0.245]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.00043 \lor \neg \left(\phi_2 \leq 0.245\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < -4.29999999999999989e-4 or 0.245 < phi2 Initial program 76.5%
Taylor expanded in phi1 around 0
lift-sin.f6447.6
Applied rewrites47.6%
if -4.29999999999999989e-4 < phi2 < 0.245Initial program 86.1%
Taylor expanded in phi1 around 0
lift-sin.f6454.3
Applied rewrites54.3%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6454.3
Applied rewrites54.3%
Taylor expanded in phi2 around 0
lower--.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6485.6
Applied rewrites85.6%
Final simplification65.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi2 -9.2e-8) (not (<= phi2 6.2e+26)))
(atan2 t_0 (sin phi2))
(atan2 t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if ((phi2 <= -9.2e-8) || !(phi2 <= 6.2e+26)) {
tmp = atan2(t_0, sin(phi2));
} else {
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = sin((lambda1 - lambda2)) * cos(phi2)
if ((phi2 <= (-9.2d-8)) .or. (.not. (phi2 <= 6.2d+26))) then
tmp = atan2(t_0, sin(phi2))
else
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if ((phi2 <= -9.2e-8) || !(phi2 <= 6.2e+26)) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if (phi2 <= -9.2e-8) or not (phi2 <= 6.2e+26): tmp = math.atan2(t_0, math.sin(phi2)) else: tmp = math.atan2(t_0, (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if ((phi2 <= -9.2e-8) || !(phi2 <= 6.2e+26)) tmp = atan(t_0, sin(phi2)); else tmp = atan(t_0, Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if ((phi2 <= -9.2e-8) || ~((phi2 <= 6.2e+26))) tmp = atan2(t_0, sin(phi2)); else tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -9.2e-8], N[Not[LessEqual[phi2, 6.2e+26]], $MachinePrecision]], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -9.2 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 6.2 \cdot 10^{+26}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -9.2000000000000003e-8 or 6.1999999999999999e26 < phi2 Initial program 75.6%
Taylor expanded in phi1 around 0
lift-sin.f6448.8
Applied rewrites48.8%
if -9.2000000000000003e-8 < phi2 < 6.1999999999999999e26Initial program 87.0%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6482.1
Applied rewrites82.1%
Final simplification64.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -9.2e-8) (not (<= phi2 6.2e+26)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2 t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -9.2e-8) || !(phi2 <= 6.2e+26)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = sin((lambda1 - lambda2))
if ((phi2 <= (-9.2d-8)) .or. (.not. (phi2 <= 6.2d+26))) then
tmp = atan2((t_0 * cos(phi2)), sin(phi2))
else
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -9.2e-8) || !(phi2 <= 6.2e+26)) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -9.2e-8) or not (phi2 <= 6.2e+26): tmp = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_0, (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -9.2e-8) || !(phi2 <= 6.2e+26)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(t_0, Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -9.2e-8) || ~((phi2 <= 6.2e+26))) tmp = atan2((t_0 * cos(phi2)), sin(phi2)); else tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -9.2e-8], N[Not[LessEqual[phi2, 6.2e+26]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -9.2 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 6.2 \cdot 10^{+26}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -9.2000000000000003e-8 or 6.1999999999999999e26 < phi2 Initial program 75.6%
Taylor expanded in phi1 around 0
lift-sin.f6448.8
Applied rewrites48.8%
if -9.2000000000000003e-8 < phi2 < 6.1999999999999999e26Initial program 87.0%
Taylor expanded in phi1 around 0
lift-sin.f6452.8
Applied rewrites52.8%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6452.8
Applied rewrites52.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6482.1
Applied rewrites82.1%
Final simplification64.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -5.0) (not (<= lambda1 1.78e-34))) (atan2 (* (sin lambda1) (cos phi2)) (sin phi2)) (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -5.0) || !(lambda1 <= 1.78e-34)) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda1 <= (-5.0d0)) .or. (.not. (lambda1 <= 1.78d-34))) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -5.0) || !(lambda1 <= 1.78e-34)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -5.0) or not (lambda1 <= 1.78e-34): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -5.0) || !(lambda1 <= 1.78e-34)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -5.0) || ~((lambda1 <= 1.78e-34))) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -5.0], N[Not[LessEqual[lambda1, 1.78e-34]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -5 \lor \neg \left(\lambda_1 \leq 1.78 \cdot 10^{-34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -5 or 1.78e-34 < lambda1 Initial program 65.9%
Taylor expanded in phi1 around 0
lift-sin.f6447.3
Applied rewrites47.3%
Taylor expanded in lambda1 around inf
Applied rewrites49.4%
if -5 < lambda1 < 1.78e-34Initial program 98.1%
Taylor expanded in phi1 around 0
lift-sin.f6454.6
Applied rewrites54.6%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6447.5
Applied rewrites47.5%
Final simplification48.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -8.2e-32) (not (<= lambda1 4.6e-38))) (atan2 (* (sin lambda1) (cos phi2)) (sin phi2)) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -8.2e-32) || !(lambda1 <= 4.6e-38)) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda1 <= (-8.2d-32)) .or. (.not. (lambda1 <= 4.6d-38))) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -8.2e-32) || !(lambda1 <= 4.6e-38)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -8.2e-32) or not (lambda1 <= 4.6e-38): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -8.2e-32) || !(lambda1 <= 4.6e-38)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -8.2e-32) || ~((lambda1 <= 4.6e-38))) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -8.2e-32], N[Not[LessEqual[lambda1, 4.6e-38]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -8.2 \cdot 10^{-32} \lor \neg \left(\lambda_1 \leq 4.6 \cdot 10^{-38}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\end{array}
\end{array}
if lambda1 < -8.1999999999999995e-32 or 4.60000000000000003e-38 < lambda1 Initial program 66.8%
Taylor expanded in phi1 around 0
lift-sin.f6446.5
Applied rewrites46.5%
Taylor expanded in lambda1 around inf
Applied rewrites47.3%
if -8.1999999999999995e-32 < lambda1 < 4.60000000000000003e-38Initial program 99.9%
Taylor expanded in phi1 around 0
lift-sin.f6456.4
Applied rewrites56.4%
Taylor expanded in phi2 around 0
Applied rewrites41.0%
Final simplification44.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
\end{array}
Initial program 81.0%
Taylor expanded in phi1 around 0
lift-sin.f6450.7
Applied rewrites50.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -3.2)
(atan2 t_0 phi2)
(atan2 t_0 (* phi2 (fma -0.16666666666666666 (* phi2 phi2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= -3.2) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (phi2 * fma(-0.16666666666666666, (phi2 * phi2), 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= -3.2) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(phi2 * fma(-0.16666666666666666, Float64(phi2 * phi2), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.2], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(phi2 * N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -3.2:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \mathsf{fma}\left(-0.16666666666666666, \phi_2 \cdot \phi_2, 1\right)}\\
\end{array}
\end{array}
if phi2 < -3.2000000000000002Initial program 70.7%
Taylor expanded in phi1 around 0
lift-sin.f6446.9
Applied rewrites46.9%
Taylor expanded in phi2 around 0
Applied rewrites25.6%
if -3.2000000000000002 < phi2 Initial program 84.6%
Taylor expanded in phi1 around 0
lift-sin.f6452.1
Applied rewrites52.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6442.6
Applied rewrites42.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 1.1e+63) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2) (atan2 (* lambda1 (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.1e+63) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2((lambda1 * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 <= 1.1d+63) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
else
tmp = atan2((lambda1 * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.1e+63) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((lambda1 * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.1e+63: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) else: tmp = math.atan2((lambda1 * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.1e+63) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(lambda1 * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1.1e+63) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan2((lambda1 * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.1e+63], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(lambda1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.1 \cdot 10^{+63}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 1.0999999999999999e63Initial program 80.6%
Taylor expanded in phi1 around 0
lift-sin.f6450.9
Applied rewrites50.9%
Taylor expanded in phi2 around 0
Applied rewrites42.1%
if 1.0999999999999999e63 < phi2 Initial program 82.2%
Taylor expanded in phi1 around 0
lift-sin.f6450.1
Applied rewrites50.1%
Taylor expanded in lambda1 around 0
+-commutativeN/A
lower-fma.f64N/A
cos-neg-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6430.5
Applied rewrites30.5%
Taylor expanded in lambda2 around 0
Applied rewrites14.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 2.6e-9) (atan2 (sin (- lambda1 lambda2)) phi2) (atan2 (- (sin lambda2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.6e-9) {
tmp = atan2(sin((lambda1 - lambda2)), phi2);
} else {
tmp = atan2(-sin(lambda2), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 <= 2.6d-9) then
tmp = atan2(sin((lambda1 - lambda2)), phi2)
else
tmp = atan2(-sin(lambda2), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.6e-9) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
} else {
tmp = Math.atan2(-Math.sin(lambda2), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 2.6e-9: tmp = math.atan2(math.sin((lambda1 - lambda2)), phi2) else: tmp = math.atan2(-math.sin(lambda2), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 2.6e-9) tmp = atan(sin(Float64(lambda1 - lambda2)), phi2); else tmp = atan(Float64(-sin(lambda2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 2.6e-9) tmp = atan2(sin((lambda1 - lambda2)), phi2); else tmp = atan2(-sin(lambda2), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.6e-9], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[(-N[Sin[lambda2], $MachinePrecision]) / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 2.6000000000000001e-9Initial program 80.3%
Taylor expanded in phi1 around 0
lift-sin.f6452.1
Applied rewrites52.1%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6440.8
Applied rewrites40.8%
Taylor expanded in phi2 around 0
Applied rewrites40.6%
if 2.6000000000000001e-9 < phi2 Initial program 82.8%
Taylor expanded in phi1 around 0
lift-sin.f6447.1
Applied rewrites47.1%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6413.0
Applied rewrites13.0%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6411.7
Applied rewrites11.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}
\end{array}
Initial program 81.0%
Taylor expanded in phi1 around 0
lift-sin.f6450.7
Applied rewrites50.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6433.2
Applied rewrites33.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 -5e-7)
(atan2 t_0 phi2)
(atan2 t_0 (* phi2 (+ 1.0 (* -0.16666666666666666 (* phi2 phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -5e-7) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = sin((lambda1 - lambda2))
if (phi2 <= (-5d-7)) then
tmp = atan2(t_0, phi2)
else
tmp = atan2(t_0, (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 * phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -5e-7) {
tmp = Math.atan2(t_0, phi2);
} else {
tmp = Math.atan2(t_0, (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -5e-7: tmp = math.atan2(t_0, phi2) else: tmp = math.atan2(t_0, (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -5e-7) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * Float64(phi2 * phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -5e-7) tmp = atan2(t_0, phi2); else tmp = atan2(t_0, (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -5e-7], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -5 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -4.99999999999999977e-7Initial program 70.0%
Taylor expanded in phi1 around 0
lift-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6417.2
Applied rewrites17.2%
Taylor expanded in phi2 around 0
Applied rewrites16.7%
if -4.99999999999999977e-7 < phi2 Initial program 85.1%
Taylor expanded in phi1 around 0
lift-sin.f6452.1
Applied rewrites52.1%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6439.2
Applied rewrites39.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6438.6
Applied rewrites38.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 -5.2e-49) (atan2 (- (sin lambda2)) phi2) (atan2 (sin lambda1) phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -5.2e-49) {
tmp = atan2(-sin(lambda2), phi2);
} else {
tmp = atan2(sin(lambda1), phi2);
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= (-5.2d-49)) then
tmp = atan2(-sin(lambda2), phi2)
else
tmp = atan2(sin(lambda1), phi2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -5.2e-49) {
tmp = Math.atan2(-Math.sin(lambda2), phi2);
} else {
tmp = Math.atan2(Math.sin(lambda1), phi2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= -5.2e-49: tmp = math.atan2(-math.sin(lambda2), phi2) else: tmp = math.atan2(math.sin(lambda1), phi2) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -5.2e-49) tmp = atan(Float64(-sin(lambda2)), phi2); else tmp = atan(sin(lambda1), phi2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= -5.2e-49) tmp = atan2(-sin(lambda2), phi2); else tmp = atan2(sin(lambda1), phi2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -5.2e-49], N[ArcTan[(-N[Sin[lambda2], $MachinePrecision]) / phi2], $MachinePrecision], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / phi2], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -5.2 \cdot 10^{-49}:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\phi_2}\\
\end{array}
\end{array}
if lambda2 < -5.1999999999999999e-49Initial program 70.5%
Taylor expanded in phi1 around 0
lift-sin.f6448.4
Applied rewrites48.4%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6431.8
Applied rewrites31.8%
Taylor expanded in phi2 around 0
Applied rewrites29.6%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6427.4
Applied rewrites27.4%
if -5.1999999999999999e-49 < lambda2 Initial program 84.9%
Taylor expanded in phi1 around 0
lift-sin.f6451.6
Applied rewrites51.6%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6433.7
Applied rewrites33.7%
Taylor expanded in phi2 around 0
Applied rewrites31.0%
Taylor expanded in lambda1 around inf
Applied rewrites29.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), phi2);
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}
\end{array}
Initial program 81.0%
Taylor expanded in phi1 around 0
lift-sin.f6450.7
Applied rewrites50.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6433.2
Applied rewrites33.2%
Taylor expanded in phi2 around 0
Applied rewrites30.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), phi2);
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin(lambda1), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\phi_2}
\end{array}
Initial program 81.0%
Taylor expanded in phi1 around 0
lift-sin.f6450.7
Applied rewrites50.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
sin-mult-revN/A
lift-sin.f64N/A
lift--.f6433.2
Applied rewrites33.2%
Taylor expanded in phi2 around 0
Applied rewrites30.6%
Taylor expanded in lambda1 around inf
Applied rewrites24.8%
herbie shell --seed 2025027
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Bearing on a great circle"
:precision binary64
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))