
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Herbie found 28 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos phi1))))
(*
(acos
(+
(* (sin phi1) (sin phi2))
(fma
(* (sin lambda1) (sin lambda2))
t_0
(* (* (cos lambda1) (cos lambda2)) t_0))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * cos(phi1);
return acos(((sin(phi1) * sin(phi2)) + fma((sin(lambda1) * sin(lambda2)), t_0, ((cos(lambda1) * cos(lambda2)) * t_0)))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(phi1)) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + fma(Float64(sin(lambda1) * sin(lambda2)), t_0, Float64(Float64(cos(lambda1) * cos(lambda2)) * t_0)))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * t$95$0 + N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \mathsf{fma}\left(\sin \lambda_1 \cdot \sin \lambda_2, t\_0, \left(\cos \lambda_1 \cdot \cos \lambda_2\right) \cdot t\_0\right)\right) \cdot R
\end{array}
\end{array}
Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites94.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right) \cdot R
\end{array}
Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R
\end{array}
Initial program 73.5%
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.f6494.2
Applied rewrites94.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(sin phi1)
(sin phi2)
(*
(* (cos phi2) (cos phi1))
(fma (sin lambda1) (sin lambda2) (* (cos lambda1) (cos lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(sin(phi1), sin(phi2), ((cos(phi2) * cos(phi1)) * fma(sin(lambda1), sin(lambda2), (cos(lambda1) * cos(lambda2)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(sin(phi1), sin(phi2), Float64(Float64(cos(phi2) * cos(phi1)) * fma(sin(lambda1), sin(lambda2), Float64(cos(lambda1) * cos(lambda2)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right) \cdot R
\end{array}
Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites94.2%
Applied rewrites94.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(*
(acos
(+ (* (sin phi1) (sin phi2)) (* t_0 (cos (- lambda1 lambda2)))))
R)))
(if (<= phi2 -0.36)
t_1
(if (<= phi2 55000000.0)
(*
(acos
(+
(*
(sin phi1)
(*
(fma
(-
(*
(fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
(* phi2 phi2))
0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))
(*
t_0
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
R)
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = acos(((sin(phi1) * sin(phi2)) + (t_0 * cos((lambda1 - lambda2))))) * R;
double tmp;
if (phi2 <= -0.36) {
tmp = t_1;
} else if (phi2 <= 55000000.0) {
tmp = acos(((sin(phi1) * (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2)) + (t_0 * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))))) * R;
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * cos(Float64(lambda1 - lambda2))))) * R) tmp = 0.0 if (phi2 <= -0.36) tmp = t_1; elseif (phi2 <= 55000000.0) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)) + Float64(t_0 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))) * R); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, -0.36], t$95$1, If[LessEqual[phi2, 55000000.0], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq -0.36:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 55000000:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2\right) + t\_0 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.35999999999999999 or 5.5e7 < phi2 Initial program 73.5%
if -0.35999999999999999 < phi2 < 5.5e7Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites46.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(*
(acos
(+ (* (sin phi1) (sin phi2)) (* t_0 (cos (- lambda1 lambda2)))))
R)))
(if (<= phi2 -0.34)
t_1
(if (<= phi2 55000000.0)
(*
(acos
(+
(*
(sin phi1)
(*
(fma
(- (* (* phi2 phi2) 0.008333333333333333) 0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))
(*
t_0
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
R)
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = acos(((sin(phi1) * sin(phi2)) + (t_0 * cos((lambda1 - lambda2))))) * R;
double tmp;
if (phi2 <= -0.34) {
tmp = t_1;
} else if (phi2 <= 55000000.0) {
tmp = acos(((sin(phi1) * (fma((((phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2)) + (t_0 * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))))) * R;
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * cos(Float64(lambda1 - lambda2))))) * R) tmp = 0.0 if (phi2 <= -0.34) tmp = t_1; elseif (phi2 <= 55000000.0) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(Float64(Float64(phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)) + Float64(t_0 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))) * R); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, -0.34], t$95$1, If[LessEqual[phi2, 55000000.0], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq -0.34:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 55000000:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2\right) + t\_0 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.340000000000000024 or 5.5e7 < phi2 Initial program 73.5%
if -0.340000000000000024 < phi2 < 5.5e7Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6446.9
Applied rewrites46.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(*
(acos
(+ (* (sin phi1) (sin phi2)) (* t_0 (cos (- lambda1 lambda2)))))
R)))
(if (<= phi2 -0.3)
t_1
(if (<= phi2 55000000.0)
(*
(acos
(+
(* (sin phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
t_0
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
R)
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = acos(((sin(phi1) * sin(phi2)) + (t_0 * cos((lambda1 - lambda2))))) * R;
double tmp;
if (phi2 <= -0.3) {
tmp = t_1;
} else if (phi2 <= 55000000.0) {
tmp = acos(((sin(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) + (t_0 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))) * R;
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * cos(Float64(lambda1 - lambda2))))) * R) tmp = 0.0 if (phi2 <= -0.3) tmp = t_1; elseif (phi2 <= 55000000.0) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) + Float64(t_0 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))) * R); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, -0.3], t$95$1, If[LessEqual[phi2, 55000000.0], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq -0.3:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 55000000:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) + t\_0 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.299999999999999989 or 5.5e7 < phi2 Initial program 73.5%
if -0.299999999999999989 < phi2 < 5.5e7Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6448.2
Applied rewrites48.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(*
(acos
(+ (* (sin phi1) (sin phi2)) (* t_0 (cos (- lambda1 lambda2)))))
R)))
(if (<= phi2 -0.00175)
t_1
(if (<= phi2 55000000.0)
(*
(acos
(+
(* (sin phi1) phi2)
(*
t_0
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
R)
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = acos(((sin(phi1) * sin(phi2)) + (t_0 * cos((lambda1 - lambda2))))) * R;
double tmp;
if (phi2 <= -0.00175) {
tmp = t_1;
} else if (phi2 <= 55000000.0) {
tmp = acos(((sin(phi1) * phi2) + (t_0 * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))))) * R;
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(t_0 * cos(Float64(lambda1 - lambda2))))) * R) tmp = 0.0 if (phi2 <= -0.00175) tmp = t_1; elseif (phi2 <= 55000000.0) tmp = Float64(acos(Float64(Float64(sin(phi1) * phi2) + Float64(t_0 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))) * R); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, -0.00175], t$95$1, If[LessEqual[phi2, 55000000.0], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(t$95$0 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq -0.00175:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 55000000:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + t\_0 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.00175000000000000004 or 5.5e7 < phi2 Initial program 73.5%
if -0.00175000000000000004 < phi2 < 5.5e7Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
Applied rewrites56.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R)))
(if (<= phi2 -1.15e-14)
t_0
(if (<= phi2 1.05e-47)
(*
(acos
(fma
(* (cos lambda2) (cos lambda1))
(cos phi1)
(* (* (sin lambda2) (sin lambda1)) (cos phi1))))
R)
t_0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
double tmp;
if (phi2 <= -1.15e-14) {
tmp = t_0;
} else if (phi2 <= 1.05e-47) {
tmp = acos(fma((cos(lambda2) * cos(lambda1)), cos(phi1), ((sin(lambda2) * sin(lambda1)) * cos(phi1)))) * R;
} else {
tmp = t_0;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) tmp = 0.0 if (phi2 <= -1.15e-14) tmp = t_0; elseif (phi2 <= 1.05e-47) tmp = Float64(acos(fma(Float64(cos(lambda2) * cos(lambda1)), cos(phi1), Float64(Float64(sin(lambda2) * sin(lambda1)) * cos(phi1)))) * R); else tmp = t_0; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, -1.15e-14], t$95$0, If[LessEqual[phi2, 1.05e-47], N[(N[ArcCos[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq -1.15 \cdot 10^{-14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 1.05 \cdot 10^{-47}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \lambda_1, \cos \phi_1, \left(\sin \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -1.14999999999999999e-14 or 1.05e-47 < phi2 Initial program 73.5%
if -1.14999999999999999e-14 < phi2 < 1.05e-47Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
lift-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
cos-diff-revN/A
distribute-rgt-inN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-cos.f6453.1
Applied rewrites53.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -6.7e-6)
(*
(acos
(fma (cos lambda1) (* (cos phi2) (cos phi1)) (* (sin phi2) (sin phi1))))
R)
(*
(acos
(fma (cos lambda2) (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2))))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -6.7e-6) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), (sin(phi2) * sin(phi1)))) * R;
} else {
tmp = acos(fma(cos(lambda2), (cos(phi1) * cos(phi2)), (sin(phi1) * sin(phi2)))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -6.7e-6) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), Float64(sin(phi2) * sin(phi1)))) * R); else tmp = Float64(acos(fma(cos(lambda2), Float64(cos(phi1) * cos(phi2)), Float64(sin(phi1) * sin(phi2)))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -6.7e-6], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -6.7 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2, \cos \phi_1 \cdot \cos \phi_2, \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -6.7e-6Initial program 73.5%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6453.7
Applied rewrites53.7%
if -6.7e-6 < lambda1 Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites94.2%
Taylor expanded in lambda1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f6452.5
Applied rewrites52.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (sin phi1))))
(if (<= lambda1 -6.7e-6)
(* (acos (fma (cos lambda1) (* (cos phi2) (cos phi1)) t_0)) R)
(* (acos (fma (* (cos lambda2) (cos phi2)) (cos phi1) t_0)) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * sin(phi1);
double tmp;
if (lambda1 <= -6.7e-6) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), t_0)) * R;
} else {
tmp = acos(fma((cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * sin(phi1)) tmp = 0.0 if (lambda1 <= -6.7e-6) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), t_0)) * R); else tmp = Float64(acos(fma(Float64(cos(lambda2) * cos(phi2)), cos(phi1), t_0)) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -6.7e-6], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -6.7 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, t\_0\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_2 \cdot \cos \phi_2, \cos \phi_1, t\_0\right)\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -6.7e-6Initial program 73.5%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6453.7
Applied rewrites53.7%
if -6.7e-6 < lambda1 Initial program 73.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6452.5
Applied rewrites52.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 73.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(sin phi2)
(sin phi1)
(* (* (cos (- lambda1 lambda2)) (cos phi2)) (cos phi1))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(sin(phi2), sin(phi1), ((cos((lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(sin(phi2), sin(phi1), Float64(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2)) * cos(phi1)))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right)\right) \cdot R
\end{array}
Initial program 73.5%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 1.9e-5)
(*
(acos
(fma (cos lambda1) (* (cos phi2) (cos phi1)) (* (sin phi2) (sin phi1))))
R)
(* (acos (* (cos (* (- (/ lambda1 lambda2) 1.0) lambda2)) (cos phi1))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 1.9e-5) {
tmp = acos(fma(cos(lambda1), (cos(phi2) * cos(phi1)), (sin(phi2) * sin(phi1)))) * R;
} else {
tmp = acos((cos((((lambda1 / lambda2) - 1.0) * lambda2)) * cos(phi1))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 1.9e-5) tmp = Float64(acos(fma(cos(lambda1), Float64(cos(phi2) * cos(phi1)), Float64(sin(phi2) * sin(phi1)))) * R); else tmp = Float64(acos(Float64(cos(Float64(Float64(Float64(lambda1 / lambda2) - 1.0) * lambda2)) * cos(phi1))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 1.9e-5], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[N[(N[(N[(lambda1 / lambda2), $MachinePrecision] - 1.0), $MachinePrecision] * lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;\cos^{-1} \left(\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2 \cdot \cos \phi_1, \sin \phi_2 \cdot \sin \phi_1\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \left(\left(\frac{\lambda_1}{\lambda_2} - 1\right) \cdot \lambda_2\right) \cdot \cos \phi_1\right) \cdot R\\
\end{array}
\end{array}
if lambda2 < 1.9000000000000001e-5Initial program 73.5%
Taylor expanded in lambda2 around 0
lower-fma.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6453.7
Applied rewrites53.7%
if 1.9000000000000001e-5 < lambda2 Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6434.8
Applied rewrites34.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -530000000000.0)
(* (acos (+ t_2 (* t_0 (fma lambda2 lambda1 1.0)))) R)
(if (<= phi2 2.45)
(*
(acos
(+
(*
(sin phi1)
(*
(fma
(-
(*
(fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
(* phi2 phi2))
0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))
(* t_0 t_1)))
R)
(* (acos (+ t_2 (* (cos phi2) t_1))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -530000000000.0) {
tmp = acos((t_2 + (t_0 * fma(lambda2, lambda1, 1.0)))) * R;
} else if (phi2 <= 2.45) {
tmp = acos(((sin(phi1) * (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2)) + (t_0 * t_1))) * R;
} else {
tmp = acos((t_2 + (cos(phi2) * t_1))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -530000000000.0) tmp = Float64(acos(Float64(t_2 + Float64(t_0 * fma(lambda2, lambda1, 1.0)))) * R); elseif (phi2 <= 2.45) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)) + Float64(t_0 * t_1))) * R); else tmp = Float64(acos(Float64(t_2 + Float64(cos(phi2) * t_1))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -530000000000.0], N[(N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[(lambda2 * lambda1 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 2.45], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -530000000000:\\
\;\;\;\;\cos^{-1} \left(t\_2 + t\_0 \cdot \mathsf{fma}\left(\lambda_2, \lambda_1, 1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 2.45:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2\right) + t\_0 \cdot t\_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_2 + \cos \phi_2 \cdot t\_1\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -5.3e11Initial program 73.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6446.6
Applied rewrites46.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6423.1
Applied rewrites23.1%
if -5.3e11 < phi2 < 2.4500000000000002Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites35.5%
if 2.4500000000000002 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
lift-cos.f6442.5
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -2.1)
(*
(acos (+ t_1 (* (* (cos phi1) (cos phi2)) (fma lambda2 lambda1 1.0))))
R)
(if (<= phi2 0.44)
(*
(acos
(+
t_1
(*
(*
(cos phi1)
(fma
(-
(*
(fma (* phi2 phi2) -0.001388888888888889 0.041666666666666664)
(* phi2 phi2))
0.5)
(* phi2 phi2)
1.0))
t_0)))
R)
(* (acos (+ t_1 (* (cos phi2) t_0))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -2.1) {
tmp = acos((t_1 + ((cos(phi1) * cos(phi2)) * fma(lambda2, lambda1, 1.0)))) * R;
} else if (phi2 <= 0.44) {
tmp = acos((t_1 + ((cos(phi1) * fma(((fma((phi2 * phi2), -0.001388888888888889, 0.041666666666666664) * (phi2 * phi2)) - 0.5), (phi2 * phi2), 1.0)) * t_0))) * R;
} else {
tmp = acos((t_1 + (cos(phi2) * t_0))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -2.1) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * fma(lambda2, lambda1, 1.0)))) * R); elseif (phi2 <= 0.44) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.001388888888888889, 0.041666666666666664) * Float64(phi2 * phi2)) - 0.5), Float64(phi2 * phi2), 1.0)) * t_0))) * R); else tmp = Float64(acos(Float64(t_1 + Float64(cos(phi2) * t_0))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.1], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(lambda2 * lambda1 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 0.44], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.1:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\lambda_2, \lambda_1, 1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 0.44:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot t\_0\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -2.10000000000000009Initial program 73.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6446.6
Applied rewrites46.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6423.1
Applied rewrites23.1%
if -2.10000000000000009 < phi2 < 0.440000000000000002Initial program 73.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.2
Applied rewrites34.2%
if 0.440000000000000002 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
lift-cos.f6442.5
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -720000000000.0)
(* (acos (+ t_2 (* t_0 (fma lambda2 lambda1 1.0)))) R)
(if (<= phi2 2.4)
(*
(acos
(+
(*
(sin phi1)
(*
(fma
(- (* (* phi2 phi2) 0.008333333333333333) 0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))
(* t_0 t_1)))
R)
(* (acos (+ t_2 (* (cos phi2) t_1))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -720000000000.0) {
tmp = acos((t_2 + (t_0 * fma(lambda2, lambda1, 1.0)))) * R;
} else if (phi2 <= 2.4) {
tmp = acos(((sin(phi1) * (fma((((phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2)) + (t_0 * t_1))) * R;
} else {
tmp = acos((t_2 + (cos(phi2) * t_1))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -720000000000.0) tmp = Float64(acos(Float64(t_2 + Float64(t_0 * fma(lambda2, lambda1, 1.0)))) * R); elseif (phi2 <= 2.4) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(Float64(Float64(phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)) + Float64(t_0 * t_1))) * R); else tmp = Float64(acos(Float64(t_2 + Float64(cos(phi2) * t_1))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -720000000000.0], N[(N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[(lambda2 * lambda1 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 2.4], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -720000000000:\\
\;\;\;\;\cos^{-1} \left(t\_2 + t\_0 \cdot \mathsf{fma}\left(\lambda_2, \lambda_1, 1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 2.4:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2\right) + t\_0 \cdot t\_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_2 + \cos \phi_2 \cdot t\_1\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -7.2e11Initial program 73.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6446.6
Applied rewrites46.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6423.1
Applied rewrites23.1%
if -7.2e11 < phi2 < 2.39999999999999991Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6436.1
Applied rewrites36.1%
if 2.39999999999999991 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
lift-cos.f6442.5
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -2.1)
(*
(acos (+ t_1 (* (* (cos phi1) (cos phi2)) (fma lambda2 lambda1 1.0))))
R)
(if (<= phi2 0.41)
(*
(acos
(+
t_1
(*
(*
(cos phi1)
(fma
(- (* (* phi2 phi2) 0.041666666666666664) 0.5)
(* phi2 phi2)
1.0))
t_0)))
R)
(* (acos (+ t_1 (* (cos phi2) t_0))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -2.1) {
tmp = acos((t_1 + ((cos(phi1) * cos(phi2)) * fma(lambda2, lambda1, 1.0)))) * R;
} else if (phi2 <= 0.41) {
tmp = acos((t_1 + ((cos(phi1) * fma((((phi2 * phi2) * 0.041666666666666664) - 0.5), (phi2 * phi2), 1.0)) * t_0))) * R;
} else {
tmp = acos((t_1 + (cos(phi2) * t_0))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -2.1) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * fma(lambda2, lambda1, 1.0)))) * R); elseif (phi2 <= 0.41) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * fma(Float64(Float64(Float64(phi2 * phi2) * 0.041666666666666664) - 0.5), Float64(phi2 * phi2), 1.0)) * t_0))) * R); else tmp = Float64(acos(Float64(t_1 + Float64(cos(phi2) * t_0))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.1], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(lambda2 * lambda1 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 0.41], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.1:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\lambda_2, \lambda_1, 1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 0.41:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.041666666666666664 - 0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot t\_0\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -2.10000000000000009Initial program 73.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6446.6
Applied rewrites46.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6423.1
Applied rewrites23.1%
if -2.10000000000000009 < phi2 < 0.409999999999999976Initial program 73.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.2
Applied rewrites34.2%
if 0.409999999999999976 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
lift-cos.f6442.5
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -2.1)
(*
(acos (+ t_1 (* (* (cos phi1) (cos phi2)) (fma lambda2 lambda1 1.0))))
R)
(if (<= phi2 0.4)
(*
(acos
(+
(* (sin phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(*
(cos phi1)
(fma
(- (* (* phi2 phi2) 0.041666666666666664) 0.5)
(* phi2 phi2)
1.0))
t_0)))
R)
(* (acos (+ t_1 (* (cos phi2) t_0))) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -2.1) {
tmp = acos((t_1 + ((cos(phi1) * cos(phi2)) * fma(lambda2, lambda1, 1.0)))) * R;
} else if (phi2 <= 0.4) {
tmp = acos(((sin(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) + ((cos(phi1) * fma((((phi2 * phi2) * 0.041666666666666664) - 0.5), (phi2 * phi2), 1.0)) * t_0))) * R;
} else {
tmp = acos((t_1 + (cos(phi2) * t_0))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -2.1) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * fma(lambda2, lambda1, 1.0)))) * R); elseif (phi2 <= 0.4) tmp = Float64(acos(Float64(Float64(sin(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) + Float64(Float64(cos(phi1) * fma(Float64(Float64(Float64(phi2 * phi2) * 0.041666666666666664) - 0.5), Float64(phi2 * phi2), 1.0)) * t_0))) * R); else tmp = Float64(acos(Float64(t_1 + Float64(cos(phi2) * t_0))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.1], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(lambda2 * lambda1 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 0.4], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.1:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\lambda_2, \lambda_1, 1\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 0.4:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) + \left(\cos \phi_1 \cdot \mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.041666666666666664 - 0.5, \phi_2 \cdot \phi_2, 1\right)\right) \cdot t\_0\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right) \cdot R\\
\end{array}
\end{array}
if phi2 < -2.10000000000000009Initial program 73.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6446.6
Applied rewrites46.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6423.1
Applied rewrites23.1%
if -2.10000000000000009 < phi2 < 0.40000000000000002Initial program 73.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.2
Applied rewrites34.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6434.2
Applied rewrites34.2%
if 0.40000000000000002 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
lift-cos.f6442.5
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 1.4e-6)
(* (acos (* t_0 (cos phi1))) R)
(* (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi2) t_0))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.4e-6) {
tmp = acos((t_0 * cos(phi1))) * R;
} else {
tmp = acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * t_0))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
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 (phi2 <= 1.4d-6) then
tmp = acos((t_0 * cos(phi1))) * r
else
tmp = acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * t_0))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.4e-6) {
tmp = Math.acos((t_0 * Math.cos(phi1))) * R;
} else {
tmp = Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * t_0))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 1.4e-6: tmp = math.acos((t_0 * math.cos(phi1))) * R else: tmp = math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * t_0))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 1.4e-6) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); else tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * t_0))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 1.4e-6) tmp = acos((t_0 * cos(phi1))) * R; else tmp = acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * t_0))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 1.4e-6], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t\_0\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 1.39999999999999994e-6Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
if 1.39999999999999994e-6 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
lift-cos.f6442.5
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 1.4e-6)
(* (acos (* t_0 (cos phi1))) R)
(* (acos (* t_0 (cos phi2))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.4e-6) {
tmp = acos((t_0 * cos(phi1))) * R;
} else {
tmp = acos((t_0 * cos(phi2))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
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 (phi2 <= 1.4d-6) then
tmp = acos((t_0 * cos(phi1))) * r
else
tmp = acos((t_0 * cos(phi2))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.4e-6) {
tmp = Math.acos((t_0 * Math.cos(phi1))) * R;
} else {
tmp = Math.acos((t_0 * Math.cos(phi2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 1.4e-6: tmp = math.acos((t_0 * math.cos(phi1))) * R else: tmp = math.acos((t_0 * math.cos(phi2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 1.4e-6) tmp = Float64(acos(Float64(t_0 * cos(phi1))) * R); else tmp = Float64(acos(Float64(t_0 * cos(phi2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 1.4e-6) tmp = acos((t_0 * cos(phi1))) * R; else tmp = acos((t_0 * cos(phi2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 1.4e-6], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 1.39999999999999994e-6Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
if 1.39999999999999994e-6 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -1.02e-5) (* (acos (* (cos lambda1) (cos phi1))) R) (* (acos (* (cos lambda2) (cos phi1))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.02e-5) {
tmp = acos((cos(lambda1) * cos(phi1))) * R;
} else {
tmp = acos((cos(lambda2) * cos(phi1))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
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 <= (-1.02d-5)) then
tmp = acos((cos(lambda1) * cos(phi1))) * r
else
tmp = acos((cos(lambda2) * cos(phi1))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.02e-5) {
tmp = Math.acos((Math.cos(lambda1) * Math.cos(phi1))) * R;
} else {
tmp = Math.acos((Math.cos(lambda2) * Math.cos(phi1))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -1.02e-5: tmp = math.acos((math.cos(lambda1) * math.cos(phi1))) * R else: tmp = math.acos((math.cos(lambda2) * math.cos(phi1))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -1.02e-5) tmp = Float64(acos(Float64(cos(lambda1) * cos(phi1))) * R); else tmp = Float64(acos(Float64(cos(lambda2) * cos(phi1))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -1.02e-5) tmp = acos((cos(lambda1) * cos(phi1))) * R; else tmp = acos((cos(lambda2) * cos(phi1))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1.02e-5], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.02 \cdot 10^{-5}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \cos \phi_1\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -1.0200000000000001e-5Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6431.4
Applied rewrites31.4%
if -1.0200000000000001e-5 < lambda1 Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6430.6
Applied rewrites30.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (* (cos (- lambda1 lambda2)) (cos phi1))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos((cos((lambda1 - lambda2)) * cos(phi1))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos((cos((lambda1 - lambda2)) * cos(phi1))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos((Math.cos((lambda1 - lambda2)) * Math.cos(phi1))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos((math.cos((lambda1 - lambda2)) * math.cos(phi1))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(cos(Float64(lambda1 - lambda2)) * cos(phi1))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos((cos((lambda1 - lambda2)) * cos(phi1))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_1\right) \cdot R
\end{array}
Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -1.1e-16) (* (acos (* (cos lambda1) (cos phi1))) R) (* (acos (* (cos (- lambda1 lambda2)) (fma (* phi1 phi1) -0.5 1.0))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.1e-16) {
tmp = acos((cos(lambda1) * cos(phi1))) * R;
} else {
tmp = acos((cos((lambda1 - lambda2)) * fma((phi1 * phi1), -0.5, 1.0))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -1.1e-16) tmp = Float64(acos(Float64(cos(lambda1) * cos(phi1))) * R); else tmp = Float64(acos(Float64(cos(Float64(lambda1 - lambda2)) * fma(Float64(phi1 * phi1), -0.5, 1.0))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -1.1e-16], N[(N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.1 \cdot 10^{-16}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -1.1e-16Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6431.4
Applied rewrites31.4%
if -1.1e-16 < phi1 Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6418.6
Applied rewrites18.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.042)
(* (acos (+ (cos (- lambda1 lambda2)) (* phi1 phi2))) R)
(*
(acos (* (sin (+ (- lambda1 lambda2) (/ PI 2.0))) (* (* phi1 phi1) -0.5)))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.042) {
tmp = acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * R;
} else {
tmp = acos((sin(((lambda1 - lambda2) + (((double) M_PI) / 2.0))) * ((phi1 * phi1) * -0.5))) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.042) {
tmp = Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * phi2))) * R;
} else {
tmp = Math.acos((Math.sin(((lambda1 - lambda2) + (Math.PI / 2.0))) * ((phi1 * phi1) * -0.5))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.042: tmp = math.acos((math.cos((lambda1 - lambda2)) + (phi1 * phi2))) * R else: tmp = math.acos((math.sin(((lambda1 - lambda2) + (math.pi / 2.0))) * ((phi1 * phi1) * -0.5))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.042) tmp = Float64(acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * phi2))) * R); else tmp = Float64(acos(Float64(sin(Float64(Float64(lambda1 - lambda2) + Float64(pi / 2.0))) * Float64(Float64(phi1 * phi1) * -0.5))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.042) tmp = acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * R; else tmp = acos((sin(((lambda1 - lambda2) + (pi / 2.0))) * ((phi1 * phi1) * -0.5))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.042], N[(N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.042:\\
\;\;\;\;\cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\sin \left(\left(\lambda_1 - \lambda_2\right) + \frac{\pi}{2}\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot -0.5\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 0.0420000000000000026Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
cos-diff-revN/A
cos-neg-revN/A
lift-neg.f64N/A
sin-+PI/2N/A
lift-neg.f64N/A
Applied rewrites36.0%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lower-*.f6418.4
Applied rewrites18.4%
if 0.0420000000000000026 < phi2 Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6418.6
Applied rewrites18.6%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f649.6
Applied rewrites9.6%
lift--.f64N/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift-PI.f649.6
Applied rewrites9.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 0.042)
(* (acos (+ t_0 (* phi1 phi2))) R)
(* (acos (* t_0 (* (* phi1 phi1) -0.5))) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.042) {
tmp = acos((t_0 + (phi1 * phi2))) * R;
} else {
tmp = acos((t_0 * ((phi1 * phi1) * -0.5))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
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 (phi2 <= 0.042d0) then
tmp = acos((t_0 + (phi1 * phi2))) * r
else
tmp = acos((t_0 * ((phi1 * phi1) * (-0.5d0)))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.042) {
tmp = Math.acos((t_0 + (phi1 * phi2))) * R;
} else {
tmp = Math.acos((t_0 * ((phi1 * phi1) * -0.5))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 0.042: tmp = math.acos((t_0 + (phi1 * phi2))) * R else: tmp = math.acos((t_0 * ((phi1 * phi1) * -0.5))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.042) tmp = Float64(acos(Float64(t_0 + Float64(phi1 * phi2))) * R); else tmp = Float64(acos(Float64(t_0 * Float64(Float64(phi1 * phi1) * -0.5))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 0.042) tmp = acos((t_0 + (phi1 * phi2))) * R; else tmp = acos((t_0 * ((phi1 * phi1) * -0.5))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.042], N[(N[ArcCos[N[(t$95$0 + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(t$95$0 * N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 0.042:\\
\;\;\;\;\cos^{-1} \left(t\_0 + \phi_1 \cdot \phi_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t\_0 \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot -0.5\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 0.0420000000000000026Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
cos-diff-revN/A
cos-neg-revN/A
lift-neg.f64N/A
sin-+PI/2N/A
lift-neg.f64N/A
Applied rewrites36.0%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lower-*.f6418.4
Applied rewrites18.4%
if 0.0420000000000000026 < phi2 Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6418.6
Applied rewrites18.6%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f649.6
Applied rewrites9.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 0.042) (* (acos (+ (cos (- lambda1 lambda2)) (* phi1 phi2))) R) (* (acos (* (cos lambda2) (* (* phi1 phi1) -0.5))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.042) {
tmp = acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * R;
} else {
tmp = acos((cos(lambda2) * ((phi1 * phi1) * -0.5))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 0.042d0) then
tmp = acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * r
else
tmp = acos((cos(lambda2) * ((phi1 * phi1) * (-0.5d0)))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.042) {
tmp = Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * phi2))) * R;
} else {
tmp = Math.acos((Math.cos(lambda2) * ((phi1 * phi1) * -0.5))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.042: tmp = math.acos((math.cos((lambda1 - lambda2)) + (phi1 * phi2))) * R else: tmp = math.acos((math.cos(lambda2) * ((phi1 * phi1) * -0.5))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.042) tmp = Float64(acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * phi2))) * R); else tmp = Float64(acos(Float64(cos(lambda2) * Float64(Float64(phi1 * phi1) * -0.5))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.042) tmp = acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * R; else tmp = acos((cos(lambda2) * ((phi1 * phi1) * -0.5))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.042], N[(N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] * N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.042:\\
\;\;\;\;\cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \lambda_2 \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot -0.5\right)\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 0.0420000000000000026Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
cos-diff-revN/A
cos-neg-revN/A
lift-neg.f64N/A
sin-+PI/2N/A
lift-neg.f64N/A
Applied rewrites36.0%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lower-*.f6418.4
Applied rewrites18.4%
if 0.0420000000000000026 < phi2 Initial program 73.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6418.6
Applied rewrites18.6%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f649.6
Applied rewrites9.6%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f649.6
Applied rewrites9.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (acos (+ (cos (- lambda1 lambda2)) (* phi1 phi2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * R;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * phi2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos((math.cos((lambda1 - lambda2)) + (phi1 * phi2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * phi2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos((cos((lambda1 - lambda2)) + (phi1 * phi2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right) \cdot R
\end{array}
Initial program 73.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6494.2
Applied rewrites94.2%
lift-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6494.2
Applied rewrites94.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
cos-diff-revN/A
cos-neg-revN/A
lift-neg.f64N/A
sin-+PI/2N/A
lift-neg.f64N/A
Applied rewrites36.0%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lower-*.f6418.4
Applied rewrites18.4%
herbie shell --seed 2025128
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Spherical law of cosines"
:precision binary64
(* (acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))) R))