
(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 44 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
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos 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(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(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(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(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[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[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(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 78.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.f6489.3
Applied rewrites89.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
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
(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 78.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.f6489.3
Applied rewrites89.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%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -6.9e-6) (not (<= phi2 2.7e-30)))
(atan2
t_1
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
t_1
(-
t_0
(*
(sin phi1)
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -6.9e-6) || !(phi2 <= 2.7e-30)) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -6.9e-6) || !(phi2 <= 2.7e-30)) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))); end return 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[(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]}, If[Or[LessEqual[phi2, -6.9e-6], N[Not[LessEqual[phi2, 2.7e-30]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -6.9 \cdot 10^{-6} \lor \neg \left(\phi_2 \leq 2.7 \cdot 10^{-30}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \sin \phi_1 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -6.9e-6 or 2.69999999999999987e-30 < phi2 Initial program 76.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.f6490.6
Applied rewrites90.6%
if -6.9e-6 < phi2 < 2.69999999999999987e-30Initial program 81.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.f6487.8
Applied rewrites87.8%
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
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-sin.f6499.8
Applied rewrites99.8%
Final simplification95.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -1.25e-13) (not (<= phi2 2.7e-30)))
(atan2
t_0
(- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2)))))
(atan2
t_0
(-
(sin phi2)
(*
t_1
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -1.25e-13) || !(phi2 <= 2.7e-30)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, (sin(phi2) - (t_1 * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -1.25e-13) || !(phi2 <= 2.7e-30)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(t_1 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -1.25e-13], N[Not[LessEqual[phi2, 2.7e-30]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.25 \cdot 10^{-13} \lor \neg \left(\phi_2 \leq 2.7 \cdot 10^{-30}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -1.24999999999999997e-13 or 2.69999999999999987e-30 < phi2 Initial program 76.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.7
Applied rewrites90.7%
if -1.24999999999999997e-13 < phi2 < 2.69999999999999987e-30Initial program 81.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.f6487.6
Applied rewrites87.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.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
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Final simplification95.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -6.9e-6) (not (<= phi2 2.7e-30)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
(atan2
(fma (cos lambda2) (sin lambda1) (* (- (cos lambda1)) (sin lambda2)))
(-
t_0
(*
t_1
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -6.9e-6) || !(phi2 <= 2.7e-30)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(fma(cos(lambda2), sin(lambda1), (-cos(lambda1) * sin(lambda2))), (t_0 - (t_1 * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -6.9e-6) || !(phi2 <= 2.7e-30)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(fma(cos(lambda2), sin(lambda1), Float64(Float64(-cos(lambda1)) * sin(lambda2))), Float64(t_0 - Float64(t_1 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))); end return 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[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -6.9e-6], N[Not[LessEqual[phi2, 2.7e-30]], $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[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -6.9 \cdot 10^{-6} \lor \neg \left(\phi_2 \leq 2.7 \cdot 10^{-30}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \sin \lambda_1, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -6.9e-6 or 2.69999999999999987e-30 < phi2 Initial program 76.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.f6490.6
Applied rewrites90.6%
if -6.9e-6 < phi2 < 2.69999999999999987e-30Initial program 81.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.f6487.8
Applied rewrites87.8%
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
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
sin-diff-revN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Final simplification95.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -1.12e-38) (not (<= phi2 1.95e-87)))
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
t_0
(-
(fma
(* (cos lambda1) (cos lambda2))
(sin phi1)
(* (* (sin lambda2) (sin lambda1)) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -1.12e-38) || !(phi2 <= 1.95e-87)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, -fma((cos(lambda1) * cos(lambda2)), sin(phi1), ((sin(lambda2) * sin(lambda1)) * sin(phi1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -1.12e-38) || !(phi2 <= 1.95e-87)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(-fma(Float64(cos(lambda1) * cos(lambda2)), sin(phi1), Float64(Float64(sin(lambda2) * sin(lambda1)) * sin(phi1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, If[Or[LessEqual[phi2, -1.12e-38], N[Not[LessEqual[phi2, 1.95e-87]], $MachinePrecision]], N[ArcTan[t$95$0 / 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], N[ArcTan[t$95$0 / (-N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.12 \cdot 10^{-38} \lor \neg \left(\phi_2 \leq 1.95 \cdot 10^{-87}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-\mathsf{fma}\left(\cos \lambda_1 \cdot \cos \lambda_2, \sin \phi_1, \left(\sin \lambda_2 \cdot \sin \lambda_1\right) \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -1.1200000000000001e-38 or 1.9499999999999999e-87 < phi2 Initial program 76.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.6
Applied rewrites90.6%
if -1.1200000000000001e-38 < phi2 < 1.9499999999999999e-87Initial program 83.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.f6487.2
Applied rewrites87.2%
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.f6484.6
Applied rewrites84.6%
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
cos-diff-revN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-sin.f6497.2
Applied rewrites97.2%
Final simplification93.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (cos lambda1)))
(t_1 (fma (sin phi2) (cos phi1) (* t_0 (* (cos phi2) (sin phi1))))))
(if (<= lambda1 -10500000000.0)
(atan2
(* (fma (sin lambda1) (cos lambda2) (* t_0 (sin lambda2))) (cos phi2))
t_1)
(if (<= lambda1 2.6e-9)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -cos(lambda1);
double t_1 = fma(sin(phi2), cos(phi1), (t_0 * (cos(phi2) * sin(phi1))));
double tmp;
if (lambda1 <= -10500000000.0) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (t_0 * sin(lambda2))) * cos(phi2)), t_1);
} else if (lambda1 <= 2.6e-9) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), t_1);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-cos(lambda1)) t_1 = fma(sin(phi2), cos(phi1), Float64(t_0 * Float64(cos(phi2) * sin(phi1)))) tmp = 0.0 if (lambda1 <= -10500000000.0) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(t_0 * sin(lambda2))) * cos(phi2)), t_1); elseif (lambda1 <= 2.6e-9) tmp = atan(Float64(sin(Float64(lambda1 - 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)))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Cos[lambda1], $MachinePrecision])}, Block[{t$95$1 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -10500000000.0], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(t$95$0 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[lambda1, 2.6e-9], 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[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $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] / t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\cos \lambda_1\\
t_1 := \mathsf{fma}\left(\sin \phi_2, \cos \phi_1, t\_0 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)\\
\mathbf{if}\;\lambda_1 \leq -10500000000:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, t\_0 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\mathbf{elif}\;\lambda_1 \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;\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 \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \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}{t\_1}\\
\end{array}
\end{array}
if lambda1 < -1.05e10Initial program 56.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.f6474.7
Applied rewrites74.7%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6475.1
Applied rewrites75.1%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f6475.1
Applied rewrites75.1%
if -1.05e10 < lambda1 < 2.6000000000000001e-9Initial program 99.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6499.2
Applied rewrites99.2%
if 2.6000000000000001e-9 < lambda1 Initial program 65.8%
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.f6486.6
Applied rewrites86.6%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6486.6
Applied rewrites86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin lambda2))))
(if (or (<= lambda1 -3.6e-5) (not (<= lambda1 2.6e-9)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (cos lambda1)) (* (cos phi2) (sin phi1)))))
(atan2
(* (fma (cos lambda2) lambda1 t_0) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (fma (- lambda1) t_0 (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -sin(lambda2);
double tmp;
if ((lambda1 <= -3.6e-5) || !(lambda1 <= 2.6e-9)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2((fma(cos(lambda2), lambda1, t_0) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(-lambda1, t_0, cos(lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-sin(lambda2)) tmp = 0.0 if ((lambda1 <= -3.6e-5) || !(lambda1 <= 2.6e-9)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(Float64(fma(cos(lambda2), lambda1, t_0) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(Float64(-lambda1), t_0, cos(lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Sin[lambda2], $MachinePrecision])}, If[Or[LessEqual[lambda1, -3.6e-5], N[Not[LessEqual[lambda1, 2.6e-9]], $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[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * lambda1 + t$95$0), $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[((-lambda1) * t$95$0 + N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin \lambda_2\\
\mathbf{if}\;\lambda_1 \leq -3.6 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 2.6 \cdot 10^{-9}\right):\\
\;\;\;\;\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(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \lambda_1, t\_0\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(-\lambda_1, t\_0, \cos \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -3.60000000000000009e-5 or 2.6000000000000001e-9 < lambda1 Initial program 62.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.f6481.1
Applied rewrites81.1%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6481.0
Applied rewrites81.0%
if -3.60000000000000009e-5 < lambda1 < 2.6000000000000001e-9Initial program 99.3%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f6499.3
Applied rewrites99.3%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
Final simplification89.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin lambda2)))
(t_1 (- (cos lambda1)))
(t_2 (fma (sin phi2) (cos phi1) (* t_1 (* (cos phi2) (sin phi1))))))
(if (<= lambda1 -3.6e-5)
(atan2
(* (fma (sin lambda1) (cos lambda2) (* t_1 (sin lambda2))) (cos phi2))
t_2)
(if (<= lambda1 2.6e-9)
(atan2
(* (fma (cos lambda2) lambda1 t_0) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (fma (- lambda1) t_0 (cos lambda2)))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -sin(lambda2);
double t_1 = -cos(lambda1);
double t_2 = fma(sin(phi2), cos(phi1), (t_1 * (cos(phi2) * sin(phi1))));
double tmp;
if (lambda1 <= -3.6e-5) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (t_1 * sin(lambda2))) * cos(phi2)), t_2);
} else if (lambda1 <= 2.6e-9) {
tmp = atan2((fma(cos(lambda2), lambda1, t_0) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(-lambda1, t_0, cos(lambda2)))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-sin(lambda2)) t_1 = Float64(-cos(lambda1)) t_2 = fma(sin(phi2), cos(phi1), Float64(t_1 * Float64(cos(phi2) * sin(phi1)))) tmp = 0.0 if (lambda1 <= -3.6e-5) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(t_1 * sin(lambda2))) * cos(phi2)), t_2); elseif (lambda1 <= 2.6e-9) tmp = atan(Float64(fma(cos(lambda2), lambda1, t_0) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(Float64(-lambda1), t_0, cos(lambda2))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Sin[lambda2], $MachinePrecision])}, Block[{t$95$1 = (-N[Cos[lambda1], $MachinePrecision])}, Block[{t$95$2 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -3.6e-5], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(t$95$1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[lambda1, 2.6e-9], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * lambda1 + t$95$0), $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[((-lambda1) * t$95$0 + N[Cos[lambda2], $MachinePrecision]), $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] / t$95$2], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin \lambda_2\\
t_1 := -\cos \lambda_1\\
t_2 := \mathsf{fma}\left(\sin \phi_2, \cos \phi_1, t\_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)\\
\mathbf{if}\;\lambda_1 \leq -3.6 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, t\_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\lambda_1 \leq 2.6 \cdot 10^{-9}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \lambda_1, t\_0\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(-\lambda_1, t\_0, \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}{t\_2}\\
\end{array}
\end{array}
if lambda1 < -3.60000000000000009e-5Initial program 58.8%
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.f6475.8
Applied rewrites75.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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6475.6
Applied rewrites75.6%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lift-cos.f64N/A
lift-neg.f64N/A
lift-sin.f6475.6
Applied rewrites75.6%
if -3.60000000000000009e-5 < lambda1 < 2.6000000000000001e-9Initial program 99.3%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f6499.3
Applied rewrites99.3%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
if 2.6000000000000001e-9 < lambda1 Initial program 65.8%
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.f6486.6
Applied rewrites86.6%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6486.6
Applied rewrites86.6%
(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 78.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.f6489.3
Applied rewrites89.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (- t_1 (* (* (sin phi1) (cos phi2)) t_2)))
(t_4 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -0.0035)
(atan2 (* (- (sin lambda1) t_4) (cos phi2)) t_3)
(if (<= phi1 5.4e-6)
(atan2
(* (- t_0 t_4) (cos phi2))
(-
t_1
(*
(* (* (fma (* phi1 phi1) -0.16666666666666666 1.0) phi1) (cos phi2))
t_2)))
(atan2 (* (- t_0 (sin lambda2)) (cos phi2)) t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = cos((lambda1 - lambda2));
double t_3 = t_1 - ((sin(phi1) * cos(phi2)) * t_2);
double t_4 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -0.0035) {
tmp = atan2(((sin(lambda1) - t_4) * cos(phi2)), t_3);
} else if (phi1 <= 5.4e-6) {
tmp = atan2(((t_0 - t_4) * cos(phi2)), (t_1 - (((fma((phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_2)));
} else {
tmp = atan2(((t_0 - sin(lambda2)) * cos(phi2)), t_3);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2)) t_4 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -0.0035) tmp = atan(Float64(Float64(sin(lambda1) - t_4) * cos(phi2)), t_3); elseif (phi1 <= 5.4e-6) tmp = atan(Float64(Float64(t_0 - t_4) * cos(phi2)), Float64(t_1 - Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_2))); else tmp = atan(Float64(Float64(t_0 - sin(lambda2)) * cos(phi2)), t_3); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0035], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$4), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$3], $MachinePrecision], If[LessEqual[phi1, 5.4e-6], N[ArcTan[N[(N[(t$95$0 - t$95$4), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$3], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\\
t_4 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -0.0035:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_4\right) \cdot \cos \phi_2}{t\_3}\\
\mathbf{elif}\;\phi_1 \leq 5.4 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - t\_4\right) \cdot \cos \phi_2}{t\_1 - \left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_3}\\
\end{array}
\end{array}
if phi1 < -0.00350000000000000007Initial program 73.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.f6476.8
Applied rewrites76.8%
Taylor expanded in lambda2 around 0
lift-sin.f6475.6
Applied rewrites75.6%
if -0.00350000000000000007 < phi1 < 5.39999999999999997e-6Initial program 80.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.f6498.8
Applied rewrites98.8%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6498.8
Applied rewrites98.8%
if 5.39999999999999997e-6 < phi1 Initial program 82.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.f6484.3
Applied rewrites84.3%
Taylor expanded in lambda1 around 0
lift-sin.f6483.0
Applied rewrites83.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -0.0035) (not (<= phi1 1.7e-6)))
(atan2
(* (- (sin lambda1) t_0) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_1)))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_0) (cos phi2))
(fma (- phi1) (* t_1 (cos phi2)) (sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.0035) || !(phi1 <= 1.7e-6)) {
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), fma(-phi1, (t_1 * cos(phi2)), sin(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -0.0035) || !(phi1 <= 1.7e-6)) tmp = atan(Float64(Float64(sin(lambda1) - t_0) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), fma(Float64(-phi1), Float64(t_1 * cos(phi2)), sin(phi2))); 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.0035], N[Not[LessEqual[phi1, 1.7e-6]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $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] * t$95$1), $MachinePrecision]), $MachinePrecision]], $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[((-phi1) * N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.0035 \lor \neg \left(\phi_1 \leq 1.7 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_0\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_0\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, t\_1 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\end{array}
\end{array}
if phi1 < -0.00350000000000000007 or 1.70000000000000003e-6 < phi1 Initial program 77.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.f6480.5
Applied rewrites80.5%
Taylor expanded in lambda2 around 0
lift-sin.f6479.0
Applied rewrites79.0%
if -0.00350000000000000007 < phi1 < 1.70000000000000003e-6Initial program 80.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.f6498.8
Applied rewrites98.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6498.5
Applied rewrites98.5%
Final simplification88.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))
(t_2 (- (* (cos phi1) (sin phi2)) t_1))
(t_3 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -0.0035)
(atan2 (* (- (sin lambda1) t_3) (cos phi2)) t_2)
(if (<= phi1 1.75e-6)
(atan2 (* (- t_0 t_3) (cos phi2)) (- (sin phi2) t_1))
(atan2 (* (- t_0 (sin lambda2)) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double t_2 = (cos(phi1) * sin(phi2)) - t_1;
double t_3 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -0.0035) {
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2);
} else if (phi1 <= 1.75e-6) {
tmp = atan2(((t_0 - t_3) * cos(phi2)), (sin(phi2) - t_1));
} else {
tmp = atan2(((t_0 - sin(lambda2)) * 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 = sin(lambda1) * cos(lambda2)
t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
t_2 = (cos(phi1) * sin(phi2)) - t_1
t_3 = cos(lambda1) * sin(lambda2)
if (phi1 <= (-0.0035d0)) then
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2)
else if (phi1 <= 1.75d-6) then
tmp = atan2(((t_0 - t_3) * cos(phi2)), (sin(phi2) - t_1))
else
tmp = atan2(((t_0 - sin(lambda2)) * 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.sin(lambda1) * Math.cos(lambda2);
double t_1 = (Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double t_2 = (Math.cos(phi1) * Math.sin(phi2)) - t_1;
double t_3 = Math.cos(lambda1) * Math.sin(lambda2);
double tmp;
if (phi1 <= -0.0035) {
tmp = Math.atan2(((Math.sin(lambda1) - t_3) * Math.cos(phi2)), t_2);
} else if (phi1 <= 1.75e-6) {
tmp = Math.atan2(((t_0 - t_3) * Math.cos(phi2)), (Math.sin(phi2) - t_1));
} else {
tmp = Math.atan2(((t_0 - Math.sin(lambda2)) * Math.cos(phi2)), t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(lambda1) * math.cos(lambda2) t_1 = (math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) t_2 = (math.cos(phi1) * math.sin(phi2)) - t_1 t_3 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if phi1 <= -0.0035: tmp = math.atan2(((math.sin(lambda1) - t_3) * math.cos(phi2)), t_2) elif phi1 <= 1.75e-6: tmp = math.atan2(((t_0 - t_3) * math.cos(phi2)), (math.sin(phi2) - t_1)) else: tmp = math.atan2(((t_0 - math.sin(lambda2)) * math.cos(phi2)), t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - t_1) t_3 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -0.0035) tmp = atan(Float64(Float64(sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 1.75e-6) tmp = atan(Float64(Float64(t_0 - t_3) * cos(phi2)), Float64(sin(phi2) - t_1)); else tmp = atan(Float64(Float64(t_0 - sin(lambda2)) * cos(phi2)), t_2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(lambda1) * cos(lambda2); t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); t_2 = (cos(phi1) * sin(phi2)) - t_1; t_3 = cos(lambda1) * sin(lambda2); tmp = 0.0; if (phi1 <= -0.0035) tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 1.75e-6) tmp = atan2(((t_0 - t_3) * cos(phi2)), (sin(phi2) - t_1)); else tmp = atan2(((t_0 - sin(lambda2)) * cos(phi2)), t_2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0035], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 1.75e-6], N[ArcTan[N[(N[(t$95$0 - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - t\_1\\
t_3 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -0.0035:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_3\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 1.75 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - t\_3\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi1 < -0.00350000000000000007Initial program 73.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.f6476.8
Applied rewrites76.8%
Taylor expanded in lambda2 around 0
lift-sin.f6475.6
Applied rewrites75.6%
if -0.00350000000000000007 < phi1 < 1.74999999999999997e-6Initial program 80.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.f6498.8
Applied rewrites98.8%
Taylor expanded in phi1 around 0
lift-sin.f6498.5
Applied rewrites98.5%
if 1.74999999999999997e-6 < phi1 Initial program 82.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.f6484.3
Applied rewrites84.3%
Taylor expanded in lambda1 around 0
lift-sin.f6483.0
Applied rewrites83.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_1)))
(t_3 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -0.0035)
(atan2 (* (- (sin lambda1) t_3) (cos phi2)) t_2)
(if (<= phi1 1.75e-6)
(atan2
(* (- t_0 t_3) (cos phi2))
(fma (- phi1) (* t_1 (cos phi2)) (sin phi2)))
(atan2 (* (- t_0 (sin lambda2)) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = (cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1);
double t_3 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -0.0035) {
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2);
} else if (phi1 <= 1.75e-6) {
tmp = atan2(((t_0 - t_3) * cos(phi2)), fma(-phi1, (t_1 * cos(phi2)), sin(phi2)));
} else {
tmp = atan2(((t_0 - sin(lambda2)) * cos(phi2)), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_1)) t_3 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -0.0035) tmp = atan(Float64(Float64(sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 1.75e-6) tmp = atan(Float64(Float64(t_0 - t_3) * cos(phi2)), fma(Float64(-phi1), Float64(t_1 * cos(phi2)), sin(phi2))); else tmp = atan(Float64(Float64(t_0 - sin(lambda2)) * cos(phi2)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0035], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 1.75e-6], N[ArcTan[N[(N[(t$95$0 - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-phi1) * N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\\
t_3 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -0.0035:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_3\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 1.75 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - t\_3\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, t\_1 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi1 < -0.00350000000000000007Initial program 73.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.f6476.8
Applied rewrites76.8%
Taylor expanded in lambda2 around 0
lift-sin.f6475.6
Applied rewrites75.6%
if -0.00350000000000000007 < phi1 < 1.74999999999999997e-6Initial program 80.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.f6498.8
Applied rewrites98.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6498.5
Applied rewrites98.5%
if 1.74999999999999997e-6 < phi1 Initial program 82.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.f6484.3
Applied rewrites84.3%
Taylor expanded in lambda1 around 0
lift-sin.f6483.0
Applied rewrites83.0%
Final simplification88.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -0.0035) (not (<= phi1 1.75e-6)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma (- phi1) (* t_0 (cos phi2)) (sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.0035) || !(phi1 <= 1.75e-6)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(-phi1, (t_0 * cos(phi2)), sin(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -0.0035) || !(phi1 <= 1.75e-6)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-phi1), Float64(t_0 * 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[Or[LessEqual[phi1, -0.0035], N[Not[LessEqual[phi1, 1.75e-6]], $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[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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[((-phi1) * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.0035 \lor \neg \left(\phi_1 \leq 1.75 \cdot 10^{-6}\right):\\
\;\;\;\;\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 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}{\mathsf{fma}\left(-\phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\end{array}
\end{array}
if phi1 < -0.00350000000000000007 or 1.74999999999999997e-6 < phi1 Initial program 77.9%
if -0.00350000000000000007 < phi1 < 1.74999999999999997e-6Initial program 80.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.f6498.8
Applied rewrites98.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6498.5
Applied rewrites98.5%
Final simplification87.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -0.0035) (not (<= phi1 1.05e-10)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma (- phi1) (* (cos lambda1) (cos phi2)) (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -0.0035) || !(phi1 <= 1.05e-10)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(-phi1, (cos(lambda1) * cos(phi2)), sin(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -0.0035) || !(phi1 <= 1.05e-10)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-phi1), Float64(cos(lambda1) * cos(phi2)), sin(phi2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -0.0035], N[Not[LessEqual[phi1, 1.05e-10]], $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[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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[((-phi1) * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.0035 \lor \neg \left(\phi_1 \leq 1.05 \cdot 10^{-10}\right):\\
\;\;\;\;\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)}\\
\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}{\mathsf{fma}\left(-\phi_1, \cos \lambda_1 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\end{array}
\end{array}
if phi1 < -0.00350000000000000007 or 1.05e-10 < phi1 Initial program 77.9%
if -0.00350000000000000007 < phi1 < 1.05e-10Initial program 80.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.f6498.8
Applied rewrites98.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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6498.3
Applied rewrites98.3%
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-sin.f6498.1
Applied rewrites98.1%
Final simplification87.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2)))
(t_1 (* (sin phi1) (cos phi2))))
(if (<= lambda2 -2.8e-19)
t_0
(if (<= lambda2 2.8e-223)
(atan2
(* (sin lambda1) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (cos lambda1)) (* (cos phi2) (sin phi1)))))
(if (<= lambda2 3e+33)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* t_1 (cos (- lambda1 lambda2)))))
(if (<= lambda2 2.5e+261)
(atan2
(* (- (sin lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* t_1 (cos lambda2))))
t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if (lambda2 <= -2.8e-19) {
tmp = t_0;
} else if (lambda2 <= 2.8e-223) {
tmp = atan2((sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * (cos(phi2) * sin(phi1)))));
} else if (lambda2 <= 3e+33) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (t_1 * cos((lambda1 - lambda2)))));
} else if (lambda2 <= 2.5e+261) {
tmp = atan2((-sin(lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_1 * cos(lambda2))));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if (lambda2 <= -2.8e-19) tmp = t_0; elseif (lambda2 <= 2.8e-223) tmp = atan(Float64(sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * Float64(cos(phi2) * sin(phi1))))); elseif (lambda2 <= 3e+33) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); elseif (lambda2 <= 2.5e+261) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(lambda2)))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -2.8e-19], t$95$0, If[LessEqual[lambda2, 2.8e-223], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 3e+33], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 2.5e+261], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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}\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -2.8 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 2.8 \cdot 10^{-223}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{+33}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\lambda_2 \leq 2.5 \cdot 10^{+261}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -2.80000000000000003e-19 or 2.5e261 < lambda2 Initial program 52.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.f6478.8
Applied rewrites78.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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6464.2
Applied rewrites64.2%
Taylor expanded in phi1 around 0
lift-sin.f6463.7
Applied rewrites63.7%
if -2.80000000000000003e-19 < lambda2 < 2.80000000000000015e-223Initial program 99.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.f6499.6
Applied rewrites99.6%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
sin-diff-revN/A
lift-sin.f6492.1
Applied rewrites92.1%
if 2.80000000000000015e-223 < lambda2 < 2.99999999999999984e33Initial program 94.7%
Taylor expanded in phi1 around 0
lift-sin.f6484.0
Applied rewrites84.0%
if 2.99999999999999984e33 < lambda2 < 2.5e261Initial program 72.3%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6472.3
Applied rewrites72.3%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6473.8
Applied rewrites73.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))
(if (<= lambda2 -5e-7)
t_1
(if (<= lambda2 7.8e+14)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* (- (cos lambda1)) t_0)))
(if (<= lambda2 2.5e+261)
(atan2
(* (- (sin lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* t_0 (cos lambda2))))
t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
double tmp;
if (lambda2 <= -5e-7) {
tmp = t_1;
} else if (lambda2 <= 7.8e+14) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * t_0)));
} else if (lambda2 <= 2.5e+261) {
tmp = atan2((-sin(lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * cos(lambda2))));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda2 <= -5e-7) tmp = t_1; elseif (lambda2 <= 7.8e+14) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * t_0))); elseif (lambda2 <= 2.5e+261) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * cos(lambda2)))); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[lambda2, -5e-7], t$95$1, If[LessEqual[lambda2, 7.8e+14], 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], If[LessEqual[lambda2, 2.5e+261], N[ArcTan[N[((-N[Sin[lambda2], $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], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \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{if}\;\lambda_2 \leq -5 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 7.8 \cdot 10^{+14}:\\
\;\;\;\;\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)}\\
\mathbf{elif}\;\lambda_2 \leq 2.5 \cdot 10^{+261}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -4.99999999999999977e-7 or 2.5e261 < lambda2 Initial program 52.1%
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.f6478.6
Applied rewrites78.6%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6463.8
Applied rewrites63.8%
Taylor expanded in phi1 around 0
lift-sin.f6463.3
Applied rewrites63.3%
if -4.99999999999999977e-7 < lambda2 < 7.8e14Initial program 99.1%
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.1
Applied rewrites99.1%
if 7.8e14 < lambda2 < 2.5e261Initial program 70.2%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6470.3
Applied rewrites70.3%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6471.1
Applied rewrites71.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -2.8e-9) (not (<= phi1 6e-11)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 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 tmp;
if ((phi1 <= -2.8e-9) || !(phi1 <= 6e-11)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} 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 <= (-2.8d-9)) .or. (.not. (phi1 <= 6d-11))) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
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 <= -2.8e-9) || !(phi1 <= 6e-11)) {
tmp = 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)))));
} 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 <= -2.8e-9) or not (phi1 <= 6e-11): tmp = 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))))) 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 <= -2.8e-9) || !(phi1 <= 6e-11)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); 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 <= -2.8e-9) || ~((phi1 <= 6e-11))) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); 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, -2.8e-9], N[Not[LessEqual[phi1, 6e-11]], $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[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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 -2.8 \cdot 10^{-9} \lor \neg \left(\phi_1 \leq 6 \cdot 10^{-11}\right):\\
\;\;\;\;\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)}\\
\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 < -2.79999999999999984e-9 or 6e-11 < phi1 Initial program 77.3%
if -2.79999999999999984e-9 < phi1 < 6e-11Initial program 80.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.f6499.6
Applied rewrites99.6%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in phi1 around 0
lift-sin.f6497.2
Applied rewrites97.2%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -2.7e+16)
(atan2
(* (sin lambda1) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (cos lambda1)) (* (cos phi2) (sin phi1)))))
(if (<= phi1 6e-6)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -2.7e+16) {
tmp = atan2((sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * (cos(phi2) * sin(phi1)))));
} else if (phi1 <= 6e-6) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -2.7e+16) tmp = atan(Float64(sin(lambda1) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * Float64(cos(phi2) * sin(phi1))))); elseif (phi1 <= 6e-6) 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)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -2.7e+16], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 6e-6], 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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -2.7 \cdot 10^{+16}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\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}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi1 < -2.7e16Initial program 74.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.f6477.7
Applied rewrites77.7%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6467.1
Applied rewrites67.1%
Taylor expanded in lambda2 around 0
sin-diff-revN/A
lift-sin.f6458.2
Applied rewrites58.2%
if -2.7e16 < phi1 < 6.0000000000000002e-6Initial program 79.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.f6498.1
Applied rewrites98.1%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
lift-sin.f6494.7
Applied rewrites94.7%
if 6.0000000000000002e-6 < phi1 Initial program 81.8%
Taylor expanded in phi2 around 0
lift-sin.f6454.1
Applied rewrites54.1%
Final simplification75.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -46000000000000.0)
(atan2 t_1 (- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))
(if (<= phi1 6e-6)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin phi1) 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 <= -46000000000000.0) {
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 6e-6) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
}
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 <= (-46000000000000.0d0)) then
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)))
else if (phi1 <= 6d-6) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)))
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 <= -46000000000000.0) {
tmp = Math.atan2(t_1, (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else if (phi1 <= 6e-6) {
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.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * t_0)));
}
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 <= -46000000000000.0: tmp = math.atan2(t_1, (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) elif phi1 <= 6e-6: 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.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * 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 <= -46000000000000.0) tmp = atan(t_1, Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 6e-6) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0))); 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 <= -46000000000000.0) tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 6e-6) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0))); 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, -46000000000000.0], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 6e-6], 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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $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 -46000000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\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}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -4.6e13Initial program 74.7%
Taylor expanded in phi1 around 0
lift-sin.f6446.3
Applied rewrites46.3%
if -4.6e13 < phi1 < 6.0000000000000002e-6Initial program 79.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.f6498.1
Applied rewrites98.1%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
lift-sin.f6494.7
Applied rewrites94.7%
if 6.0000000000000002e-6 < phi1 Initial program 81.8%
Taylor expanded in phi2 around 0
lift-sin.f6454.1
Applied rewrites54.1%
Final simplification71.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2))))
(if (or (<= phi1 -46000000000000.0) (not (<= phi1 6.5e-6)))
(atan2
(* (- (sin lambda1) t_0) (cos phi2))
(* (cos (- lambda1 lambda2)) (- (sin phi1))))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_0) (cos phi2))
(sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double tmp;
if ((phi1 <= -46000000000000.0) || !(phi1 <= 6.5e-6)) {
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), (cos((lambda1 - lambda2)) * -sin(phi1)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * 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) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
if ((phi1 <= (-46000000000000.0d0)) .or. (.not. (phi1 <= 6.5d-6))) then
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), (cos((lambda1 - lambda2)) * -sin(phi1)))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * 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) * Math.sin(lambda2);
double tmp;
if ((phi1 <= -46000000000000.0) || !(phi1 <= 6.5e-6)) {
tmp = Math.atan2(((Math.sin(lambda1) - t_0) * Math.cos(phi2)), (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_0) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if (phi1 <= -46000000000000.0) or not (phi1 <= 6.5e-6): tmp = math.atan2(((math.sin(lambda1) - t_0) * math.cos(phi2)), (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_0) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if ((phi1 <= -46000000000000.0) || !(phi1 <= 6.5e-6)) tmp = atan(Float64(Float64(sin(lambda1) - t_0) * cos(phi2)), Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); tmp = 0.0; if ((phi1 <= -46000000000000.0) || ~((phi1 <= 6.5e-6))) tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), (cos((lambda1 - lambda2)) * -sin(phi1))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -46000000000000.0], N[Not[LessEqual[phi1, 6.5e-6]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $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[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -46000000000000 \lor \neg \left(\phi_1 \leq 6.5 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_0\right) \cdot \cos \phi_2}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_0\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -4.6e13 or 6.4999999999999996e-6 < phi1 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.f6480.8
Applied rewrites80.8%
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.f6450.0
Applied rewrites50.0%
Taylor expanded in lambda2 around 0
lift-sin.f6448.7
Applied rewrites48.7%
if -4.6e13 < phi1 < 6.4999999999999996e-6Initial program 79.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.f6498.1
Applied rewrites98.1%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
lift-sin.f6494.7
Applied rewrites94.7%
Final simplification71.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -46000000000000.0)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))
(if (<= phi1 6.5e-6)
(atan2
(* (- t_1 (* (cos lambda1) (sin lambda2))) (cos phi2))
(sin phi2))
(atan2 (* (- t_1 (sin lambda2)) (cos phi2)) (* t_0 (- (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -46000000000000.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 6.5e-6) {
tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(((t_1 - sin(lambda2)) * cos(phi2)), (t_0 * -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) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin(lambda1) * cos(lambda2)
if (phi1 <= (-46000000000000.0d0)) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)))
else if (phi1 <= 6.5d-6) then
tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2(((t_1 - sin(lambda2)) * cos(phi2)), (t_0 * -sin(phi1)))
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) * Math.cos(lambda2);
double tmp;
if (phi1 <= -46000000000000.0) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else if (phi1 <= 6.5e-6) {
tmp = Math.atan2(((t_1 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(((t_1 - Math.sin(lambda2)) * Math.cos(phi2)), (t_0 * -Math.sin(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(lambda1) * math.cos(lambda2) tmp = 0 if phi1 <= -46000000000000.0: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) elif phi1 <= 6.5e-6: tmp = math.atan2(((t_1 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(((t_1 - math.sin(lambda2)) * math.cos(phi2)), (t_0 * -math.sin(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -46000000000000.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 6.5e-6) tmp = atan(Float64(Float64(t_1 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(Float64(t_1 - sin(lambda2)) * cos(phi2)), Float64(t_0 * Float64(-sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(lambda1) * cos(lambda2); tmp = 0.0; if (phi1 <= -46000000000000.0) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 6.5e-6) tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2(((t_1 - sin(lambda2)) * cos(phi2)), (t_0 * -sin(phi1))); 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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -46000000000000.0], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 6.5e-6], N[ArcTan[N[(N[(t$95$1 - 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[(t$95$1 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -46000000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 6.5 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -4.6e13Initial program 74.7%
Taylor expanded in phi1 around 0
lift-sin.f6446.3
Applied rewrites46.3%
if -4.6e13 < phi1 < 6.4999999999999996e-6Initial program 79.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.f6498.1
Applied rewrites98.1%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
lift-sin.f6494.7
Applied rewrites94.7%
if 6.4999999999999996e-6 < phi1 Initial program 81.8%
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.1
Applied rewrites84.1%
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.f6453.8
Applied rewrites53.8%
Taylor expanded in lambda1 around 0
lift-sin.f6452.6
Applied rewrites52.6%
Final simplification71.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1))))
(t_1 (* (cos lambda1) (sin lambda2)))
(t_2 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -46000000000000.0)
(atan2 (* (- (sin lambda1) t_1) (cos phi2)) t_0)
(if (<= phi1 6.5e-6)
(atan2 (* (- t_2 t_1) (cos phi2)) (sin phi2))
(atan2 (* (- t_2 (sin lambda2)) (cos phi2)) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2)) * -sin(phi1);
double t_1 = cos(lambda1) * sin(lambda2);
double t_2 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -46000000000000.0) {
tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), t_0);
} else if (phi1 <= 6.5e-6) {
tmp = atan2(((t_2 - t_1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_0);
}
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((lambda1 - lambda2)) * -sin(phi1)
t_1 = cos(lambda1) * sin(lambda2)
t_2 = sin(lambda1) * cos(lambda2)
if (phi1 <= (-46000000000000.0d0)) then
tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), t_0)
else if (phi1 <= 6.5d-6) then
tmp = atan2(((t_2 - t_1) * cos(phi2)), sin(phi2))
else
tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_0)
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)) * -Math.sin(phi1);
double t_1 = Math.cos(lambda1) * Math.sin(lambda2);
double t_2 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if (phi1 <= -46000000000000.0) {
tmp = Math.atan2(((Math.sin(lambda1) - t_1) * Math.cos(phi2)), t_0);
} else if (phi1 <= 6.5e-6) {
tmp = Math.atan2(((t_2 - t_1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(((t_2 - Math.sin(lambda2)) * Math.cos(phi2)), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) * -math.sin(phi1) t_1 = math.cos(lambda1) * math.sin(lambda2) t_2 = math.sin(lambda1) * math.cos(lambda2) tmp = 0 if phi1 <= -46000000000000.0: tmp = math.atan2(((math.sin(lambda1) - t_1) * math.cos(phi2)), t_0) elif phi1 <= 6.5e-6: tmp = math.atan2(((t_2 - t_1) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(((t_2 - math.sin(lambda2)) * math.cos(phi2)), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1))) t_1 = Float64(cos(lambda1) * sin(lambda2)) t_2 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -46000000000000.0) tmp = atan(Float64(Float64(sin(lambda1) - t_1) * cos(phi2)), t_0); elseif (phi1 <= 6.5e-6) tmp = atan(Float64(Float64(t_2 - t_1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(Float64(t_2 - sin(lambda2)) * cos(phi2)), t_0); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)) * -sin(phi1); t_1 = cos(lambda1) * sin(lambda2); t_2 = sin(lambda1) * cos(lambda2); tmp = 0.0; if (phi1 <= -46000000000000.0) tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), t_0); elseif (phi1 <= 6.5e-6) tmp = atan2(((t_2 - t_1) * cos(phi2)), sin(phi2)); else tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_0); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -46000000000000.0], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], If[LessEqual[phi1, 6.5e-6], N[ArcTan[N[(N[(t$95$2 - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$2 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)\\
t_1 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -46000000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_1\right) \cdot \cos \phi_2}{t\_0}\\
\mathbf{elif}\;\phi_1 \leq 6.5 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - t\_1\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0}\\
\end{array}
\end{array}
if phi1 < -4.6e13Initial program 74.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.f6477.7
Applied rewrites77.7%
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.f6446.3
Applied rewrites46.3%
Taylor expanded in lambda2 around 0
lift-sin.f6445.4
Applied rewrites45.4%
if -4.6e13 < phi1 < 6.4999999999999996e-6Initial program 79.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.f6498.1
Applied rewrites98.1%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
lift-sin.f6494.7
Applied rewrites94.7%
if 6.4999999999999996e-6 < phi1 Initial program 81.8%
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.1
Applied rewrites84.1%
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.f6453.8
Applied rewrites53.8%
Taylor expanded in lambda1 around 0
lift-sin.f6452.6
Applied rewrites52.6%
Final simplification71.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -3.2e+16) (not (<= phi1 6.5e-6)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(* (cos (- lambda1 lambda2)) (- (sin phi1))))
(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 <= -3.2e+16) || !(phi1 <= 6.5e-6)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (cos((lambda1 - lambda2)) * -sin(phi1)));
} 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 <= (-3.2d+16)) .or. (.not. (phi1 <= 6.5d-6))) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (cos((lambda1 - lambda2)) * -sin(phi1)))
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 <= -3.2e+16) || !(phi1 <= 6.5e-6)) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
} 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 <= -3.2e+16) or not (phi1 <= 6.5e-6): tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) 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 <= -3.2e+16) || !(phi1 <= 6.5e-6)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); 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 <= -3.2e+16) || ~((phi1 <= 6.5e-6))) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (cos((lambda1 - lambda2)) * -sin(phi1))); 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, -3.2e+16], N[Not[LessEqual[phi1, 6.5e-6]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $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 -3.2 \cdot 10^{+16} \lor \neg \left(\phi_1 \leq 6.5 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\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 phi1 < -3.2e16 or 6.4999999999999996e-6 < phi1 Initial program 78.2%
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.f6447.8
Applied rewrites47.8%
if -3.2e16 < phi1 < 6.4999999999999996e-6Initial program 79.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.f6498.1
Applied rewrites98.1%
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
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
lift-sin.f6494.7
Applied rewrites94.7%
Final simplification70.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi1 -0.00345) (not (<= phi1 0.00095)))
(atan2 t_1 (* t_0 (- (sin phi1))))
(atan2
t_1
(fma
(sin phi2)
(fma (* phi1 phi1) -0.5 1.0)
(*
(*
(* (fma (* phi1 phi1) -0.16666666666666666 1.0) 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 <= -0.00345) || !(phi1 <= 0.00095)) {
tmp = atan2(t_1, (t_0 * -sin(phi1)));
} else {
tmp = atan2(t_1, fma(sin(phi2), fma((phi1 * phi1), -0.5, 1.0), (((fma((phi1 * phi1), -0.16666666666666666, 1.0) * 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 <= -0.00345) || !(phi1 <= 0.00095)) tmp = atan(t_1, Float64(t_0 * Float64(-sin(phi1)))); else tmp = atan(t_1, fma(sin(phi2), fma(Float64(phi1 * phi1), -0.5, 1.0), Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * Float64(-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[Or[LessEqual[phi1, -0.00345], N[Not[LessEqual[phi1, 0.00095]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] + N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * 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 -0.00345 \lor \neg \left(\phi_1 \leq 0.00095\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right), \left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot \phi_1\right) \cdot \left(-\cos \phi_2\right)\right) \cdot t\_0\right)}\\
\end{array}
\end{array}
if phi1 < -0.0034499999999999999 or 9.49999999999999998e-4 < phi1 Initial program 77.2%
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.f6447.3
Applied rewrites47.3%
if -0.0034499999999999999 < phi1 < 9.49999999999999998e-4Initial program 80.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.8
Applied rewrites80.8%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6480.8
Applied rewrites80.8%
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
Applied rewrites80.8%
Final simplification63.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi1 -0.00345) (not (<= phi1 0.00095)))
(atan2 t_1 (* t_0 (- (sin phi1))))
(atan2
t_1
(-
(* (fma (* phi1 phi1) -0.5 1.0) (sin phi2))
(*
(* (* (fma (* phi1 phi1) -0.16666666666666666 1.0) 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 <= -0.00345) || !(phi1 <= 0.00095)) {
tmp = atan2(t_1, (t_0 * -sin(phi1)));
} else {
tmp = atan2(t_1, ((fma((phi1 * phi1), -0.5, 1.0) * sin(phi2)) - (((fma((phi1 * phi1), -0.16666666666666666, 1.0) * 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 <= -0.00345) || !(phi1 <= 0.00095)) tmp = atan(t_1, Float64(t_0 * Float64(-sin(phi1)))); else tmp = atan(t_1, Float64(Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) * sin(phi2)) - Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * 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[Or[LessEqual[phi1, -0.00345], N[Not[LessEqual[phi1, 0.00095]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * 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 -0.00345 \lor \neg \left(\phi_1 \leq 0.00095\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) \cdot \sin \phi_2 - \left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -0.0034499999999999999 or 9.49999999999999998e-4 < phi1 Initial program 77.2%
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.f6447.3
Applied rewrites47.3%
if -0.0034499999999999999 < phi1 < 9.49999999999999998e-4Initial program 80.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.8
Applied rewrites80.8%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6480.8
Applied rewrites80.8%
Final simplification63.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi1 -0.0031) (not (<= phi1 0.00095)))
(atan2 t_1 (* t_0 (- (sin phi1))))
(atan2
t_1
(-
(* (fma (* phi1 phi1) -0.5 1.0) (sin phi2))
(* (* 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 <= -0.0031) || !(phi1 <= 0.00095)) {
tmp = atan2(t_1, (t_0 * -sin(phi1)));
} else {
tmp = atan2(t_1, ((fma((phi1 * phi1), -0.5, 1.0) * sin(phi2)) - ((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 <= -0.0031) || !(phi1 <= 0.00095)) tmp = atan(t_1, Float64(t_0 * Float64(-sin(phi1)))); else tmp = atan(t_1, Float64(Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) * sin(phi2)) - Float64(Float64(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[Or[LessEqual[phi1, -0.0031], N[Not[LessEqual[phi1, 0.00095]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(phi1 * 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 -0.0031 \lor \neg \left(\phi_1 \leq 0.00095\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) \cdot \sin \phi_2 - \left(\phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -0.00309999999999999989 or 9.49999999999999998e-4 < phi1 Initial program 77.2%
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.f6447.3
Applied rewrites47.3%
if -0.00309999999999999989 < phi1 < 9.49999999999999998e-4Initial program 80.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.8
Applied rewrites80.8%
Taylor expanded in phi1 around 0
Applied rewrites80.8%
Final simplification63.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi2 -102000000.0) (not (<= phi2 1500.0)))
(atan2 t_0 (sin phi2))
(atan2
t_0
(- (* (cos phi1) phi2) (* (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 <= -102000000.0) || !(phi2 <= 1500.0)) {
tmp = atan2(t_0, sin(phi2));
} else {
tmp = atan2(t_0, ((cos(phi1) * phi2) - (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 <= (-102000000.0d0)) .or. (.not. (phi2 <= 1500.0d0))) then
tmp = atan2(t_0, sin(phi2))
else
tmp = atan2(t_0, ((cos(phi1) * phi2) - (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 <= -102000000.0) || !(phi2 <= 1500.0)) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * phi2) - (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 <= -102000000.0) or not (phi2 <= 1500.0): tmp = math.atan2(t_0, math.sin(phi2)) else: tmp = math.atan2(t_0, ((math.cos(phi1) * phi2) - (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 <= -102000000.0) || !(phi2 <= 1500.0)) tmp = atan(t_0, sin(phi2)); else tmp = atan(t_0, Float64(Float64(cos(phi1) * phi2) - Float64(cos(Float64(lambda1 - lambda2)) * 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 <= -102000000.0) || ~((phi2 <= 1500.0))) tmp = atan2(t_0, sin(phi2)); else tmp = atan2(t_0, ((cos(phi1) * phi2) - (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, -102000000.0], N[Not[LessEqual[phi2, 1500.0]], $MachinePrecision]], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $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) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -102000000 \lor \neg \left(\phi_2 \leq 1500\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < -1.02e8 or 1500 < phi2 Initial program 75.2%
Taylor expanded in phi1 around 0
lift-sin.f6443.8
Applied rewrites43.8%
if -1.02e8 < phi2 < 1500Initial program 82.6%
Taylor expanded in phi2 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6481.3
Applied rewrites81.3%
Final simplification62.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 -102000000.0)
(atan2 t_0 (sin phi2))
(if (<= phi2 135.0)
(atan2 t_0 (- (* (cos phi1) phi2) (* t_1 (sin phi1))))
(atan2 t_0 (fma (- phi1) (* t_1 (cos phi2)) (sin phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -102000000.0) {
tmp = atan2(t_0, sin(phi2));
} else if (phi2 <= 135.0) {
tmp = atan2(t_0, ((cos(phi1) * phi2) - (t_1 * sin(phi1))));
} else {
tmp = atan2(t_0, fma(-phi1, (t_1 * cos(phi2)), sin(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -102000000.0) tmp = atan(t_0, sin(phi2)); elseif (phi2 <= 135.0) tmp = atan(t_0, Float64(Float64(cos(phi1) * phi2) - Float64(t_1 * sin(phi1)))); else tmp = atan(t_0, fma(Float64(-phi1), Float64(t_1 * cos(phi2)), sin(phi2))); 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]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -102000000.0], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 135.0], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $MachinePrecision] - N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[((-phi1) * N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -102000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{elif}\;\phi_2 \leq 135:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \phi_2 - t\_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(-\phi_1, t\_1 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\end{array}
\end{array}
if phi2 < -1.02e8Initial program 68.0%
Taylor expanded in phi1 around 0
lift-sin.f6440.8
Applied rewrites40.8%
if -1.02e8 < phi2 < 135Initial program 82.6%
Taylor expanded in phi2 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6481.3
Applied rewrites81.3%
if 135 < phi2 Initial program 83.5%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6449.6
Applied rewrites49.6%
Final simplification63.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -5.2e-7) (not (<= phi2 135.0)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(* t_0 1.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 <= -5.2e-7) || !(phi2 <= 135.0)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_0 * 1.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 <= (-5.2d-7)) .or. (.not. (phi2 <= 135.0d0))) then
tmp = atan2((t_0 * cos(phi2)), sin(phi2))
else
tmp = atan2((t_0 * 1.0d0), ((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 <= -5.2e-7) || !(phi2 <= 135.0)) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((t_0 * 1.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 <= -5.2e-7) or not (phi2 <= 135.0): tmp = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((t_0 * 1.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 <= -5.2e-7) || !(phi2 <= 135.0)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_0 * 1.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 <= -5.2e-7) || ~((phi2 <= 135.0))) tmp = atan2((t_0 * cos(phi2)), sin(phi2)); else tmp = atan2((t_0 * 1.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, -5.2e-7], N[Not[LessEqual[phi2, 135.0]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / 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 -5.2 \cdot 10^{-7} \lor \neg \left(\phi_2 \leq 135\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < -5.19999999999999998e-7 or 135 < phi2 Initial program 75.4%
Taylor expanded in phi1 around 0
lift-sin.f6444.1
Applied rewrites44.1%
if -5.19999999999999998e-7 < phi2 < 135Initial program 82.5%
Taylor expanded in phi1 around 0
lift-sin.f6450.6
Applied rewrites50.6%
Taylor expanded in phi2 around 0
Applied rewrites50.6%
Taylor expanded in phi2 around 0
Applied rewrites50.6%
Taylor expanded in phi2 around 0
fp-cancel-sub-sign-invN/A
sin-+PI/2-revN/A
fp-cancel-sub-sign-invN/A
lower--.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f6481.9
Applied rewrites81.9%
Final simplification62.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi1 -46000000000000.0) (not (<= phi1 6.4e-6)))
(atan2 t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if ((phi1 <= -46000000000000.0) || !(phi1 <= 6.4e-6)) {
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)));
} else {
tmp = atan2(t_0, 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) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
if ((phi1 <= (-46000000000000.0d0)) .or. (.not. (phi1 <= 6.4d-6))) then
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)))
else
tmp = atan2(t_0, sin(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)) * Math.cos(phi2);
double tmp;
if ((phi1 <= -46000000000000.0) || !(phi1 <= 6.4e-6)) {
tmp = Math.atan2(t_0, (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if (phi1 <= -46000000000000.0) or not (phi1 <= 6.4e-6): tmp = math.atan2(t_0, (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if ((phi1 <= -46000000000000.0) || !(phi1 <= 6.4e-6)) tmp = atan(t_0, Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if ((phi1 <= -46000000000000.0) || ~((phi1 <= 6.4e-6))) tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1))); else tmp = atan2(t_0, sin(phi2)); 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[phi1, -46000000000000.0], N[Not[LessEqual[phi1, 6.4e-6]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -46000000000000 \lor \neg \left(\phi_1 \leq 6.4 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -4.6e13 or 6.3999999999999997e-6 < phi1 Initial program 78.2%
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.f6447.8
Applied rewrites47.8%
if -4.6e13 < phi1 < 6.3999999999999997e-6Initial program 79.6%
Taylor expanded in phi1 around 0
lift-sin.f6476.3
Applied rewrites76.3%
Final simplification61.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -3.2e-9) (not (<= phi2 5.8e-11)))
(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 <= -3.2e-9) || !(phi2 <= 5.8e-11)) {
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 <= (-3.2d-9)) .or. (.not. (phi2 <= 5.8d-11))) 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 <= -3.2e-9) || !(phi2 <= 5.8e-11)) {
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 <= -3.2e-9) or not (phi2 <= 5.8e-11): 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 <= -3.2e-9) || !(phi2 <= 5.8e-11)) 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 <= -3.2e-9) || ~((phi2 <= 5.8e-11))) 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, -3.2e-9], N[Not[LessEqual[phi2, 5.8e-11]], $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 -3.2 \cdot 10^{-9} \lor \neg \left(\phi_2 \leq 5.8 \cdot 10^{-11}\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 < -3.20000000000000012e-9 or 5.8e-11 < phi2 Initial program 75.7%
Taylor expanded in phi1 around 0
lift-sin.f6444.3
Applied rewrites44.3%
if -3.20000000000000012e-9 < phi2 < 5.8e-11Initial 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.f6487.9
Applied rewrites87.9%
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.f6483.6
Applied rewrites83.6%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6478.0
Applied rewrites78.0%
Final simplification60.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -2.5e-62) (not (<= lambda1 1.45e-49))) (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 <= -2.5e-62) || !(lambda1 <= 1.45e-49)) {
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 <= (-2.5d-62)) .or. (.not. (lambda1 <= 1.45d-49))) 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 <= -2.5e-62) || !(lambda1 <= 1.45e-49)) {
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 <= -2.5e-62) or not (lambda1 <= 1.45e-49): 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 <= -2.5e-62) || !(lambda1 <= 1.45e-49)) 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 <= -2.5e-62) || ~((lambda1 <= 1.45e-49))) 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, -2.5e-62], N[Not[LessEqual[lambda1, 1.45e-49]], $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 -2.5 \cdot 10^{-62} \lor \neg \left(\lambda_1 \leq 1.45 \cdot 10^{-49}\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 < -2.5000000000000001e-62 or 1.45e-49 < lambda1 Initial program 67.2%
Taylor expanded in phi1 around 0
lift-sin.f6439.4
Applied rewrites39.4%
Taylor expanded in lambda1 around inf
Applied rewrites41.2%
if -2.5000000000000001e-62 < lambda1 < 1.45e-49Initial program 99.7%
Taylor expanded in phi1 around 0
lift-sin.f6461.3
Applied rewrites61.3%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6455.8
Applied rewrites55.8%
Final simplification46.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -3.9e-115) (not (<= lambda1 4e-9))) (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 <= -3.9e-115) || !(lambda1 <= 4e-9)) {
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 <= (-3.9d-115)) .or. (.not. (lambda1 <= 4d-9))) 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 <= -3.9e-115) || !(lambda1 <= 4e-9)) {
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 <= -3.9e-115) or not (lambda1 <= 4e-9): 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 <= -3.9e-115) || !(lambda1 <= 4e-9)) 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 <= -3.9e-115) || ~((lambda1 <= 4e-9))) 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, -3.9e-115], N[Not[LessEqual[lambda1, 4e-9]], $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 -3.9 \cdot 10^{-115} \lor \neg \left(\lambda_1 \leq 4 \cdot 10^{-9}\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 < -3.8999999999999998e-115 or 4.00000000000000025e-9 < lambda1 Initial program 66.7%
Taylor expanded in phi1 around 0
lift-sin.f6441.1
Applied rewrites41.1%
Taylor expanded in lambda1 around inf
Applied rewrites41.9%
if -3.8999999999999998e-115 < lambda1 < 4.00000000000000025e-9Initial program 99.3%
Taylor expanded in phi1 around 0
lift-sin.f6457.6
Applied rewrites57.6%
Taylor expanded in phi2 around 0
Applied rewrites36.2%
Final simplification39.8%
(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 78.9%
Taylor expanded in phi1 around 0
lift-sin.f6447.3
Applied rewrites47.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -3.6)
(atan2 t_0 phi2)
(atan2 t_0 (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= -3.6) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= -3.6) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); 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.6], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $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.6:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -3.60000000000000009Initial program 68.9%
Taylor expanded in phi1 around 0
lift-sin.f6441.2
Applied rewrites41.2%
Taylor expanded in phi2 around 0
Applied rewrites21.1%
if -3.60000000000000009 < phi2 Initial program 82.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.6
Applied rewrites49.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6442.2
Applied rewrites42.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 1.45e+15) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2) (atan2 (* (sin lambda1) 1.0) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.45e+15) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2((sin(lambda1) * 1.0), 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.45d+15) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
else
tmp = atan2((sin(lambda1) * 1.0d0), 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.45e+15) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((Math.sin(lambda1) * 1.0), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.45e+15: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) else: tmp = math.atan2((math.sin(lambda1) * 1.0), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.45e+15) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(sin(lambda1) * 1.0), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1.45e+15) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan2((sin(lambda1) * 1.0), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.45e+15], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.45 \cdot 10^{+15}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot 1}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 1.45e15Initial program 77.9%
Taylor expanded in phi1 around 0
lift-sin.f6448.0
Applied rewrites48.0%
Taylor expanded in phi2 around 0
Applied rewrites39.7%
if 1.45e15 < phi2 Initial program 82.6%
Taylor expanded in phi1 around 0
lift-sin.f6444.7
Applied rewrites44.7%
Taylor expanded in phi2 around 0
Applied rewrites13.2%
Taylor expanded in lambda1 around inf
Applied rewrites15.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -82.0)
(atan2 (* (cos phi2) (- (sin lambda2))) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -82.0) {
tmp = atan2((cos(phi2) * -sin(lambda2)), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -82.0) tmp = atan(Float64(cos(phi2) * Float64(-sin(lambda2))), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -82.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -82:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -82Initial program 68.9%
Taylor expanded in phi1 around 0
lift-sin.f6441.2
Applied rewrites41.2%
Taylor expanded in phi2 around 0
Applied rewrites16.4%
Taylor expanded in phi2 around 0
Applied rewrites14.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6420.6
Applied rewrites20.6%
if -82 < phi2 Initial program 82.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.6
Applied rewrites49.6%
Taylor expanded in phi2 around 0
Applied rewrites38.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6438.9
Applied rewrites38.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 1.16e+15) (atan2 (sin (- lambda1 lambda2)) phi2) (atan2 (* (sin lambda1) 1.0) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.16e+15) {
tmp = atan2(sin((lambda1 - lambda2)), phi2);
} else {
tmp = atan2((sin(lambda1) * 1.0), 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.16d+15) then
tmp = atan2(sin((lambda1 - lambda2)), phi2)
else
tmp = atan2((sin(lambda1) * 1.0d0), 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.16e+15) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
} else {
tmp = Math.atan2((Math.sin(lambda1) * 1.0), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.16e+15: tmp = math.atan2(math.sin((lambda1 - lambda2)), phi2) else: tmp = math.atan2((math.sin(lambda1) * 1.0), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.16e+15) tmp = atan(sin(Float64(lambda1 - lambda2)), phi2); else tmp = atan(Float64(sin(lambda1) * 1.0), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1.16e+15) tmp = atan2(sin((lambda1 - lambda2)), phi2); else tmp = atan2((sin(lambda1) * 1.0), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.16e+15], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.16 \cdot 10^{+15}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot 1}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 1.16e15Initial program 77.9%
Taylor expanded in phi1 around 0
lift-sin.f6448.0
Applied rewrites48.0%
Taylor expanded in phi2 around 0
Applied rewrites38.0%
Taylor expanded in phi2 around 0
Applied rewrites37.4%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6437.4
Applied rewrites37.4%
if 1.16e15 < phi2 Initial program 82.6%
Taylor expanded in phi1 around 0
lift-sin.f6444.7
Applied rewrites44.7%
Taylor expanded in phi2 around 0
Applied rewrites13.2%
Taylor expanded in lambda1 around inf
Applied rewrites15.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) 1.0) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * 1.0), 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)) * 1.0d0), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * 1.0), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * 1.0), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\sin \phi_2}
\end{array}
Initial program 78.9%
Taylor expanded in phi1 around 0
lift-sin.f6447.3
Applied rewrites47.3%
Taylor expanded in phi2 around 0
Applied rewrites32.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -44000.0)
(atan2 (* (sin lambda1) 1.0) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(*
(fma
(-
(*
(fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
(* phi2 phi2))
0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -44000.0) {
tmp = atan2((sin(lambda1) * 1.0), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -44000.0) tmp = atan(Float64(sin(lambda1) * 1.0), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -44000.0], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -44000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot 1}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -44000Initial program 68.5%
Taylor expanded in phi1 around 0
lift-sin.f6441.6
Applied rewrites41.6%
Taylor expanded in phi2 around 0
Applied rewrites16.6%
Taylor expanded in phi2 around 0
Applied rewrites14.9%
Taylor expanded in lambda1 around inf
Applied rewrites15.7%
if -44000 < phi2 Initial program 82.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.4
Applied rewrites49.4%
Taylor expanded in phi2 around 0
Applied rewrites38.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -44000.0)
(atan2 (* (sin lambda1) 1.0) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -44000.0) {
tmp = atan2((sin(lambda1) * 1.0), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -44000.0) tmp = atan(Float64(sin(lambda1) * 1.0), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -44000.0], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -44000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot 1}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -44000Initial program 68.5%
Taylor expanded in phi1 around 0
lift-sin.f6441.6
Applied rewrites41.6%
Taylor expanded in phi2 around 0
Applied rewrites16.6%
Taylor expanded in phi2 around 0
Applied rewrites14.9%
Taylor expanded in lambda1 around inf
Applied rewrites15.7%
if -44000 < phi2 Initial program 82.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.4
Applied rewrites49.4%
Taylor expanded in phi2 around 0
Applied rewrites38.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6438.7
Applied rewrites38.7%
(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 78.9%
Taylor expanded in phi1 around 0
lift-sin.f6447.3
Applied rewrites47.3%
Taylor expanded in phi2 around 0
Applied rewrites32.6%
Taylor expanded in phi2 around 0
Applied rewrites30.0%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6430.0
Applied rewrites30.0%
herbie shell --seed 2025080
(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))))))