
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 21 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
(fma
(* (cos phi2) (cos lambda2))
(sin lambda1)
(* (* (- (cos lambda1)) (sin lambda2)) (cos phi2)))
(-
(* (cos phi1) (sin phi2))
(fma
(* t_0 (sin lambda1))
(sin lambda2)
(* (* t_0 (cos lambda1)) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
return atan2(fma((cos(phi2) * cos(lambda2)), sin(lambda1), ((-cos(lambda1) * sin(lambda2)) * cos(phi2))), ((cos(phi1) * sin(phi2)) - fma((t_0 * sin(lambda1)), sin(lambda2), ((t_0 * cos(lambda1)) * cos(lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) return atan(fma(Float64(cos(phi2) * cos(lambda2)), sin(lambda1), Float64(Float64(Float64(-cos(lambda1)) * sin(lambda2)) * cos(phi2))), Float64(Float64(cos(phi1) * sin(phi2)) - fma(Float64(t_0 * sin(lambda1)), sin(lambda2), Float64(Float64(t_0 * cos(lambda1)) * cos(lambda2))))) 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[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \phi_2 \cdot \cos \lambda_2, \sin \lambda_1, \left(\left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \mathsf{fma}\left(t\_0 \cdot \sin \lambda_1, \sin \lambda_2, \left(t\_0 \cdot \cos \lambda_1\right) \cdot \cos \lambda_2\right)}
\end{array}
\end{array}
Initial program 80.4%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-inN/A
lower-+.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6490.2
Applied rewrites90.2%
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))))
(atan2
(*
(cos phi2)
(fma (- (cos lambda1)) (sin lambda2) (* (cos lambda2) (sin lambda1))))
(-
(* (cos phi1) (sin phi2))
(fma
(* t_0 (sin lambda1))
(sin lambda2)
(* (* t_0 (cos lambda1)) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
return atan2((cos(phi2) * fma(-cos(lambda1), sin(lambda2), (cos(lambda2) * sin(lambda1)))), ((cos(phi1) * sin(phi2)) - fma((t_0 * sin(lambda1)), sin(lambda2), ((t_0 * cos(lambda1)) * cos(lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) return atan(Float64(cos(phi2) * fma(Float64(-cos(lambda1)), sin(lambda2), Float64(cos(lambda2) * sin(lambda1)))), Float64(Float64(cos(phi1) * sin(phi2)) - fma(Float64(t_0 * sin(lambda1)), sin(lambda2), Float64(Float64(t_0 * cos(lambda1)) * cos(lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(-\cos \lambda_1, \sin \lambda_2, \cos \lambda_2 \cdot \sin \lambda_1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \mathsf{fma}\left(t\_0 \cdot \sin \lambda_1, \sin \lambda_2, \left(t\_0 \cdot \cos \lambda_1\right) \cdot \cos \lambda_2\right)}
\end{array}
\end{array}
Initial program 80.4%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-inN/A
lower-+.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6490.2
Applied rewrites90.2%
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 80.4%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6480.6
Applied rewrites80.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (- (* (* (cos lambda2) (sin lambda1)) (cos phi2)) (* (* (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((((cos(lambda2) * sin(lambda1)) * cos(phi2)) - ((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((((cos(lambda2) * sin(lambda1)) * cos(phi2)) - ((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.cos(lambda2) * Math.sin(lambda1)) * Math.cos(phi2)) - ((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.cos(lambda2) * math.sin(lambda1)) * math.cos(phi2)) - ((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(cos(lambda2) * sin(lambda1)) * cos(phi2)) - Float64(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((((cos(lambda2) * sin(lambda1)) * cos(phi2)) - ((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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2 - \left(\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 80.4%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-inN/A
lower-+.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6490.2
Applied rewrites90.2%
Final simplification90.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.75e-13) (not (<= phi1 1.1e-31)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(*
(fma (sin lambda1) (sin lambda2) (* (cos lambda1) (cos lambda2)))
(sin phi1))
(cos phi2))))
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.75e-13) || !(phi1 <= 1.1e-31)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((fma(sin(lambda1), sin(lambda2), (cos(lambda1) * cos(lambda2))) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1.75e-13) || !(phi1 <= 1.1e-31)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(fma(sin(lambda1), sin(lambda2), Float64(cos(lambda1) * cos(lambda2))) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1.75e-13], N[Not[LessEqual[phi1, 1.1e-31]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.75 \cdot 10^{-13} \lor \neg \left(\phi_1 \leq 1.1 \cdot 10^{-31}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi1 < -1.7500000000000001e-13 or 1.10000000000000005e-31 < phi1 Initial program 80.5%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6480.9
Applied rewrites80.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6480.8
Applied rewrites80.8%
if -1.7500000000000001e-13 < phi1 < 1.10000000000000005e-31Initial program 80.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6480.4
Applied rewrites80.4%
Taylor expanded in phi1 around 0
lower-sin.f6480.4
Applied rewrites80.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Final simplification89.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_2 (* (cos lambda1) (cos lambda2))))
(if (<= phi1 -1.75e-13)
(atan2
t_1
(-
t_0
(* (* (sin phi1) (cos phi2)) (fma (sin lambda2) (sin lambda1) t_2))))
(if (<= phi1 1.1e-31)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2
t_1
(-
t_0
(*
(* (fma (sin lambda1) (sin lambda2) t_2) (sin phi1))
(cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double t_2 = cos(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -1.75e-13) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), t_2))));
} else if (phi1 <= 1.1e-31) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - ((fma(sin(lambda1), sin(lambda2), t_2) * sin(phi1)) * cos(phi2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_2 = Float64(cos(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -1.75e-13) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), t_2)))); elseif (phi1 <= 1.1e-31) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(Float64(fma(sin(lambda1), sin(lambda2), t_2) * sin(phi1)) * cos(phi2)))); 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.75e-13], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.1e-31], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + t$95$2), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -1.75 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, t\_2\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.1 \cdot 10^{-31}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, t\_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.7500000000000001e-13Initial program 82.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6482.9
Applied rewrites82.9%
if -1.7500000000000001e-13 < phi1 < 1.10000000000000005e-31Initial program 80.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6480.4
Applied rewrites80.4%
Taylor expanded in phi1 around 0
lower-sin.f6480.4
Applied rewrites80.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
if 1.10000000000000005e-31 < phi1 Initial program 78.2%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6478.7
Applied rewrites78.7%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6478.7
Applied rewrites78.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (cos lambda2) (sin lambda1)) (* (sin lambda2) (cos lambda1))) (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((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * 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((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * 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.cos(lambda2) * Math.sin(lambda1)) - (Math.sin(lambda2) * Math.cos(lambda1))) * 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.cos(lambda2) * math.sin(lambda1)) - (math.sin(lambda2) * math.cos(lambda1))) * 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(cos(lambda2) * sin(lambda1)) - Float64(sin(lambda2) * cos(lambda1))) * 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((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * 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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $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(\cos \lambda_2 \cdot \sin \lambda_1 - \sin \lambda_2 \cdot \cos \lambda_1\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 80.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6490.2
Applied rewrites90.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -1.9e-13) (not (<= phi1 1.1e-31)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) t_0) (sin phi1))))
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(- (sin phi2) (* (sin phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.9e-13) || !(phi1 <= 1.1e-31)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), ((-cos(phi2) * t_0) * sin(phi1))));
} else {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -1.9e-13) || !(phi1 <= 1.1e-31)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * t_0) * sin(phi1)))); else tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.9e-13], N[Not[LessEqual[phi1, 1.1e-31]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * t$95$0), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.9 \cdot 10^{-13} \lor \neg \left(\phi_1 \leq 1.1 \cdot 10^{-31}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot t\_0\right) \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -1.9e-13 or 1.10000000000000005e-31 < phi1 Initial program 80.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6453.0
Applied rewrites53.0%
Taylor expanded in phi1 around 0
lower-sin.f6451.7
Applied rewrites51.7%
Taylor expanded in lambda1 around 0
Applied rewrites80.5%
if -1.9e-13 < phi1 < 1.10000000000000005e-31Initial program 80.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6480.4
Applied rewrites80.4%
Taylor expanded in phi1 around 0
lower-sin.f6480.4
Applied rewrites80.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Final simplification88.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi2 -4.2e-7) (not (<= phi2 0.0022)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) t_0) (sin phi1))))
(atan2
(*
(fma -0.5 (* phi2 phi2) 1.0)
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2))))
(- (sin phi2) (* (sin phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi2 <= -4.2e-7) || !(phi2 <= 0.0022)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), ((-cos(phi2) * t_0) * sin(phi1))));
} else {
tmp = atan2((fma(-0.5, (phi2 * phi2), 1.0) * fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2)))), (sin(phi2) - (sin(phi1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -4.2e-7) || !(phi2 <= 0.0022)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * t_0) * sin(phi1)))); else tmp = atan(Float64(fma(-0.5, Float64(phi2 * phi2), 1.0) * fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2)))), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.2e-7], N[Not[LessEqual[phi2, 0.0022]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * t$95$0), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.2 \cdot 10^{-7} \lor \neg \left(\phi_2 \leq 0.0022\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot t\_0\right) \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right) \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi2 < -4.2e-7 or 0.00220000000000000013 < phi2 Initial program 78.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6450.9
Applied rewrites50.9%
Taylor expanded in phi1 around 0
lower-sin.f6449.6
Applied rewrites49.6%
Taylor expanded in lambda1 around 0
Applied rewrites78.3%
if -4.2e-7 < phi2 < 0.00220000000000000013Initial program 83.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6483.4
Applied rewrites83.4%
Taylor expanded in phi1 around 0
lower-sin.f6483.4
Applied rewrites83.4%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-sin.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6483.4
Applied rewrites83.4%
Applied rewrites91.1%
Final simplification83.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -2.2e+23) (not (<= lambda2 0.021)))
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_0 (* t_1 (cos lambda2))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* t_1 (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -2.2e+23) || !(lambda2 <= 0.021)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))));
}
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(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
if ((lambda2 <= (-2.2d+23)) .or. (.not. (lambda2 <= 0.021d0))) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))))
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 tmp;
if ((lambda2 <= -2.2e+23) || !(lambda2 <= 0.021)) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda2 <= -2.2e+23) or not (lambda2 <= 0.021): tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -2.2e+23) || !(lambda2 <= 0.021)) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda2 <= -2.2e+23) || ~((lambda2 <= 0.021))) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2)))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * cos(lambda1)))); 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]}, If[Or[LessEqual[lambda2, -2.2e+23], N[Not[LessEqual[lambda2, 0.021]], $MachinePrecision]], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -2.2 \cdot 10^{+23} \lor \neg \left(\lambda_2 \leq 0.021\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -2.20000000000000008e23 or 0.0210000000000000013 < lambda2 Initial program 60.3%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6463.6
Applied rewrites63.6%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6463.7
Applied rewrites63.7%
if -2.20000000000000008e23 < lambda2 < 0.0210000000000000013Initial program 98.3%
Taylor expanded in lambda2 around 0
lower-cos.f6497.6
Applied rewrites97.6%
Final simplification81.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -0.0003) (not (<= lambda1 52000000.0)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -0.0003) || !(lambda1 <= 52000000.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-0.0003d0)) .or. (.not. (lambda1 <= 52000000.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -0.0003) || !(lambda1 <= 52000000.0)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -0.0003) or not (lambda1 <= 52000000.0): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -0.0003) || !(lambda1 <= 52000000.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(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.0003) || ~((lambda1 <= 52000000.0))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.0003], N[Not[LessEqual[lambda1, 52000000.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.0003 \lor \neg \left(\lambda_1 \leq 52000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\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}\\
\end{array}
\end{array}
if lambda1 < -2.99999999999999974e-4 or 5.2e7 < lambda1 Initial program 64.5%
Taylor expanded in lambda2 around 0
lower-sin.f6463.6
Applied rewrites63.6%
if -2.99999999999999974e-4 < lambda1 < 5.2e7Initial program 97.9%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6497.9
Applied rewrites97.9%
Final simplification80.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda1 -3.35e-57) (not (<= lambda1 52000000.0)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_0 (* t_1 (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda1 <= -3.35e-57) || !(lambda1 <= 52000000.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
}
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(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
if ((lambda1 <= (-3.35d-57)) .or. (.not. (lambda1 <= 52000000.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))))
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 tmp;
if ((lambda1 <= -3.35e-57) || !(lambda1 <= 52000000.0)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda1 <= -3.35e-57) or not (lambda1 <= 52000000.0): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (t_1 * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda1 <= -3.35e-57) || !(lambda1 <= 52000000.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda1 <= -3.35e-57) || ~((lambda1 <= 52000000.0))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2))))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2)))); 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]}, If[Or[LessEqual[lambda1, -3.35e-57], N[Not[LessEqual[lambda1, 52000000.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 \leq -3.35 \cdot 10^{-57} \lor \neg \left(\lambda_1 \leq 52000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda1 < -3.3500000000000003e-57 or 5.2e7 < lambda1 Initial program 65.8%
Taylor expanded in lambda2 around 0
lower-sin.f6463.6
Applied rewrites63.6%
if -3.3500000000000003e-57 < lambda1 < 5.2e7Initial program 97.8%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6486.3
Applied rewrites86.3%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6486.3
Applied rewrites86.3%
Final simplification74.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -1.92e+118) (not (<= lambda2 450.0)))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos lambda2))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (* (cos (- lambda1 lambda2)) (sin phi1)) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -1.92e+118) || !(lambda2 <= 450.0)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda2 <= (-1.92d+118)) .or. (.not. (lambda2 <= 450.0d0))) then
tmp = atan2((sin(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda2))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -1.92e+118) || !(lambda2 <= 450.0)) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.cos((lambda1 - lambda2)) * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda2 <= -1.92e+118) or not (lambda2 <= 450.0): tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda2)))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.cos((lambda1 - lambda2)) * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -1.92e+118) || !(lambda2 <= 450.0)) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda2 <= -1.92e+118) || ~((lambda2 <= 450.0))) tmp = atan2((sin(-lambda2) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda2)))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -1.92e+118], N[Not[LessEqual[lambda2, 450.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[(-lambda2)], $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[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -1.92 \cdot 10^{+118} \lor \neg \left(\lambda_2 \leq 450\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\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 \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda2 < -1.9199999999999999e118 or 450 < lambda2 Initial program 63.1%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6468.3
Applied rewrites68.3%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6468.3
Applied rewrites68.3%
if -1.9199999999999999e118 < lambda2 < 450Initial program 91.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6472.8
Applied rewrites72.8%
Taylor expanded in phi1 around 0
lower-sin.f6471.9
Applied rewrites71.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-sin.f64N/A
lower-cos.f6473.4
Applied rewrites73.4%
Final simplification71.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (cos (- lambda1 lambda2))) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), ((-cos(phi2) * cos((lambda1 - lambda2))) * sin(phi1))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * cos(Float64(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[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot \sin \phi_1\right)}
\end{array}
Initial program 80.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6464.7
Applied rewrites64.7%
Taylor expanded in phi1 around 0
lower-sin.f6464.0
Applied rewrites64.0%
Taylor expanded in lambda1 around 0
Applied rewrites80.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (sin phi2) (* (* (cos (- lambda1 lambda2)) (sin phi1)) (cos phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(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) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(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) - ((Math.cos((lambda1 - lambda2)) * Math.sin(phi1)) * Math.cos(phi2))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.cos((lambda1 - lambda2)) * math.sin(phi1)) * math.cos(phi2))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}
\end{array}
Initial program 80.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6464.7
Applied rewrites64.7%
Taylor expanded in phi1 around 0
lower-sin.f6464.0
Applied rewrites64.0%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-sin.f64N/A
lower-cos.f6465.0
Applied rewrites65.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -2.2e+23) (not (<= lambda2 0.023)))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (sin phi1) (cos lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -2.2e+23) || !(lambda2 <= 0.023)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos(lambda1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda2 <= (-2.2d+23)) .or. (.not. (lambda2 <= 0.023d0))) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -2.2e+23) || !(lambda2 <= 0.023)) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda2 <= -2.2e+23) or not (lambda2 <= 0.023): tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -2.2e+23) || !(lambda2 <= 0.023)) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda2 <= -2.2e+23) || ~((lambda2 <= 0.023))) tmp = atan2((sin(-lambda2) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -2.2e+23], N[Not[LessEqual[lambda2, 0.023]], $MachinePrecision]], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -2.2 \cdot 10^{+23} \lor \neg \left(\lambda_2 \leq 0.023\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -2.20000000000000008e23 or 0.023 < lambda2 Initial program 60.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6450.5
Applied rewrites50.5%
Taylor expanded in phi1 around 0
lower-sin.f6450.1
Applied rewrites50.1%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6453.4
Applied rewrites53.4%
if -2.20000000000000008e23 < lambda2 < 0.023Initial program 98.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6477.3
Applied rewrites77.3%
Taylor expanded in phi1 around 0
lower-sin.f6476.4
Applied rewrites76.4%
Taylor expanded in lambda2 around 0
Applied rewrites76.4%
Final simplification65.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -5.2e-5) (not (<= phi2 0.0022)))
(atan2 (* t_0 (cos phi2)) (- (sin phi2) (* (sin phi1) (cos lambda1))))
(atan2
(* (fma -0.5 (* phi2 phi2) 1.0) t_0)
(- (* (cos phi1) phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -5.2e-5) || !(phi2 <= 0.0022)) {
tmp = atan2((t_0 * cos(phi2)), (sin(phi2) - (sin(phi1) * cos(lambda1))));
} else {
tmp = atan2((fma(-0.5, (phi2 * phi2), 1.0) * t_0), ((cos(phi1) * phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -5.2e-5) || !(phi2 <= 0.0022)) tmp = atan(Float64(t_0 * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(lambda1)))); else tmp = atan(Float64(fma(-0.5, Float64(phi2 * phi2), 1.0) * t_0), Float64(Float64(cos(phi1) * phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -5.2e-5], N[Not[LessEqual[phi2, 0.0022]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -5.2 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 0.0022\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right) \cdot t\_0}{\cos \phi_1 \cdot \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -5.19999999999999968e-5 or 0.00220000000000000013 < phi2 Initial program 78.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6450.6
Applied rewrites50.6%
Taylor expanded in phi1 around 0
lower-sin.f6449.6
Applied rewrites49.6%
Taylor expanded in lambda2 around 0
Applied rewrites49.4%
if -5.19999999999999968e-5 < phi2 < 0.00220000000000000013Initial program 83.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6483.5
Applied rewrites83.5%
Taylor expanded in phi1 around 0
lower-sin.f6483.3
Applied rewrites83.3%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-sin.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6483.3
Applied rewrites83.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6483.5
Applied rewrites83.5%
Final simplification64.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(if (or (<= phi2 -5.2e-5) (not (<= phi2 0.72)))
(atan2 (* (sin lambda1) (cos phi2)) (- (sin phi2) t_0))
(atan2
(* (fma -0.5 (* phi2 phi2) 1.0) (sin (- lambda1 lambda2)))
(- (* (cos phi1) phi2) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos((lambda1 - lambda2));
double tmp;
if ((phi2 <= -5.2e-5) || !(phi2 <= 0.72)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - t_0));
} else {
tmp = atan2((fma(-0.5, (phi2 * phi2), 1.0) * sin((lambda1 - lambda2))), ((cos(phi1) * phi2) - t_0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi2 <= -5.2e-5) || !(phi2 <= 0.72)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - t_0)); else tmp = atan(Float64(fma(-0.5, Float64(phi2 * phi2), 1.0) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * phi2) - t_0)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -5.2e-5], N[Not[LessEqual[phi2, 0.72]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -5.2 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 0.72\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \phi_2 - t\_0}\\
\end{array}
\end{array}
if phi2 < -5.19999999999999968e-5 or 0.71999999999999997 < phi2 Initial program 78.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6450.6
Applied rewrites50.6%
Taylor expanded in phi1 around 0
lower-sin.f6449.6
Applied rewrites49.6%
Taylor expanded in lambda2 around 0
lower-sin.f6430.6
Applied rewrites30.6%
if -5.19999999999999968e-5 < phi2 < 0.71999999999999997Initial program 83.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6483.5
Applied rewrites83.5%
Taylor expanded in phi1 around 0
lower-sin.f6483.3
Applied rewrites83.3%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-sin.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6483.3
Applied rewrites83.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6483.5
Applied rewrites83.5%
Final simplification53.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= lambda1 -1.5e-7)
(atan2 t_0 (- (sin phi2) (* (sin phi1) (cos lambda1))))
(if (<= lambda1 1.35)
(atan2 t_0 (- (sin phi2) (* (sin phi1) (cos lambda2))))
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (lambda1 <= -1.5e-7) {
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos(lambda1))));
} else if (lambda1 <= 1.35) {
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos(lambda2))));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
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 (lambda1 <= (-1.5d-7)) then
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos(lambda1))))
else if (lambda1 <= 1.35d0) then
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos(lambda2))))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))))
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 (lambda1 <= -1.5e-7) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.sin(phi1) * Math.cos(lambda1))));
} else if (lambda1 <= 1.35) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.sin(phi1) * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if lambda1 <= -1.5e-7: tmp = math.atan2(t_0, (math.sin(phi2) - (math.sin(phi1) * math.cos(lambda1)))) elif lambda1 <= 1.35: tmp = math.atan2(t_0, (math.sin(phi2) - (math.sin(phi1) * math.cos(lambda2)))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (lambda1 <= -1.5e-7) tmp = atan(t_0, Float64(sin(phi2) - Float64(sin(phi1) * cos(lambda1)))); elseif (lambda1 <= 1.35) tmp = atan(t_0, Float64(sin(phi2) - Float64(sin(phi1) * cos(lambda2)))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (lambda1 <= -1.5e-7) tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos(lambda1)))); elseif (lambda1 <= 1.35) tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos(lambda2)))); else tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); 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[lambda1, -1.5e-7], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 1.35], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.5 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \sin \phi_1 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 1.35:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \sin \phi_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -1.4999999999999999e-7Initial program 65.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6452.2
Applied rewrites52.2%
Taylor expanded in phi1 around 0
lower-sin.f6451.1
Applied rewrites51.1%
Taylor expanded in lambda2 around 0
Applied rewrites51.1%
if -1.4999999999999999e-7 < lambda1 < 1.3500000000000001Initial program 99.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6482.7
Applied rewrites82.7%
Taylor expanded in phi1 around 0
lower-sin.f6482.3
Applied rewrites82.3%
Taylor expanded in lambda1 around 0
Applied rewrites82.3%
if 1.3500000000000001 < lambda1 Initial program 62.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6445.6
Applied rewrites45.6%
Taylor expanded in phi1 around 0
lower-sin.f6444.8
Applied rewrites44.8%
Taylor expanded in lambda2 around 0
lower-sin.f6446.2
Applied rewrites46.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6464.7
Applied rewrites64.7%
Taylor expanded in phi1 around 0
lower-sin.f6464.0
Applied rewrites64.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((1.0 * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * 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((1.0d0 * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((1.0 * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((1.0 * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((1.0 * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower-cos.f64N/A
metadata-evalN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
lower--.f6464.7
Applied rewrites64.7%
Taylor expanded in phi1 around 0
lower-sin.f6464.0
Applied rewrites64.0%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-sin.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6442.0
Applied rewrites42.0%
Taylor expanded in phi2 around 0
Applied rewrites45.8%
herbie shell --seed 2025003
(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))))))