
(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]
\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)}
Herbie found 22 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]
\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)}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (* (sin lambda1) (sin lambda2)))
(t_2 (* (cos lambda2) (cos lambda1))))
(+
lambda1
(atan2
(* (cos phi2) (* (- 1.0 (/ (* (sin lambda2) (cos lambda1)) t_0)) t_0))
(+
(cos phi1)
(*
(cos phi2)
(/
(+ (pow t_1 3.0) (pow t_2 3.0))
(fma t_1 t_1 (- (* t_2 t_2) (* t_1 t_2))))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = sin(lambda1) * sin(lambda2);
double t_2 = cos(lambda2) * cos(lambda1);
return lambda1 + atan2((cos(phi2) * ((1.0 - ((sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), (cos(phi1) + (cos(phi2) * ((pow(t_1, 3.0) + pow(t_2, 3.0)) / fma(t_1, t_1, ((t_2 * t_2) - (t_1 * t_2)))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(sin(lambda1) * sin(lambda2)) t_2 = Float64(cos(lambda2) * cos(lambda1)) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(1.0 - Float64(Float64(sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), Float64(cos(phi1) + Float64(cos(phi2) * Float64(Float64((t_1 ^ 3.0) + (t_2 ^ 3.0)) / fma(t_1, t_1, Float64(Float64(t_2 * t_2) - Float64(t_1 * t_2)))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(1.0 - N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Power[t$95$1, 3.0], $MachinePrecision] + N[Power[t$95$2, 3.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 * t$95$1 + N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2\\
t_2 := \cos \lambda_2 \cdot \cos \lambda_1\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\left(1 - \frac{\sin \lambda_2 \cdot \cos \lambda_1}{t\_0}\right) \cdot t\_0\right)}{\cos \phi_1 + \cos \phi_2 \cdot \frac{{t\_1}^{3} + {t\_2}^{3}}{\mathsf{fma}\left(t\_1, t\_1, t\_2 \cdot t\_2 - t\_1 \cdot t\_2\right)}}
\end{array}
Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.6
Applied rewrites98.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
lift-fma.f64N/A
flip3-+N/A
lower-unsound-/.f64N/A
lower-unsound-+.f64N/A
lower-unsound-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-fma.f64N/A
Applied rewrites99.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2))))
(+
lambda1
(atan2
(* (cos phi2) (* (- 1.0 (/ (* (sin lambda2) (cos lambda1)) t_0)) t_0))
(+
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
return lambda1 + atan2((cos(phi2) * ((1.0 - ((sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), (cos(phi1) + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(1.0 - Float64(Float64(sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), Float64(cos(phi1) + Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(1.0 - N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\left(1 - \frac{\sin \lambda_2 \cdot \cos \lambda_1}{t\_0}\right) \cdot t\_0\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.6
Applied rewrites98.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $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[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}
Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.6
Applied rewrites98.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
sub-to-mult-revN/A
lower--.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2))))
(+
lambda1
(atan2
(* (cos phi2) (* (- 1.0 (/ (* (sin lambda2) (cos lambda1)) t_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) * cos(lambda2);
return lambda1 + atan2((cos(phi2) * ((1.0 - ((sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), (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
real(8) :: t_0
t_0 = sin(lambda1) * cos(lambda2)
code = lambda1 + atan2((cos(phi2) * ((1.0d0 - ((sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(lambda1) * Math.cos(lambda2);
return lambda1 + Math.atan2((Math.cos(phi2) * ((1.0 - ((Math.sin(lambda2) * Math.cos(lambda1)) / t_0)) * t_0)), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(lambda1) * math.cos(lambda2) return lambda1 + math.atan2((math.cos(phi2) * ((1.0 - ((math.sin(lambda2) * math.cos(lambda1)) / t_0)) * t_0)), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(1.0 - Float64(Float64(sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = sin(lambda1) * cos(lambda2); tmp = lambda1 + atan2((cos(phi2) * ((1.0 - ((sin(lambda2) * cos(lambda1)) / t_0)) * t_0)), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(1.0 - N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $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}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\left(1 - \frac{\sin \lambda_2 \cdot \cos \lambda_1}{t\_0}\right) \cdot t\_0\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(*
(- 1.0 (* (/ (cos lambda1) (sin lambda1)) (tan lambda2)))
(* (sin lambda1) (cos lambda2))))
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((1.0 - ((cos(lambda1) / sin(lambda1)) * tan(lambda2))) * (sin(lambda1) * cos(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) * ((1.0d0 - ((cos(lambda1) / sin(lambda1)) * tan(lambda2))) * (sin(lambda1) * cos(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) * ((1.0 - ((Math.cos(lambda1) / Math.sin(lambda1)) * Math.tan(lambda2))) * (Math.sin(lambda1) * Math.cos(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * ((1.0 - ((math.cos(lambda1) / math.sin(lambda1)) * math.tan(lambda2))) * (math.sin(lambda1) * math.cos(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(1.0 - Float64(Float64(cos(lambda1) / sin(lambda1)) * tan(lambda2))) * Float64(sin(lambda1) * cos(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * ((1.0 - ((cos(lambda1) / sin(lambda1)) * tan(lambda2))) * (sin(lambda1) * cos(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[(1.0 - N[(N[(N[Cos[lambda1], $MachinePrecision] / N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Tan[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[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]
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\left(1 - \frac{\cos \lambda_1}{\sin \lambda_1} \cdot \tan \lambda_2\right) \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.6
Applied rewrites98.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
quot-tanN/A
lower-tan.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(*
(- 1.0 (/ (sin lambda2) (* lambda1 (cos lambda2))))
(* (sin lambda1) (cos lambda2))))
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((1.0 - (sin(lambda2) / (lambda1 * cos(lambda2)))) * (sin(lambda1) * cos(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) * ((1.0d0 - (sin(lambda2) / (lambda1 * cos(lambda2)))) * (sin(lambda1) * cos(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) * ((1.0 - (Math.sin(lambda2) / (lambda1 * Math.cos(lambda2)))) * (Math.sin(lambda1) * Math.cos(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * ((1.0 - (math.sin(lambda2) / (lambda1 * math.cos(lambda2)))) * (math.sin(lambda1) * math.cos(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(1.0 - Float64(sin(lambda2) / Float64(lambda1 * cos(lambda2)))) * Float64(sin(lambda1) * cos(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * ((1.0 - (sin(lambda2) / (lambda1 * cos(lambda2)))) * (sin(lambda1) * cos(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[(1.0 - N[(N[Sin[lambda2], $MachinePrecision] / N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[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]
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\left(1 - \frac{\sin \lambda_2}{\lambda_1 \cdot \cos \lambda_2}\right) \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda1 around 0
lower-/.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f6498.5
Applied rewrites98.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (fma (cos (- lambda2 lambda1)) (cos phi2) (cos phi1))) lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(cos((lambda2 - lambda1)), cos(phi2), cos(phi1))) + lambda1;
}
function code(lambda1, lambda2, phi1, phi2) return Float64(atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(cos(Float64(lambda2 - lambda1)), cos(phi2), cos(phi1))) + lambda1) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right), \cos \phi_2, \cos \phi_1\right)} + \lambda_1
Initial program 98.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_1 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))
(t_2 (atan2 t_0 t_1))
(t_3 (+ lambda1 t_2))
(t_4
(+ lambda1 (atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos lambda1)))))))
(if (<= t_3 -3.14)
(+ lambda1 (atan2 (* (cos phi2) (sin lambda1)) t_1))
(if (<= t_3 -0.02)
t_2
(if (<= t_3 4e-8) t_4 (if (<= t_3 3.0) t_2 t_4))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double t_1 = cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)));
double t_2 = atan2(t_0, t_1);
double t_3 = lambda1 + t_2;
double t_4 = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda1))));
double tmp;
if (t_3 <= -3.14) {
tmp = lambda1 + atan2((cos(phi2) * sin(lambda1)), t_1);
} else if (t_3 <= -0.02) {
tmp = t_2;
} else if (t_3 <= 4e-8) {
tmp = t_4;
} else if (t_3 <= 3.0) {
tmp = t_2;
} else {
tmp = t_4;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
t_1 = cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))
t_2 = atan2(t_0, t_1)
t_3 = lambda1 + t_2
t_4 = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda1))))
if (t_3 <= (-3.14d0)) then
tmp = lambda1 + atan2((cos(phi2) * sin(lambda1)), t_1)
else if (t_3 <= (-0.02d0)) then
tmp = t_2
else if (t_3 <= 4d-8) then
tmp = t_4
else if (t_3 <= 3.0d0) then
tmp = t_2
else
tmp = t_4
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 t_1 = Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)));
double t_2 = Math.atan2(t_0, t_1);
double t_3 = lambda1 + t_2;
double t_4 = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda1))));
double tmp;
if (t_3 <= -3.14) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), t_1);
} else if (t_3 <= -0.02) {
tmp = t_2;
} else if (t_3 <= 4e-8) {
tmp = t_4;
} else if (t_3 <= 3.0) {
tmp = t_2;
} else {
tmp = t_4;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_1 = math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2))) t_2 = math.atan2(t_0, t_1) t_3 = lambda1 + t_2 t_4 = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda1)))) tmp = 0 if t_3 <= -3.14: tmp = lambda1 + math.atan2((math.cos(phi2) * math.sin(lambda1)), t_1) elif t_3 <= -0.02: tmp = t_2 elif t_3 <= 4e-8: tmp = t_4 elif t_3 <= 3.0: tmp = t_2 else: tmp = t_4 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))) t_2 = atan(t_0, t_1) t_3 = Float64(lambda1 + t_2) t_4 = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda1))))) tmp = 0.0 if (t_3 <= -3.14) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(lambda1)), t_1)); elseif (t_3 <= -0.02) tmp = t_2; elseif (t_3 <= 4e-8) tmp = t_4; elseif (t_3 <= 3.0) tmp = t_2; else tmp = t_4; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); t_1 = cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))); t_2 = atan2(t_0, t_1); t_3 = lambda1 + t_2; t_4 = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda1)))); tmp = 0.0; if (t_3 <= -3.14) tmp = lambda1 + atan2((cos(phi2) * sin(lambda1)), t_1); elseif (t_3 <= -0.02) tmp = t_2; elseif (t_3 <= 4e-8) tmp = t_4; elseif (t_3 <= 3.0) tmp = t_2; else tmp = t_4; 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]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[t$95$0 / t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -3.14], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -0.02], t$95$2, If[LessEqual[t$95$3, 4e-8], t$95$4, If[LessEqual[t$95$3, 3.0], t$95$2, t$95$4]]]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{t\_0}{t\_1}\\
t_3 := \lambda_1 + t\_2\\
t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_1}\\
\mathbf{if}\;t\_3 \leq -3.14:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_1}\\
\mathbf{elif}\;t\_3 \leq -0.02:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 4 \cdot 10^{-8}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_3 \leq 3:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
if (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -3.14000000000000012Initial program 98.6%
Taylor expanded in lambda2 around 0
lower-sin.f6463.8
Applied rewrites63.8%
if -3.14000000000000012 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0200000000000000004 or 4.0000000000000001e-8 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 3Initial program 98.6%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6441.7
Applied rewrites41.7%
if -0.0200000000000000004 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 4.0000000000000001e-8 or 3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) Initial program 98.6%
Taylor expanded in lambda2 around 0
lower-cos.f6478.8
Applied rewrites78.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(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(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(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(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(lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(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[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}
Initial program 98.6%
lift-cos.f64N/A
sin-+PI/2-revN/A
lift--.f64N/A
sub-flipN/A
associate-+l+N/A
sin-sumN/A
sin-+PI/2-revN/A
cos-neg-revN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-PI.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda1 around 0
lower-cos.f6497.8
Applied rewrites97.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))
(t_1 (+ lambda1 (atan2 (* (cos phi2) (sin lambda1)) t_0))))
(if (<= lambda1 -2.9e-8)
t_1
(if (<= lambda1 9.5e-18)
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) t_0)
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)));
double t_1 = lambda1 + atan2((cos(phi2) * sin(lambda1)), t_0);
double tmp;
if (lambda1 <= -2.9e-8) {
tmp = t_1;
} else if (lambda1 <= 9.5e-18) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))
t_1 = lambda1 + atan2((cos(phi2) * sin(lambda1)), t_0)
if (lambda1 <= (-2.9d-8)) then
tmp = t_1
else if (lambda1 <= 9.5d-18) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)));
double t_1 = lambda1 + Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), t_0);
double tmp;
if (lambda1 <= -2.9e-8) {
tmp = t_1;
} else if (lambda1 <= 9.5e-18) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2))) t_1 = lambda1 + math.atan2((math.cos(phi2) * math.sin(lambda1)), t_0) tmp = 0 if lambda1 <= -2.9e-8: tmp = t_1 elif lambda1 <= 9.5e-18: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), t_0) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))) t_1 = Float64(lambda1 + atan(Float64(cos(phi2) * sin(lambda1)), t_0)) tmp = 0.0 if (lambda1 <= -2.9e-8) tmp = t_1; elseif (lambda1 <= 9.5e-18) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))); t_1 = lambda1 + atan2((cos(phi2) * sin(lambda1)), t_0); tmp = 0.0; if (lambda1 <= -2.9e-8) tmp = t_1; elseif (lambda1 <= 9.5e-18) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -2.9e-8], t$95$1, If[LessEqual[lambda1, 9.5e-18], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_0}\\
\mathbf{if}\;\lambda_1 \leq -2.9 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 9.5 \cdot 10^{-18}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda1 < -2.9000000000000002e-8 or 9.5000000000000003e-18 < lambda1 Initial program 98.6%
Taylor expanded in lambda2 around 0
lower-sin.f6463.8
Applied rewrites63.8%
if -2.9000000000000002e-8 < lambda1 < 9.5000000000000003e-18Initial program 98.6%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6441.7
Applied rewrites41.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (+ (cos phi1) t_1))
(t_3 (cos (fabs phi2)))
(t_4 (* t_3 t_0)))
(if (<= lambda1 -0.2)
(+ lambda1 (atan2 (* (sin (fma 0.5 PI (fabs phi2))) t_0) t_2))
(if (<= lambda1 3.5e-13)
(atan2 t_4 (+ (cos phi1) (* t_3 t_1)))
(+ lambda1 (atan2 t_4 t_2))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi1) + t_1;
double t_3 = cos(fabs(phi2));
double t_4 = t_3 * t_0;
double tmp;
if (lambda1 <= -0.2) {
tmp = lambda1 + atan2((sin(fma(0.5, ((double) M_PI), fabs(phi2))) * t_0), t_2);
} else if (lambda1 <= 3.5e-13) {
tmp = atan2(t_4, (cos(phi1) + (t_3 * t_1)));
} else {
tmp = lambda1 + atan2(t_4, t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi1) + t_1) t_3 = cos(abs(phi2)) t_4 = Float64(t_3 * t_0) tmp = 0.0 if (lambda1 <= -0.2) tmp = Float64(lambda1 + atan(Float64(sin(fma(0.5, pi, abs(phi2))) * t_0), t_2)); elseif (lambda1 <= 3.5e-13) tmp = atan(t_4, Float64(cos(phi1) + Float64(t_3 * t_1))); else tmp = Float64(lambda1 + atan(t_4, t_2)); 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]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[Abs[phi2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * t$95$0), $MachinePrecision]}, If[LessEqual[lambda1, -0.2], N[(lambda1 + N[ArcTan[N[(N[Sin[N[(0.5 * Pi + N[Abs[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 3.5e-13], N[ArcTan[t$95$4 / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$3 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$4 / t$95$2], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 + t\_1\\
t_3 := \cos \left(\left|\phi_2\right|\right)\\
t_4 := t\_3 \cdot t\_0\\
\mathbf{if}\;\lambda_1 \leq -0.2:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\mathsf{fma}\left(0.5, \pi, \left|\phi_2\right|\right)\right) \cdot t\_0}{t\_2}\\
\mathbf{elif}\;\lambda_1 \leq 3.5 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{\cos \phi_1 + t\_3 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_4}{t\_2}\\
\end{array}
if lambda1 < -0.20000000000000001Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-PI.f64N/A
mult-flip-revN/A
metadata-evalN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.6
Applied rewrites75.6%
if -0.20000000000000001 < lambda1 < 3.5000000000000002e-13Initial program 98.6%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6441.7
Applied rewrites41.7%
if 3.5000000000000002e-13 < lambda1 Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (cos (fabs phi2))))
(if (<= (fabs phi2) 7500000.0)
(+
lambda1
(atan2 (* (sin (+ (- (fabs phi2)) (* 0.5 PI))) t_0) (+ (cos phi1) t_1)))
(+
lambda1
(atan2 (* t_2 t_0) (+ 1.0 (fma -0.5 (pow phi1 2.0) (* t_2 t_1))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(fabs(phi2));
double tmp;
if (fabs(phi2) <= 7500000.0) {
tmp = lambda1 + atan2((sin((-fabs(phi2) + (0.5 * ((double) M_PI)))) * t_0), (cos(phi1) + t_1));
} else {
tmp = lambda1 + atan2((t_2 * t_0), (1.0 + fma(-0.5, pow(phi1, 2.0), (t_2 * t_1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = cos(abs(phi2)) tmp = 0.0 if (abs(phi2) <= 7500000.0) tmp = Float64(lambda1 + atan(Float64(sin(Float64(Float64(-abs(phi2)) + Float64(0.5 * pi))) * t_0), Float64(cos(phi1) + t_1))); else tmp = Float64(lambda1 + atan(Float64(t_2 * t_0), Float64(1.0 + fma(-0.5, (phi1 ^ 2.0), Float64(t_2 * t_1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[Abs[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[phi2], $MachinePrecision], 7500000.0], N[(lambda1 + N[ArcTan[N[(N[Sin[N[((-N[Abs[phi2], $MachinePrecision]) + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(t$95$2 * t$95$0), $MachinePrecision] / N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision] + N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \left(\left|\phi_2\right|\right)\\
\mathbf{if}\;\left|\phi_2\right| \leq 7500000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\left(-\left|\phi_2\right|\right) + 0.5 \cdot \pi\right) \cdot t\_0}{\cos \phi_1 + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2 \cdot t\_0}{1 + \mathsf{fma}\left(-0.5, {\phi_1}^{2}, t\_2 \cdot t\_1\right)}\\
\end{array}
if phi2 < 7.5e6Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lift-PI.f64N/A
mult-flip-revN/A
metadata-evalN/A
lift-*.f64N/A
lower-+.f64N/A
lower-neg.f6475.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.7
Applied rewrites75.7%
if 7.5e6 < phi2 Initial program 98.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6479.4
Applied rewrites79.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (fabs phi1) 4.6e-7)
(+ lambda1 (atan2 t_1 (+ 1.0 (* (cos phi2) t_0))))
(+ lambda1 (atan2 t_1 (+ (cos (fabs phi1)) t_0))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (fabs(phi1) <= 4.6e-7) {
tmp = lambda1 + atan2(t_1, (1.0 + (cos(phi2) * t_0)));
} else {
tmp = lambda1 + atan2(t_1, (cos(fabs(phi1)) + t_0));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (abs(phi1) <= 4.6d-7) then
tmp = lambda1 + atan2(t_1, (1.0d0 + (cos(phi2) * t_0)))
else
tmp = lambda1 + atan2(t_1, (cos(abs(phi1)) + t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (Math.abs(phi1) <= 4.6e-7) {
tmp = lambda1 + Math.atan2(t_1, (1.0 + (Math.cos(phi2) * t_0)));
} else {
tmp = lambda1 + Math.atan2(t_1, (Math.cos(Math.abs(phi1)) + t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.fabs(phi1) <= 4.6e-7: tmp = lambda1 + math.atan2(t_1, (1.0 + (math.cos(phi2) * t_0))) else: tmp = lambda1 + math.atan2(t_1, (math.cos(math.fabs(phi1)) + t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (abs(phi1) <= 4.6e-7) tmp = Float64(lambda1 + atan(t_1, Float64(1.0 + Float64(cos(phi2) * t_0)))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(abs(phi1)) + t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (abs(phi1) <= 4.6e-7) tmp = lambda1 + atan2(t_1, (1.0 + (cos(phi2) * t_0))); else tmp = lambda1 + atan2(t_1, (cos(abs(phi1)) + t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[phi1], $MachinePrecision], 4.6e-7], N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[N[Abs[phi1], $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\left|\phi_1\right| \leq 4.6 \cdot 10^{-7}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \left(\left|\phi_1\right|\right) + t\_0}\\
\end{array}
if phi1 < 4.5999999999999999e-7Initial program 98.6%
Taylor expanded in phi1 around 0
Applied rewrites78.0%
if 4.5999999999999999e-7 < phi1 Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi2) 0.65)
(+ lambda1 (atan2 t_1 (+ (+ 1.0 (* -0.5 (pow phi1 2.0))) t_0)))
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.65) {
tmp = lambda1 + atan2(t_1, ((1.0 + (-0.5 * pow(phi1, 2.0))) + t_0));
} else {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (cos(phi2) <= 0.65d0) then
tmp = lambda1 + atan2(t_1, ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) + t_0))
else
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.65) {
tmp = lambda1 + Math.atan2(t_1, ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) + t_0));
} else {
tmp = lambda1 + Math.atan2(t_1, (Math.cos(phi1) + t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.65: tmp = lambda1 + math.atan2(t_1, ((1.0 + (-0.5 * math.pow(phi1, 2.0))) + t_0)) else: tmp = lambda1 + math.atan2(t_1, (math.cos(phi1) + t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi2) <= 0.65) tmp = Float64(lambda1 + atan(t_1, Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + t_0))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.65) tmp = lambda1 + atan2(t_1, ((1.0 + (-0.5 * (phi1 ^ 2.0))) + t_0)); else tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.65], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.65:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
if (cos.f64 phi2) < 0.650000000000000022Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6468.8
Applied rewrites68.8%
if 0.650000000000000022 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi2) 0.65)
(+
lambda1
(atan2
t_0
(+ (+ 1.0 (* -0.5 (pow phi1 2.0))) (cos (- lambda1 lambda2)))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- 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.65) {
tmp = lambda1 + atan2(t_0, ((1.0 + (-0.5 * pow(phi1, 2.0))) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(-lambda2)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
if (cos(phi2) <= 0.65d0) then
tmp = lambda1 + atan2(t_0, ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) + cos((lambda1 - lambda2))))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(-lambda2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.65) {
tmp = lambda1 + Math.atan2(t_0, ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(-lambda2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.65: tmp = lambda1 + math.atan2(t_0, ((1.0 + (-0.5 * math.pow(phi1, 2.0))) + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(-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.65) tmp = Float64(lambda1 + atan(t_0, Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + cos(Float64(lambda1 - lambda2))))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(-lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.65) tmp = lambda1 + atan2(t_0, ((1.0 + (-0.5 * (phi1 ^ 2.0))) + cos((lambda1 - lambda2)))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(-lambda2))); 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[N[Cos[phi2], $MachinePrecision], 0.65], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.65:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(-\lambda_2\right)}\\
\end{array}
if (cos.f64 phi2) < 0.650000000000000022Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6468.8
Applied rewrites68.8%
if 0.650000000000000022 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-neg.f6477.3
Applied rewrites77.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= (fabs phi2) 31000000000.0)
(+
lambda1
(atan2
(* (+ 1.0 (* -0.5 (pow (fabs phi2) 2.0))) t_0)
(+ (cos phi1) t_1)))
(+
lambda1
(atan2
(* (cos (fabs phi2)) t_0)
(+ (+ 1.0 (* -0.5 (pow phi1 2.0))) t_1))))))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 (fabs(phi2) <= 31000000000.0) {
tmp = lambda1 + atan2(((1.0 + (-0.5 * pow(fabs(phi2), 2.0))) * t_0), (cos(phi1) + t_1));
} else {
tmp = lambda1 + atan2((cos(fabs(phi2)) * t_0), ((1.0 + (-0.5 * pow(phi1, 2.0))) + t_1));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = cos((lambda1 - lambda2))
if (abs(phi2) <= 31000000000.0d0) then
tmp = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (abs(phi2) ** 2.0d0))) * t_0), (cos(phi1) + t_1))
else
tmp = lambda1 + atan2((cos(abs(phi2)) * t_0), ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) + t_1))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (Math.abs(phi2) <= 31000000000.0) {
tmp = lambda1 + Math.atan2(((1.0 + (-0.5 * Math.pow(Math.abs(phi2), 2.0))) * t_0), (Math.cos(phi1) + t_1));
} else {
tmp = lambda1 + Math.atan2((Math.cos(Math.abs(phi2)) * t_0), ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) + t_1));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if math.fabs(phi2) <= 31000000000.0: tmp = lambda1 + math.atan2(((1.0 + (-0.5 * math.pow(math.fabs(phi2), 2.0))) * t_0), (math.cos(phi1) + t_1)) else: tmp = lambda1 + math.atan2((math.cos(math.fabs(phi2)) * t_0), ((1.0 + (-0.5 * math.pow(phi1, 2.0))) + t_1)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (abs(phi2) <= 31000000000.0) tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * (abs(phi2) ^ 2.0))) * t_0), Float64(cos(phi1) + t_1))); else tmp = Float64(lambda1 + atan(Float64(cos(abs(phi2)) * t_0), Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (abs(phi2) <= 31000000000.0) tmp = lambda1 + atan2(((1.0 + (-0.5 * (abs(phi2) ^ 2.0))) * t_0), (cos(phi1) + t_1)); else tmp = lambda1 + atan2((cos(abs(phi2)) * t_0), ((1.0 + (-0.5 * (phi1 ^ 2.0))) + t_1)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[phi2], $MachinePrecision], 31000000000.0], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[Power[N[Abs[phi2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[N[Abs[phi2], $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\left|\phi_2\right| \leq 31000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot {\left(\left|\phi_2\right|\right)}^{2}\right) \cdot t\_0}{\cos \phi_1 + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \left(\left|\phi_2\right|\right) \cdot t\_0}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + t\_1}\\
\end{array}
if phi2 < 3.1e10Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6474.9
Applied rewrites74.9%
if 3.1e10 < phi2 Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6468.8
Applied rewrites68.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (fma (* (fabs phi2) (fabs phi2)) -0.5 1.0)))
(if (<= (fabs phi2) 3.1)
(+
(atan2 (* t_1 t_0) (fma t_1 (cos (- lambda2 lambda1)) (cos phi1)))
lambda1)
(+
lambda1
(atan2
(* (cos (fabs phi2)) t_0)
(+ (+ 1.0 (* -0.5 (pow phi1 2.0))) (cos (- lambda1 lambda2))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = fma((fabs(phi2) * fabs(phi2)), -0.5, 1.0);
double tmp;
if (fabs(phi2) <= 3.1) {
tmp = atan2((t_1 * t_0), fma(t_1, cos((lambda2 - lambda1)), cos(phi1))) + lambda1;
} else {
tmp = lambda1 + atan2((cos(fabs(phi2)) * t_0), ((1.0 + (-0.5 * pow(phi1, 2.0))) + cos((lambda1 - lambda2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = fma(Float64(abs(phi2) * abs(phi2)), -0.5, 1.0) tmp = 0.0 if (abs(phi2) <= 3.1) tmp = Float64(atan(Float64(t_1 * t_0), fma(t_1, cos(Float64(lambda2 - lambda1)), cos(phi1))) + lambda1); else tmp = Float64(lambda1 + atan(Float64(cos(abs(phi2)) * t_0), Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + 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[(N[Abs[phi2], $MachinePrecision] * N[Abs[phi2], $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[N[Abs[phi2], $MachinePrecision], 3.1], N[(N[ArcTan[N[(t$95$1 * t$95$0), $MachinePrecision] / N[(t$95$1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[N[Abs[phi2], $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \mathsf{fma}\left(\left|\phi_2\right| \cdot \left|\phi_2\right|, -0.5, 1\right)\\
\mathbf{if}\;\left|\phi_2\right| \leq 3.1:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot t\_0}{\mathsf{fma}\left(t\_1, \cos \left(\lambda_2 - \lambda_1\right), \cos \phi_1\right)} + \lambda_1\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \left(\left|\phi_2\right|\right) \cdot t\_0}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
if phi2 < 3.10000000000000009Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sub-negate-revN/A
sin-negN/A
sub-negate-revN/A
lift--.f64N/A
sin-+PI-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower-PI.f6453.5
Applied rewrites53.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6451.8
Applied rewrites51.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6452.4
Applied rewrites52.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6452.4
Applied rewrites75.9%
if 3.10000000000000009 < phi2 Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6468.8
Applied rewrites68.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (cos (- lambda2 lambda1)))
(t_2 (fma (* (fabs phi2) (fabs phi2)) -0.5 1.0)))
(if (<= (fabs phi2) 7.6e+48)
(+ (atan2 (* t_2 t_0) (fma t_2 t_1 (cos phi1))) lambda1)
(+ (atan2 (* t_0 (cos (fabs phi2))) (- t_1 -1.0)) lambda1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda2 - lambda1));
double t_2 = fma((fabs(phi2) * fabs(phi2)), -0.5, 1.0);
double tmp;
if (fabs(phi2) <= 7.6e+48) {
tmp = atan2((t_2 * t_0), fma(t_2, t_1, cos(phi1))) + lambda1;
} else {
tmp = atan2((t_0 * cos(fabs(phi2))), (t_1 - -1.0)) + lambda1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda2 - lambda1)) t_2 = fma(Float64(abs(phi2) * abs(phi2)), -0.5, 1.0) tmp = 0.0 if (abs(phi2) <= 7.6e+48) tmp = Float64(atan(Float64(t_2 * t_0), fma(t_2, t_1, cos(phi1))) + lambda1); else tmp = Float64(atan(Float64(t_0 * cos(abs(phi2))), Float64(t_1 - -1.0)) + lambda1); 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[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Abs[phi2], $MachinePrecision] * N[Abs[phi2], $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[N[Abs[phi2], $MachinePrecision], 7.6e+48], N[(N[ArcTan[N[(t$95$2 * t$95$0), $MachinePrecision] / N[(t$95$2 * t$95$1 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision], N[(N[ArcTan[N[(t$95$0 * N[Cos[N[Abs[phi2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - -1.0), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_2 := \mathsf{fma}\left(\left|\phi_2\right| \cdot \left|\phi_2\right|, -0.5, 1\right)\\
\mathbf{if}\;\left|\phi_2\right| \leq 7.6 \cdot 10^{+48}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot t\_0}{\mathsf{fma}\left(t\_2, t\_1, \cos \phi_1\right)} + \lambda_1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \left(\left|\phi_2\right|\right)}{t\_1 - -1} + \lambda_1\\
\end{array}
if phi2 < 7.60000000000000001e48Initial program 98.6%
lift-sin.f64N/A
lift--.f64N/A
sub-negate-revN/A
sin-negN/A
sub-negate-revN/A
lift--.f64N/A
sin-+PI-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower-PI.f6453.5
Applied rewrites53.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6451.8
Applied rewrites51.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6452.4
Applied rewrites52.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6452.4
Applied rewrites75.9%
if 7.60000000000000001e48 < phi2 Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6467.3
Applied rewrites67.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (cos (- lambda2 lambda1)) -1.0)) lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), (cos((lambda2 - lambda1)) - -1.0)) + 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 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (cos((lambda2 - lambda1)) - (-1.0d0))) + lambda1
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.cos((lambda2 - lambda1)) - -1.0)) + lambda1;
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.cos((lambda2 - lambda1)) - -1.0)) + lambda1
function code(lambda1, lambda2, phi1, phi2) return Float64(atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(cos(Float64(lambda2 - lambda1)) - -1.0)) + lambda1) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (cos((lambda2 - lambda1)) - -1.0)) + lambda1; end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \left(\lambda_2 - \lambda_1\right) - -1} + \lambda_1
Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6467.3
Applied rewrites67.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= (fabs phi2) 1.15e-15)
(+
(atan2
(* (sin (- lambda1 lambda2)) (fma (* (fabs phi2) (fabs phi2)) -0.5 1.0))
(- (cos (- lambda2 lambda1)) -1.0))
lambda1)
(+
lambda1
(atan2
(* (cos (fabs phi2)) (sin (- lambda2)))
(+ 1.0 (cos (- lambda1 lambda2)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (fabs(phi2) <= 1.15e-15) {
tmp = atan2((sin((lambda1 - lambda2)) * fma((fabs(phi2) * fabs(phi2)), -0.5, 1.0)), (cos((lambda2 - lambda1)) - -1.0)) + lambda1;
} else {
tmp = lambda1 + atan2((cos(fabs(phi2)) * sin(-lambda2)), (1.0 + cos((lambda1 - lambda2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (abs(phi2) <= 1.15e-15) tmp = Float64(atan(Float64(sin(Float64(lambda1 - lambda2)) * fma(Float64(abs(phi2) * abs(phi2)), -0.5, 1.0)), Float64(cos(Float64(lambda2 - lambda1)) - -1.0)) + lambda1); else tmp = Float64(lambda1 + atan(Float64(cos(abs(phi2)) * sin(Float64(-lambda2))), Float64(1.0 + cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[Abs[phi2], $MachinePrecision], 1.15e-15], N[(N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Abs[phi2], $MachinePrecision] * N[Abs[phi2], $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[N[Abs[phi2], $MachinePrecision]], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\phi_2\right| \leq 1.15 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\left|\phi_2\right| \cdot \left|\phi_2\right|, -0.5, 1\right)}{\cos \left(\lambda_2 - \lambda_1\right) - -1} + \lambda_1\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \left(\left|\phi_2\right|\right) \cdot \sin \left(-\lambda_2\right)}{1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
if phi2 < 1.14999999999999995e-15Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.8
Applied rewrites64.8%
if 1.14999999999999995e-15 < phi2 Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6464.1
Applied rewrites64.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (fabs phi2) 1.2)
(+
(atan2
(* t_0 (fma (* (fabs phi2) (fabs phi2)) -0.5 1.0))
(- (cos (- lambda2 lambda1)) -1.0))
lambda1)
(+ lambda1 (atan2 (* (cos (fabs phi2)) t_0) (+ 1.0 (cos lambda1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (fabs(phi2) <= 1.2) {
tmp = atan2((t_0 * fma((fabs(phi2) * fabs(phi2)), -0.5, 1.0)), (cos((lambda2 - lambda1)) - -1.0)) + lambda1;
} else {
tmp = lambda1 + atan2((cos(fabs(phi2)) * t_0), (1.0 + cos(lambda1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (abs(phi2) <= 1.2) tmp = Float64(atan(Float64(t_0 * fma(Float64(abs(phi2) * abs(phi2)), -0.5, 1.0)), Float64(cos(Float64(lambda2 - lambda1)) - -1.0)) + lambda1); else tmp = Float64(lambda1 + atan(Float64(cos(abs(phi2)) * t_0), Float64(1.0 + cos(lambda1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[phi2], $MachinePrecision], 1.2], N[(N[ArcTan[N[(t$95$0 * N[(N[(N[Abs[phi2], $MachinePrecision] * N[Abs[phi2], $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[N[Abs[phi2], $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\left|\phi_2\right| \leq 1.2:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\left|\phi_2\right| \cdot \left|\phi_2\right|, -0.5, 1\right)}{\cos \left(\lambda_2 - \lambda_1\right) - -1} + \lambda_1\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \left(\left|\phi_2\right|\right) \cdot t\_0}{1 + \cos \lambda_1}\\
\end{array}
if phi2 < 1.19999999999999996Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.8
Applied rewrites64.8%
if 1.19999999999999996 < phi2 Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-cos.f6462.0
Applied rewrites62.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ (atan2 (* (sin (- lambda1 lambda2)) (fma (* phi2 phi2) -0.5 1.0)) (- (cos (- lambda2 lambda1)) -1.0)) lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * fma((phi2 * phi2), -0.5, 1.0)), (cos((lambda2 - lambda1)) - -1.0)) + lambda1;
}
function code(lambda1, lambda2, phi1, phi2) return Float64(atan(Float64(sin(Float64(lambda1 - lambda2)) * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(cos(Float64(lambda2 - lambda1)) - -1.0)) + lambda1) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \left(\lambda_2 - \lambda_1\right) - -1} + \lambda_1
Initial program 98.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6467.3
Applied rewrites67.3%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6464.8
Applied rewrites64.8%
herbie shell --seed 2025168
(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)))))))