
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma
(cos lambda1)
(cos lambda2)
(*
(*
(fma
(-
(*
(fma
-0.0001984126984126984
(* lambda1 lambda1)
0.008333333333333333)
(* lambda1 lambda1))
0.16666666666666666)
(* lambda1 lambda1)
1.0)
lambda1)
(sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), ((fma(((fma(-0.0001984126984126984, (lambda1 * lambda1), 0.008333333333333333) * (lambda1 * lambda1)) - 0.16666666666666666), (lambda1 * lambda1), 1.0) * lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(Float64(fma(Float64(Float64(fma(-0.0001984126984126984, Float64(lambda1 * lambda1), 0.008333333333333333) * Float64(lambda1 * lambda1)) - 0.16666666666666666), Float64(lambda1 * lambda1), 1.0) * lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[(N[(N[(N[(N[(-0.0001984126984126984 * N[(lambda1 * lambda1), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(lambda1 * lambda1), $MachinePrecision] + 1.0), $MachinePrecision] * lambda1), $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, \lambda_1 \cdot \lambda_1, 0.008333333333333333\right) \cdot \left(\lambda_1 \cdot \lambda_1\right) - 0.16666666666666666, \lambda_1 \cdot \lambda_1, 1\right) \cdot \lambda_1\right) \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma
(cos lambda1)
(cos lambda2)
(*
(* (fma (* lambda1 lambda1) -0.16666666666666666 1.0) lambda1)
(sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), ((fma((lambda1 * lambda1), -0.16666666666666666, 1.0) * lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(Float64(fma(Float64(lambda1 * lambda1), -0.16666666666666666, 1.0) * lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[(N[(N[(lambda1 * lambda1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * lambda1), $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \left(\mathsf{fma}\left(\lambda_1 \cdot \lambda_1, -0.16666666666666666, 1\right) \cdot \lambda_1\right) \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6498.9
Applied rewrites98.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* lambda1 (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), (lambda1 * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(lambda1 * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in lambda1 around 0
Applied rewrites98.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<=
(+
lambda1
(atan2 (* (cos phi2) t_1) (+ (cos phi1) (* (cos phi2) t_0))))
-3.1)
(+ lambda1 (atan2 t_1 (+ (cos lambda1) (+ 1.0 (* -0.5 (* phi1 phi1))))))
(+ 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 = sin((lambda1 - lambda2));
double tmp;
if ((lambda1 + atan2((cos(phi2) * t_1), (cos(phi1) + (cos(phi2) * t_0)))) <= -3.1) {
tmp = lambda1 + atan2(t_1, (cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1)))));
} 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 = sin((lambda1 - lambda2))
if ((lambda1 + atan2((cos(phi2) * t_1), (cos(phi1) + (cos(phi2) * t_0)))) <= (-3.1d0)) then
tmp = lambda1 + atan2(t_1, (cos(lambda1) + (1.0d0 + ((-0.5d0) * (phi1 * phi1)))))
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.sin((lambda1 - lambda2));
double tmp;
if ((lambda1 + Math.atan2((Math.cos(phi2) * t_1), (Math.cos(phi1) + (Math.cos(phi2) * t_0)))) <= -3.1) {
tmp = lambda1 + Math.atan2(t_1, (Math.cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1)))));
} 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.sin((lambda1 - lambda2)) tmp = 0 if (lambda1 + math.atan2((math.cos(phi2) * t_1), (math.cos(phi1) + (math.cos(phi2) * t_0)))) <= -3.1: tmp = lambda1 + math.atan2(t_1, (math.cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1))))) 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 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) <= -3.1) tmp = Float64(lambda1 + atan(t_1, Float64(cos(lambda1) + Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1)))))); 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 = sin((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 + atan2((cos(phi2) * t_1), (cos(phi1) + (cos(phi2) * t_0)))) <= -3.1) tmp = lambda1 + atan2(t_1, (cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1))))); 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -3.1], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[lambda1], $MachinePrecision] + N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0} \leq -3.1:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \lambda_1 + \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
\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.10000000000000009Initial program 98.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.5
Applied rewrites98.5%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6492.6
Applied rewrites92.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6486.1
Applied rewrites86.1%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6492.6
Applied rewrites92.6%
if -3.10000000000000009 < (+.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 97.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6497.9
Applied rewrites97.9%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6471.8
Applied rewrites71.8%
Taylor expanded in phi2 around 0
cos-diff-revN/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-diff-revN/A
lift-cos.f64N/A
Applied rewrites72.0%
Final simplification77.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<=
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
-1.95)
(+ lambda1 (atan2 t_0 (+ (cos lambda1) (+ 1.0 (* -0.5 (* phi1 phi1))))))
(+ lambda1 (atan2 t_0 (+ (cos lambda1) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))) <= -1.95) {
tmp = lambda1 + atan2(t_0, (cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1)))));
} else {
tmp = lambda1 + atan2(t_0, (cos(lambda1) + cos(phi1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))) <= (-1.95d0)) then
tmp = lambda1 + atan2(t_0, (cos(lambda1) + (1.0d0 + ((-0.5d0) * (phi1 * phi1)))))
else
tmp = lambda1 + atan2(t_0, (cos(lambda1) + cos(phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))))) <= -1.95) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1)))));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda1) + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) <= -1.95: tmp = lambda1 + math.atan2(t_0, (math.cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1))))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(lambda1) + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) <= -1.95) tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda1) + Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1)))))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda1) + cos(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))) <= -1.95) tmp = lambda1 + atan2(t_0, (cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1))))); else tmp = lambda1 + atan2(t_0, (cos(lambda1) + cos(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.95], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda1], $MachinePrecision] + N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda1], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \leq -1.95:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_1 + \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_1 + \cos \phi_1}\\
\end{array}
\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)))))) < -1.94999999999999996Initial program 99.0%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6490.6
Applied rewrites90.6%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6484.9
Applied rewrites84.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.0
Applied rewrites79.0%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.3
Applied rewrites85.3%
if -1.94999999999999996 < (+.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 97.8%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6472.0
Applied rewrites72.0%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6460.2
Applied rewrites60.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6460.2
Applied rewrites60.2%
Final simplification67.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<=
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
-1.95)
(+ lambda1 (atan2 t_0 (+ (cos lambda1) (+ 1.0 (* -0.5 (* phi1 phi1))))))
(+ lambda1 (atan2 t_0 (+ 1.0 (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))) <= -1.95) {
tmp = lambda1 + atan2(t_0, (cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1)))));
} else {
tmp = lambda1 + atan2(t_0, (1.0 + cos(phi1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))) <= (-1.95d0)) then
tmp = lambda1 + atan2(t_0, (cos(lambda1) + (1.0d0 + ((-0.5d0) * (phi1 * phi1)))))
else
tmp = lambda1 + atan2(t_0, (1.0d0 + cos(phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))))) <= -1.95) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1)))));
} else {
tmp = lambda1 + Math.atan2(t_0, (1.0 + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) <= -1.95: tmp = lambda1 + math.atan2(t_0, (math.cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1))))) else: tmp = lambda1 + math.atan2(t_0, (1.0 + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) <= -1.95) tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda1) + Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1)))))); else tmp = Float64(lambda1 + atan(t_0, Float64(1.0 + cos(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))) <= -1.95) tmp = lambda1 + atan2(t_0, (cos(lambda1) + (1.0 + (-0.5 * (phi1 * phi1))))); else tmp = lambda1 + atan2(t_0, (1.0 + cos(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1.95], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda1], $MachinePrecision] + N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(1.0 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \leq -1.95:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_1 + \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{1 + \cos \phi_1}\\
\end{array}
\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)))))) < -1.94999999999999996Initial program 99.0%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6490.6
Applied rewrites90.6%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6484.9
Applied rewrites84.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.0
Applied rewrites79.0%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.3
Applied rewrites85.3%
if -1.94999999999999996 < (+.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 97.8%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6472.0
Applied rewrites72.0%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6460.2
Applied rewrites60.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6460.2
Applied rewrites60.2%
Taylor expanded in lambda1 around 0
Applied rewrites59.9%
Final simplification67.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -195.0) (not (<= lambda2 5e-42)))
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma (cos lambda1) (cos phi2) (cos phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -195.0) || !(lambda2 <= 5e-42)) {
tmp = lambda1 + atan2((cos(phi2) * sin(-lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
} else {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -195.0) || !(lambda2 <= 5e-42)) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(-lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -195.0], N[Not[LessEqual[lambda2, 5e-42]], $MachinePrecision]], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -195 \lor \neg \left(\lambda_2 \leq 5 \cdot 10^{-42}\right):\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2, \cos \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -195 or 5.00000000000000003e-42 < lambda2 Initial program 97.0%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6496.6
Applied rewrites96.6%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6496.6
Applied rewrites96.6%
if -195 < lambda2 < 5.00000000000000003e-42Initial program 99.3%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6499.3
Applied rewrites99.3%
Final simplification97.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -195.0) (not (<= lambda2 5e-42)))
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+ (cos phi1) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -195.0) || !(lambda2 <= 5e-42)) {
tmp = lambda1 + atan2((cos(phi2) * sin(-lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
} else {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + cos(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -195.0) || !(lambda2 <= 5e-42)) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(-lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + cos(phi2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -195.0], N[Not[LessEqual[lambda2, 5e-42]], $MachinePrecision]], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -195 \lor \neg \left(\lambda_2 \leq 5 \cdot 10^{-42}\right):\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2}\\
\end{array}
\end{array}
if lambda2 < -195 or 5.00000000000000003e-42 < lambda2 Initial program 97.0%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6496.6
Applied rewrites96.6%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6496.6
Applied rewrites96.6%
if -195 < lambda2 < 5.00000000000000003e-42Initial program 99.3%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6499.3
Applied rewrites99.3%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6498.3
Applied rewrites98.3%
Final simplification97.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= (cos phi2) -0.03)
(+
lambda1
(atan2
(* (+ 1.0 (* -0.5 (* phi2 phi2))) t_0)
(+ 1.0 (* (cos phi2) t_1))))
(if (<= (cos phi2) 0.63)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) 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 (cos(phi2) <= -0.03) {
tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 * phi2))) * t_0), (1.0 + (cos(phi2) * t_1)));
} else if (cos(phi2) <= 0.63) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + 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 (cos(phi2) <= (-0.03d0)) then
tmp = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (phi2 * phi2))) * t_0), (1.0d0 + (cos(phi2) * t_1)))
else if (cos(phi2) <= 0.63d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + 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.cos(phi2) <= -0.03) {
tmp = lambda1 + Math.atan2(((1.0 + (-0.5 * (phi2 * phi2))) * t_0), (1.0 + (Math.cos(phi2) * t_1)));
} else if (Math.cos(phi2) <= 0.63) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + 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.cos(phi2) <= -0.03: tmp = lambda1 + math.atan2(((1.0 + (-0.5 * (phi2 * phi2))) * t_0), (1.0 + (math.cos(phi2) * t_1))) elif math.cos(phi2) <= 0.63: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(phi2))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + 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 (cos(phi2) <= -0.03) tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * t_0), Float64(1.0 + Float64(cos(phi2) * t_1)))); elseif (cos(phi2) <= 0.63) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + 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 (cos(phi2) <= -0.03) tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 * phi2))) * t_0), (1.0 + (cos(phi2) * t_1))); elseif (cos(phi2) <= 0.63) tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + 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[Cos[phi2], $MachinePrecision], -0.03], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.63], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq -0.03:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot t\_0}{1 + \cos \phi_2 \cdot t\_1}\\
\mathbf{elif}\;\cos \phi_2 \leq 0.63:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + t\_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.029999999999999999Initial program 98.1%
Taylor expanded in phi1 around 0
Applied rewrites75.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.2
Applied rewrites57.2%
if -0.029999999999999999 < (cos.f64 phi2) < 0.630000000000000004Initial program 97.8%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6481.0
Applied rewrites81.0%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6467.7
Applied rewrites67.7%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6467.7
Applied rewrites67.7%
if 0.630000000000000004 < (cos.f64 phi2) Initial program 98.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.3
Applied rewrites98.3%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6489.7
Applied rewrites89.7%
Taylor expanded in phi2 around 0
cos-diff-revN/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-diff-revN/A
lift-cos.f64N/A
Applied rewrites89.8%
Final simplification79.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi2) 0.9875)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.9875) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
if (cos(phi2) <= 0.9875d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.9875) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos((lambda1 - 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.9875: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(phi2))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos((lambda1 - lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi2) <= 0.9875) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - 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.9875) tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - 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.9875], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.9875:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.98750000000000004Initial program 97.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6478.5
Applied rewrites78.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.4
Applied rewrites78.4%
if 0.98750000000000004 < (cos.f64 phi2) Initial program 98.3%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6495.2
Applied rewrites95.2%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.9875)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi1) (cos phi2))))
(+
lambda1
(atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.9875) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi2) <= 0.9875d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.9875) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi1) + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.9875: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi1) + math.cos(phi2))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.9875) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.9875) tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.9875], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.9875:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.98750000000000004Initial program 97.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6478.5
Applied rewrites78.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.4
Applied rewrites78.4%
if 0.98750000000000004 < (cos.f64 phi2) Initial program 98.3%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6495.2
Applied rewrites95.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.9875)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi1) (cos phi2))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.9875) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi2) <= 0.9875d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.9875) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi1) + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.9875: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi1) + math.cos(phi2))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos((lambda1 - lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.9875) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.9875) tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.9875], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.9875:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.98750000000000004Initial program 97.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6478.5
Applied rewrites78.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.4
Applied rewrites78.4%
if 0.98750000000000004 < (cos.f64 phi2) Initial program 98.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.4
Applied rewrites98.4%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6495.3
Applied rewrites95.3%
Taylor expanded in phi2 around 0
cos-diff-revN/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-diff-revN/A
lift-cos.f64N/A
Applied rewrites95.2%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.01)
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 phi2))) (cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= -0.01) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * 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 = sin((lambda1 - lambda2))
if (cos(phi2) <= (-0.01d0)) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + ((1.0d0 + ((-0.5d0) * (phi2 * phi2))) * cos((lambda1 - lambda2)))))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= -0.01) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= -0.01: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * math.cos((lambda1 - lambda2))))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= -0.01) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= -0.01) tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * cos((lambda1 - lambda2))))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], -0.01], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq -0.01:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.0100000000000000002Initial program 98.2%
Taylor expanded in phi1 around 0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.3
Applied rewrites64.3%
if -0.0100000000000000002 < (cos.f64 phi2) Initial program 98.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6486.0
Applied rewrites86.0%
Taylor expanded in lambda1 around 0
cos-diff-revN/A
lift-cos.f6485.4
Applied rewrites85.4%
Final simplification80.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (fma (cos (- lambda1 lambda2)) (cos phi2) (cos phi1))) lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(cos((lambda1 - lambda2)), cos(phi2), cos(phi1))) + lambda1;
}
function code(lambda1, lambda2, phi1, phi2) return Float64(atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(cos(Float64(lambda1 - lambda2)), 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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), \cos \phi_2, \cos \phi_1\right)} + \lambda_1
\end{array}
Initial program 98.1%
lift-+.f64N/A
lift-atan2.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites98.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos lambda2) (cos phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}
\end{array}
Initial program 98.1%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.4
Applied rewrites97.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.63)
(+
lambda1
(atan2
(* (cos phi2) t_1)
(+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 phi2))) 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 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.63) {
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * 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 = sin((lambda1 - lambda2))
if (cos(phi2) <= 0.63d0) then
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0d0 + ((1.0d0 + ((-0.5d0) * (phi2 * phi2))) * 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.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.63) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_1), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * 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.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.63: tmp = lambda1 + math.atan2((math.cos(phi2) * t_1), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * 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 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.63) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * 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 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.63) tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.63], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.63:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.630000000000000004Initial program 98.0%
Taylor expanded in phi1 around 0
Applied rewrites73.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6463.7
Applied rewrites63.7%
if 0.630000000000000004 < (cos.f64 phi2) Initial program 98.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.3
Applied rewrites98.3%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6489.7
Applied rewrites89.7%
Taylor expanded in phi2 around 0
cos-diff-revN/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-diff-revN/A
lift-cos.f64N/A
Applied rewrites89.8%
Final simplification80.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi2 5.9e-8)
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0)))
(+
lambda1
(atan2
(* (cos phi2) t_1)
(+ (fma (* phi1 phi1) -0.5 1.0) (* (cos phi2) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 5.9e-8) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_1), (fma((phi1 * phi1), -0.5, 1.0) + (cos(phi2) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 5.9e-8) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) + Float64(cos(phi2) * t_0)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 5.9e-8], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 5.9 \cdot 10^{-8}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) + \cos \phi_2 \cdot t\_0}\\
\end{array}
\end{array}
if phi2 < 5.8999999999999999e-8Initial program 98.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.1
Applied rewrites98.1%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6484.7
Applied rewrites84.7%
Taylor expanded in phi2 around 0
cos-diff-revN/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-diff-revN/A
lift-cos.f64N/A
Applied rewrites83.7%
if 5.8999999999999999e-8 < phi2 Initial program 98.3%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.3
Applied rewrites79.3%
Final simplification82.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 0.0033)
(+ lambda1 (atan2 (* (cos phi2) t_1) (fma t_0 (cos phi2) 1.0)))
(+ lambda1 (atan2 t_1 (+ (cos phi1) (* (cos phi2) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 0.0033) {
tmp = lambda1 + atan2((cos(phi2) * t_1), fma(t_0, cos(phi2), 1.0));
} else {
tmp = lambda1 + atan2(t_1, (cos(phi1) + (cos(phi2) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= 0.0033) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), fma(t_0, cos(phi2), 1.0))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 0.0033], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 0.0033:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < 0.0033Initial program 98.4%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6480.5
Applied rewrites80.5%
if 0.0033 < phi1 Initial program 97.4%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.4
Applied rewrites77.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos phi1) (cos phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos(phi2)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos(phi2)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(phi1) + Math.cos(phi2)));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(phi1) + math.cos(phi2)))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + cos(phi2)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos(phi2))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2}
\end{array}
Initial program 98.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6477.7
Applied rewrites77.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6467.8
Applied rewrites67.8%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6467.4
Applied rewrites67.4%
Final simplification67.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ 1.0 (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (1.0 + cos(phi1)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2(sin((lambda1 - lambda2)), (1.0d0 + cos(phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (1.0 + Math.cos(phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (1.0 + math.cos(phi1)))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(1.0 + cos(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (1.0 + cos(phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(1.0 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \phi_1}
\end{array}
Initial program 98.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6477.7
Applied rewrites77.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6467.8
Applied rewrites67.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6466.0
Applied rewrites66.0%
Taylor expanded in lambda1 around 0
Applied rewrites65.6%
Final simplification65.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ 1.0 (cos lambda1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (1.0 + cos(lambda1)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2(sin((lambda1 - lambda2)), (1.0d0 + cos(lambda1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (1.0 + Math.cos(lambda1)));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (1.0 + math.cos(lambda1)))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(1.0 + cos(lambda1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (1.0 + cos(lambda1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(1.0 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \lambda_1}
\end{array}
Initial program 98.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6477.7
Applied rewrites77.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-sin.f64N/A
lift--.f6467.8
Applied rewrites67.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6466.0
Applied rewrites66.0%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f6458.3
Applied rewrites58.3%
Final simplification58.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 lambda1)
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1;
}
def code(lambda1, lambda2, phi1, phi2): return lambda1
function code(lambda1, lambda2, phi1, phi2) return lambda1 end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1; end
code[lambda1_, lambda2_, phi1_, phi2_] := lambda1
\begin{array}{l}
\\
\lambda_1
\end{array}
Initial program 98.1%
Taylor expanded in lambda1 around inf
Applied rewrites48.5%
herbie shell --seed 2025051
(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)))))))