
(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 32 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-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.8
Applied rewrites98.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (atan2 (* t_1 (cos phi2)) (fma t_0 (cos phi2) 1.0)))
(t_3 (* (cos phi2) t_1))
(t_4
(+
lambda1
(atan2 t_3 (+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 phi2))) t_0)))))
(t_5 (+ lambda1 (atan2 t_3 (+ (cos phi1) (* (cos phi2) t_0))))))
(if (<= t_5 -3.0)
t_4
(if (<= t_5 -0.5)
(atan2 (* (cos phi2) (- (sin lambda2))) (+ (cos phi1) t_0))
(if (<= t_5 -1e-55)
t_2
(if (<= t_5 1e-20)
(+
lambda1
(atan2
(* 1.0 t_1)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1)))))
(if (<= t_5 3.0) t_2 t_4)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double t_2 = atan2((t_1 * cos(phi2)), fma(t_0, cos(phi2), 1.0));
double t_3 = cos(phi2) * t_1;
double t_4 = lambda1 + atan2(t_3, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0)));
double t_5 = lambda1 + atan2(t_3, (cos(phi1) + (cos(phi2) * t_0)));
double tmp;
if (t_5 <= -3.0) {
tmp = t_4;
} else if (t_5 <= -0.5) {
tmp = atan2((cos(phi2) * -sin(lambda2)), (cos(phi1) + t_0));
} else if (t_5 <= -1e-55) {
tmp = t_2;
} else if (t_5 <= 1e-20) {
tmp = lambda1 + atan2((1.0 * t_1), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
} else if (t_5 <= 3.0) {
tmp = t_2;
} else {
tmp = t_4;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = atan(Float64(t_1 * cos(phi2)), fma(t_0, cos(phi2), 1.0)) t_3 = Float64(cos(phi2) * t_1) t_4 = Float64(lambda1 + atan(t_3, Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * t_0)))) t_5 = Float64(lambda1 + atan(t_3, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (t_5 <= -3.0) tmp = t_4; elseif (t_5 <= -0.5) tmp = atan(Float64(cos(phi2) * Float64(-sin(lambda2))), Float64(cos(phi1) + t_0)); elseif (t_5 <= -1e-55) tmp = t_2; elseif (t_5 <= 1e-20) tmp = Float64(lambda1 + atan(Float64(1.0 * t_1), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))); elseif (t_5 <= 3.0) tmp = t_2; else tmp = t_4; 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]}, Block[{t$95$2 = N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$3 / N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(lambda1 + N[ArcTan[t$95$3 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, -3.0], t$95$4, If[LessEqual[t$95$5, -0.5], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$5, -1e-55], t$95$2, If[LessEqual[t$95$5, 1e-20], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 3.0], t$95$2, t$95$4]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{\mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)}\\
t_3 := \cos \phi_2 \cdot t\_1\\
t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_3}{1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot t\_0}\\
t_5 := \lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;t\_5 \leq -3:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_5 \leq -0.5:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\cos \phi_1 + t\_0}\\
\mathbf{elif}\;t\_5 \leq -1 \cdot 10^{-55}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_5 \leq 10^{-20}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_1}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
\mathbf{elif}\;t\_5 \leq 3:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\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 or 3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) Initial program 99.1%
Taylor expanded in phi1 around 0
Applied rewrites92.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.9
Applied rewrites96.9%
if -3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.5Initial program 98.2%
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.f6497.7
Applied rewrites97.7%
Taylor expanded in phi2 around 0
Applied rewrites60.1%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6460.0
Applied rewrites60.0%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6464.2
Applied rewrites64.2%
if -0.5 < (+.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)))))) < -9.99999999999999995e-56 or 9.99999999999999945e-21 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 3Initial program 97.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.f6487.1
Applied rewrites87.1%
Taylor expanded in phi1 around 0
Applied rewrites57.2%
if -9.99999999999999995e-56 < (+.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)))))) < 9.99999999999999945e-21Initial program 99.0%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6499.0
Applied rewrites99.0%
Taylor expanded in phi2 around 0
Applied rewrites62.0%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6462.4
Applied rewrites62.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (+ (cos phi1) (* (cos phi2) t_0)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (+ lambda1 (atan2 (* (cos phi2) t_2) t_1)))
(t_4 (* t_2 (cos phi2)))
(t_5 (+ phi2 (/ PI 2.0))))
(if (<= t_3 -400000.0)
(+
lambda1
(atan2
t_2
(+
(cos phi1)
(/
(+
(sin (- t_5 (- lambda1 lambda2)))
(sin (+ t_5 (- lambda1 lambda2))))
2.0))))
(if (<= t_3 -0.005)
(atan2 t_4 (fma (cos lambda2) (cos phi2) (cos phi1)))
(if (<= t_3 2e-34)
(+ lambda1 (atan2 (* (cos phi2) (+ lambda1 (* -1.0 lambda2))) t_1))
(if (<= t_3 5.0)
(atan2 t_4 (fma t_0 (cos phi2) (cos phi1)))
(+
lambda1
(atan2
(* 1.0 t_2)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1)))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi1) + (cos(phi2) * t_0);
double t_2 = sin((lambda1 - lambda2));
double t_3 = lambda1 + atan2((cos(phi2) * t_2), t_1);
double t_4 = t_2 * cos(phi2);
double t_5 = phi2 + (((double) M_PI) / 2.0);
double tmp;
if (t_3 <= -400000.0) {
tmp = lambda1 + atan2(t_2, (cos(phi1) + ((sin((t_5 - (lambda1 - lambda2))) + sin((t_5 + (lambda1 - lambda2)))) / 2.0)));
} else if (t_3 <= -0.005) {
tmp = atan2(t_4, fma(cos(lambda2), cos(phi2), cos(phi1)));
} else if (t_3 <= 2e-34) {
tmp = lambda1 + atan2((cos(phi2) * (lambda1 + (-1.0 * lambda2))), t_1);
} else if (t_3 <= 5.0) {
tmp = atan2(t_4, fma(t_0, cos(phi2), cos(phi1)));
} else {
tmp = lambda1 + atan2((1.0 * t_2), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) + Float64(cos(phi2) * t_0)) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = Float64(lambda1 + atan(Float64(cos(phi2) * t_2), t_1)) t_4 = Float64(t_2 * cos(phi2)) t_5 = Float64(phi2 + Float64(pi / 2.0)) tmp = 0.0 if (t_3 <= -400000.0) tmp = Float64(lambda1 + atan(t_2, Float64(cos(phi1) + Float64(Float64(sin(Float64(t_5 - Float64(lambda1 - lambda2))) + sin(Float64(t_5 + Float64(lambda1 - lambda2)))) / 2.0)))); elseif (t_3 <= -0.005) tmp = atan(t_4, fma(cos(lambda2), cos(phi2), cos(phi1))); elseif (t_3 <= 2e-34) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(lambda1 + Float64(-1.0 * lambda2))), t_1)); elseif (t_3 <= 5.0) tmp = atan(t_4, fma(t_0, cos(phi2), cos(phi1))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_2), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))); 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[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(phi2 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -400000.0], N[(lambda1 + N[ArcTan[t$95$2 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[Sin[N[(t$95$5 - N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Sin[N[(t$95$5 + N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -0.005], N[ArcTan[t$95$4 / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$3, 2e-34], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 + N[(-1.0 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5.0], N[ArcTan[t$95$4 / N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$2), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 + \cos \phi_2 \cdot t\_0\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_2}{t\_1}\\
t_4 := t\_2 \cdot \cos \phi_2\\
t_5 := \phi_2 + \frac{\pi}{2}\\
\mathbf{if}\;t\_3 \leq -400000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2}{\cos \phi_1 + \frac{\sin \left(t\_5 - \left(\lambda_1 - \lambda_2\right)\right) + \sin \left(t\_5 + \left(\lambda_1 - \lambda_2\right)\right)}{2}}\\
\mathbf{elif}\;t\_3 \leq -0.005:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-34}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)}{t\_1}\\
\mathbf{elif}\;t\_3 \leq 5:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{\mathsf{fma}\left(t\_0, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_2}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
\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)))))) < -4e5Initial program 99.6%
lift-*.f64N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift--.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6499.4
Applied rewrites99.4%
if -4e5 < (+.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.0050000000000000001Initial program 97.3%
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.f6494.8
Applied rewrites94.8%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
sin-+PI/2N/A
cos-neg-revN/A
lift-cos.f6494.8
Applied rewrites94.8%
if -0.0050000000000000001 < (+.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.99999999999999986e-34Initial program 98.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.9
Applied rewrites98.9%
Taylor expanded in lambda1 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f6498.2
Applied rewrites98.2%
if 1.99999999999999986e-34 < (+.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)))))) < 5Initial program 98.0%
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.f6491.6
Applied rewrites91.6%
if 5 < (+.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.9%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6498.9
Applied rewrites98.9%
Taylor expanded in phi2 around 0
Applied rewrites98.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6498.3
Applied rewrites98.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))
(t_1 (sin (- lambda1 lambda2)))
(t_2
(atan2 (* t_1 (cos phi2)) (fma (cos lambda2) (cos phi2) (cos phi1))))
(t_3 (+ lambda1 (atan2 (* (cos phi2) t_1) t_0)))
(t_4 (+ phi2 (/ PI 2.0))))
(if (<= t_3 -400000.0)
(+
lambda1
(atan2
t_1
(+
(cos phi1)
(/
(+
(sin (- t_4 (- lambda1 lambda2)))
(sin (+ t_4 (- lambda1 lambda2))))
2.0))))
(if (<= t_3 -0.005)
t_2
(if (<= t_3 2e-34)
(+ lambda1 (atan2 (* (cos phi2) (+ lambda1 (* -1.0 lambda2))) t_0))
(if (<= t_3 5.0)
t_2
(+
lambda1
(atan2
(* 1.0 t_1)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1)))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)));
double t_1 = sin((lambda1 - lambda2));
double t_2 = atan2((t_1 * cos(phi2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
double t_3 = lambda1 + atan2((cos(phi2) * t_1), t_0);
double t_4 = phi2 + (((double) M_PI) / 2.0);
double tmp;
if (t_3 <= -400000.0) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + ((sin((t_4 - (lambda1 - lambda2))) + sin((t_4 + (lambda1 - lambda2)))) / 2.0)));
} else if (t_3 <= -0.005) {
tmp = t_2;
} else if (t_3 <= 2e-34) {
tmp = lambda1 + atan2((cos(phi2) * (lambda1 + (-1.0 * lambda2))), t_0);
} else if (t_3 <= 5.0) {
tmp = t_2;
} else {
tmp = lambda1 + atan2((1.0 * t_1), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = atan(Float64(t_1 * cos(phi2)), fma(cos(lambda2), cos(phi2), cos(phi1))) t_3 = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), t_0)) t_4 = Float64(phi2 + Float64(pi / 2.0)) tmp = 0.0 if (t_3 <= -400000.0) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(Float64(sin(Float64(t_4 - Float64(lambda1 - lambda2))) + sin(Float64(t_4 + Float64(lambda1 - lambda2)))) / 2.0)))); elseif (t_3 <= -0.005) tmp = t_2; elseif (t_3 <= 2e-34) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(lambda1 + Float64(-1.0 * lambda2))), t_0)); elseif (t_3 <= 5.0) tmp = t_2; else tmp = Float64(lambda1 + atan(Float64(1.0 * t_1), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(phi2 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -400000.0], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[Sin[N[(t$95$4 - N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Sin[N[(t$95$4 + N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -0.005], t$95$2, If[LessEqual[t$95$3, 2e-34], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 + N[(-1.0 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5.0], t$95$2, N[(lambda1 + N[ArcTan[N[(1.0 * t$95$1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{t\_0}\\
t_4 := \phi_2 + \frac{\pi}{2}\\
\mathbf{if}\;t\_3 \leq -400000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \frac{\sin \left(t\_4 - \left(\lambda_1 - \lambda_2\right)\right) + \sin \left(t\_4 + \left(\lambda_1 - \lambda_2\right)\right)}{2}}\\
\mathbf{elif}\;t\_3 \leq -0.005:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-34}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)}{t\_0}\\
\mathbf{elif}\;t\_3 \leq 5:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_1}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
\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)))))) < -4e5Initial program 99.6%
lift-*.f64N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift--.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
lower-/.f64N/A
Applied rewrites99.4%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6499.4
Applied rewrites99.4%
if -4e5 < (+.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.0050000000000000001 or 1.99999999999999986e-34 < (+.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)))))) < 5Initial program 97.6%
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.f6493.2
Applied rewrites93.2%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
sin-+PI/2N/A
cos-neg-revN/A
lift-cos.f6493.2
Applied rewrites93.2%
if -0.0050000000000000001 < (+.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.99999999999999986e-34Initial program 98.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.9
Applied rewrites98.9%
Taylor expanded in lambda1 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f6498.2
Applied rewrites98.2%
if 5 < (+.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.9%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6498.9
Applied rewrites98.9%
Taylor expanded in phi2 around 0
Applied rewrites98.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6498.3
Applied rewrites98.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (atan2 (* (cos phi2) (- (sin lambda2))) (+ (cos phi1) t_0)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (* (cos phi2) t_2))
(t_4
(+
lambda1
(atan2 t_3 (+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 phi2))) t_0)))))
(t_5 (+ lambda1 (atan2 t_3 (+ (cos phi1) (* (cos phi2) t_0))))))
(if (<= t_5 -3.0)
t_4
(if (<= t_5 -0.005)
t_1
(if (<= t_5 0.02)
(+
lambda1
(atan2
(* 1.0 t_2)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1)))))
(if (<= t_5 3.0) t_1 t_4))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((cos(phi2) * -sin(lambda2)), (cos(phi1) + t_0));
double t_2 = sin((lambda1 - lambda2));
double t_3 = cos(phi2) * t_2;
double t_4 = lambda1 + atan2(t_3, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0)));
double t_5 = lambda1 + atan2(t_3, (cos(phi1) + (cos(phi2) * t_0)));
double tmp;
if (t_5 <= -3.0) {
tmp = t_4;
} else if (t_5 <= -0.005) {
tmp = t_1;
} else if (t_5 <= 0.02) {
tmp = lambda1 + atan2((1.0 * t_2), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
} else if (t_5 <= 3.0) {
tmp = t_1;
} else {
tmp = t_4;
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.atan2((Math.cos(phi2) * -Math.sin(lambda2)), (Math.cos(phi1) + t_0));
double t_2 = Math.sin((lambda1 - lambda2));
double t_3 = Math.cos(phi2) * t_2;
double t_4 = lambda1 + Math.atan2(t_3, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0)));
double t_5 = lambda1 + Math.atan2(t_3, (Math.cos(phi1) + (Math.cos(phi2) * t_0)));
double tmp;
if (t_5 <= -3.0) {
tmp = t_4;
} else if (t_5 <= -0.005) {
tmp = t_1;
} else if (t_5 <= 0.02) {
tmp = lambda1 + Math.atan2((1.0 * t_2), (Math.cos(phi1) + Math.sin(((lambda2 + (0.5 * Math.PI)) - lambda1))));
} else if (t_5 <= 3.0) {
tmp = t_1;
} else {
tmp = t_4;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.atan2((math.cos(phi2) * -math.sin(lambda2)), (math.cos(phi1) + t_0)) t_2 = math.sin((lambda1 - lambda2)) t_3 = math.cos(phi2) * t_2 t_4 = lambda1 + math.atan2(t_3, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0))) t_5 = lambda1 + math.atan2(t_3, (math.cos(phi1) + (math.cos(phi2) * t_0))) tmp = 0 if t_5 <= -3.0: tmp = t_4 elif t_5 <= -0.005: tmp = t_1 elif t_5 <= 0.02: tmp = lambda1 + math.atan2((1.0 * t_2), (math.cos(phi1) + math.sin(((lambda2 + (0.5 * math.pi)) - lambda1)))) elif t_5 <= 3.0: tmp = t_1 else: tmp = t_4 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(cos(phi2) * Float64(-sin(lambda2))), Float64(cos(phi1) + t_0)) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = Float64(cos(phi2) * t_2) t_4 = Float64(lambda1 + atan(t_3, Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * t_0)))) t_5 = Float64(lambda1 + atan(t_3, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (t_5 <= -3.0) tmp = t_4; elseif (t_5 <= -0.005) tmp = t_1; elseif (t_5 <= 0.02) tmp = Float64(lambda1 + atan(Float64(1.0 * t_2), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))); elseif (t_5 <= 3.0) tmp = t_1; else tmp = t_4; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = atan2((cos(phi2) * -sin(lambda2)), (cos(phi1) + t_0)); t_2 = sin((lambda1 - lambda2)); t_3 = cos(phi2) * t_2; t_4 = lambda1 + atan2(t_3, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0))); t_5 = lambda1 + atan2(t_3, (cos(phi1) + (cos(phi2) * t_0))); tmp = 0.0; if (t_5 <= -3.0) tmp = t_4; elseif (t_5 <= -0.005) tmp = t_1; elseif (t_5 <= 0.02) tmp = lambda1 + atan2((1.0 * t_2), (cos(phi1) + sin(((lambda2 + (0.5 * pi)) - lambda1)))); elseif (t_5 <= 3.0) tmp = t_1; else tmp = t_4; 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[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $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]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$3 / N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(lambda1 + N[ArcTan[t$95$3 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, -3.0], t$95$4, If[LessEqual[t$95$5, -0.005], t$95$1, If[LessEqual[t$95$5, 0.02], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$2), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 3.0], t$95$1, t$95$4]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\cos \phi_1 + t\_0}\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \cos \phi_2 \cdot t\_2\\
t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_3}{1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot t\_0}\\
t_5 := \lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;t\_5 \leq -3:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_5 \leq -0.005:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_5 \leq 0.02:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_2}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
\mathbf{elif}\;t\_5 \leq 3:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\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 or 3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) Initial program 99.1%
Taylor expanded in phi1 around 0
Applied rewrites92.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.9
Applied rewrites96.9%
if -3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0050000000000000001 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)))))) < 3Initial program 97.6%
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.f6496.6
Applied rewrites96.6%
Taylor expanded in phi2 around 0
Applied rewrites55.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6454.9
Applied rewrites54.9%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6459.3
Applied rewrites59.3%
if -0.0050000000000000001 < (+.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.0200000000000000004Initial program 99.0%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6498.0
Applied rewrites98.0%
Taylor expanded in phi2 around 0
Applied rewrites61.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6461.5
Applied rewrites61.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* (cos phi2) t_1))
(t_3 (+ (cos phi1) (* (cos phi2) t_0)))
(t_4 (+ lambda1 (atan2 t_2 t_3))))
(if (<= t_4 -0.5)
(+ lambda1 (atan2 t_1 t_3))
(if (<= t_4 -1e-55)
(atan2 (* t_1 (cos phi2)) (fma t_0 (cos phi2) 1.0))
(if (<= t_4 3.0)
(+ lambda1 (atan2 t_2 (+ (cos phi1) t_0)))
(+
lambda1
(atan2 t_2 (+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 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 t_2 = cos(phi2) * t_1;
double t_3 = cos(phi1) + (cos(phi2) * t_0);
double t_4 = lambda1 + atan2(t_2, t_3);
double tmp;
if (t_4 <= -0.5) {
tmp = lambda1 + atan2(t_1, t_3);
} else if (t_4 <= -1e-55) {
tmp = atan2((t_1 * cos(phi2)), fma(t_0, cos(phi2), 1.0));
} else if (t_4 <= 3.0) {
tmp = lambda1 + atan2(t_2, (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2(t_2, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * t_1) t_3 = Float64(cos(phi1) + Float64(cos(phi2) * t_0)) t_4 = Float64(lambda1 + atan(t_2, t_3)) tmp = 0.0 if (t_4 <= -0.5) tmp = Float64(lambda1 + atan(t_1, t_3)); elseif (t_4 <= -1e-55) tmp = atan(Float64(t_1 * cos(phi2)), fma(t_0, cos(phi2), 1.0)); elseif (t_4 <= 3.0) tmp = Float64(lambda1 + atan(t_2, Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(t_2, Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * 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]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$2 / t$95$3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -0.5], N[(lambda1 + N[ArcTan[t$95$1 / t$95$3], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -1e-55], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$4, 3.0], N[(lambda1 + N[ArcTan[t$95$2 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$2 / N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $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)\\
t_2 := \cos \phi_2 \cdot t\_1\\
t_3 := \cos \phi_1 + \cos \phi_2 \cdot t\_0\\
t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_2}{t\_3}\\
\mathbf{if}\;t\_4 \leq -0.5:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{t\_3}\\
\mathbf{elif}\;t\_4 \leq -1 \cdot 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{\mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)}\\
\mathbf{elif}\;t\_4 \leq 3:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2}{1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot 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)))))) < -0.5Initial program 99.0%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6486.1
Applied rewrites86.1%
if -0.5 < (+.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)))))) < -9.99999999999999995e-56Initial program 97.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.f6475.7
Applied rewrites75.7%
Taylor expanded in phi1 around 0
Applied rewrites56.6%
if -9.99999999999999995e-56 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 3Initial program 98.4%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6462.6
Applied rewrites62.6%
if 3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) Initial program 99.0%
Taylor expanded in phi1 around 0
Applied rewrites92.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.8
Applied rewrites96.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* (cos phi2) t_1))
(t_3
(+
lambda1
(atan2 t_2 (+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 phi2))) t_0)))))
(t_4 (+ lambda1 (atan2 t_2 (+ (cos phi1) (* (cos phi2) t_0))))))
(if (<= t_4 -3.0)
t_3
(if (<= t_4 -0.005)
(atan2 t_1 (fma t_0 (cos phi2) (cos phi1)))
(if (<= t_4 0.1)
(+
lambda1
(atan2
(* 1.0 t_1)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1)))))
t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double t_2 = cos(phi2) * t_1;
double t_3 = lambda1 + atan2(t_2, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0)));
double t_4 = lambda1 + atan2(t_2, (cos(phi1) + (cos(phi2) * t_0)));
double tmp;
if (t_4 <= -3.0) {
tmp = t_3;
} else if (t_4 <= -0.005) {
tmp = atan2(t_1, fma(t_0, cos(phi2), cos(phi1)));
} else if (t_4 <= 0.1) {
tmp = lambda1 + atan2((1.0 * t_1), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
} else {
tmp = t_3;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * t_1) t_3 = Float64(lambda1 + atan(t_2, Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * t_0)))) t_4 = Float64(lambda1 + atan(t_2, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (t_4 <= -3.0) tmp = t_3; elseif (t_4 <= -0.005) tmp = atan(t_1, fma(t_0, cos(phi2), cos(phi1))); elseif (t_4 <= 0.1) tmp = Float64(lambda1 + atan(Float64(1.0 * t_1), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))); else tmp = t_3; 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]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[t$95$2 / N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$2 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -3.0], t$95$3, If[LessEqual[t$95$4, -0.005], N[ArcTan[t$95$1 / N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$4, 0.1], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot t\_1\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{t\_2}{1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot t\_0}\\
t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_2}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;t\_4 \leq -3:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq -0.005:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(t\_0, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{elif}\;t\_4 \leq 0.1:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_1}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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 or 0.10000000000000001 < (+.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.8%
Taylor expanded in phi1 around 0
Applied rewrites86.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.0
Applied rewrites87.0%
if -3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0050000000000000001Initial program 97.8%
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.f6496.6
Applied rewrites96.6%
Taylor expanded in phi2 around 0
Applied rewrites53.3%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6453.3
Applied rewrites53.3%
if -0.0050000000000000001 < (+.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.10000000000000001Initial program 99.0%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6495.2
Applied rewrites95.2%
Taylor expanded in phi2 around 0
Applied rewrites59.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6459.6
Applied rewrites59.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* (cos phi2) t_1))
(t_3
(+
lambda1
(atan2 t_2 (+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 phi2))) t_0)))))
(t_4 (+ lambda1 (atan2 t_2 (+ (cos phi1) (* (cos phi2) t_0))))))
(if (<= t_4 -3.0)
t_3
(if (<= t_4 -0.005)
(atan2 (* (- (sin lambda2)) 1.0) (+ (cos phi1) t_0))
(if (<= t_4 0.1)
(+
lambda1
(atan2
(* 1.0 t_1)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1)))))
t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double t_2 = cos(phi2) * t_1;
double t_3 = lambda1 + atan2(t_2, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0)));
double t_4 = lambda1 + atan2(t_2, (cos(phi1) + (cos(phi2) * t_0)));
double tmp;
if (t_4 <= -3.0) {
tmp = t_3;
} else if (t_4 <= -0.005) {
tmp = atan2((-sin(lambda2) * 1.0), (cos(phi1) + t_0));
} else if (t_4 <= 0.1) {
tmp = lambda1 + atan2((1.0 * t_1), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
} else {
tmp = t_3;
}
return tmp;
}
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 t_2 = Math.cos(phi2) * t_1;
double t_3 = lambda1 + Math.atan2(t_2, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0)));
double t_4 = lambda1 + Math.atan2(t_2, (Math.cos(phi1) + (Math.cos(phi2) * t_0)));
double tmp;
if (t_4 <= -3.0) {
tmp = t_3;
} else if (t_4 <= -0.005) {
tmp = Math.atan2((-Math.sin(lambda2) * 1.0), (Math.cos(phi1) + t_0));
} else if (t_4 <= 0.1) {
tmp = lambda1 + Math.atan2((1.0 * t_1), (Math.cos(phi1) + Math.sin(((lambda2 + (0.5 * Math.PI)) - lambda1))));
} else {
tmp = t_3;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) t_2 = math.cos(phi2) * t_1 t_3 = lambda1 + math.atan2(t_2, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0))) t_4 = lambda1 + math.atan2(t_2, (math.cos(phi1) + (math.cos(phi2) * t_0))) tmp = 0 if t_4 <= -3.0: tmp = t_3 elif t_4 <= -0.005: tmp = math.atan2((-math.sin(lambda2) * 1.0), (math.cos(phi1) + t_0)) elif t_4 <= 0.1: tmp = lambda1 + math.atan2((1.0 * t_1), (math.cos(phi1) + math.sin(((lambda2 + (0.5 * math.pi)) - lambda1)))) else: tmp = t_3 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * t_1) t_3 = Float64(lambda1 + atan(t_2, Float64(1.0 + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * t_0)))) t_4 = Float64(lambda1 + atan(t_2, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (t_4 <= -3.0) tmp = t_3; elseif (t_4 <= -0.005) tmp = atan(Float64(Float64(-sin(lambda2)) * 1.0), Float64(cos(phi1) + t_0)); elseif (t_4 <= 0.1) tmp = Float64(lambda1 + atan(Float64(1.0 * t_1), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))); else tmp = t_3; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); t_2 = cos(phi2) * t_1; t_3 = lambda1 + atan2(t_2, (1.0 + ((1.0 + (-0.5 * (phi2 * phi2))) * t_0))); t_4 = lambda1 + atan2(t_2, (cos(phi1) + (cos(phi2) * t_0))); tmp = 0.0; if (t_4 <= -3.0) tmp = t_3; elseif (t_4 <= -0.005) tmp = atan2((-sin(lambda2) * 1.0), (cos(phi1) + t_0)); elseif (t_4 <= 0.1) tmp = lambda1 + atan2((1.0 * t_1), (cos(phi1) + sin(((lambda2 + (0.5 * pi)) - lambda1)))); else tmp = t_3; 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]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[t$95$2 / N[(1.0 + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$2 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -3.0], t$95$3, If[LessEqual[t$95$4, -0.005], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * 1.0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$4, 0.1], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot t\_1\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{t\_2}{1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot t\_0}\\
t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_2}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;t\_4 \leq -3:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq -0.005:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\cos \phi_1 + t\_0}\\
\mathbf{elif}\;t\_4 \leq 0.1:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_1}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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 or 0.10000000000000001 < (+.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.8%
Taylor expanded in phi1 around 0
Applied rewrites86.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.0
Applied rewrites87.0%
if -3 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0050000000000000001Initial program 97.8%
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.f6496.6
Applied rewrites96.6%
Taylor expanded in phi2 around 0
Applied rewrites53.3%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6453.3
Applied rewrites53.3%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6453.1
Applied rewrites53.1%
if -0.0050000000000000001 < (+.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.10000000000000001Initial program 99.0%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6495.2
Applied rewrites95.2%
Taylor expanded in phi2 around 0
Applied rewrites59.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6459.6
Applied rewrites59.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) t_0))
(t_2 (sin (- lambda1 lambda2)))
(t_3
(+
lambda1
(atan2
(* 1.0 t_2)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1))))))
(t_4 (+ lambda1 (atan2 (* (cos phi2) t_2) (+ (cos phi1) t_1))))
(t_5 (+ 1.0 (* -0.5 (* phi2 phi2)))))
(if (<= t_4 -400000.0)
t_3
(if (<= t_4 -0.005)
(atan2 (* t_2 1.0) (fma t_0 t_5 (cos phi1)))
(if (<= t_4 0.1) t_3 (+ lambda1 (atan2 (* t_5 t_2) (+ 1.0 t_1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * t_0;
double t_2 = sin((lambda1 - lambda2));
double t_3 = lambda1 + atan2((1.0 * t_2), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
double t_4 = lambda1 + atan2((cos(phi2) * t_2), (cos(phi1) + t_1));
double t_5 = 1.0 + (-0.5 * (phi2 * phi2));
double tmp;
if (t_4 <= -400000.0) {
tmp = t_3;
} else if (t_4 <= -0.005) {
tmp = atan2((t_2 * 1.0), fma(t_0, t_5, cos(phi1)));
} else if (t_4 <= 0.1) {
tmp = t_3;
} else {
tmp = lambda1 + atan2((t_5 * t_2), (1.0 + t_1));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * t_0) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = Float64(lambda1 + atan(Float64(1.0 * t_2), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))) t_4 = Float64(lambda1 + atan(Float64(cos(phi2) * t_2), Float64(cos(phi1) + t_1))) t_5 = Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) tmp = 0.0 if (t_4 <= -400000.0) tmp = t_3; elseif (t_4 <= -0.005) tmp = atan(Float64(t_2 * 1.0), fma(t_0, t_5, cos(phi1))); elseif (t_4 <= 0.1) tmp = t_3; else tmp = Float64(lambda1 + atan(Float64(t_5 * t_2), Float64(1.0 + t_1))); 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[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[N[(1.0 * t$95$2), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -400000.0], t$95$3, If[LessEqual[t$95$4, -0.005], N[ArcTan[N[(t$95$2 * 1.0), $MachinePrecision] / N[(t$95$0 * t$95$5 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$4, 0.1], t$95$3, N[(lambda1 + N[ArcTan[N[(t$95$5 * t$95$2), $MachinePrecision] / N[(1.0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot t\_0\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_2}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
t_4 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_2}{\cos \phi_1 + t\_1}\\
t_5 := 1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\\
\mathbf{if}\;t\_4 \leq -400000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq -0.005:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot 1}{\mathsf{fma}\left(t\_0, t\_5, \cos \phi_1\right)}\\
\mathbf{elif}\;t\_4 \leq 0.1:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_5 \cdot t\_2}{1 + t\_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)))))) < -4e5 or -0.0050000000000000001 < (+.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.10000000000000001Initial program 99.3%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6497.6
Applied rewrites97.6%
Taylor expanded in phi2 around 0
Applied rewrites80.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6480.8
Applied rewrites80.8%
if -4e5 < (+.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.0050000000000000001Initial program 97.3%
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.f6494.8
Applied rewrites94.8%
Taylor expanded in phi2 around 0
Applied rewrites49.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6446.8
Applied rewrites46.8%
if 0.10000000000000001 < (+.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.5%
Taylor expanded in phi1 around 0
Applied rewrites82.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6476.5
Applied rewrites76.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
(+
1.0
(*
(* lambda1 lambda1)
(- (* 0.041666666666666664 (* lambda1 lambda1)) 0.5)))
(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((1.0 + ((lambda1 * lambda1) * ((0.041666666666666664 * (lambda1 * lambda1)) - 0.5))), 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(Float64(1.0 + Float64(Float64(lambda1 * lambda1) * Float64(Float64(0.041666666666666664 * Float64(lambda1 * lambda1)) - 0.5))), 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[(1.0 + N[(N[(lambda1 * lambda1), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $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(1 + \left(\lambda_1 \cdot \lambda_1\right) \cdot \left(0.041666666666666664 \cdot \left(\lambda_1 \cdot \lambda_1\right) - 0.5\right), \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.8
Applied rewrites98.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.5
Applied rewrites98.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (- (* (sin lambda1) (cos lambda2)) (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)) - 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)) - 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[Sin[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 \left(\sin \lambda_1 \cdot \cos \lambda_2 - \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-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.8
Applied rewrites98.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in lambda1 around 0
lift-sin.f6498.9
Applied rewrites98.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(-
(* (sin lambda1) (cos lambda2))
(* (+ 1.0 (* -0.5 (* lambda1 lambda1))) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma
(+
1.0
(*
(* lambda1 lambda1)
(- (* 0.041666666666666664 (* lambda1 lambda1)) 0.5)))
(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)) - ((1.0 + (-0.5 * (lambda1 * lambda1))) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma((1.0 + ((lambda1 * lambda1) * ((0.041666666666666664 * (lambda1 * lambda1)) - 0.5))), 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(Float64(1.0 + Float64(-0.5 * Float64(lambda1 * lambda1))) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(Float64(1.0 + Float64(Float64(lambda1 * lambda1) * Float64(Float64(0.041666666666666664 * Float64(lambda1 * lambda1)) - 0.5))), 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[(1.0 + N[(-0.5 * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(1.0 + N[(N[(lambda1 * lambda1), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $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 - \left(1 + -0.5 \cdot \left(\lambda_1 \cdot \lambda_1\right)\right) \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(1 + \left(\lambda_1 \cdot \lambda_1\right) \cdot \left(0.041666666666666664 \cdot \left(\lambda_1 \cdot \lambda_1\right) - 0.5\right), \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.8
Applied rewrites98.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.5
Applied rewrites98.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6498.5
Applied rewrites98.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.8
Applied rewrites98.8%
(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) (* (cos lambda1) (sin lambda2)))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * (sin(lambda1) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * (sin(lambda1) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * (math.sin(lambda1) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(sin(lambda1) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * (sin(lambda1) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.8
Applied rewrites98.8%
Taylor expanded in lambda2 around 0
lift-sin.f6498.8
Applied rewrites98.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi1) 0.999)
(+
lambda1
(atan2 t_1 (+ (cos phi1) (* (fma (* phi2 phi2) -0.5 1.0) t_0))))
(+ lambda1 (atan2 t_1 (+ 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 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.999) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + (fma((phi2 * phi2), -0.5, 1.0) * t_0)));
} else {
tmp = lambda1 + atan2(t_1, (1.0 + (cos(phi2) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi1) <= 0.999) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * t_0)))); else tmp = Float64(lambda1 + atan(t_1, Float64(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[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.999], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 + 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 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.999:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1 + \cos \phi_2 \cdot t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.998999999999999999Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6481.9
Applied rewrites81.9%
if 0.998999999999999999 < (cos.f64 phi1) Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites97.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos (- lambda1 lambda2))))
(t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.999)
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0)))
(+ lambda1 (atan2 (* (cos phi2) t_1) (+ 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 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.999) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + 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(phi2) * cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
if (cos(phi1) <= 0.999d0) then
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0))
else
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0d0 + 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(phi2) * Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi1) <= 0.999) {
tmp = lambda1 + Math.atan2(t_1, (Math.cos(phi1) + t_0));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_1), (1.0 + t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi1) <= 0.999: tmp = lambda1 + math.atan2(t_1, (math.cos(phi1) + t_0)) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_1), (1.0 + t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.999) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(1.0 + t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi1) <= 0.999) tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0)); else tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + t_0)); end tmp_2 = 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.999], 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[(1.0 + 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 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.999:\\
\;\;\;\;\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}{1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.998999999999999999Initial program 98.7%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6478.6
Applied rewrites78.6%
if 0.998999999999999999 < (cos.f64 phi1) Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites97.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.999)
(+ lambda1 (atan2 t_1 (+ (cos phi1) (* (cos phi2) t_0))))
(+ lambda1 (atan2 (* (cos phi2) t_1) (fma t_0 (cos phi2) 1.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(phi1) <= 0.999) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + (cos(phi2) * t_0)));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_1), fma(t_0, cos(phi2), 1.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(phi1) <= 0.999) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), fma(t_0, cos(phi2), 1.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[N[Cos[phi1], $MachinePrecision], 0.999], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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]]]]
\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_1 \leq 0.999:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.998999999999999999Initial program 98.7%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6478.6
Applied rewrites78.6%
if 0.998999999999999999 < (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.f6497.9
Applied rewrites97.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.999)
(+
lambda1
(atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(+
lambda1
(atan2 (* (cos phi2) t_0) (+ 1.0 (* (cos phi2) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.999) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (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(phi1) <= 0.999d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + (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(phi1) <= 0.999) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + (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(phi1) <= 0.999: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + (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(phi1) <= 0.999) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + 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(phi1) <= 0.999) tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); else tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (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[phi1], $MachinePrecision], 0.999], 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], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + 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_1 \leq 0.999:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.998999999999999999Initial program 98.7%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6478.6
Applied rewrites78.6%
if 0.998999999999999999 < (cos.f64 phi1) Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites97.9%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6497.3
Applied rewrites97.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= (cos phi2) 0.8882)
(+
lambda1
(atan2 (* (cos phi2) lambda1) (+ (cos phi1) (* (cos phi2) t_0))))
(+
lambda1
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.8882) {
tmp = lambda1 + atan2((cos(phi2) * lambda1), (cos(phi1) + (cos(phi2) * t_0)));
} else {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (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) :: tmp
t_0 = cos((lambda1 - lambda2))
if (cos(phi2) <= 0.8882d0) then
tmp = lambda1 + atan2((cos(phi2) * lambda1), (cos(phi1) + (cos(phi2) * t_0)))
else
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (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 tmp;
if (Math.cos(phi2) <= 0.8882) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * lambda1), (Math.cos(phi1) + (Math.cos(phi2) * t_0)));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.8882: tmp = lambda1 + math.atan2((math.cos(phi2) * lambda1), (math.cos(phi1) + (math.cos(phi2) * t_0))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.8882) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * lambda1), Float64(cos(phi1) + Float64(cos(phi2) * t_0)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.8882) tmp = lambda1 + atan2((cos(phi2) * lambda1), (cos(phi1) + (cos(phi2) * t_0))); else tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (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]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.8882], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * lambda1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.8882:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \lambda_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.88819999999999999Initial program 98.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda1 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in lambda2 around 0
Applied rewrites65.1%
if 0.88819999999999999 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6494.0
Applied rewrites94.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.1)
(+
lambda1
(atan2
(* (cos phi2) t_1)
(+ 1.0 (* (+ 1.0 (* -0.5 (* phi2 phi2))) t_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 (cos(phi2) <= -0.1) {
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) + (cos(phi2) * 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.1d0)) 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) + (cos(phi2) * 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.1) {
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) + (Math.cos(phi2) * 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.1: 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) + (math.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 (cos(phi2) <= -0.1) 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) + Float64(cos(phi2) * 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.1) 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) + (cos(phi2) * 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.1], 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] + 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}\;\cos \phi_2 \leq -0.1:\\
\;\;\;\;\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 + \cos \phi_2 \cdot t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.10000000000000001Initial program 98.2%
Taylor expanded in phi1 around 0
Applied rewrites77.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6461.1
Applied rewrites61.1%
if -0.10000000000000001 < (cos.f64 phi2) Initial program 98.9%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6486.3
Applied rewrites86.3%
(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 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda2))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\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 \lambda_2}
\end{array}
Initial program 98.7%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6498.0
Applied rewrites98.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos lambda2) (cos phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}
\end{array}
Initial program 98.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 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) t_0))
(t_2 (+ (cos phi1) t_1))
(t_3 (sin (- lambda1 lambda2)))
(t_4 (* (cos phi2) t_3)))
(if (<= phi1 3.3e-11)
(+ lambda1 (atan2 t_4 (+ 1.0 t_1)))
(if (<= phi1 5.4e+73)
(+ lambda1 (atan2 t_4 (+ (cos phi1) t_0)))
(if (<= phi1 3.8e+170)
(+ lambda1 (atan2 (* (cos phi2) (+ lambda1 (* -1.0 lambda2))) t_2))
(+ lambda1 (atan2 t_3 t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * t_0;
double t_2 = cos(phi1) + t_1;
double t_3 = sin((lambda1 - lambda2));
double t_4 = cos(phi2) * t_3;
double tmp;
if (phi1 <= 3.3e-11) {
tmp = lambda1 + atan2(t_4, (1.0 + t_1));
} else if (phi1 <= 5.4e+73) {
tmp = lambda1 + atan2(t_4, (cos(phi1) + t_0));
} else if (phi1 <= 3.8e+170) {
tmp = lambda1 + atan2((cos(phi2) * (lambda1 + (-1.0 * lambda2))), t_2);
} else {
tmp = lambda1 + atan2(t_3, t_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi2) * t_0
t_2 = cos(phi1) + t_1
t_3 = sin((lambda1 - lambda2))
t_4 = cos(phi2) * t_3
if (phi1 <= 3.3d-11) then
tmp = lambda1 + atan2(t_4, (1.0d0 + t_1))
else if (phi1 <= 5.4d+73) then
tmp = lambda1 + atan2(t_4, (cos(phi1) + t_0))
else if (phi1 <= 3.8d+170) then
tmp = lambda1 + atan2((cos(phi2) * (lambda1 + ((-1.0d0) * lambda2))), t_2)
else
tmp = lambda1 + atan2(t_3, t_2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi2) * t_0;
double t_2 = Math.cos(phi1) + t_1;
double t_3 = Math.sin((lambda1 - lambda2));
double t_4 = Math.cos(phi2) * t_3;
double tmp;
if (phi1 <= 3.3e-11) {
tmp = lambda1 + Math.atan2(t_4, (1.0 + t_1));
} else if (phi1 <= 5.4e+73) {
tmp = lambda1 + Math.atan2(t_4, (Math.cos(phi1) + t_0));
} else if (phi1 <= 3.8e+170) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * (lambda1 + (-1.0 * lambda2))), t_2);
} else {
tmp = lambda1 + Math.atan2(t_3, t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi2) * t_0 t_2 = math.cos(phi1) + t_1 t_3 = math.sin((lambda1 - lambda2)) t_4 = math.cos(phi2) * t_3 tmp = 0 if phi1 <= 3.3e-11: tmp = lambda1 + math.atan2(t_4, (1.0 + t_1)) elif phi1 <= 5.4e+73: tmp = lambda1 + math.atan2(t_4, (math.cos(phi1) + t_0)) elif phi1 <= 3.8e+170: tmp = lambda1 + math.atan2((math.cos(phi2) * (lambda1 + (-1.0 * lambda2))), t_2) else: tmp = lambda1 + math.atan2(t_3, t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * t_0) t_2 = Float64(cos(phi1) + t_1) t_3 = sin(Float64(lambda1 - lambda2)) t_4 = Float64(cos(phi2) * t_3) tmp = 0.0 if (phi1 <= 3.3e-11) tmp = Float64(lambda1 + atan(t_4, Float64(1.0 + t_1))); elseif (phi1 <= 5.4e+73) tmp = Float64(lambda1 + atan(t_4, Float64(cos(phi1) + t_0))); elseif (phi1 <= 3.8e+170) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(lambda1 + Float64(-1.0 * lambda2))), t_2)); else tmp = Float64(lambda1 + atan(t_3, t_2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi2) * t_0; t_2 = cos(phi1) + t_1; t_3 = sin((lambda1 - lambda2)); t_4 = cos(phi2) * t_3; tmp = 0.0; if (phi1 <= 3.3e-11) tmp = lambda1 + atan2(t_4, (1.0 + t_1)); elseif (phi1 <= 5.4e+73) tmp = lambda1 + atan2(t_4, (cos(phi1) + t_0)); elseif (phi1 <= 3.8e+170) tmp = lambda1 + atan2((cos(phi2) * (lambda1 + (-1.0 * lambda2))), t_2); else tmp = lambda1 + atan2(t_3, t_2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[phi1, 3.3e-11], N[(lambda1 + N[ArcTan[t$95$4 / N[(1.0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 5.4e+73], N[(lambda1 + N[ArcTan[t$95$4 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.8e+170], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 + N[(-1.0 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$3 / t$95$2], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot t\_0\\
t_2 := \cos \phi_1 + t\_1\\
t_3 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_4 := \cos \phi_2 \cdot t\_3\\
\mathbf{if}\;\phi_1 \leq 3.3 \cdot 10^{-11}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_4}{1 + t\_1}\\
\mathbf{elif}\;\phi_1 \leq 5.4 \cdot 10^{+73}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_4}{\cos \phi_1 + t\_0}\\
\mathbf{elif}\;\phi_1 \leq 3.8 \cdot 10^{+170}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{t\_2}\\
\end{array}
\end{array}
if phi1 < 3.3000000000000002e-11Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites85.7%
if 3.3000000000000002e-11 < phi1 < 5.3999999999999998e73Initial program 98.8%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6477.9
Applied rewrites77.9%
if 5.3999999999999998e73 < phi1 < 3.7999999999999998e170Initial program 99.1%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.1
Applied rewrites99.1%
Taylor expanded in lambda1 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6498.3
Applied rewrites98.3%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f6476.1
Applied rewrites76.1%
if 3.7999999999999998e170 < phi1 Initial program 98.6%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.3
Applied rewrites77.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi1 0.058)
(+ lambda1 (atan2 t_0 (+ 1.0 (* (cos phi2) (cos (- lambda1 lambda2))))))
(+
lambda1
(atan2
(* 1.0 t_0)
(+ (cos phi1) (sin (- (+ lambda2 (* 0.5 PI)) lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 0.058) {
tmp = lambda1 + atan2(t_0, (1.0 + (cos(phi2) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((1.0 * t_0), (cos(phi1) + sin(((lambda2 + (0.5 * ((double) M_PI))) - lambda1))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 0.058) {
tmp = lambda1 + Math.atan2(t_0, (1.0 + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + Math.atan2((1.0 * t_0), (Math.cos(phi1) + Math.sin(((lambda2 + (0.5 * Math.PI)) - lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= 0.058: tmp = lambda1 + math.atan2(t_0, (1.0 + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) else: tmp = lambda1 + math.atan2((1.0 * t_0), (math.cos(phi1) + math.sin(((lambda2 + (0.5 * math.pi)) - lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= 0.058) tmp = Float64(lambda1 + atan(t_0, Float64(1.0 + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_0), Float64(cos(phi1) + sin(Float64(Float64(lambda2 + Float64(0.5 * pi)) - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= 0.058) tmp = lambda1 + atan2(t_0, (1.0 + (cos(phi2) * cos((lambda1 - lambda2))))); else tmp = lambda1 + atan2((1.0 * t_0), (cos(phi1) + sin(((lambda2 + (0.5 * pi)) - lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 0.058], N[(lambda1 + N[ArcTan[t$95$0 / N[(1.0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Sin[N[(N[(lambda2 + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 0.058:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_0}{\cos \phi_1 + \sin \left(\left(\lambda_2 + 0.5 \cdot \pi\right) - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < 0.0580000000000000029Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites85.7%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6470.8
Applied rewrites70.8%
if 0.0580000000000000029 < phi1 Initial program 98.8%
lift--.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lower-neg.f64N/A
lift--.f64N/A
lower-/.f64N/A
lower-PI.f6479.2
Applied rewrites79.2%
Taylor expanded in phi2 around 0
Applied rewrites67.5%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-PI.f6466.1
Applied rewrites66.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (+ lambda1 (atan2 t_1 (+ 1.0 (* (cos phi2) t_0))))))
(if (<= lambda1 -4.2e-44)
t_2
(if (<= lambda1 1.7e-100) (atan2 t_1 (+ (cos phi1) t_0)) t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double t_2 = lambda1 + atan2(t_1, (1.0 + (cos(phi2) * t_0)));
double tmp;
if (lambda1 <= -4.2e-44) {
tmp = t_2;
} else if (lambda1 <= 1.7e-100) {
tmp = atan2(t_1, (cos(phi1) + t_0));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
t_2 = lambda1 + atan2(t_1, (1.0d0 + (cos(phi2) * t_0)))
if (lambda1 <= (-4.2d-44)) then
tmp = t_2
else if (lambda1 <= 1.7d-100) then
tmp = atan2(t_1, (cos(phi1) + t_0))
else
tmp = t_2
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 t_2 = lambda1 + Math.atan2(t_1, (1.0 + (Math.cos(phi2) * t_0)));
double tmp;
if (lambda1 <= -4.2e-44) {
tmp = t_2;
} else if (lambda1 <= 1.7e-100) {
tmp = Math.atan2(t_1, (Math.cos(phi1) + t_0));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) t_2 = lambda1 + math.atan2(t_1, (1.0 + (math.cos(phi2) * t_0))) tmp = 0 if lambda1 <= -4.2e-44: tmp = t_2 elif lambda1 <= 1.7e-100: tmp = math.atan2(t_1, (math.cos(phi1) + t_0)) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(lambda1 + atan(t_1, Float64(1.0 + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (lambda1 <= -4.2e-44) tmp = t_2; elseif (lambda1 <= 1.7e-100) tmp = atan(t_1, Float64(cos(phi1) + t_0)); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); t_2 = lambda1 + atan2(t_1, (1.0 + (cos(phi2) * t_0))); tmp = 0.0; if (lambda1 <= -4.2e-44) tmp = t_2; elseif (lambda1 <= 1.7e-100) tmp = atan2(t_1, (cos(phi1) + t_0)); else tmp = t_2; 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]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -4.2e-44], t$95$2, If[LessEqual[lambda1, 1.7e-100], N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;\lambda_1 \leq -4.2 \cdot 10^{-44}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 1.7 \cdot 10^{-100}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda1 < -4.20000000000000003e-44 or 1.69999999999999988e-100 < lambda1 Initial program 98.4%
Taylor expanded in phi1 around 0
Applied rewrites91.2%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6486.6
Applied rewrites86.6%
if -4.20000000000000003e-44 < lambda1 < 1.69999999999999988e-100Initial program 99.3%
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.f6484.8
Applied rewrites84.8%
Taylor expanded in phi2 around 0
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6447.1
Applied rewrites47.1%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6447.1
Applied rewrites47.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.58)
lambda1
(if (<= lambda1 2.35e-12)
(atan2 (sin (- lambda1 lambda2)) (+ (cos phi1) (cos (- lambda1 lambda2))))
lambda1)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.58) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-0.58d0)) then
tmp = lambda1
else if (lambda1 <= 2.35d-12) then
tmp = atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2))))
else
tmp = lambda1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.58) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -0.58: tmp = lambda1 elif lambda1 <= 2.35e-12: tmp = math.atan2(math.sin((lambda1 - lambda2)), (math.cos(phi1) + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.58) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2)))); else tmp = lambda1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -0.58) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2)))); else tmp = lambda1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.58], lambda1, If[LessEqual[lambda1, 2.35e-12], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], lambda1]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.58:\\
\;\;\;\;\lambda_1\\
\mathbf{elif}\;\lambda_1 \leq 2.35 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1\\
\end{array}
\end{array}
if lambda1 < -0.57999999999999996 or 2.34999999999999988e-12 < lambda1 Initial program 98.6%
Taylor expanded in lambda1 around inf
Applied rewrites96.6%
if -0.57999999999999996 < lambda1 < 2.34999999999999988e-12Initial program 98.8%
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.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
Applied rewrites46.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6444.6
Applied rewrites44.6%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6444.6
Applied rewrites44.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.6)
lambda1
(if (<= lambda1 2.35e-12)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(+
(+
1.0
(*
(* phi1 phi1)
(-
(*
(* phi1 phi1)
(+ 0.041666666666666664 (* -0.001388888888888889 (* phi1 phi1))))
0.5)))
(cos (- lambda1 lambda2))))
lambda1)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.6) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), ((1.0 + ((phi1 * phi1) * (((phi1 * phi1) * (0.041666666666666664 + (-0.001388888888888889 * (phi1 * phi1)))) - 0.5))) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-0.6d0)) then
tmp = lambda1
else if (lambda1 <= 2.35d-12) then
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), ((1.0d0 + ((phi1 * phi1) * (((phi1 * phi1) * (0.041666666666666664d0 + ((-0.001388888888888889d0) * (phi1 * phi1)))) - 0.5d0))) + cos((lambda1 - lambda2))))
else
tmp = lambda1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.6) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), ((1.0 + ((phi1 * phi1) * (((phi1 * phi1) * (0.041666666666666664 + (-0.001388888888888889 * (phi1 * phi1)))) - 0.5))) + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -0.6: tmp = lambda1 elif lambda1 <= 2.35e-12: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), ((1.0 + ((phi1 * phi1) * (((phi1 * phi1) * (0.041666666666666664 + (-0.001388888888888889 * (phi1 * phi1)))) - 0.5))) + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.6) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(Float64(1.0 + Float64(Float64(phi1 * phi1) * Float64(Float64(Float64(phi1 * phi1) * Float64(0.041666666666666664 + Float64(-0.001388888888888889 * Float64(phi1 * phi1)))) - 0.5))) + cos(Float64(lambda1 - lambda2)))); else tmp = lambda1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -0.6) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan2((sin((lambda1 - lambda2)) * 1.0), ((1.0 + ((phi1 * phi1) * (((phi1 * phi1) * (0.041666666666666664 + (-0.001388888888888889 * (phi1 * phi1)))) - 0.5))) + cos((lambda1 - lambda2)))); else tmp = lambda1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.6], lambda1, If[LessEqual[lambda1, 2.35e-12], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(1.0 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(N[(N[(phi1 * phi1), $MachinePrecision] * N[(0.041666666666666664 + N[(-0.001388888888888889 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], lambda1]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.6:\\
\;\;\;\;\lambda_1\\
\mathbf{elif}\;\lambda_1 \leq 2.35 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) - 0.5\right)\right) + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1\\
\end{array}
\end{array}
if lambda1 < -0.599999999999999978 or 2.34999999999999988e-12 < lambda1 Initial program 98.6%
Taylor expanded in lambda1 around inf
Applied rewrites96.6%
if -0.599999999999999978 < lambda1 < 2.34999999999999988e-12Initial program 98.8%
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.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
Applied rewrites46.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6444.6
Applied rewrites44.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6428.1
Applied rewrites28.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.6)
lambda1
(if (<= lambda1 2.35e-12)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(+ (+ 1.0 (* -0.5 (* phi1 phi1))) (cos (- lambda1 lambda2))))
lambda1)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.6) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), ((1.0 + (-0.5 * (phi1 * phi1))) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-0.6d0)) then
tmp = lambda1
else if (lambda1 <= 2.35d-12) then
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), ((1.0d0 + ((-0.5d0) * (phi1 * phi1))) + cos((lambda1 - lambda2))))
else
tmp = lambda1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.6) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), ((1.0 + (-0.5 * (phi1 * phi1))) + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -0.6: tmp = lambda1 elif lambda1 <= 2.35e-12: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), ((1.0 + (-0.5 * (phi1 * phi1))) + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.6) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))) + cos(Float64(lambda1 - lambda2)))); else tmp = lambda1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -0.6) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan2((sin((lambda1 - lambda2)) * 1.0), ((1.0 + (-0.5 * (phi1 * phi1))) + cos((lambda1 - lambda2)))); else tmp = lambda1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.6], lambda1, If[LessEqual[lambda1, 2.35e-12], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], lambda1]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.6:\\
\;\;\;\;\lambda_1\\
\mathbf{elif}\;\lambda_1 \leq 2.35 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1\\
\end{array}
\end{array}
if lambda1 < -0.599999999999999978 or 2.34999999999999988e-12 < lambda1 Initial program 98.6%
Taylor expanded in lambda1 around inf
Applied rewrites96.6%
if -0.599999999999999978 < lambda1 < 2.34999999999999988e-12Initial program 98.8%
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.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
Applied rewrites46.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6444.6
Applied rewrites44.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6428.1
Applied rewrites28.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.18)
lambda1
(if (<= lambda1 2.35e-12)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(+ 1.0 (cos (- lambda1 lambda2))))
lambda1)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.18) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (1.0 + cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-0.18d0)) then
tmp = lambda1
else if (lambda1 <= 2.35d-12) then
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), (1.0d0 + cos((lambda1 - lambda2))))
else
tmp = lambda1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.18) {
tmp = lambda1;
} else if (lambda1 <= 2.35e-12) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), (1.0 + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -0.18: tmp = lambda1 elif lambda1 <= 2.35e-12: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), (1.0 + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.18) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(1.0 + cos(Float64(lambda1 - lambda2)))); else tmp = lambda1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -0.18) tmp = lambda1; elseif (lambda1 <= 2.35e-12) tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (1.0 + cos((lambda1 - lambda2)))); else tmp = lambda1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.18], lambda1, If[LessEqual[lambda1, 2.35e-12], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], lambda1]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.18:\\
\;\;\;\;\lambda_1\\
\mathbf{elif}\;\lambda_1 \leq 2.35 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1\\
\end{array}
\end{array}
if lambda1 < -0.17999999999999999 or 2.34999999999999988e-12 < lambda1 Initial program 98.6%
Taylor expanded in lambda1 around inf
Applied rewrites96.5%
if -0.17999999999999999 < lambda1 < 2.34999999999999988e-12Initial program 98.8%
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.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
Applied rewrites46.0%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f6444.6
Applied rewrites44.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift--.f6428.7
Applied rewrites28.7%
(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.7%
Taylor expanded in lambda1 around inf
Applied rewrites53.6%
herbie shell --seed 2025100
(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)))))))