
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Herbie found 28 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma
(- (* -0.5 (* (cos lambda2) lambda1)) (- (sin lambda2)))
lambda1
(cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(((-0.5 * (cos(lambda2) * lambda1)) - -sin(lambda2)), lambda1, cos(lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(Float64(Float64(-0.5 * Float64(cos(lambda2) * lambda1)) - Float64(-sin(lambda2))), lambda1, cos(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[(-0.5 * N[(N[Cos[lambda2], $MachinePrecision] * lambda1), $MachinePrecision]), $MachinePrecision] - (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] * lambda1 + N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(-0.5 \cdot \left(\cos \lambda_2 \cdot \lambda_1\right) - \left(-\sin \lambda_2\right), \lambda_1, \cos \lambda_2\right)}
\end{array}
Initial program 98.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
cos-neg-revN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f6498.2
Applied rewrites98.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(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 = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (- (* (sin lambda1) (cos lambda2)) (sin lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - sin(lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - sin(lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - Math.sin(lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - math.sin(lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - sin(lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - sin(lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
Taylor expanded in lambda1 around 0
lift-sin.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (- (sin lambda1) (* (cos lambda1) (sin lambda2)))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * (sin(lambda1) - (cos(lambda1) * sin(lambda2)))), (cos(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 = lambda1 + atan2((cos(phi2) * (sin(lambda1) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * (math.sin(lambda1) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(sin(lambda1) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * (sin(lambda1) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
Taylor expanded in lambda2 around 0
lift-sin.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi2) 0.3)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2))))
(if (<= (cos phi2) 0.99995)
(+ lambda1 (atan2 t_0 (fma (cos lambda2) (cos phi2) 1.0)))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.3) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2)));
} else if (cos(phi2) <= 0.99995) {
tmp = lambda1 + atan2(t_0, fma(cos(lambda2), cos(phi2), 1.0));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi2) <= 0.3) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2)))); elseif (cos(phi2) <= 0.99995) tmp = Float64(lambda1 + atan(t_0, fma(cos(lambda2), cos(phi2), 1.0))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.3], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.99995], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.3:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{elif}\;\cos \phi_2 \leq 0.99995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.299999999999999989Initial program 98.3%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.9
Applied rewrites78.9%
if 0.299999999999999989 < (cos.f64 phi2) < 0.999950000000000006Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
Applied rewrites78.4%
if 0.999950000000000006 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6498.5
Applied rewrites98.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (* (cos phi2) t_0)))
(if (<= (cos phi2) 0.3)
(+ lambda1 (atan2 t_1 (+ (cos phi1) (cos phi2))))
(if (<= (cos phi2) 0.99995)
(+ lambda1 (atan2 t_1 (fma (cos lambda2) (cos phi2) 1.0)))
(+
lambda1
(atan2
t_0
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos(phi2) * t_0;
double tmp;
if (cos(phi2) <= 0.3) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + cos(phi2)));
} else if (cos(phi2) <= 0.99995) {
tmp = lambda1 + atan2(t_1, fma(cos(lambda2), cos(phi2), 1.0));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * t_0) tmp = 0.0 if (cos(phi2) <= 0.3) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + cos(phi2)))); elseif (cos(phi2) <= 0.99995) tmp = Float64(lambda1 + atan(t_1, fma(cos(lambda2), cos(phi2), 1.0))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.3], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.99995], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot t\_0\\
\mathbf{if}\;\cos \phi_2 \leq 0.3:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{elif}\;\cos \phi_2 \leq 0.99995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.299999999999999989Initial program 98.3%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.9
Applied rewrites78.9%
if 0.299999999999999989 < (cos.f64 phi2) < 0.999950000000000006Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.7
Applied rewrites97.7%
Taylor expanded in phi1 around 0
Applied rewrites78.4%
if 0.999950000000000006 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6498.5
Applied rewrites98.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (- (sin lambda1) (sin lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * (sin(lambda1) - sin(lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * (sin(lambda1) - sin(lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - Math.sin(lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * (math.sin(lambda1) - math.sin(lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(sin(lambda1) - sin(lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * (sin(lambda1) - sin(lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
Taylor expanded in lambda1 around 0
lift-sin.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda2 around 0
lift-sin.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.99995)
(+
lambda1
(atan2
(* (cos phi2) t_0)
(fma
(cos lambda2)
(cos phi2)
(fma
(-
(*
(fma (* phi1 phi1) -0.001388888888888889 0.041666666666666664)
(* phi1 phi1))
0.5)
(* phi1 phi1)
1.0))))
(+
lambda1
(atan2
(* (fma (* phi2 phi2) -0.5 1.0) t_0)
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.99995) {
tmp = lambda1 + atan2((cos(phi2) * t_0), fma(cos(lambda2), cos(phi2), fma(((fma((phi1 * phi1), -0.001388888888888889, 0.041666666666666664) * (phi1 * phi1)) - 0.5), (phi1 * phi1), 1.0)));
} else {
tmp = lambda1 + atan2((fma((phi2 * phi2), -0.5, 1.0) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.99995) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), fma(cos(lambda2), cos(phi2), fma(Float64(Float64(fma(Float64(phi1 * phi1), -0.001388888888888889, 0.041666666666666664) * Float64(phi1 * phi1)) - 0.5), Float64(phi1 * phi1), 1.0)))); else tmp = Float64(lambda1 + atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * t_0), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.99995], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.99995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \mathsf{fma}\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(\phi_1 \cdot \phi_1\right) - 0.5, \phi_1 \cdot \phi_1, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.999950000000000006Initial program 98.4%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lower-*.f6482.1
Applied rewrites82.1%
if 0.999950000000000006 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi1) 0.998)
(+
lambda1
(atan2 t_0 (fma (cos lambda2) (fma (* phi2 phi2) -0.5 1.0) (cos phi1))))
(+ lambda1 (atan2 t_0 (fma (cos (- lambda1 lambda2)) (cos phi2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.998) {
tmp = lambda1 + atan2(t_0, fma(cos(lambda2), fma((phi2 * phi2), -0.5, 1.0), cos(phi1)));
} else {
tmp = lambda1 + atan2(t_0, fma(cos((lambda1 - lambda2)), cos(phi2), 1.0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi1) <= 0.998) tmp = Float64(lambda1 + atan(t_0, fma(cos(lambda2), fma(Float64(phi2 * phi2), -0.5, 1.0), cos(phi1)))); else tmp = Float64(lambda1 + atan(t_0, fma(cos(Float64(lambda1 - lambda2)), cos(phi2), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.998], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \lambda_2, \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right), \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), \cos \phi_2, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.998Initial program 98.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.9
Applied rewrites97.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6481.4
Applied rewrites81.4%
if 0.998 < (cos.f64 phi1) Initial program 98.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6497.7
Applied rewrites97.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))))
(if (<= lambda2 -4e-7)
t_0
(if (<= lambda2 5e-19)
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma (cos lambda1) (cos phi2) (cos phi1))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + atan2((cos(phi2) * sin(-lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
double tmp;
if (lambda2 <= -4e-7) {
tmp = t_0;
} else if (lambda2 <= 5e-19) {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(-lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) tmp = 0.0 if (lambda2 <= -4e-7) tmp = t_0; elseif (lambda2 <= 5e-19) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -4e-7], t$95$0, If[LessEqual[lambda2, 5e-19], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 5 \cdot 10^{-19}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -3.9999999999999998e-7 or 5.0000000000000004e-19 < lambda2 Initial program 97.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6497.6
Applied rewrites97.6%
if -3.9999999999999998e-7 < lambda2 < 5.0000000000000004e-19Initial program 99.6%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6499.5
Applied rewrites99.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))))
(if (<= lambda2 -4e-7)
t_0
(if (<= lambda2 5e-19)
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+ (cos phi1) (cos phi2))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + atan2((cos(phi2) * sin(-lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
double tmp;
if (lambda2 <= -4e-7) {
tmp = t_0;
} else if (lambda2 <= 5e-19) {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + cos(phi2)));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(-lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) tmp = 0.0 if (lambda2 <= -4e-7) tmp = t_0; elseif (lambda2 <= 5e-19) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + cos(phi2)))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -4e-7], t$95$0, If[LessEqual[lambda2, 5e-19], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 5 \cdot 10^{-19}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -3.9999999999999998e-7 or 5.0000000000000004e-19 < lambda2 Initial program 97.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6497.6
Applied rewrites97.6%
if -3.9999999999999998e-7 < lambda2 < 5.0000000000000004e-19Initial program 99.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.1
Applied rewrites98.1%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6498.1
Applied rewrites98.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.99995)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi1) (cos phi2))))
(+
lambda1
(atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.99995) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * 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))
if (cos(phi2) <= 0.99995d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * 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));
double tmp;
if (Math.cos(phi2) <= 0.99995) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi1) + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.99995: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi1) + math.cos(phi2))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.99995) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.99995) tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.99995], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.99995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.999950000000000006Initial program 98.4%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.9
Applied rewrites78.9%
if 0.999950000000000006 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6498.5
Applied rewrites98.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (* (cos phi2) t_0)))
(if (<= (cos phi2) -0.01)
(+ lambda1 (atan2 t_1 (+ (fma (* phi1 phi1) -0.5 1.0) t_0)))
(+ lambda1 (atan2 t_1 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos(phi2) * t_0;
double tmp;
if (cos(phi2) <= -0.01) {
tmp = lambda1 + atan2(t_1, (fma((phi1 * phi1), -0.5, 1.0) + t_0));
} else {
tmp = lambda1 + atan2(t_1, (cos(lambda2) + cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * t_0) tmp = 0.0 if (cos(phi2) <= -0.01) tmp = Float64(lambda1 + atan(t_1, Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) + t_0))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(lambda2) + cos(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], -0.01], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot t\_0\\
\mathbf{if}\;\cos \phi_2 \leq -0.01:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \lambda_2 + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.0100000000000000002Initial program 98.3%
lift--.f64N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6479.8
Applied rewrites79.8%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
*-commutativeN/A
lower-sin.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-PI.f6456.2
Applied rewrites56.2%
Taylor expanded in lambda1 around inf
Applied rewrites61.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6463.9
Applied rewrites63.9%
if -0.0100000000000000002 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6485.0
Applied rewrites85.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos lambda2) (cos phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}
\end{array}
Initial program 98.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.9
Applied rewrites97.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 4e-6)
(+
lambda1
(atan2
(* (fma (* phi2 phi2) -0.5 1.0) t_0)
(+ (cos phi1) (* (cos phi2) t_1))))
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+ (fma -0.5 (* phi1 phi1) (* t_1 (cos phi2))) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 4e-6) {
tmp = lambda1 + atan2((fma((phi2 * phi2), -0.5, 1.0) * t_0), (cos(phi1) + (cos(phi2) * t_1)));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (fma(-0.5, (phi1 * phi1), (t_1 * cos(phi2))) + 1.0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 4e-6) tmp = Float64(lambda1 + atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * t_0), Float64(cos(phi1) + Float64(cos(phi2) * t_1)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(fma(-0.5, Float64(phi1 * phi1), Float64(t_1 * cos(phi2))) + 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 4e-6], N[(lambda1 + N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot t\_0}{\cos \phi_1 + \cos \phi_2 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, t\_1 \cdot \cos \phi_2\right) + 1}\\
\end{array}
\end{array}
if phi2 < 3.99999999999999982e-6Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.4
Applied rewrites83.4%
if 3.99999999999999982e-6 < phi2 Initial program 98.2%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites74.7%
Taylor expanded in phi1 around 0
Applied rewrites82.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 4e-6)
(+
lambda1
(atan2
(* (fma (* phi2 phi2) -0.5 1.0) t_0)
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(+
lambda1
(atan2
(* (cos phi2) t_0)
(fma (cos lambda2) (cos phi2) (fma (* phi1 phi1) -0.5 1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 4e-6) {
tmp = lambda1 + atan2((fma((phi2 * phi2), -0.5, 1.0) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), fma(cos(lambda2), cos(phi2), fma((phi1 * phi1), -0.5, 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 4e-6) tmp = Float64(lambda1 + atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * t_0), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), fma(cos(lambda2), cos(phi2), fma(Float64(phi1 * phi1), -0.5, 1.0)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 4e-6], N[(lambda1 + N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right)\right)}\\
\end{array}
\end{array}
if phi2 < 3.99999999999999982e-6Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.4
Applied rewrites83.4%
if 3.99999999999999982e-6 < phi2 Initial program 98.2%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6481.7
Applied rewrites81.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 175000000.0)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda1 lambda2)))))
(+
lambda1
(atan2
t_0
(fma (cos lambda2) (cos phi2) (fma (* phi1 phi1) -0.5 1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 175000000.0) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + atan2(t_0, fma(cos(lambda2), cos(phi2), fma((phi1 * phi1), -0.5, 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= 175000000.0) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); else tmp = Float64(lambda1 + atan(t_0, fma(cos(lambda2), cos(phi2), fma(Float64(phi1 * phi1), -0.5, 1.0)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 175000000.0], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 175000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right)\right)}\\
\end{array}
\end{array}
if phi2 < 1.75e8Initial program 98.7%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6484.8
Applied rewrites84.8%
if 1.75e8 < phi2 Initial program 98.2%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.5
Applied rewrites97.5%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6481.7
Applied rewrites81.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.6405)
(+
lambda1
(atan2 (* (cos phi2) t_0) (+ (fma (* phi1 phi1) -0.5 1.0) t_0)))
(+ lambda1 (atan2 t_0 (fma (cos (- lambda1 lambda2)) (cos phi2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.6405) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (fma((phi1 * phi1), -0.5, 1.0) + t_0));
} else {
tmp = lambda1 + atan2(t_0, fma(cos((lambda1 - lambda2)), cos(phi2), 1.0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.6405) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) + t_0))); else tmp = Float64(lambda1 + atan(t_0, fma(cos(Float64(lambda1 - lambda2)), cos(phi2), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.6405], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.6405:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), \cos \phi_2, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.640499999999999958Initial program 98.4%
lift--.f64N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
*-commutativeN/A
lower-sin.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-PI.f6456.6
Applied rewrites56.6%
Taylor expanded in lambda1 around inf
Applied rewrites61.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lower-*.f6462.8
Applied rewrites62.8%
if 0.640499999999999958 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites76.1%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.9
Applied rewrites54.9%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6454.9
Applied rewrites54.9%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6474.9
Applied rewrites74.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.998)
(+
lambda1
(atan2 t_0 (+ (cos phi1) (sin (- (fma PI 0.5 lambda1) lambda2)))))
(+ lambda1 (atan2 t_0 (fma (cos (- lambda1 lambda2)) (cos phi2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.998) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + sin((fma(((double) M_PI), 0.5, lambda1) - lambda2))));
} else {
tmp = lambda1 + atan2(t_0, fma(cos((lambda1 - lambda2)), cos(phi2), 1.0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.998) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + sin(Float64(fma(pi, 0.5, lambda1) - lambda2))))); else tmp = Float64(lambda1 + atan(t_0, fma(cos(Float64(lambda1 - lambda2)), cos(phi2), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.998], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(Pi * 0.5 + lambda1), $MachinePrecision] - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \sin \left(\mathsf{fma}\left(\pi, 0.5, \lambda_1\right) - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), \cos \phi_2, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.998Initial program 98.6%
lift--.f64N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6480.3
Applied rewrites80.3%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
*-commutativeN/A
lower-sin.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-PI.f6468.9
Applied rewrites68.9%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6467.5
Applied rewrites67.5%
if 0.998 < (cos.f64 phi1) Initial program 98.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites97.7%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.8
Applied rewrites54.8%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6453.7
Applied rewrites53.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6475.7
Applied rewrites75.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 3600000.0)
(+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 3600000.0) {
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
} else {
tmp = lambda1 + atan2(t_0, (cos(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(phi2) * sin((lambda1 - lambda2))
if (phi2 <= 3600000.0d0) then
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
else
tmp = lambda1 + atan2(t_0, (cos(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(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 3600000.0) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(phi2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 3600000.0: tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(phi2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= 3600000.0) tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 3600000.0) tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 3600000.0], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 3600000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2}\\
\end{array}
\end{array}
if phi2 < 3.6e6Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6484.3
Applied rewrites84.3%
if 3.6e6 < phi2 Initial program 98.2%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.5
Applied rewrites97.5%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.9
Applied rewrites78.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (fma (cos (- lambda1 lambda2)) (cos phi2) 1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), fma(cos((lambda1 - lambda2)), cos(phi2), 1.0));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), fma(cos(Float64(lambda1 - lambda2)), cos(phi2), 1.0))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), \cos \phi_2, 1\right)}
\end{array}
Initial program 98.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites75.7%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.0
Applied rewrites54.0%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6453.3
Applied rewrites53.3%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6466.5
Applied rewrites66.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(sin (- lambda1 lambda2))
(+
(fma
(* phi1 phi1)
(- (* (* phi1 phi1) 0.041666666666666664) 0.5)
(cos (- lambda1 lambda2)))
1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (fma((phi1 * phi1), (((phi1 * phi1) * 0.041666666666666664) - 0.5), cos((lambda1 - lambda2))) + 1.0));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(fma(Float64(phi1 * phi1), Float64(Float64(Float64(phi1 * phi1) * 0.041666666666666664) - 0.5), cos(Float64(lambda1 - lambda2))) + 1.0))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(phi1 * phi1), $MachinePrecision] * N[(N[(N[(phi1 * phi1), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, \left(\phi_1 \cdot \phi_1\right) \cdot 0.041666666666666664 - 0.5, \cos \left(\lambda_1 - \lambda_2\right)\right) + 1}
\end{array}
Initial program 98.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites75.7%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.0
Applied rewrites54.0%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6453.3
Applied rewrites53.3%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites64.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (* (* (* phi1 phi1) (* phi1 phi1)) 0.041666666666666664))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664));
}
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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(Float64(phi1 * phi1) * Float64(phi1 * phi1)) * 0.041666666666666664))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(phi1 * phi1), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(\phi_1 \cdot \phi_1\right)\right) \cdot 0.041666666666666664}
\end{array}
Initial program 98.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites75.7%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.0
Applied rewrites54.0%
lift-pow.f64N/A
sqr-powN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lower-*.f6454.0
Applied rewrites54.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (+ 1.0 (* -0.5 (* phi2 phi2))) (sin (- lambda1 lambda2))) (* (pow phi1 4.0) 0.041666666666666664))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(((1.0 + (-0.5 * (phi2 * phi2))) * sin((lambda1 - lambda2))), (pow(phi1, 4.0) * 0.041666666666666664));
}
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 = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (phi2 * phi2))) * sin((lambda1 - lambda2))), ((phi1 ** 4.0d0) * 0.041666666666666664d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(((1.0 + (-0.5 * (phi2 * phi2))) * Math.sin((lambda1 - lambda2))), (Math.pow(phi1, 4.0) * 0.041666666666666664));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(((1.0 + (-0.5 * (phi2 * phi2))) * math.sin((lambda1 - lambda2))), (math.pow(phi1, 4.0) * 0.041666666666666664))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * sin(Float64(lambda1 - lambda2))), Float64((phi1 ^ 4.0) * 0.041666666666666664))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 * phi2))) * sin((lambda1 - lambda2))), ((phi1 ^ 4.0) * 0.041666666666666664)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Power[phi1, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{{\phi_1}^{4} \cdot 0.041666666666666664}
\end{array}
Initial program 98.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites75.7%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.0
Applied rewrites54.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.6
Applied rewrites53.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (* (* (* phi1 phi1) (* phi1 phi1)) 0.041666666666666664))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664));
}
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 = lambda1 + atan2(sin((lambda1 - lambda2)), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(Float64(phi1 * phi1) * Float64(phi1 * phi1)) * 0.041666666666666664))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (((phi1 * phi1) * (phi1 * phi1)) * 0.041666666666666664)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(phi1 * phi1), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(\phi_1 \cdot \phi_1\right)\right) \cdot 0.041666666666666664}
\end{array}
Initial program 98.6%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites75.7%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.0
Applied rewrites54.0%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6453.3
Applied rewrites53.3%
lift-pow.f64N/A
sqr-powN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lower-*.f6453.3
Applied rewrites53.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 lambda1)
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1;
}
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 = lambda1
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1;
}
def code(lambda1, lambda2, phi1, phi2): return lambda1
function code(lambda1, lambda2, phi1, phi2) return lambda1 end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1; end
code[lambda1_, lambda2_, phi1_, phi2_] := lambda1
\begin{array}{l}
\\
\lambda_1
\end{array}
Initial program 98.6%
Taylor expanded in lambda1 around inf
Applied rewrites52.8%
herbie shell --seed 2025105
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Midpoint on a great circle"
:precision binary64
(+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))