
(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 28 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(fma
t_0
(* (cos lambda1) (cos lambda2))
(* t_0 (* (sin lambda2) (sin lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - fma(t_0, (cos(lambda1) * cos(lambda2)), (t_0 * (sin(lambda2) * sin(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - fma(t_0, Float64(cos(lambda1) * cos(lambda2)), Float64(t_0 * Float64(sin(lambda2) * sin(lambda1)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \mathsf{fma}\left(t\_0, \cos \lambda_1 \cdot \cos \lambda_2, t\_0 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1\right)\right)}
\end{array}
\end{array}
Initial program 78.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.3
Applied rewrites89.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 78.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.3
Applied rewrites89.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (* phi2 phi2) -0.5 1.0))
(t_1 (* (cos phi1) (sin phi2)))
(t_2
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(t_3
(atan2
(* t_2 (cos phi2))
(- t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= phi2 -0.0038)
t_3
(if (<= phi2 1.6e-48)
(atan2
(* t_2 t_0)
(-
t_1
(*
(* (sin phi1) t_0)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
t_3))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((phi2 * phi2), -0.5, 1.0);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2));
double t_3 = atan2((t_2 * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi2 <= -0.0038) {
tmp = t_3;
} else if (phi2 <= 1.6e-48) {
tmp = atan2((t_2 * t_0), (t_1 - ((sin(phi1) * t_0) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = t_3;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) t_3 = atan(Float64(t_2 * cos(phi2)), Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi2 <= -0.0038) tmp = t_3; elseif (phi2 <= 1.6e-48) tmp = atan(Float64(t_2 * t_0), Float64(t_1 - Float64(Float64(sin(phi1) * t_0) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = t_3; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(t$95$2 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.0038], t$95$3, If[LessEqual[phi2, 1.6e-48], N[ArcTan[N[(t$95$2 * t$95$0), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\
t_3 := \tan^{-1}_* \frac{t\_2 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_2 \leq -0.0038:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 1.6 \cdot 10^{-48}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot t\_0}{t\_1 - \left(\sin \phi_1 \cdot t\_0\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi2 < -0.00379999999999999999 or 1.5999999999999999e-48 < phi2 Initial 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.f6489.5
Applied rewrites89.5%
if -0.00379999999999999999 < phi2 < 1.5999999999999999e-48Initial 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.1
Applied rewrites89.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (* (cos lambda1) (sin lambda2)))
(t_3
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_2) (cos phi2))
(- t_0 (* t_1 (cos lambda1))))))
(if (<= lambda1 -3.7e-5)
t_3
(if (<= lambda1 8.2e+35)
(atan2
(* (- (sin lambda1) t_2) (cos phi2))
(- 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 = cos(lambda1) * sin(lambda2);
double t_3 = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))));
double tmp;
if (lambda1 <= -3.7e-5) {
tmp = t_3;
} else if (lambda1 <= 8.2e+35) {
tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
t_2 = cos(lambda1) * sin(lambda2)
t_3 = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))))
if (lambda1 <= (-3.7d-5)) then
tmp = t_3
else if (lambda1 <= 8.2d+35) then
tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))))
else
tmp = t_3
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.cos(lambda1) * Math.sin(lambda2);
double t_3 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda1))));
double tmp;
if (lambda1 <= -3.7e-5) {
tmp = t_3;
} else if (lambda1 <= 8.2e+35) {
tmp = Math.atan2(((Math.sin(lambda1) - t_2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_3;
}
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.cos(lambda1) * math.sin(lambda2) t_3 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda1)))) tmp = 0 if lambda1 <= -3.7e-5: tmp = t_3 elif lambda1 <= 8.2e+35: tmp = math.atan2(((math.sin(lambda1) - t_2) * math.cos(phi2)), (t_0 - (t_1 * math.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 = Float64(cos(lambda1) * sin(lambda2)) t_3 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda1)))) tmp = 0.0 if (lambda1 <= -3.7e-5) tmp = t_3; elseif (lambda1 <= 8.2e+35) tmp = atan(Float64(Float64(sin(lambda1) - t_2) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = t_3; 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 = cos(lambda1) * sin(lambda2); t_3 = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (t_1 * cos(lambda1)))); tmp = 0.0; if (lambda1 <= -3.7e-5) tmp = t_3; elseif (lambda1 <= 8.2e+35) tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2))))); else tmp = t_3; 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[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3.7e-5], t$95$3, If[LessEqual[lambda1, 8.2e+35], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$2), $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$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 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_3 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\mathbf{if}\;\lambda_1 \leq -3.7 \cdot 10^{-5}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_1 \leq 8.2 \cdot 10^{+35}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if lambda1 < -3.69999999999999981e-5 or 8.1999999999999997e35 < lambda1 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.f6480.0
Applied rewrites80.0%
Taylor expanded in lambda1 around inf
Applied rewrites79.8%
if -3.69999999999999981e-5 < lambda1 < 8.1999999999999997e35Initial program 97.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
Taylor expanded in lambda2 around 0
lift-sin.f6497.1
Applied rewrites97.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 78.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.3
Applied rewrites89.3%
(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 lambda2))))))
(if (<= lambda2 -130.0)
t_2
(if (<= lambda2 6.2e-17)
(atan2
(*
(fma
lambda2
(fma (* -0.5 lambda2) (sin lambda1) (- (cos lambda1)))
(sin lambda1))
(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(lambda2))));
double tmp;
if (lambda2 <= -130.0) {
tmp = t_2;
} else if (lambda2 <= 6.2e-17) {
tmp = atan2((fma(lambda2, fma((-0.5 * lambda2), sin(lambda1), -cos(lambda1)), sin(lambda1)) * cos(phi2)), (t_0 - (t_1 * 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(lambda2)))) tmp = 0.0 if (lambda2 <= -130.0) tmp = t_2; elseif (lambda2 <= 6.2e-17) tmp = atan(Float64(fma(lambda2, fma(Float64(-0.5 * lambda2), sin(lambda1), Float64(-cos(lambda1))), sin(lambda1)) * cos(phi2)), Float64(t_0 - Float64(t_1 * 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[(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[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -130.0], t$95$2, If[LessEqual[lambda2, 6.2e-17], N[ArcTan[N[(N[(lambda2 * N[(N[(-0.5 * lambda2), $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + (-N[Cos[lambda1], $MachinePrecision])), $MachinePrecision] + N[Sin[lambda1], $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_2}\\
\mathbf{if}\;\lambda_2 \leq -130:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 6.2 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(-0.5 \cdot \lambda_2, \sin \lambda_1, -\cos \lambda_1\right), \sin \lambda_1\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 lambda2 < -130 or 6.1999999999999997e-17 < lambda2 Initial program 59.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.f6479.6
Applied rewrites79.6%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6479.1
Applied rewrites79.1%
if -130 < lambda2 < 6.1999999999999997e-17Initial program 99.4%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6499.1
Applied rewrites99.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin lambda1) (cos lambda2)))
(t_2
(atan2
(* (- t_1 (sin lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -0.0017)
t_2
(if (<= phi1 5e-49)
(atan2
(* (- t_1 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (sin phi2) (* (sin phi1) t_0)))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(lambda1) * cos(lambda2);
double t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -0.0017) {
tmp = t_2;
} else if (phi1 <= 5e-49) {
tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
} 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((lambda1 - lambda2))
t_1 = sin(lambda1) * cos(lambda2)
t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)))
if (phi1 <= (-0.0017d0)) then
tmp = t_2
else if (phi1 <= 5d-49) then
tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)))
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((lambda1 - lambda2));
double t_1 = Math.sin(lambda1) * Math.cos(lambda2);
double t_2 = Math.atan2(((t_1 - Math.sin(lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -0.0017) {
tmp = t_2;
} else if (phi1 <= 5e-49) {
tmp = Math.atan2(((t_1 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_0)));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(lambda1) * math.cos(lambda2) t_2 = math.atan2(((t_1 - math.sin(lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) tmp = 0 if phi1 <= -0.0017: tmp = t_2 elif phi1 <= 5e-49: tmp = math.atan2(((t_1 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_0))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(lambda1) * cos(lambda2)) t_2 = atan(Float64(Float64(t_1 - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -0.0017) tmp = t_2; elseif (phi1 <= 5e-49) tmp = atan(Float64(Float64(t_1 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(lambda1) * cos(lambda2); t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0))); tmp = 0.0; if (phi1 <= -0.0017) tmp = t_2; elseif (phi1 <= 5e-49) tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(t$95$1 - 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, -0.0017], t$95$2, If[LessEqual[phi1, 5e-49], N[ArcTan[N[(N[(t$95$1 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_2 := \tan^{-1}_* \frac{\left(t\_1 - \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 -0.0017:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 5 \cdot 10^{-49}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -0.00169999999999999991 or 4.9999999999999999e-49 < 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.f6480.5
Applied rewrites80.5%
Taylor expanded in lambda1 around 0
lift-sin.f6477.6
Applied rewrites77.6%
if -0.00169999999999999991 < phi1 < 4.9999999999999999e-49Initial program 81.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi2 around 0
lift-sin.f6499.4
Applied rewrites99.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos lambda1) (sin lambda2)))
(t_2
(atan2
(* (- (sin lambda1) t_1) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -0.0017)
t_2
(if (<= phi1 5.4e-12)
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_1) (cos phi2))
(- (sin phi2) (* (sin phi1) t_0)))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(lambda1) * sin(lambda2);
double t_2 = atan2(((sin(lambda1) - t_1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -0.0017) {
tmp = t_2;
} else if (phi1 <= 5.4e-12) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
} 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((lambda1 - lambda2))
t_1 = cos(lambda1) * sin(lambda2)
t_2 = atan2(((sin(lambda1) - t_1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)))
if (phi1 <= (-0.0017d0)) then
tmp = t_2
else if (phi1 <= 5.4d-12) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)))
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((lambda1 - lambda2));
double t_1 = Math.cos(lambda1) * Math.sin(lambda2);
double t_2 = Math.atan2(((Math.sin(lambda1) - t_1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -0.0017) {
tmp = t_2;
} else if (phi1 <= 5.4e-12) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_1) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_0)));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(lambda1) * math.sin(lambda2) t_2 = math.atan2(((math.sin(lambda1) - t_1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) tmp = 0 if phi1 <= -0.0017: tmp = t_2 elif phi1 <= 5.4e-12: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_1) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_0))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(lambda1) * sin(lambda2)) t_2 = atan(Float64(Float64(sin(lambda1) - t_1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -0.0017) tmp = t_2; elseif (phi1 <= 5.4e-12) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(lambda1) * sin(lambda2); t_2 = atan2(((sin(lambda1) - t_1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0))); tmp = 0.0; if (phi1 <= -0.0017) tmp = t_2; elseif (phi1 <= 5.4e-12) tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$1), $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, -0.0017], t$95$2, If[LessEqual[phi1, 5.4e-12], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_1\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 -0.0017:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 5.4 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_1\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -0.00169999999999999991 or 5.39999999999999961e-12 < phi1 Initial program 76.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.4
Applied rewrites79.4%
Taylor expanded in lambda2 around 0
lift-sin.f6477.2
Applied rewrites77.2%
if -0.00169999999999999991 < phi1 < 5.39999999999999961e-12Initial program 81.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi2 around 0
lift-sin.f6499.4
Applied rewrites99.4%
(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 -0.0017)
t_1
(if (<= phi1 5.4e-12)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (sin phi1) t_0)))
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 <= -0.0017) {
tmp = t_1;
} else if (phi1 <= 5.4e-12) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
} 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 (phi1 <= (-0.0017d0)) then
tmp = t_1
else if (phi1 <= 5.4d-12) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)))
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 (phi1 <= -0.0017) {
tmp = t_1;
} else if (phi1 <= 5.4e-12) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_0)));
} 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 phi1 <= -0.0017: tmp = t_1 elif phi1 <= 5.4e-12: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_0))) 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 <= -0.0017) tmp = t_1; elseif (phi1 <= 5.4e-12) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); else tmp = 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 (phi1 <= -0.0017) tmp = t_1; elseif (phi1 <= 5.4e-12) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0))); 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[phi1, -0.0017], t$95$1, If[LessEqual[phi1, 5.4e-12], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $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 -0.0017:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 5.4 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -0.00169999999999999991 or 5.39999999999999961e-12 < phi1 Initial program 76.3%
if -0.00169999999999999991 < phi1 < 5.39999999999999961e-12Initial program 81.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi2 around 0
lift-sin.f6499.4
Applied rewrites99.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= phi1 -1.06e-13)
t_0
(if (<= phi1 3.5e-13)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.06e-13) {
tmp = t_0;
} else if (phi1 <= 3.5e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * 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((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
if (phi1 <= (-1.06d-13)) then
tmp = t_0
else if (phi1 <= 3.5d-13) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * 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((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.06e-13) {
tmp = t_0;
} else if (phi1 <= 3.5e-13) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = 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))))) tmp = 0 if phi1 <= -1.06e-13: tmp = t_0 elif phi1 <= 3.5e-13: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -1.06e-13) tmp = t_0; elseif (phi1 <= 3.5e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -1.06e-13) tmp = t_0; elseif (phi1 <= 3.5e-13) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * 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[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]}, If[LessEqual[phi1, -1.06e-13], t$95$0, If[LessEqual[phi1, 3.5e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -1.06 \cdot 10^{-13}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 3.5 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -1.06e-13 or 3.5000000000000002e-13 < phi1 Initial program 76.3%
if -1.06e-13 < phi1 < 3.5000000000000002e-13Initial 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.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6497.5
Applied rewrites97.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -0.00049)
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (cos lambda1) (cos phi2)) (sin phi1))))
(if (<= lambda1 16500000000000.0)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -0.00049) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
} else if (lambda1 <= 16500000000000.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (lambda1 <= (-0.00049d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
else if (lambda1 <= 16500000000000.0d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -0.00049) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
} else if (lambda1 <= 16500000000000.0) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -0.00049: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) elif lambda1 <= 16500000000000.0: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -0.00049) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); elseif (lambda1 <= 16500000000000.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -0.00049) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); elseif (lambda1 <= 16500000000000.0) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.00049], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 16500000000000.0], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $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], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.00049:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_1 \leq 16500000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -4.8999999999999998e-4Initial program 59.2%
Taylor expanded in lambda2 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-sin.f6459.0
Applied rewrites59.0%
Taylor expanded in lambda1 around inf
Applied rewrites58.8%
if -4.8999999999999998e-4 < lambda1 < 1.65e13Initial program 98.2%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6497.7
Applied rewrites97.7%
if 1.65e13 < lambda1 Initial program 60.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.f6479.3
Applied rewrites79.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6457.7
Applied rewrites57.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= lambda2 -130.0)
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda2)))))
(if (<= lambda2 0.0037)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda1) (cos phi2)) (sin phi1))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -130.0) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(-lambda2))));
} else if (lambda2 <= 0.0037) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (lambda2 <= (-130.0d0)) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(-lambda2))))
else if (lambda2 <= 0.0037d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -130.0) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(-lambda2))));
} else if (lambda2 <= 0.0037) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= -130.0: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(-lambda2)))) elif lambda2 <= 0.0037: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -130.0) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(-lambda2))))); elseif (lambda2 <= 0.0037) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= -130.0) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(-lambda2)))); elseif (lambda2 <= 0.0037) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -130.0], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 0.0037], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -130:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(-\lambda_2\right)}\\
\mathbf{elif}\;\lambda_2 \leq 0.0037:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda2 < -130Initial program 58.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6458.4
Applied rewrites58.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6458.5
Applied rewrites58.5%
if -130 < lambda2 < 0.0037000000000000002Initial program 99.1%
Taylor expanded in lambda2 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-sin.f6498.8
Applied rewrites98.8%
if 0.0037000000000000002 < lambda2 Initial program 58.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.f6480.1
Applied rewrites80.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lift-sin.f6460.4
Applied rewrites60.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (cos (- lambda1 lambda2)))))))
(if (<= phi1 -5.6e-12)
t_0
(if (<= phi1 0.000175)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -5.6e-12) {
tmp = t_0;
} else if (phi1 <= 0.000175) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * 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((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))))
if (phi1 <= (-5.6d-12)) then
tmp = t_0
else if (phi1 <= 0.000175d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * 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((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -5.6e-12) {
tmp = t_0;
} else if (phi1 <= 0.000175) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi1 <= -5.6e-12: tmp = t_0 elif phi1 <= 0.000175: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -5.6e-12) tmp = t_0; elseif (phi1 <= 0.000175) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -5.6e-12) tmp = t_0; elseif (phi1 <= 0.000175) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5.6e-12], t$95$0, If[LessEqual[phi1, 0.000175], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -5.6 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 0.000175:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -5.6000000000000004e-12 or 1.74999999999999998e-4 < phi1 Initial program 76.4%
Taylor expanded in phi2 around 0
lift-sin.f6449.9
Applied rewrites49.9%
if -5.6000000000000004e-12 < phi1 < 1.74999999999999998e-4Initial program 81.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6497.0
Applied rewrites97.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 -1.06e-13)
(atan2
(* t_1 (cos phi2))
(- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))
(if (<= phi1 0.00024)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
(* t_1 1.0)
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) 1.0) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.06e-13) {
tmp = atan2((t_1 * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 0.00024) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_1 * 1.0), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * 1.0) * t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
if (phi1 <= (-1.06d-13)) then
tmp = atan2((t_1 * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)))
else if (phi1 <= 0.00024d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2((t_1 * 1.0d0), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * 1.0d0) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.06e-13) {
tmp = Math.atan2((t_1 * Math.cos(phi2)), (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else if (phi1 <= 0.00024) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((t_1 * 1.0), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * 1.0) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.06e-13: tmp = math.atan2((t_1 * math.cos(phi2)), (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) elif phi1 <= 0.00024: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((t_1 * 1.0), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * 1.0) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.06e-13) tmp = atan(Float64(t_1 * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 0.00024) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_1 * 1.0), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * 1.0) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -1.06e-13) tmp = atan2((t_1 * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 0.00024) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2((t_1 * 1.0), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * 1.0) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.06e-13], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.00024], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$1 * 1.0), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.06 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 0.00024:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot 1}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot 1\right) \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -1.06e-13Initial program 76.8%
Taylor expanded in phi1 around 0
lift-sin.f6448.7
Applied rewrites48.7%
if -1.06e-13 < phi1 < 2.40000000000000006e-4Initial program 81.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6497.0
Applied rewrites97.0%
if 2.40000000000000006e-4 < phi1 Initial program 76.0%
Taylor expanded in phi2 around 0
Applied rewrites45.9%
Taylor expanded in phi2 around 0
Applied rewrites46.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 -5e-8)
(atan2 (* t_1 (cos phi2)) (- (* t_0 (sin phi1))))
(if (<= phi1 0.00024)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
(* t_1 1.0)
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) 1.0) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -5e-8) {
tmp = atan2((t_1 * cos(phi2)), -(t_0 * sin(phi1)));
} else if (phi1 <= 0.00024) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_1 * 1.0), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * 1.0) * t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
if (phi1 <= (-5d-8)) then
tmp = atan2((t_1 * cos(phi2)), -(t_0 * sin(phi1)))
else if (phi1 <= 0.00024d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2((t_1 * 1.0d0), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * 1.0d0) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -5e-8) {
tmp = Math.atan2((t_1 * Math.cos(phi2)), -(t_0 * Math.sin(phi1)));
} else if (phi1 <= 0.00024) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((t_1 * 1.0), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * 1.0) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -5e-8: tmp = math.atan2((t_1 * math.cos(phi2)), -(t_0 * math.sin(phi1))) elif phi1 <= 0.00024: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((t_1 * 1.0), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * 1.0) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -5e-8) tmp = atan(Float64(t_1 * cos(phi2)), Float64(-Float64(t_0 * sin(phi1)))); elseif (phi1 <= 0.00024) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_1 * 1.0), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * 1.0) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -5e-8) tmp = atan2((t_1 * cos(phi2)), -(t_0 * sin(phi1))); elseif (phi1 <= 0.00024) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2((t_1 * 1.0), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * 1.0) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e-8], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / (-N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision], If[LessEqual[phi1, 0.00024], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$1 * 1.0), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{-t\_0 \cdot \sin \phi_1}\\
\mathbf{elif}\;\phi_1 \leq 0.00024:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot 1}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot 1\right) \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -4.9999999999999998e-8Initial program 76.8%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6446.6
Applied rewrites46.6%
if -4.9999999999999998e-8 < phi1 < 2.40000000000000006e-4Initial program 81.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6496.7
Applied rewrites96.7%
if 2.40000000000000006e-4 < phi1 Initial program 76.0%
Taylor expanded in phi2 around 0
Applied rewrites45.9%
Taylor expanded in phi2 around 0
Applied rewrites46.0%
(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 -1.9e-11)
t_1
(if (<= phi1 0.000175) (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 <= -1.9e-11) {
tmp = t_1;
} else if (phi1 <= 0.000175) {
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 <= (-1.9d-11)) then
tmp = t_1
else if (phi1 <= 0.000175d0) 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 <= -1.9e-11) {
tmp = t_1;
} else if (phi1 <= 0.000175) {
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 <= -1.9e-11: tmp = t_1 elif phi1 <= 0.000175: 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 <= -1.9e-11) tmp = t_1; elseif (phi1 <= 0.000175) 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 <= -1.9e-11) tmp = t_1; elseif (phi1 <= 0.000175) 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, -1.9e-11], t$95$1, If[LessEqual[phi1, 0.000175], 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 -1.9 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 0.000175:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -1.8999999999999999e-11 or 1.74999999999999998e-4 < phi1 Initial program 76.4%
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.2
Applied rewrites47.2%
if -1.8999999999999999e-11 < phi1 < 1.74999999999999998e-4Initial program 81.2%
Taylor expanded in phi1 around 0
lift-sin.f6478.5
Applied rewrites78.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* 1.0 (sin phi2)) (* (cos (- lambda1 lambda2)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0 * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))));
}
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)), ((1.0d0 * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((1.0 * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((1.0 * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(1.0 * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0 * sin(phi2)) - (cos((lambda1 - lambda2)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}
\end{array}
Initial program 78.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6451.3
Applied rewrites51.3%
Taylor expanded in phi1 around 0
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.1
Applied rewrites46.1%
Taylor expanded in phi1 around 0
Applied rewrites47.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6463.7
Applied rewrites63.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 t_0 (* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -3.2e-8)
t_1
(if (<= phi1 0.00018) (atan2 (* t_0 (cos phi2)) (sin phi2)) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2(t_0, (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1))));
double tmp;
if (phi1 <= -3.2e-8) {
tmp = t_1;
} else if (phi1 <= 0.00018) {
tmp = atan2((t_0 * cos(phi2)), 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))
t_1 = atan2(t_0, ((-1.0d0) * (cos((lambda1 - lambda2)) * sin(phi1))))
if (phi1 <= (-3.2d-8)) then
tmp = t_1
else if (phi1 <= 0.00018d0) then
tmp = atan2((t_0 * cos(phi2)), 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));
double t_1 = Math.atan2(t_0, (-1.0 * (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
double tmp;
if (phi1 <= -3.2e-8) {
tmp = t_1;
} else if (phi1 <= 0.00018) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2(t_0, (-1.0 * (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) tmp = 0 if phi1 <= -3.2e-8: tmp = t_1 elif phi1 <= 0.00018: tmp = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(t_0, Float64(-1.0 * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -3.2e-8) tmp = t_1; elseif (phi1 <= 0.00018) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); 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, (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1)))); tmp = 0.0; if (phi1 <= -3.2e-8) tmp = t_1; elseif (phi1 <= 0.00018) tmp = atan2((t_0 * cos(phi2)), sin(phi2)); 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[t$95$0 / N[(-1.0 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.2e-8], t$95$1, If[LessEqual[phi1, 0.00018], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $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}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\phi_1 \leq -3.2 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 0.00018:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -3.2000000000000002e-8 or 1.80000000000000011e-4 < phi1 Initial program 76.4%
Taylor expanded in phi1 around 0
lift-sin.f6419.6
Applied rewrites19.6%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6415.1
Applied rewrites15.1%
Taylor expanded in phi2 around 0
Applied rewrites13.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6443.6
Applied rewrites43.6%
if -3.2000000000000002e-8 < phi1 < 1.80000000000000011e-4Initial program 81.2%
Taylor expanded in phi1 around 0
lift-sin.f6478.4
Applied rewrites78.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
\end{array}
Initial program 78.7%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (* (sin lambda1) (cos phi2)) (sin phi2))))
(if (<= lambda1 -5.6e-5)
t_0
(if (<= lambda1 0.013)
(atan2 (* (sin (- 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 <= -5.6e-5) {
tmp = t_0;
} else if (lambda1 <= 0.013) {
tmp = atan2((sin(-lambda2) * 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(lambda1) * cos(phi2)), sin(phi2))
if (lambda1 <= (-5.6d-5)) then
tmp = t_0
else if (lambda1 <= 0.013d0) then
tmp = atan2((sin(-lambda2) * 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(lambda1) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (lambda1 <= -5.6e-5) {
tmp = t_0;
} else if (lambda1 <= 0.013) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if lambda1 <= -5.6e-5: tmp = t_0 elif lambda1 <= 0.013: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.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 <= -5.6e-5) tmp = t_0; elseif (lambda1 <= 0.013) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); tmp = 0.0; if (lambda1 <= -5.6e-5) tmp = t_0; elseif (lambda1 <= 0.013) tmp = atan2((sin(-lambda2) * 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[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -5.6e-5], t$95$0, If[LessEqual[lambda1, 0.013], N[ArcTan[N[(N[Sin[(-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 -5.6 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 0.013:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -5.59999999999999992e-5 or 0.0129999999999999994 < lambda1 Initial program 59.8%
Taylor expanded in phi1 around 0
lift-sin.f6439.4
Applied rewrites39.4%
Taylor expanded in lambda1 around inf
Applied rewrites39.1%
if -5.59999999999999992e-5 < lambda1 < 0.0129999999999999994Initial program 99.1%
Taylor expanded in phi1 around 0
lift-sin.f6458.2
Applied rewrites58.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6449.6
Applied rewrites49.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -0.42)
(atan2 (* (sin lambda1) (cos phi2)) (sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(* phi2 (- 1.0 (* 0.16666666666666666 (* phi2 phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.42) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-0.42d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (phi2 * (1.0d0 - (0.16666666666666666d0 * (phi2 * phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.42) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -0.42: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -0.42) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(phi2 * Float64(1.0 - Float64(0.16666666666666666 * Float64(phi2 * phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -0.42) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -0.42], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(phi2 * N[(1.0 - N[(0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.42:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2 \cdot \left(1 - 0.16666666666666666 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -0.419999999999999984Initial program 75.3%
Taylor expanded in phi1 around 0
lift-sin.f6445.5
Applied rewrites45.5%
Taylor expanded in lambda1 around inf
Applied rewrites28.0%
if -0.419999999999999984 < phi2 Initial program 79.9%
Taylor expanded in phi1 around 0
lift-sin.f6449.5
Applied rewrites49.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6441.0
Applied rewrites41.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 0.076)
(atan2 t_0 phi2)
(atan2 t_0 (* phi2 (- 1.0 (* 0.16666666666666666 (* phi2 phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= 0.076) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi2 <= 0.076d0) then
tmp = atan2(t_0, phi2)
else
tmp = atan2(t_0, (phi2 * (1.0d0 - (0.16666666666666666d0 * (phi2 * phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi2 <= 0.076) {
tmp = Math.atan2(t_0, phi2);
} else {
tmp = Math.atan2(t_0, (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi2 <= 0.076: tmp = math.atan2(t_0, phi2) else: tmp = math.atan2(t_0, (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= 0.076) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(phi2 * Float64(1.0 - Float64(0.16666666666666666 * Float64(phi2 * phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi2 <= 0.076) tmp = atan2(t_0, phi2); else tmp = atan2(t_0, (phi2 * (1.0 - (0.16666666666666666 * (phi2 * phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.076], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(phi2 * N[(1.0 - N[(0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq 0.076:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \left(1 - 0.16666666666666666 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < 0.0759999999999999981Initial program 79.1%
Taylor expanded in phi1 around 0
lift-sin.f6448.1
Applied rewrites48.1%
Taylor expanded in phi2 around 0
Applied rewrites40.9%
if 0.0759999999999999981 < phi2 Initial program 77.6%
Taylor expanded in phi1 around 0
lift-sin.f6449.6
Applied rewrites49.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6425.2
Applied rewrites25.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -0.00115)
(atan2 (* (cos phi2) (- (sin lambda2))) phi2)
(atan2
(sin (- lambda1 lambda2))
(* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.00115) {
tmp = atan2((cos(phi2) * -sin(lambda2)), phi2);
} else {
tmp = atan2(sin((lambda1 - lambda2)), (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -0.00115) tmp = atan(Float64(cos(phi2) * Float64(-sin(lambda2))), phi2); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -0.00115], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00115:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -0.00115Initial program 75.3%
Taylor expanded in phi1 around 0
lift-sin.f6445.4
Applied rewrites45.4%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6413.8
Applied rewrites13.8%
Taylor expanded in phi2 around 0
Applied rewrites13.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6419.7
Applied rewrites19.7%
if -0.00115 < phi2 Initial program 79.9%
Taylor expanded in phi1 around 0
lift-sin.f6449.5
Applied rewrites49.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6437.3
Applied rewrites37.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), 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)), 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)), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}
\end{array}
Initial program 78.7%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
Applied rewrites31.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), sin(phi2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}
\end{array}
Initial program 78.7%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6431.6
Applied rewrites31.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), phi2);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}
\end{array}
Initial program 78.7%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6431.6
Applied rewrites31.6%
Taylor expanded in phi2 around 0
Applied rewrites28.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (sin lambda1) phi2)))
(if (<= lambda1 -0.00065)
t_0
(if (<= lambda1 3.1e+28) (atan2 (- (sin lambda2)) phi2) t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2(sin(lambda1), phi2);
double tmp;
if (lambda1 <= -0.00065) {
tmp = t_0;
} else if (lambda1 <= 3.1e+28) {
tmp = atan2(-sin(lambda2), 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(lambda1), phi2)
if (lambda1 <= (-0.00065d0)) then
tmp = t_0
else if (lambda1 <= 3.1d+28) then
tmp = atan2(-sin(lambda2), 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(lambda1), phi2);
double tmp;
if (lambda1 <= -0.00065) {
tmp = t_0;
} else if (lambda1 <= 3.1e+28) {
tmp = Math.atan2(-Math.sin(lambda2), phi2);
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2(math.sin(lambda1), phi2) tmp = 0 if lambda1 <= -0.00065: tmp = t_0 elif lambda1 <= 3.1e+28: tmp = math.atan2(-math.sin(lambda2), phi2) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(sin(lambda1), phi2) tmp = 0.0 if (lambda1 <= -0.00065) tmp = t_0; elseif (lambda1 <= 3.1e+28) tmp = atan(Float64(-sin(lambda2)), phi2); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2(sin(lambda1), phi2); tmp = 0.0; if (lambda1 <= -0.00065) tmp = t_0; elseif (lambda1 <= 3.1e+28) tmp = atan2(-sin(lambda2), phi2); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[Sin[lambda1], $MachinePrecision] / phi2], $MachinePrecision]}, If[LessEqual[lambda1, -0.00065], t$95$0, If[LessEqual[lambda1, 3.1e+28], N[ArcTan[(-N[Sin[lambda2], $MachinePrecision]) / phi2], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \lambda_1}{\phi_2}\\
\mathbf{if}\;\lambda_1 \leq -0.00065:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 3.1 \cdot 10^{+28}:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -6.4999999999999997e-4 or 3.1000000000000001e28 < lambda1 Initial program 59.5%
Taylor expanded in phi1 around 0
lift-sin.f6439.3
Applied rewrites39.3%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6427.7
Applied rewrites27.7%
Taylor expanded in phi2 around 0
Applied rewrites25.6%
Taylor expanded in lambda1 around inf
Applied rewrites25.6%
if -6.4999999999999997e-4 < lambda1 < 3.1000000000000001e28Initial program 97.3%
Taylor expanded in phi1 around 0
lift-sin.f6457.3
Applied rewrites57.3%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6435.2
Applied rewrites35.2%
Taylor expanded in phi2 around 0
Applied rewrites31.5%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6427.8
Applied rewrites27.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), phi2);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin(lambda1), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\phi_2}
\end{array}
Initial program 78.7%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6431.6
Applied rewrites31.6%
Taylor expanded in phi2 around 0
Applied rewrites28.6%
Taylor expanded in lambda1 around inf
Applied rewrites21.8%
herbie shell --seed 2025116
(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))))))