
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Herbie found 22 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\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.7%
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.7
Applied rewrites98.7%
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.6
Applied rewrites99.6%
(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.7%
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.7
Applied rewrites98.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
lambda1
(atan2
(* (cos phi2) (- (sin lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))))
(if (<= lambda2 -5e-7)
t_0
(if (<= lambda2 2e-38)
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma (cos lambda1) (cos phi2) (cos phi1))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + atan2((cos(phi2) * -sin(lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
double tmp;
if (lambda2 <= -5e-7) {
tmp = t_0;
} else if (lambda2 <= 2e-38) {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(-sin(lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) tmp = 0.0 if (lambda2 <= -5e-7) tmp = t_0; elseif (lambda2 <= 2e-38) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -5e-7], t$95$0, If[LessEqual[lambda2, 2e-38], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -5 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -4.99999999999999977e-7 or 1.9999999999999999e-38 < lambda2 Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lift-cos.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6488.3
Applied rewrites88.3%
if -4.99999999999999977e-7 < lambda2 < 1.9999999999999999e-38Initial program 98.7%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6479.7
Applied rewrites79.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos (- lambda1 lambda2))))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (+ lambda1 (atan2 t_1 (+ (cos phi1) (cos phi2)))))
(t_3 (+ lambda1 (atan2 t_1 (+ (cos phi1) t_0))))
(t_4
(atan2
(* (sin (- lambda2)) (cos phi2))
(fma (cos (- lambda2)) (cos phi2) (cos phi1)))))
(if (<= t_3 -3.14)
t_2
(if (<= t_3 -0.02)
t_4
(if (<= t_3 2e-19)
t_2
(if (<= t_3 3.1)
t_4
(+ lambda1 (atan2 t_1 (+ (fma (* phi1 phi1) -0.5 1.0) t_0)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * cos((lambda1 - lambda2));
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double t_2 = lambda1 + atan2(t_1, (cos(phi1) + cos(phi2)));
double t_3 = lambda1 + atan2(t_1, (cos(phi1) + t_0));
double t_4 = atan2((sin(-lambda2) * cos(phi2)), fma(cos(-lambda2), cos(phi2), cos(phi1)));
double tmp;
if (t_3 <= -3.14) {
tmp = t_2;
} else if (t_3 <= -0.02) {
tmp = t_4;
} else if (t_3 <= 2e-19) {
tmp = t_2;
} else if (t_3 <= 3.1) {
tmp = t_4;
} else {
tmp = lambda1 + atan2(t_1, (fma((phi1 * phi1), -0.5, 1.0) + t_0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + cos(phi2)))) t_3 = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))) t_4 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), fma(cos(Float64(-lambda2)), cos(phi2), cos(phi1))) tmp = 0.0 if (t_3 <= -3.14) tmp = t_2; elseif (t_3 <= -0.02) tmp = t_4; elseif (t_3 <= 2e-19) tmp = t_2; elseif (t_3 <= 3.1) tmp = t_4; else tmp = Float64(lambda1 + atan(t_1, Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) + t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$3, -3.14], t$95$2, If[LessEqual[t$95$3, -0.02], t$95$4, If[LessEqual[t$95$3, 2e-19], t$95$2, If[LessEqual[t$95$3, 3.1], t$95$4, N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2}\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
t_4 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \left(-\lambda_2\right), \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{if}\;t\_3 \leq -3.14:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq -0.02:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-19}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 3.1:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) + 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.14000000000000012 or -0.0200000000000000004 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 2e-19Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.1
Applied rewrites79.1%
if -3.14000000000000012 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0200000000000000004 or 2e-19 < (+.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.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-cos.f6441.4
Applied rewrites41.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6439.2
Applied rewrites39.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6439.2
Applied rewrites39.2%
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 98.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.7
Applied rewrites79.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
lambda1
(atan2
(* (cos phi2) (- (sin lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))))
(if (<= lambda2 -5e-7)
t_0
(if (<= lambda2 2e-38)
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+ (cos phi1) (cos phi2))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + atan2((cos(phi2) * -sin(lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
double tmp;
if (lambda2 <= -5e-7) {
tmp = t_0;
} else if (lambda2 <= 2e-38) {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + cos(phi2)));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(-sin(lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) tmp = 0.0 if (lambda2 <= -5e-7) tmp = t_0; elseif (lambda2 <= 2e-38) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + cos(phi2)))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -5e-7], t$95$0, If[LessEqual[lambda2, 2e-38], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -5 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 2 \cdot 10^{-38}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -4.99999999999999977e-7 or 1.9999999999999999e-38 < lambda2 Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lift-cos.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6488.3
Applied rewrites88.3%
if -4.99999999999999977e-7 < lambda2 < 1.9999999999999999e-38Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.1
Applied rewrites79.1%
(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.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(- (* (* phi2 phi2) 0.041666666666666664) 0.5)
(* phi2 phi2)
1.0))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (* (cos phi2) t_2)))
(if (<= (cos phi2) -0.59)
(+
lambda1
(atan2 t_3 (+ (fma (* phi1 phi1) -0.5 1.0) (* (cos phi2) t_1))))
(if (<= (cos phi2) 0.999)
(+ lambda1 (atan2 t_3 (+ (cos phi1) (cos phi2))))
(+ lambda1 (atan2 (* t_0 t_2) (+ (cos phi1) (* t_0 t_1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((((phi2 * phi2) * 0.041666666666666664) - 0.5), (phi2 * phi2), 1.0);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2));
double t_3 = cos(phi2) * t_2;
double tmp;
if (cos(phi2) <= -0.59) {
tmp = lambda1 + atan2(t_3, (fma((phi1 * phi1), -0.5, 1.0) + (cos(phi2) * t_1)));
} else if (cos(phi2) <= 0.999) {
tmp = lambda1 + atan2(t_3, (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2((t_0 * t_2), (cos(phi1) + (t_0 * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(Float64(Float64(phi2 * phi2) * 0.041666666666666664) - 0.5), Float64(phi2 * phi2), 1.0) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = Float64(cos(phi2) * t_2) tmp = 0.0 if (cos(phi2) <= -0.59) tmp = Float64(lambda1 + atan(t_3, Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) + Float64(cos(phi2) * t_1)))); elseif (cos(phi2) <= 0.999) tmp = Float64(lambda1 + atan(t_3, Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(Float64(t_0 * t_2), Float64(cos(phi1) + Float64(t_0 * t_1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], -0.59], N[(lambda1 + N[ArcTan[t$95$3 / N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.999], N[(lambda1 + N[ArcTan[t$95$3 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(t$95$0 * t$95$2), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.041666666666666664 - 0.5, \phi_2 \cdot \phi_2, 1\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \cos \phi_2 \cdot t\_2\\
\mathbf{if}\;\cos \phi_2 \leq -0.59:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) + \cos \phi_2 \cdot t\_1}\\
\mathbf{elif}\;\cos \phi_2 \leq 0.999:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot t\_2}{\cos \phi_1 + t\_0 \cdot t\_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.589999999999999969Initial program 98.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.7
Applied rewrites79.7%
if -0.589999999999999969 < (cos.f64 phi2) < 0.998999999999999999Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.1
Applied rewrites79.1%
if 0.998999999999999999 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.8
Applied rewrites75.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi1) 0.995)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2))))
(+ lambda1 (atan2 t_0 (fma (cos (- lambda1 lambda2)) (cos phi2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.995) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2(t_0, fma(cos((lambda1 - lambda2)), cos(phi2), 1.0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi1) <= 0.995) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(t_0, fma(cos(Float64(lambda1 - lambda2)), cos(phi2), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.995], 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), \cos \phi_2, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.994999999999999996Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.1
Applied rewrites79.1%
if 0.994999999999999996 < (cos.f64 phi1) Initial program 98.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6478.1
Applied rewrites78.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (fma (* phi2 phi2) -0.5 1.0)))
(if (<= phi2 5.2e-5)
(+
lambda1
(atan2 (* t_1 t_0) (+ (cos phi1) (* t_1 (cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi1) (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = fma((phi2 * phi2), -0.5, 1.0);
double tmp;
if (phi2 <= 5.2e-5) {
tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = fma(Float64(phi2 * phi2), -0.5, 1.0) tmp = 0.0 if (phi2 <= 5.2e-5) tmp = Float64(lambda1 + atan(Float64(t_1 * t_0), Float64(cos(phi1) + Float64(t_1 * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi1) + cos(phi2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[phi2, 5.2e-5], N[(lambda1 + N[ArcTan[N[(t$95$1 * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\mathbf{if}\;\phi_2 \leq 5.2 \cdot 10^{-5}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot t\_0}{\cos \phi_1 + t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 + \cos \phi_2}\\
\end{array}
\end{array}
if phi2 < 5.19999999999999968e-5Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
if 5.19999999999999968e-5 < phi2 Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.1
Applied rewrites79.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos lambda2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(lambda2) + 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((cos(phi2) * sin((lambda1 - lambda2))), (cos(lambda2) + cos(phi1)))
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(lambda2) + Math.cos(phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(lambda2) + math.cos(phi1)))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(lambda2) + cos(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(lambda2) + 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[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}
\end{array}
Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6477.9
Applied rewrites77.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (* phi2 phi2) -0.5 1.0)))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(+ (cos phi1) (* t_0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((phi2 * phi2), -0.5, 1.0);
return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), (cos(phi1) + (t_0 * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0) return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.5 (* phi2 phi2)))))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(fma (cos lambda2) t_0 (cos phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + (-0.5 * (phi2 * phi2));
return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), fma(cos(lambda2), t_0, cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), fma(cos(lambda2), t_0, cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * t$95$0 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, t\_0, \cos \phi_1\right)}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6475.6
Applied rewrites75.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6476.2
Applied rewrites76.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (* phi2 phi2) -0.5 1.0)))
(if (<= (cos phi1) 0.94)
(+
lambda1
(atan2
(* t_0 (sin (- lambda2)))
(+ (cos phi1) (* t_0 (cos (- lambda2))))))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(+
(+
1.0
(*
(-
(*
(- 0.041666666666666664 (* 0.001388888888888889 (* phi1 phi1)))
(* phi1 phi1))
0.5)
(* phi1 phi1)))
(* t_0 (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((phi2 * phi2), -0.5, 1.0);
double tmp;
if (cos(phi1) <= 0.94) {
tmp = lambda1 + atan2((t_0 * sin(-lambda2)), (cos(phi1) + (t_0 * cos(-lambda2))));
} else {
tmp = lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0 + ((((0.041666666666666664 - (0.001388888888888889 * (phi1 * phi1))) * (phi1 * phi1)) - 0.5) * (phi1 * phi1))) + (t_0 * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0) tmp = 0.0 if (cos(phi1) <= 0.94) tmp = Float64(lambda1 + atan(Float64(t_0 * sin(Float64(-lambda2))), Float64(cos(phi1) + Float64(t_0 * cos(Float64(-lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.041666666666666664 - Float64(0.001388888888888889 * Float64(phi1 * phi1))) * Float64(phi1 * phi1)) - 0.5) * Float64(phi1 * phi1))) + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.94], N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(N[(N[(N[(0.041666666666666664 - N[(0.001388888888888889 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.94:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(-\lambda_2\right)}{\cos \phi_1 + t\_0 \cdot \cos \left(-\lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(1 + \left(\left(0.041666666666666664 - 0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) \cdot \left(\phi_1 \cdot \phi_1\right) - 0.5\right) \cdot \left(\phi_1 \cdot \phi_1\right)\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.93999999999999995Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6471.2
Applied rewrites71.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6471.2
Applied rewrites71.2%
if 0.93999999999999995 < (cos.f64 phi1) Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6463.2
Applied rewrites63.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (* phi2 phi2) -0.5 1.0)))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(+ (- 1.0 (* 0.5 (* phi1 phi1))) (* t_0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((phi2 * phi2), -0.5, 1.0);
return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0) return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(Float64(1.0 - Float64(0.5 * Float64(phi1 * phi1))) + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[(0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(1 - 0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (fma (* phi2 phi2) -0.5 1.0) (sin (- lambda1 lambda2)))
(+
(- 1.0 (* 0.5 (* phi1 phi1)))
(* (fma (exp (* (log phi2) 2.0)) -0.5 1.0) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((fma((phi2 * phi2), -0.5, 1.0) * sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (fma(exp((log(phi2) * 2.0)), -0.5, 1.0) * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * sin(Float64(lambda1 - lambda2))), Float64(Float64(1.0 - Float64(0.5 * Float64(phi1 * phi1))) + Float64(fma(exp(Float64(log(phi2) * 2.0)), -0.5, 1.0) * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[(0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Exp[N[(N[Log[phi2], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(1 - 0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + \mathsf{fma}\left(e^{\log \phi_2 \cdot 2}, -0.5, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
lift-*.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6431.0
Applied rewrites31.0%
lift-*.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6431.0
Applied rewrites31.0%
lift-exp.f64N/A
lift-*.f64N/A
lift-log.f64N/A
pow-to-expN/A
pow2N/A
lift-*.f6431.0
Applied rewrites31.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- 1.0 (* 0.5 (* phi1 phi1))))
(t_2 (fma (* phi2 phi2) -0.5 1.0))
(t_3 (* -0.5 (* phi2 phi2)))
(t_4 (+ 1.0 t_3))
(t_5 (sin (- lambda1 lambda2))))
(if (<= lambda1 -6.8e-6)
(+ lambda1 (atan2 (* t_3 t_5) (+ t_1 (* t_3 (cos lambda2)))))
(if (<= lambda1 4.45e-13)
(atan2 (* t_5 t_4) (fma t_0 t_4 t_1))
(+
lambda1
(atan2 (* t_2 t_5) (+ (* -0.5 (* phi1 phi1)) (* t_2 t_0))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = 1.0 - (0.5 * (phi1 * phi1));
double t_2 = fma((phi2 * phi2), -0.5, 1.0);
double t_3 = -0.5 * (phi2 * phi2);
double t_4 = 1.0 + t_3;
double t_5 = sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -6.8e-6) {
tmp = lambda1 + atan2((t_3 * t_5), (t_1 + (t_3 * cos(lambda2))));
} else if (lambda1 <= 4.45e-13) {
tmp = atan2((t_5 * t_4), fma(t_0, t_4, t_1));
} else {
tmp = lambda1 + atan2((t_2 * t_5), ((-0.5 * (phi1 * phi1)) + (t_2 * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(1.0 - Float64(0.5 * Float64(phi1 * phi1))) t_2 = fma(Float64(phi2 * phi2), -0.5, 1.0) t_3 = Float64(-0.5 * Float64(phi2 * phi2)) t_4 = Float64(1.0 + t_3) t_5 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (lambda1 <= -6.8e-6) tmp = Float64(lambda1 + atan(Float64(t_3 * t_5), Float64(t_1 + Float64(t_3 * cos(lambda2))))); elseif (lambda1 <= 4.45e-13) tmp = atan(Float64(t_5 * t_4), fma(t_0, t_4, t_1)); else tmp = Float64(lambda1 + atan(Float64(t_2 * t_5), Float64(Float64(-0.5 * Float64(phi1 * phi1)) + Float64(t_2 * 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[(1.0 - N[(0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 + t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -6.8e-6], N[(lambda1 + N[ArcTan[N[(t$95$3 * t$95$5), $MachinePrecision] / N[(t$95$1 + N[(t$95$3 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 4.45e-13], N[ArcTan[N[(t$95$5 * t$95$4), $MachinePrecision] / N[(t$95$0 * t$95$4 + t$95$1), $MachinePrecision]], $MachinePrecision], N[(lambda1 + N[ArcTan[N[(t$95$2 * t$95$5), $MachinePrecision] / N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := 1 - 0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\\
t_2 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
t_3 := -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\\
t_4 := 1 + t\_3\\
t_5 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -6.8 \cdot 10^{-6}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3 \cdot t\_5}{t\_1 + t\_3 \cdot \cos \lambda_2}\\
\mathbf{elif}\;\lambda_1 \leq 4.45 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_5 \cdot t\_4}{\mathsf{fma}\left(t\_0, t\_4, t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2 \cdot t\_5}{-0.5 \cdot \left(\phi_1 \cdot \phi_1\right) + t\_2 \cdot t\_0}\\
\end{array}
\end{array}
if lambda1 < -6.80000000000000012e-6Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6452.4
Applied rewrites52.4%
if -6.80000000000000012e-6 < lambda1 < 4.4500000000000002e-13Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-cos.f6441.4
Applied rewrites41.4%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6426.5
Applied rewrites26.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6415.3
Applied rewrites15.3%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6415.3
Applied rewrites15.3%
if 4.4500000000000002e-13 < lambda1 Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in phi1 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6454.5
Applied rewrites54.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (* phi2 phi2) -0.5 1.0)))
(+
lambda1
(atan2
(* t_0 (- (sin lambda2)))
(+ (- 1.0 (* 0.5 (* phi1 phi1))) (* t_0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((phi2 * phi2), -0.5, 1.0);
return lambda1 + atan2((t_0 * -sin(lambda2)), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0) return Float64(lambda1 + atan(Float64(t_0 * Float64(-sin(lambda2))), Float64(Float64(1.0 - Float64(0.5 * Float64(phi1 * phi1))) + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[(1.0 - N[(0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \left(-\sin \lambda_2\right)}{\left(1 - 0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6461.2
Applied rewrites61.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (* phi2 phi2) -0.5 1.0)))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(+ (* -0.5 (* phi1 phi1)) (* t_0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((phi2 * phi2), -0.5, 1.0);
return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((-0.5 * (phi1 * phi1)) + (t_0 * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0) return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(Float64(-0.5 * Float64(phi1 * phi1)) + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{-0.5 \cdot \left(\phi_1 \cdot \phi_1\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in phi1 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6454.5
Applied rewrites54.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* -0.5 (* phi2 phi2))))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(+ (- 1.0 (* 0.5 (* phi1 phi1))) (* t_0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -0.5 * (phi2 * phi2);
return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (-0.5d0) * (phi2 * phi2)
code = lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0d0 - (0.5d0 * (phi1 * phi1))) + (t_0 * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -0.5 * (phi2 * phi2);
return lambda1 + Math.atan2((t_0 * Math.sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = -0.5 * (phi2 * phi2) return lambda1 + math.atan2((t_0 * math.sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-0.5 * Float64(phi2 * phi2)) return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(Float64(1.0 - Float64(0.5 * Float64(phi1 * phi1))) + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = -0.5 * (phi2 * phi2); tmp = lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[(0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(1 - 0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* -0.5 (* phi2 phi2))))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(+ (- 1.0 (* 0.5 (* phi1 phi1))) (* t_0 (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -0.5 * (phi2 * phi2);
return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * cos(lambda2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (-0.5d0) * (phi2 * phi2)
code = lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0d0 - (0.5d0 * (phi1 * phi1))) + (t_0 * cos(lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -0.5 * (phi2 * phi2);
return lambda1 + Math.atan2((t_0 * Math.sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * Math.cos(lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = -0.5 * (phi2 * phi2) return lambda1 + math.atan2((t_0 * math.sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * math.cos(lambda2))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-0.5 * Float64(phi2 * phi2)) return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(Float64(1.0 - Float64(0.5 * Float64(phi1 * phi1))) + Float64(t_0 * cos(lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = -0.5 * (phi2 * phi2); tmp = lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((1.0 - (0.5 * (phi1 * phi1))) + (t_0 * cos(lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[(0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(1 - 0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + t\_0 \cdot \cos \lambda_2}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6452.4
Applied rewrites52.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* -0.5 (* phi2 phi2))))
(+
lambda1
(atan2
(* t_0 (sin (- lambda1 lambda2)))
(+ (* -0.5 (* phi1 phi1)) (* t_0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -0.5 * (phi2 * phi2);
return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((-0.5 * (phi1 * phi1)) + (t_0 * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (-0.5d0) * (phi2 * phi2)
code = lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), (((-0.5d0) * (phi1 * phi1)) + (t_0 * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -0.5 * (phi2 * phi2);
return lambda1 + Math.atan2((t_0 * Math.sin((lambda1 - lambda2))), ((-0.5 * (phi1 * phi1)) + (t_0 * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = -0.5 * (phi2 * phi2) return lambda1 + math.atan2((t_0 * math.sin((lambda1 - lambda2))), ((-0.5 * (phi1 * phi1)) + (t_0 * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-0.5 * Float64(phi2 * phi2)) return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(Float64(-0.5 * Float64(phi1 * phi1)) + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = -0.5 * (phi2 * phi2); tmp = lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), ((-0.5 * (phi1 * phi1)) + (t_0 * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{-0.5 \cdot \left(\phi_1 \cdot \phi_1\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.5%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in phi2 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in phi1 around inf
lower-*.f64N/A
pow2N/A
lift-*.f6450.9
Applied rewrites50.9%
herbie shell --seed 2025139
(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)))))))