
(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}
Herbie found 38 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(fma
(* (- (cos lambda1)) (sin lambda2))
(cos phi2)
(* (* (cos lambda2) (sin lambda1)) (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(fma((-cos(lambda1) * sin(lambda2)), cos(phi2), ((cos(lambda2) * sin(lambda1)) * 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(fma(Float64(Float64(-cos(lambda1)) * sin(lambda2)), cos(phi2), Float64(Float64(cos(lambda2) * sin(lambda1)) * 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[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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{\mathsf{fma}\left(\left(-\cos \lambda_1\right) \cdot \sin \lambda_2, \cos \phi_2, \left(\cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2\right)}{\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 79.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.f6489.6
Applied rewrites89.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.7
Applied rewrites99.7%
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
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lift-cos.f64N/A
*-commutativeN/A
distribute-rgt-inN/A
lower-fma.f64N/A
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (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((fma(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(fma(sin(lambda1), cos(lambda2), Float64(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[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $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{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \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 79.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.f6489.6
Applied rewrites89.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.7
Applied rewrites99.7%
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
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.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 79.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.f6489.6
Applied rewrites89.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.7
Applied rewrites99.7%
(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)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -2e-11)
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* t_1 t_2)))
(if (<= phi2 5.8e-72)
(atan2
t_0
(-
(sin phi2)
(*
t_1
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
t_0
(fma (sin phi2) (cos phi1) (* (- (* (cos phi2) (sin phi1))) t_2)))))))
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 t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -2e-11) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * t_2)));
} else if (phi2 <= 5.8e-72) {
tmp = atan2(t_0, (sin(phi2) - (t_1 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_0, fma(sin(phi2), cos(phi1), (-(cos(phi2) * sin(phi1)) * t_2)));
}
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)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -2e-11) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * t_2))); elseif (phi2 <= 5.8e-72) tmp = atan(t_0, Float64(sin(phi2) - Float64(t_1 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_0, fma(sin(phi2), cos(phi1), Float64(Float64(-Float64(cos(phi2) * sin(phi1))) * t_2))); 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]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2e-11], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 5.8e-72], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * 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[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]) * t$95$2), $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\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -2 \cdot 10^{-11}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 5.8 \cdot 10^{-72}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - t\_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2 \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -1.99999999999999988e-11Initial program 76.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.2
Applied rewrites90.2%
if -1.99999999999999988e-11 < phi2 < 5.79999999999999995e-72Initial 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.f6488.9
Applied rewrites88.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6499.8
Applied rewrites99.8%
if 5.79999999999999995e-72 < phi2 Initial program 78.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.f6489.9
Applied rewrites89.9%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites89.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos lambda1))))))
(if (<= lambda1 -25000.0)
t_2
(if (<= lambda1 8e-12)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
t_2))))
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 t_2 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))));
double tmp;
if (lambda1 <= -25000.0) {
tmp = t_2;
} else if (lambda1 <= 8e-12) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = 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) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
t_2 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))))
if (lambda1 <= (-25000.0d0)) then
tmp = t_2
else if (lambda1 <= 8d-12) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(phi1) * Math.cos(phi2);
double t_2 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda1))));
double tmp;
if (lambda1 <= -25000.0) {
tmp = t_2;
} else if (lambda1 <= 8e-12) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos(phi2) t_2 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda1)))) tmp = 0 if lambda1 <= -25000.0: tmp = t_2 elif lambda1 <= 8e-12: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (t_1 * math.cos((lambda1 - lambda2))))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda1)))) tmp = 0.0 if (lambda1 <= -25000.0) tmp = t_2; elseif (lambda1 <= 8e-12) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(phi1) * cos(phi2); t_2 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda1)))); tmp = 0.0; if (lambda1 <= -25000.0) tmp = t_2; elseif (lambda1 <= 8e-12) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2))))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -25000.0], t$95$2, If[LessEqual[lambda1, 8e-12], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $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], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \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 \lambda_1}\\
\mathbf{if}\;\lambda_1 \leq -25000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 8 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda1 < -25000 or 7.99999999999999984e-12 < lambda1 Initial program 59.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.8
Applied rewrites79.8%
Taylor expanded in lambda1 around inf
Applied rewrites79.5%
if -25000 < lambda1 < 7.99999999999999984e-12Initial program 98.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos lambda1) (sin lambda2)))
(t_2
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_1) (cos phi2))
(- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2))))))
(if (<= lambda2 -2.15e+43)
t_2
(if (<= lambda2 1.15e-6)
(atan2
(* (- (sin lambda1) t_1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(lambda1) * sin(lambda2);
double t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
double tmp;
if (lambda2 <= -2.15e+43) {
tmp = t_2;
} else if (lambda2 <= 1.15e-6) {
tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = 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) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(lambda1) * sin(lambda2)
t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
if (lambda2 <= (-2.15d+43)) then
tmp = t_2
else if (lambda2 <= 1.15d-6) then
tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(lambda1) * Math.sin(lambda2);
double t_2 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_1) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
double tmp;
if (lambda2 <= -2.15e+43) {
tmp = t_2;
} else if (lambda2 <= 1.15e-6) {
tmp = Math.atan2(((Math.sin(lambda1) - t_1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(lambda1) * math.sin(lambda2) t_2 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_1) * math.cos(phi2)), (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) tmp = 0 if lambda2 <= -2.15e+43: tmp = t_2 elif lambda2 <= 1.15e-6: tmp = math.atan2(((math.sin(lambda1) - t_1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(lambda1) * sin(lambda2)) t_2 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (lambda2 <= -2.15e+43) tmp = t_2; elseif (lambda2 <= 1.15e-6) tmp = atan(Float64(Float64(sin(lambda1) - t_1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(lambda1) * sin(lambda2); t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); tmp = 0.0; if (lambda2 <= -2.15e+43) tmp = t_2; elseif (lambda2 <= 1.15e-6) tmp = atan2(((sin(lambda1) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2.15e+43], t$95$2, If[LessEqual[lambda2, 1.15e-6], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / 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], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_1\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -2.15 \cdot 10^{+43}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 1.15 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_1\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -2.15e43 or 1.15e-6 < lambda2 Initial program 59.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.f6479.7
Applied rewrites79.7%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6479.6
Applied rewrites79.6%
if -2.15e43 < lambda2 < 1.15e-6Initial program 96.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.3
Applied rewrites98.3%
Taylor expanded in lambda2 around 0
lift-sin.f6497.0
Applied rewrites97.0%
(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 79.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.f6489.6
Applied rewrites89.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (- (* (sin lambda1) (cos lambda2)) (sin lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -4.8e-7)
t_1
(if (<= phi1 2.8e-8)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((((sin(lambda1) * cos(lambda2)) - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -4.8e-7) {
tmp = t_1;
} else if (phi1 <= 2.8e-8) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -4.8e-7) tmp = t_1; elseif (phi1 <= 2.8e-8) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = t_1; 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[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[Sin[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]}, If[LessEqual[phi1, -4.8e-7], t$95$1, If[LessEqual[phi1, 2.8e-8], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \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 t\_0}\\
\mathbf{if}\;\phi_1 \leq -4.8 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -4.79999999999999957e-7 or 2.7999999999999999e-8 < phi1 Initial program 76.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.f6479.6
Applied rewrites79.6%
Taylor expanded in lambda1 around 0
lift-sin.f6477.4
Applied rewrites77.4%
if -4.79999999999999957e-7 < phi1 < 2.7999999999999999e-8Initial 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.f6499.7
Applied rewrites99.7%
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--.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
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
cos-diff-revN/A
+-commutativeN/A
associate-*r*N/A
cos-diff-revN/A
lower-fma.f64N/A
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (- (sin lambda1) (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -4.8e-7)
t_1
(if (<= phi1 2.8e-8)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2(((sin(lambda1) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -4.8e-7) {
tmp = t_1;
} else if (phi1 <= 2.8e-8) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(Float64(sin(lambda1) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -4.8e-7) tmp = t_1; elseif (phi1 <= 2.8e-8) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = t_1; 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[ArcTan[N[(N[(N[Sin[lambda1], $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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -4.8e-7], t$95$1, If[LessEqual[phi1, 2.8e-8], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - \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 t\_0}\\
\mathbf{if}\;\phi_1 \leq -4.8 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -4.79999999999999957e-7 or 2.7999999999999999e-8 < phi1 Initial program 76.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.f6479.6
Applied rewrites79.6%
Taylor expanded in lambda2 around 0
lift-sin.f6477.5
Applied rewrites77.5%
if -4.79999999999999957e-7 < phi1 < 2.7999999999999999e-8Initial 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.f6499.7
Applied rewrites99.7%
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--.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
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
cos-diff-revN/A
+-commutativeN/A
associate-*r*N/A
cos-diff-revN/A
lower-fma.f64N/A
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -4.8e-7)
t_1
(if (<= phi1 2.8e-8)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -4.8e-7) {
tmp = t_1;
} else if (phi1 <= 2.8e-8) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -4.8e-7) tmp = t_1; elseif (phi1 <= 2.8e-8) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = t_1; 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[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]}, If[LessEqual[phi1, -4.8e-7], t$95$1, If[LessEqual[phi1, 2.8e-8], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \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{if}\;\phi_1 \leq -4.8 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -4.79999999999999957e-7 or 2.7999999999999999e-8 < phi1 Initial program 76.6%
if -4.79999999999999957e-7 < phi1 < 2.7999999999999999e-8Initial 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.f6499.7
Applied rewrites99.7%
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--.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
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
cos-diff-revN/A
+-commutativeN/A
associate-*r*N/A
cos-diff-revN/A
lower-fma.f64N/A
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -4.8e-7)
t_1
(if (<= phi1 2.8e-8)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -4.8e-7) {
tmp = t_1;
} else if (phi1 <= 2.8e-8) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -4.8e-7) tmp = t_1; elseif (phi1 <= 2.8e-8) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = t_1; 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[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]}, If[LessEqual[phi1, -4.8e-7], t$95$1, If[LessEqual[phi1, 2.8e-8], 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[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \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{if}\;\phi_1 \leq -4.8 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-8}:\\
\;\;\;\;\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(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -4.79999999999999957e-7 or 2.7999999999999999e-8 < phi1 Initial program 76.6%
if -4.79999999999999957e-7 < phi1 < 2.7999999999999999e-8Initial 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.f6499.7
Applied rewrites99.7%
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.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi2 -1850000000000.0)
t_1
(if (<= phi2 5.8e-72)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (* (cos phi1) phi2) (* t_0 (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi2 <= -1850000000000.0) {
tmp = t_1;
} else if (phi2 <= 5.8e-72) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * phi2) - (t_0 * sin(phi1))));
} else {
tmp = t_1;
}
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 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)))
if (phi2 <= (-1850000000000.0d0)) then
tmp = t_1
else if (phi2 <= 5.8d-72) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * phi2) - (t_0 * sin(phi1))))
else
tmp = t_1
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.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
double tmp;
if (phi2 <= -1850000000000.0) {
tmp = t_1;
} else if (phi2 <= 5.8e-72) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * phi2) - (t_0 * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) tmp = 0 if phi2 <= -1850000000000.0: tmp = t_1 elif phi2 <= 5.8e-72: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * phi2) - (t_0 * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi2 <= -1850000000000.0) tmp = t_1; elseif (phi2 <= 5.8e-72) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * phi2) - Float64(t_0 * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0))); tmp = 0.0; if (phi2 <= -1850000000000.0) tmp = t_1; elseif (phi2 <= 5.8e-72) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * phi2) - (t_0 * sin(phi1)))); else tmp = t_1; 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[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]}, If[LessEqual[phi2, -1850000000000.0], t$95$1, If[LessEqual[phi2, 5.8e-72], 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] * phi2), $MachinePrecision] - N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \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{if}\;\phi_2 \leq -1850000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 5.8 \cdot 10^{-72}:\\
\;\;\;\;\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 \phi_2 - t\_0 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -1.85e12 or 5.79999999999999995e-72 < phi2 Initial program 77.3%
if -1.85e12 < phi2 < 5.79999999999999995e-72Initial program 81.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.0
Applied rewrites89.0%
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.f6487.3
Applied rewrites87.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi2 -2.25e-79)
t_1
(if (<= phi2 2.6e-104)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (* t_0 (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi2 <= -2.25e-79) {
tmp = t_1;
} else if (phi2 <= 2.6e-104) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), -(t_0 * sin(phi1)));
} else {
tmp = t_1;
}
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 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)))
if (phi2 <= (-2.25d-79)) then
tmp = t_1
else if (phi2 <= 2.6d-104) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), -(t_0 * sin(phi1)))
else
tmp = t_1
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.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
double tmp;
if (phi2 <= -2.25e-79) {
tmp = t_1;
} else if (phi2 <= 2.6e-104) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), -(t_0 * Math.sin(phi1)));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) tmp = 0 if phi2 <= -2.25e-79: tmp = t_1 elif phi2 <= 2.6e-104: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), -(t_0 * math.sin(phi1))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi2 <= -2.25e-79) tmp = t_1; elseif (phi2 <= 2.6e-104) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(-Float64(t_0 * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0))); tmp = 0.0; if (phi2 <= -2.25e-79) tmp = t_1; elseif (phi2 <= 2.6e-104) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), -(t_0 * sin(phi1))); else tmp = t_1; 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[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]}, If[LessEqual[phi2, -2.25e-79], t$95$1, If[LessEqual[phi2, 2.6e-104], 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[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \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{if}\;\phi_2 \leq -2.25 \cdot 10^{-79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 2.6 \cdot 10^{-104}:\\
\;\;\;\;\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 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -2.2500000000000001e-79 or 2.60000000000000003e-104 < phi2 Initial program 77.5%
if -2.2500000000000001e-79 < phi2 < 2.60000000000000003e-104Initial program 82.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.5
Applied rewrites89.5%
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.f6488.2
Applied rewrites88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1
(atan2
(* (sin (- lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* t_0 (cos (- lambda1 lambda2)))))))
(if (<= lambda2 -38000.0)
t_1
(if (<= lambda2 8e+28)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* (- (cos lambda1)) t_0)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = atan2((sin(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * cos((lambda1 - lambda2)))));
double tmp;
if (lambda2 <= -38000.0) {
tmp = t_1;
} else if (lambda2 <= 8e+28) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda2 <= -38000.0) tmp = t_1; elseif (lambda2 <= 8e+28) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * t_0))); 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[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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -38000.0], t$95$1, If[LessEqual[lambda2, 8e+28], 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], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\lambda_2 \leq -38000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 8 \cdot 10^{+28}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -38000 or 7.99999999999999967e28 < lambda2 Initial program 59.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6459.4
Applied rewrites59.4%
if -38000 < lambda2 < 7.99999999999999967e28Initial program 97.2%
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-*.f6495.9
Applied rewrites95.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1
(atan2
(* (sin (- lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* t_0 (cos lambda2))))))
(if (<= lambda2 -38000.0)
t_1
(if (<= lambda2 8e+28)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* (- (cos lambda1)) t_0)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = atan2((sin(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * cos(lambda2))));
double tmp;
if (lambda2 <= -38000.0) {
tmp = t_1;
} else if (lambda2 <= 8e+28) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * cos(lambda2)))) tmp = 0.0 if (lambda2 <= -38000.0) tmp = t_1; elseif (lambda2 <= 8e+28) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * t_0))); 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[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]}, If[LessEqual[lambda2, -38000.0], t$95$1, If[LessEqual[lambda2, 8e+28], 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], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -38000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 8 \cdot 10^{+28}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -38000 or 7.99999999999999967e28 < lambda2 Initial program 59.2%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6459.1
Applied rewrites59.1%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6459.4
Applied rewrites59.4%
if -38000 < lambda2 < 7.99999999999999967e28Initial program 97.2%
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-*.f6495.9
Applied rewrites95.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1
(atan2
(* (sin (- lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* t_0 (cos lambda2))))))
(if (<= lambda2 -7.5e+52)
t_1
(if (<= lambda2 1.6e+29)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* t_0 (cos (- lambda1 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(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * cos(lambda2))));
double tmp;
if (lambda2 <= -7.5e+52) {
tmp = t_1;
} else if (lambda2 <= 1.6e+29) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
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 = sin(phi1) * cos(phi2)
t_1 = atan2((sin(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * cos(lambda2))))
if (lambda2 <= (-7.5d+52)) then
tmp = t_1
else if (lambda2 <= 1.6d+29) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (t_0 * Math.cos(lambda2))));
double tmp;
if (lambda2 <= -7.5e+52) {
tmp = t_1;
} else if (lambda2 <= 1.6e+29) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - (t_0 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (t_0 * math.cos(lambda2)))) tmp = 0 if lambda2 <= -7.5e+52: tmp = t_1 elif lambda2 <= 1.6e+29: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - (t_0 * math.cos((lambda1 - lambda2))))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * cos(lambda2)))) tmp = 0.0 if (lambda2 <= -7.5e+52) tmp = t_1; elseif (lambda2 <= 1.6e+29) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = atan2((sin(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * cos(lambda2)))); tmp = 0.0; if (lambda2 <= -7.5e+52) tmp = t_1; elseif (lambda2 <= 1.6e+29) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2))))); else tmp = t_1; end tmp_2 = 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[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]}, If[LessEqual[lambda2, -7.5e+52], t$95$1, If[LessEqual[lambda2, 1.6e+29], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -7.5 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 1.6 \cdot 10^{+29}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -7.49999999999999995e52 or 1.59999999999999993e29 < lambda2 Initial program 59.1%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6459.1
Applied rewrites59.1%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6459.1
Applied rewrites59.1%
if -7.49999999999999995e52 < lambda2 < 1.59999999999999993e29Initial program 94.6%
Taylor expanded in phi1 around 0
lift-sin.f6478.1
Applied rewrites78.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (atan2 (* t_2 (cos phi2)) (- t_0 (* t_1 1.0)))))
(if (<= phi2 -2750000000000.0)
t_3
(if (<= phi2 0.012)
(atan2
(* t_2 (fma (* phi2 phi2) -0.5 1.0))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
t_3))))
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 t_2 = sin((lambda1 - lambda2));
double t_3 = atan2((t_2 * cos(phi2)), (t_0 - (t_1 * 1.0)));
double tmp;
if (phi2 <= -2750000000000.0) {
tmp = t_3;
} else if (phi2 <= 0.012) {
tmp = atan2((t_2 * fma((phi2 * phi2), -0.5, 1.0)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = t_3;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = atan(Float64(t_2 * cos(phi2)), Float64(t_0 - Float64(t_1 * 1.0))) tmp = 0.0 if (phi2 <= -2750000000000.0) tmp = t_3; elseif (phi2 <= 0.012) tmp = atan(Float64(t_2 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = t_3; 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]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(t$95$2 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2750000000000.0], t$95$3, If[LessEqual[phi2, 0.012], N[ArcTan[N[(t$95$2 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \tan^{-1}_* \frac{t\_2 \cdot \cos \phi_2}{t\_0 - t\_1 \cdot 1}\\
\mathbf{if}\;\phi_2 \leq -2750000000000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 0.012:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi2 < -2.75e12 or 0.012 < phi2 Initial program 76.9%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6467.6
Applied rewrites67.6%
Taylor expanded in lambda2 around 0
Applied rewrites58.3%
if -2.75e12 < phi2 < 0.012Initial program 81.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.2
Applied rewrites80.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2
(atan2 (* t_1 (cos phi2)) (- t_0 (* (* (sin phi1) (cos phi2)) 1.0)))))
(if (<= phi2 -1850000000000.0)
t_2
(if (<= phi2 0.012)
(atan2
(* t_1 (fma (* phi2 phi2) -0.5 1.0))
(-
t_0
(*
(*
(sin phi1)
(fma
(- (* (* phi2 phi2) 0.041666666666666664) 0.5)
(* phi2 phi2)
1.0))
(cos (- lambda1 lambda2)))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double t_2 = atan2((t_1 * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * 1.0)));
double tmp;
if (phi2 <= -1850000000000.0) {
tmp = t_2;
} else if (phi2 <= 0.012) {
tmp = atan2((t_1 * fma((phi2 * phi2), -0.5, 1.0)), (t_0 - ((sin(phi1) * fma((((phi2 * phi2) * 0.041666666666666664) - 0.5), (phi2 * phi2), 1.0)) * cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * 1.0))) tmp = 0.0 if (phi2 <= -1850000000000.0) tmp = t_2; elseif (phi2 <= 0.012) tmp = atan(Float64(t_1 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(t_0 - Float64(Float64(sin(phi1) * fma(Float64(Float64(Float64(phi2 * phi2) * 0.041666666666666664) - 0.5), Float64(phi2 * phi2), 1.0)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1850000000000.0], t$95$2, If[LessEqual[phi2, 0.012], N[ArcTan[N[(t$95$1 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot 1}\\
\mathbf{if}\;\phi_2 \leq -1850000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 0.012:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{t\_0 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.041666666666666664 - 0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi2 < -1.85e12 or 0.012 < phi2 Initial program 76.9%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6467.6
Applied rewrites67.6%
Taylor expanded in lambda2 around 0
Applied rewrites58.3%
if -1.85e12 < phi2 < 0.012Initial program 81.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.2
Applied rewrites80.2%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6480.1
Applied rewrites80.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (* t_0 (cos phi2))))
(if (<= phi2 -2750000000000.0)
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos lambda2))))
(if (<= phi2 3.8)
(atan2
(* t_0 (fma (* phi2 phi2) -0.5 1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(fma (* (* phi2 phi2) (sin phi1)) -0.5 (sin phi1))
(cos (- lambda1 lambda2)))))
(atan2
t_1
(- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = t_0 * cos(phi2);
double tmp;
if (phi2 <= -2750000000000.0) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos(lambda2))));
} else if (phi2 <= 3.8) {
tmp = atan2((t_0 * fma((phi2 * phi2), -0.5, 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - (fma(((phi2 * phi2) * sin(phi1)), -0.5, sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(t_0 * cos(phi2)) tmp = 0.0 if (phi2 <= -2750000000000.0) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(lambda2)))); elseif (phi2 <= 3.8) tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(fma(Float64(Float64(phi2 * phi2) * sin(phi1)), -0.5, sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2750000000000.0], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3.8], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * -0.5 + N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := t\_0 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -2750000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \lambda_2}\\
\mathbf{elif}\;\phi_2 \leq 3.8:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot \sin \phi_1, -0.5, \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if phi2 < -2.75e12Initial program 76.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6466.7
Applied rewrites66.7%
Taylor expanded in phi2 around 0
lift-sin.f6449.4
Applied rewrites49.4%
if -2.75e12 < phi2 < 3.7999999999999998Initial program 81.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.0
Applied rewrites80.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f6479.9
Applied rewrites79.9%
if 3.7999999999999998 < phi2 Initial program 77.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6468.4
Applied rewrites68.4%
Taylor expanded in phi1 around 0
lift-sin.f6451.9
Applied rewrites51.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1
(atan2
(* t_0 (cos phi2))
(- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos lambda2))))))
(if (<= phi2 -1850000000000.0)
t_1
(if (<= phi2 0.0122)
(atan2
(* t_0 (fma (* phi2 phi2) -0.5 1.0))
(-
(* (cos phi1) (sin phi2))
(*
(*
(sin phi1)
(fma
(- (* (* phi2 phi2) 0.041666666666666664) 0.5)
(* phi2 phi2)
1.0))
(cos (- lambda1 lambda2)))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
double tmp;
if (phi2 <= -1850000000000.0) {
tmp = t_1;
} else if (phi2 <= 0.0122) {
tmp = atan2((t_0 * fma((phi2 * phi2), -0.5, 1.0)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * fma((((phi2 * phi2) * 0.041666666666666664) - 0.5), (phi2 * phi2), 1.0)) * cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))) tmp = 0.0 if (phi2 <= -1850000000000.0) tmp = t_1; elseif (phi2 <= 0.0122) tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * fma(Float64(Float64(Float64(phi2 * phi2) * 0.041666666666666664) - 0.5), Float64(phi2 * phi2), 1.0)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1850000000000.0], t$95$1, If[LessEqual[phi2, 0.0122], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2}\\
\mathbf{if}\;\phi_2 \leq -1850000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.0122:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.041666666666666664 - 0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -1.85e12 or 0.0122000000000000008 < phi2 Initial program 76.9%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6467.6
Applied rewrites67.6%
Taylor expanded in phi1 around 0
lift-sin.f6450.6
Applied rewrites50.6%
if -1.85e12 < phi2 < 0.0122000000000000008Initial program 81.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.2
Applied rewrites80.2%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6480.1
Applied rewrites80.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (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)), (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)), (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.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.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(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)), (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[Sin[phi2], $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}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.2%
Taylor expanded in phi1 around 0
lift-sin.f6465.8
Applied rewrites65.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* t_0 (sin phi1)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (* t_2 (cos phi2))))
(if (<= phi1 -0.0026)
(atan2 t_3 (- t_1))
(if (<= phi1 1.02e-7)
(atan2 t_3 (fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
(atan2 t_2 (- (* (cos phi1) (sin phi2)) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = t_0 * sin(phi1);
double t_2 = sin((lambda1 - lambda2));
double t_3 = t_2 * cos(phi2);
double tmp;
if (phi1 <= -0.0026) {
tmp = atan2(t_3, -t_1);
} else if (phi1 <= 1.02e-7) {
tmp = atan2(t_3, fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = atan2(t_2, ((cos(phi1) * sin(phi2)) - t_1));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(t_0 * sin(phi1)) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = Float64(t_2 * cos(phi2)) tmp = 0.0 if (phi1 <= -0.0026) tmp = atan(t_3, Float64(-t_1)); elseif (phi1 <= 1.02e-7) tmp = atan(t_3, fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = atan(t_2, Float64(Float64(cos(phi1) * sin(phi2)) - t_1)); 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[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0026], N[ArcTan[t$95$3 / (-t$95$1)], $MachinePrecision], If[LessEqual[phi1, 1.02e-7], N[ArcTan[t$95$3 / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := t\_0 \cdot \sin \phi_1\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := t\_2 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.0026:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3}{-t\_1}\\
\mathbf{elif}\;\phi_1 \leq 1.02 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_1}\\
\end{array}
\end{array}
if phi1 < -0.0025999999999999999Initial program 76.0%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6447.4
Applied rewrites47.4%
if -0.0025999999999999999 < phi1 < 1.02e-7Initial program 81.9%
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.f6481.8
Applied rewrites81.8%
if 1.02e-7 < phi1 Initial program 77.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.f6480.1
Applied rewrites80.1%
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.6
Applied rewrites99.6%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6446.8
Applied rewrites46.8%
Taylor expanded in phi2 around 0
cos-diff-revN/A
cos-diff-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f64N/A
lift-sin.f6446.4
Applied rewrites46.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -7.8e+18)
t_1
(if (<= phi2 0.01)
(atan2
t_0
(- (* (cos phi1) (sin phi2)) (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -7.8e+18) {
tmp = t_1;
} else if (phi2 <= 0.01) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_1;
}
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 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
if (phi2 <= (-7.8d+18)) then
tmp = t_1
else if (phi2 <= 0.01d0) then
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
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 t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -7.8e+18) {
tmp = t_1;
} else if (phi2 <= 0.01) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -7.8e+18: tmp = t_1 elif phi2 <= 0.01: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -7.8e+18) tmp = t_1; elseif (phi2 <= 0.01) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -7.8e+18) tmp = t_1; elseif (phi2 <= 0.01) tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -7.8e+18], t$95$1, If[LessEqual[phi2, 0.01], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -7.8 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.01:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -7.8e18 or 0.0100000000000000002 < phi2 Initial program 76.9%
Taylor expanded in phi1 around 0
lift-sin.f6448.8
Applied rewrites48.8%
if -7.8e18 < phi2 < 0.0100000000000000002Initial program 81.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.2
Applied rewrites89.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6479.7
Applied rewrites79.7%
Taylor expanded in phi2 around 0
cos-diff-revN/A
cos-diff-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f64N/A
lift-sin.f6479.5
Applied rewrites79.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -1850000000000.0)
t_1
(if (<= phi2 0.0155)
(atan2
(* t_0 (fma (* phi2 phi2) -0.5 1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(*
(sin phi1)
(fma
(- (* (* phi2 phi2) 0.041666666666666664) 0.5)
(* phi2 phi2)
1.0))
(cos (- lambda1 lambda2)))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -1850000000000.0) {
tmp = t_1;
} else if (phi2 <= 0.0155) {
tmp = atan2((t_0 * fma((phi2 * phi2), -0.5, 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * fma((((phi2 * phi2) * 0.041666666666666664) - 0.5), (phi2 * phi2), 1.0)) * cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -1850000000000.0) tmp = t_1; elseif (phi2 <= 0.0155) tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * fma(Float64(Float64(Float64(phi2 * phi2) * 0.041666666666666664) - 0.5), Float64(phi2 * phi2), 1.0)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1850000000000.0], t$95$1, If[LessEqual[phi2, 0.0155], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -1850000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.0155:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.041666666666666664 - 0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -1.85e12 or 0.0155 < phi2 Initial program 76.9%
Taylor expanded in phi1 around 0
lift-sin.f6448.8
Applied rewrites48.8%
if -1.85e12 < phi2 < 0.0155Initial program 81.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6480.2
Applied rewrites80.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6480.0
Applied rewrites80.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6480.0
Applied rewrites80.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -0.00075)
t_1
(if (<= phi2 0.01)
(atan2
t_0
(- (* (cos phi1) phi2) (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -0.00075) {
tmp = t_1;
} else if (phi2 <= 0.01) {
tmp = atan2(t_0, ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_1;
}
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 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
if (phi2 <= (-0.00075d0)) then
tmp = t_1
else if (phi2 <= 0.01d0) then
tmp = atan2(t_0, ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
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 t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -0.00075) {
tmp = t_1;
} else if (phi2 <= 0.01) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * phi2) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -0.00075: tmp = t_1 elif phi2 <= 0.01: tmp = math.atan2(t_0, ((math.cos(phi1) * phi2) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -0.00075) tmp = t_1; elseif (phi2 <= 0.01) tmp = atan(t_0, Float64(Float64(cos(phi1) * phi2) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -0.00075) tmp = t_1; elseif (phi2 <= 0.01) tmp = atan2(t_0, ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.00075], t$95$1, If[LessEqual[phi2, 0.01], 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], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -0.00075:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.01:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -7.5000000000000002e-4 or 0.0100000000000000002 < phi2 Initial program 76.9%
Taylor expanded in phi1 around 0
lift-sin.f6448.9
Applied rewrites48.9%
if -7.5000000000000002e-4 < phi2 < 0.0100000000000000002Initial 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.f6489.2
Applied rewrites89.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6481.7
Applied rewrites81.7%
Taylor expanded in phi2 around 0
cos-diff-revN/A
cos-diff-revN/A
*-commutativeN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f64N/A
lift-sin.f6481.6
Applied rewrites81.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (atan2 t_0 (- (* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -9.5e-7)
t_1
(if (<= phi1 2.85e-9) (atan2 t_0 (sin phi2)) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1)));
double tmp;
if (phi1 <= -9.5e-7) {
tmp = t_1;
} else if (phi1 <= 2.85e-9) {
tmp = atan2(t_0, sin(phi2));
} else {
tmp = t_1;
}
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 = sin((lambda1 - lambda2)) * cos(phi2)
t_1 = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1)))
if (phi1 <= (-9.5d-7)) then
tmp = t_1
else if (phi1 <= 2.85d-9) then
tmp = atan2(t_0, sin(phi2))
else
tmp = t_1
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 t_1 = Math.atan2(t_0, -(Math.cos((lambda1 - lambda2)) * Math.sin(phi1)));
double tmp;
if (phi1 <= -9.5e-7) {
tmp = t_1;
} else if (phi1 <= 2.85e-9) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_1 = math.atan2(t_0, -(math.cos((lambda1 - lambda2)) * math.sin(phi1))) tmp = 0 if phi1 <= -9.5e-7: tmp = t_1 elif phi1 <= 2.85e-9: tmp = math.atan2(t_0, math.sin(phi2)) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = atan(t_0, Float64(-Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -9.5e-7) tmp = t_1; elseif (phi1 <= 2.85e-9) tmp = atan(t_0, sin(phi2)); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); t_1 = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1))); tmp = 0.0; if (phi1 <= -9.5e-7) tmp = t_1; elseif (phi1 <= 2.85e-9) tmp = atan2(t_0, sin(phi2)); else tmp = t_1; 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]}, Block[{t$95$1 = N[ArcTan[t$95$0 / (-N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]}, If[LessEqual[phi1, -9.5e-7], t$95$1, If[LessEqual[phi1, 2.85e-9], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{t\_0}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 2.85 \cdot 10^{-9}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -9.5000000000000001e-7 or 2.8499999999999999e-9 < phi1 Initial program 76.6%
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.9
Applied rewrites47.9%
if -9.5000000000000001e-7 < phi1 < 2.8499999999999999e-9Initial program 81.9%
Taylor expanded in phi1 around 0
lift-sin.f6479.3
Applied rewrites79.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -7.8e+18)
t_1
(if (<= phi2 0.000104)
(atan2 t_0 (- (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -7.8e+18) {
tmp = t_1;
} else if (phi2 <= 0.000104) {
tmp = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1)));
} else {
tmp = t_1;
}
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 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
if (phi2 <= (-7.8d+18)) then
tmp = t_1
else if (phi2 <= 0.000104d0) then
tmp = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1)))
else
tmp = t_1
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 t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -7.8e+18) {
tmp = t_1;
} else if (phi2 <= 0.000104) {
tmp = Math.atan2(t_0, -(Math.cos((lambda1 - lambda2)) * Math.sin(phi1)));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -7.8e+18: tmp = t_1 elif phi2 <= 0.000104: tmp = math.atan2(t_0, -(math.cos((lambda1 - lambda2)) * math.sin(phi1))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -7.8e+18) tmp = t_1; elseif (phi2 <= 0.000104) tmp = atan(t_0, Float64(-Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -7.8e+18) tmp = t_1; elseif (phi2 <= 0.000104) tmp = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -7.8e+18], t$95$1, If[LessEqual[phi2, 0.000104], N[ArcTan[t$95$0 / (-N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -7.8 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.000104:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -7.8e18 or 1.03999999999999994e-4 < phi2 Initial program 77.0%
Taylor expanded in phi1 around 0
lift-sin.f6448.8
Applied rewrites48.8%
if -7.8e18 < phi2 < 1.03999999999999994e-4Initial program 81.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.1
Applied rewrites89.1%
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%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6479.7
Applied rewrites79.7%
Taylor expanded in phi2 around 0
cos-diff-revN/A
mul-1-negN/A
cos-diff-revN/A
*-commutativeN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f64N/A
lift-sin.f6476.1
Applied rewrites76.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))))
(if (<= lambda2 -1.05e-6)
t_0
(if (<= lambda2 5.9e-68)
(atan2 (* (sin lambda1) (cos phi2)) (sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
double tmp;
if (lambda2 <= -1.05e-6) {
tmp = t_0;
} else if (lambda2 <= 5.9e-68) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = 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) :: tmp
t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2))
if (lambda2 <= (-1.05d-6)) then
tmp = t_0
else if (lambda2 <= 5.9d-68) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (lambda2 <= -1.05e-6) {
tmp = t_0;
} else if (lambda2 <= 5.9e-68) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if lambda2 <= -1.05e-6: tmp = t_0 elif lambda2 <= 5.9e-68: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda2 <= -1.05e-6) tmp = t_0; elseif (lambda2 <= 5.9e-68) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2)); tmp = 0.0; if (lambda2 <= -1.05e-6) tmp = t_0; elseif (lambda2 <= 5.9e-68) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1.05e-6], t$95$0, If[LessEqual[lambda2, 5.9e-68], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -1.05 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 5.9 \cdot 10^{-68}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -1.0499999999999999e-6 or 5.9e-68 < lambda2 Initial program 63.2%
Taylor expanded in phi1 around 0
lift-sin.f6442.0
Applied rewrites42.0%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6440.1
Applied rewrites40.1%
if -1.0499999999999999e-6 < lambda2 < 5.9e-68Initial program 99.7%
Taylor expanded in phi1 around 0
lift-sin.f6458.7
Applied rewrites58.7%
Taylor expanded in lambda1 around inf
Applied rewrites50.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (* (sin lambda1) (cos phi2)) (sin phi2))))
(if (<= lambda1 -0.0038)
t_0
(if (<= lambda1 1.75e-34)
(atan2
(*
(fma (fma (* lambda2 lambda2) -0.5 1.0) lambda1 (- lambda2))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
double tmp;
if (lambda1 <= -0.0038) {
tmp = t_0;
} else if (lambda1 <= 1.75e-34) {
tmp = atan2((fma(fma((lambda2 * lambda2), -0.5, 1.0), lambda1, -lambda2) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda1 <= -0.0038) tmp = t_0; elseif (lambda1 <= 1.75e-34) tmp = atan(Float64(fma(fma(Float64(lambda2 * lambda2), -0.5, 1.0), lambda1, Float64(-lambda2)) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.0038], t$95$0, If[LessEqual[lambda1, 1.75e-34], N[ArcTan[N[(N[(N[(N[(lambda2 * lambda2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * lambda1 + (-lambda2)), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_1 \leq -0.0038:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 1.75 \cdot 10^{-34}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\lambda_2 \cdot \lambda_2, -0.5, 1\right), \lambda_1, -\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -0.00379999999999999999 or 1.75e-34 < lambda1 Initial program 60.6%
Taylor expanded in phi1 around 0
lift-sin.f6440.6
Applied rewrites40.6%
Taylor expanded in lambda1 around inf
Applied rewrites39.6%
if -0.00379999999999999999 < lambda1 < 1.75e-34Initial program 99.5%
Taylor expanded in phi1 around 0
lift-sin.f6458.9
Applied rewrites58.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6439.2
Applied rewrites39.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6439.0
Applied rewrites39.0%
(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 79.2%
Taylor expanded in phi1 around 0
lift-sin.f6449.4
Applied rewrites49.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -1850000000000.0)
(atan2 t_0 phi2)
(atan2
t_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 t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= -1850000000000.0) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_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) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= -1850000000000.0) tmp = atan(t_0, phi2); else tmp = atan(t_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_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1850000000000.0], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / 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}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1850000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\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 < -1.85e12Initial program 76.4%
Taylor expanded in phi1 around 0
lift-sin.f6447.6
Applied rewrites47.6%
Taylor expanded in phi2 around 0
Applied rewrites25.1%
if -1.85e12 < phi2 Initial program 80.1%
Taylor expanded in phi1 around 0
lift-sin.f6449.9
Applied rewrites49.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -1850000000000.0)
(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 <= -1850000000000.0) {
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 <= -1850000000000.0) 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, -1850000000000.0], 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 -1850000000000:\\
\;\;\;\;\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 < -1.85e12Initial program 76.4%
Taylor expanded in phi1 around 0
lift-sin.f6447.6
Applied rewrites47.6%
Taylor expanded in phi2 around 0
Applied rewrites25.1%
if -1.85e12 < phi2 Initial program 80.1%
Taylor expanded in phi1 around 0
lift-sin.f6449.9
Applied rewrites49.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6441.2
Applied rewrites41.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 75.0)
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2)
(atan2
(* (fma (fma (* lambda2 lambda2) -0.5 1.0) lambda1 (- lambda2)) (cos phi2))
(sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 75.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2((fma(fma((lambda2 * lambda2), -0.5, 1.0), lambda1, -lambda2) * cos(phi2)), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 75.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(fma(fma(Float64(lambda2 * lambda2), -0.5, 1.0), lambda1, Float64(-lambda2)) * cos(phi2)), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 75.0], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[(N[(N[(lambda2 * lambda2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * lambda1 + (-lambda2)), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 75:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\lambda_2 \cdot \lambda_2, -0.5, 1\right), \lambda_1, -\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 75Initial program 79.9%
Taylor expanded in phi1 around 0
lift-sin.f6449.1
Applied rewrites49.1%
Taylor expanded in phi2 around 0
Applied rewrites41.4%
if 75 < phi2 Initial program 77.4%
Taylor expanded in phi1 around 0
lift-sin.f6450.1
Applied rewrites50.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6436.8
Applied rewrites36.8%
Taylor expanded in lambda1 around 0
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6425.4
Applied rewrites25.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 4.8e-5) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2) (atan2 (* (- lambda2) (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 4.8e-5) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2((-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 (phi2 <= 4.8d-5) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
else
tmp = atan2((-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 (phi2 <= 4.8e-5) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((-lambda2 * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 4.8e-5: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) else: tmp = math.atan2((-lambda2 * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 4.8e-5) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(Float64(-lambda2) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 4.8e-5) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan2((-lambda2 * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 4.8e-5], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[((-lambda2) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 4.8 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 4.8000000000000001e-5Initial program 79.9%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
Taylor expanded in phi2 around 0
Applied rewrites41.6%
if 4.8000000000000001e-5 < phi2 Initial program 77.4%
Taylor expanded in phi1 around 0
lift-sin.f6449.9
Applied rewrites49.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6436.6
Applied rewrites36.6%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6417.8
Applied rewrites17.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -1.25)
(atan2 (* (- (sin lambda2)) (cos phi2)) 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 <= -1.25) {
tmp = atan2((-sin(lambda2) * cos(phi2)), 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 <= -1.25) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), 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, -1.25], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $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 -1.25:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{\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 < -1.25Initial program 76.4%
Taylor expanded in phi1 around 0
lift-sin.f6447.8
Applied rewrites47.8%
Taylor expanded in phi2 around 0
Applied rewrites14.8%
Taylor expanded in phi2 around 0
Applied rewrites14.7%
Taylor expanded in lambda1 around 0
sin-negN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f6420.1
Applied rewrites20.1%
if -1.25 < phi2 Initial program 80.2%
Taylor expanded in phi1 around 0
lift-sin.f6449.9
Applied rewrites49.9%
Taylor expanded in phi2 around 0
Applied rewrites37.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites37.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) 1.0)))
(if (<= phi2 -1.12e+14)
(atan2 t_0 phi2)
(atan2
t_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 t_0 = sin((lambda1 - lambda2)) * 1.0;
double tmp;
if (phi2 <= -1.12e+14) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_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) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * 1.0) tmp = 0.0 if (phi2 <= -1.12e+14) tmp = atan(t_0, phi2); else tmp = atan(t_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_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[phi2, -1.12e+14], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / 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}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot 1\\
\mathbf{if}\;\phi_2 \leq -1.12 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\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 < -1.12e14Initial program 76.4%
Taylor expanded in phi1 around 0
lift-sin.f6447.6
Applied rewrites47.6%
Taylor expanded in phi2 around 0
Applied rewrites14.8%
Taylor expanded in phi2 around 0
Applied rewrites14.7%
if -1.12e14 < phi2 Initial program 80.1%
Taylor expanded in phi1 around 0
lift-sin.f6449.9
Applied rewrites49.9%
Taylor expanded in phi2 around 0
Applied rewrites37.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites37.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) 1.0) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * 1.0), 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), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * 1.0), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * 1.0), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2}
\end{array}
Initial program 79.2%
Taylor expanded in phi1 around 0
lift-sin.f6449.4
Applied rewrites49.4%
Taylor expanded in phi2 around 0
Applied rewrites32.1%
Taylor expanded in phi2 around 0
Applied rewrites29.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda2)) 1.0) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(-lambda2) * 1.0), 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(-lambda2) * 1.0d0), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(-lambda2) * 1.0), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(-lambda2) * 1.0), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(-lambda2)) * 1.0), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(-lambda2) * 1.0), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot 1}{\phi_2}
\end{array}
Initial program 79.2%
Taylor expanded in phi1 around 0
lift-sin.f6449.4
Applied rewrites49.4%
Taylor expanded in phi2 around 0
Applied rewrites32.1%
Taylor expanded in phi2 around 0
Applied rewrites29.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6422.3
Applied rewrites22.3%
herbie shell --seed 2025103
(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))))))