
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))) (* R (sqrt (+ (* t_0 t_0) (* (- phi1 phi2) (- phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0));
return R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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
t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0d0))
code = r * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0));
return R * Math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0)) return R * math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0))) return Float64(R * sqrt(Float64(Float64(t_0 * t_0) + Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)); tmp = R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t\_0 \cdot t\_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\end{array}
\end{array}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))) (* R (sqrt (+ (* t_0 t_0) (* (- phi1 phi2) (- phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0));
return R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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
t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0d0))
code = r * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0));
return R * Math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0)) return R * math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0))) return Float64(R * sqrt(Float64(Float64(t_0 * t_0) + Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)); tmp = R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t\_0 \cdot t\_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(hypot
(- phi2 phi1)
(fma
(* (- lambda1 lambda2) (cos (* -0.5 phi2)))
(cos (* 0.5 phi1))
(* (* (- lambda1 lambda2) (sin (* 0.5 phi2))) (sin (* -0.5 phi1)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), fma(((lambda1 - lambda2) * cos((-0.5 * phi2))), cos((0.5 * phi1)), (((lambda1 - lambda2) * sin((0.5 * phi2))) * sin((-0.5 * phi1))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), fma(Float64(Float64(lambda1 - lambda2) * cos(Float64(-0.5 * phi2))), cos(Float64(0.5 * phi1)), Float64(Float64(Float64(lambda1 - lambda2) * sin(Float64(0.5 * phi2))) * sin(Float64(-0.5 * phi1))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] + N[(N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(-0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \mathsf{fma}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(-0.5 \cdot \phi_2\right), \cos \left(0.5 \cdot \phi_1\right), \left(\left(\lambda_1 - \lambda_2\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right) \cdot \sin \left(-0.5 \cdot \phi_1\right)\right)\right) \cdot R
\end{array}
Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
sin-+PI/2-revN/A
cos-neg-revN/A
cos-neg-revN/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
+-commutativeN/A
add-flipN/A
div-subN/A
cos-diffN/A
lower-fma.f64N/A
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
distribute-lft-inN/A
lower-fma.f64N/A
Applied rewrites99.9%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(hypot
(- phi2 phi1)
(*
(fma
(cos (* phi2 0.5))
(cos (/ phi1 -2.0))
(* (sin (* phi2 0.5)) (sin (/ phi1 -2.0))))
(- lambda1 lambda2)))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), (fma(cos((phi2 * 0.5)), cos((phi1 / -2.0)), (sin((phi2 * 0.5)) * sin((phi1 / -2.0)))) * (lambda1 - lambda2))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), Float64(fma(cos(Float64(phi2 * 0.5)), cos(Float64(phi1 / -2.0)), Float64(sin(Float64(phi2 * 0.5)) * sin(Float64(phi1 / -2.0)))) * Float64(lambda1 - lambda2))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 / -2.0), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 / -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \mathsf{fma}\left(\cos \left(\phi_2 \cdot 0.5\right), \cos \left(\frac{\phi_1}{-2}\right), \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\frac{\phi_1}{-2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
sin-+PI/2-revN/A
cos-neg-revN/A
cos-neg-revN/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
+-commutativeN/A
add-flipN/A
div-subN/A
cos-diffN/A
lower-fma.f64N/A
Applied rewrites99.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(hypot
(- phi2 phi1)
(*
(-
(* (cos (* phi2 0.5)) (cos (* phi1 0.5)))
(* (sin (* phi2 0.5)) (sin (* phi1 0.5))))
(- lambda1 lambda2)))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), (((cos((phi2 * 0.5)) * cos((phi1 * 0.5))) - (sin((phi2 * 0.5)) * sin((phi1 * 0.5)))) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi2 - phi1), (((Math.cos((phi2 * 0.5)) * Math.cos((phi1 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.sin((phi1 * 0.5)))) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi2 - phi1), (((math.cos((phi2 * 0.5)) * math.cos((phi1 * 0.5))) - (math.sin((phi2 * 0.5)) * math.sin((phi1 * 0.5)))) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), Float64(Float64(Float64(cos(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5)))) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi2 - phi1), (((cos((phi2 * 0.5)) * cos((phi1 * 0.5))) - (sin((phi2 * 0.5)) * sin((phi1 * 0.5)))) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
sin-+PI/2-revN/A
cos-neg-revN/A
cos-neg-revN/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
div-addN/A
+-commutativeN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= (- lambda1 lambda2) -1e+254)
(*
(hypot
phi2
(*
(fma
(cos (* phi2 0.5))
(cos (/ phi1 -2.0))
(* (sin (* phi2 0.5)) (sin (/ phi1 -2.0))))
(- lambda1 lambda2)))
R)
(*
(hypot (- phi2 phi1) (* (cos (* (+ phi2 phi1) -0.5)) (- lambda1 lambda2)))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 - lambda2) <= -1e+254) {
tmp = hypot(phi2, (fma(cos((phi2 * 0.5)), cos((phi1 / -2.0)), (sin((phi2 * 0.5)) * sin((phi1 / -2.0)))) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1e+254) tmp = Float64(hypot(phi2, Float64(fma(cos(Float64(phi2 * 0.5)), cos(Float64(phi1 / -2.0)), Float64(sin(Float64(phi2 * 0.5)) * sin(Float64(phi1 / -2.0)))) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(Float64(phi2 + phi1) * -0.5)) * Float64(lambda1 - lambda2))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+254], N[(N[Sqrt[phi2 ^ 2 + N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 / -2.0), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 / -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+254}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2, \mathsf{fma}\left(\cos \left(\phi_2 \cdot 0.5\right), \cos \left(\frac{\phi_1}{-2}\right), \sin \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\frac{\phi_1}{-2}\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(\left(\phi_2 + \phi_1\right) \cdot -0.5\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -9.9999999999999994e253Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
sin-+PI/2-revN/A
cos-neg-revN/A
cos-neg-revN/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
+-commutativeN/A
add-flipN/A
div-subN/A
cos-diffN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in phi1 around 0
Applied rewrites79.7%
if -9.9999999999999994e253 < (-.f64 lambda1 lambda2) Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -5.2e+152)
(*
(hypot
(- phi2 phi1)
(*
lambda1
(fma
(cos (* -0.5 phi1))
(cos (* 0.5 phi2))
(* (sin (* -0.5 phi1)) (sin (* 0.5 phi2))))))
R)
(*
(hypot (- phi2 phi1) (* (cos (* (+ phi2 phi1) -0.5)) (- lambda1 lambda2)))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -5.2e+152) {
tmp = hypot((phi2 - phi1), (lambda1 * fma(cos((-0.5 * phi1)), cos((0.5 * phi2)), (sin((-0.5 * phi1)) * sin((0.5 * phi2)))))) * R;
} else {
tmp = hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -5.2e+152) tmp = Float64(hypot(Float64(phi2 - phi1), Float64(lambda1 * fma(cos(Float64(-0.5 * phi1)), cos(Float64(0.5 * phi2)), Float64(sin(Float64(-0.5 * phi1)) * sin(Float64(0.5 * phi2)))))) * R); else tmp = Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(Float64(phi2 + phi1) * -0.5)) * Float64(lambda1 - lambda2))) * R); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -5.2e+152], N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(lambda1 * N[(N[Cos[N[(-0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(-0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -5.2 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2 - \phi_1, \lambda_1 \cdot \mathsf{fma}\left(\cos \left(-0.5 \cdot \phi_1\right), \cos \left(0.5 \cdot \phi_2\right), \sin \left(-0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(\left(\phi_2 + \phi_1\right) \cdot -0.5\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if lambda1 < -5.2000000000000001e152Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
sin-+PI/2-revN/A
cos-neg-revN/A
cos-neg-revN/A
distribute-neg-frac2N/A
distribute-frac-negN/A
frac-2negN/A
+-commutativeN/A
add-flipN/A
div-subN/A
cos-diffN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6480.0
Applied rewrites80.0%
if -5.2000000000000001e152 < lambda1 Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -1.76e+16) (* (hypot (- phi2 phi1) (* (cos (* -0.5 phi1)) (- lambda1 lambda2))) R) (* (hypot (- phi2 phi1) (* (cos (* -0.5 phi2)) (- lambda1 lambda2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.76e+16) {
tmp = hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot((phi2 - phi1), (cos((-0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.76e+16) {
tmp = Math.hypot((phi2 - phi1), (Math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = Math.hypot((phi2 - phi1), (Math.cos((-0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -1.76e+16: tmp = math.hypot((phi2 - phi1), (math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R else: tmp = math.hypot((phi2 - phi1), (math.cos((-0.5 * phi2)) * (lambda1 - lambda2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -1.76e+16) tmp = Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(-0.5 * phi1)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(-0.5 * phi2)) * Float64(lambda1 - lambda2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -1.76e+16) tmp = hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R; else tmp = hypot((phi2 - phi1), (cos((-0.5 * phi2)) * (lambda1 - lambda2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -1.76e+16], N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(-0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.76 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(-0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(-0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -1.76e16Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
Taylor expanded in phi1 around inf
lower-*.f6491.0
Applied rewrites91.0%
if -1.76e16 < phi1 Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
Taylor expanded in phi1 around 0
lower-*.f6490.7
Applied rewrites90.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (hypot (- phi2 phi1) (* (cos (* (+ phi2 phi1) -0.5)) (- lambda1 lambda2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi2 - phi1), (Math.cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi2 - phi1), (math.cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(Float64(phi2 + phi1) * -0.5)) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(\left(\phi_2 + \phi_1\right) \cdot -0.5\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (hypot (- phi2 phi1) (* (cos (* -0.5 phi1)) (- lambda1 lambda2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi2 - phi1), (Math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi2 - phi1), (math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(-0.5 * phi1)) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(-0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(-0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
Taylor expanded in phi1 around inf
lower-*.f6491.0
Applied rewrites91.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sqrt (+ 0.5 (* 0.5 (cos (* -1.0 (+ phi1 phi2))))))))
(if (<= lambda2 -5e+77)
(* (* -1.0 (* lambda1 t_0)) R)
(if (<= lambda2 2.9e+93)
(* R (+ phi2 (* -1.0 phi1)))
(* (* lambda2 t_0) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((0.5 + (0.5 * cos((-1.0 * (phi1 + phi2))))));
double tmp;
if (lambda2 <= -5e+77) {
tmp = (-1.0 * (lambda1 * t_0)) * R;
} else if (lambda2 <= 2.9e+93) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = (lambda2 * 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 = sqrt((0.5d0 + (0.5d0 * cos(((-1.0d0) * (phi1 + phi2))))))
if (lambda2 <= (-5d+77)) then
tmp = ((-1.0d0) * (lambda1 * t_0)) * r
else if (lambda2 <= 2.9d+93) then
tmp = r * (phi2 + ((-1.0d0) * phi1))
else
tmp = (lambda2 * 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.sqrt((0.5 + (0.5 * Math.cos((-1.0 * (phi1 + phi2))))));
double tmp;
if (lambda2 <= -5e+77) {
tmp = (-1.0 * (lambda1 * t_0)) * R;
} else if (lambda2 <= 2.9e+93) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = (lambda2 * t_0) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((0.5 + (0.5 * math.cos((-1.0 * (phi1 + phi2)))))) tmp = 0 if lambda2 <= -5e+77: tmp = (-1.0 * (lambda1 * t_0)) * R elif lambda2 <= 2.9e+93: tmp = R * (phi2 + (-1.0 * phi1)) else: tmp = (lambda2 * t_0) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(0.5 + Float64(0.5 * cos(Float64(-1.0 * Float64(phi1 + phi2)))))) tmp = 0.0 if (lambda2 <= -5e+77) tmp = Float64(Float64(-1.0 * Float64(lambda1 * t_0)) * R); elseif (lambda2 <= 2.9e+93) tmp = Float64(R * Float64(phi2 + Float64(-1.0 * phi1))); else tmp = Float64(Float64(lambda2 * t_0) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((0.5 + (0.5 * cos((-1.0 * (phi1 + phi2)))))); tmp = 0.0; if (lambda2 <= -5e+77) tmp = (-1.0 * (lambda1 * t_0)) * R; elseif (lambda2 <= 2.9e+93) tmp = R * (phi2 + (-1.0 * phi1)); else tmp = (lambda2 * t_0) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(0.5 + N[(0.5 * N[Cos[N[(-1.0 * N[(phi1 + phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -5e+77], N[(N[(-1.0 * N[(lambda1 * t$95$0), $MachinePrecision]), $MachinePrecision] * R), $MachinePrecision], If[LessEqual[lambda2, 2.9e+93], N[(R * N[(phi2 + N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(lambda2 * t$95$0), $MachinePrecision] * R), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{0.5 + 0.5 \cdot \cos \left(-1 \cdot \left(\phi_1 + \phi_2\right)\right)}\\
\mathbf{if}\;\lambda_2 \leq -5 \cdot 10^{+77}:\\
\;\;\;\;\left(-1 \cdot \left(\lambda_1 \cdot t\_0\right)\right) \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 2.9 \cdot 10^{+93}:\\
\;\;\;\;R \cdot \left(\phi_2 + -1 \cdot \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\lambda_2 \cdot t\_0\right) \cdot R\\
\end{array}
\end{array}
if lambda2 < -5.00000000000000004e77Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
Applied rewrites60.3%
Taylor expanded in lambda1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-+.f6416.4
Applied rewrites16.4%
if -5.00000000000000004e77 < lambda2 < 2.8999999999999998e93Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6425.6
Applied rewrites25.6%
Taylor expanded in R around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 2.8999999999999998e93 < lambda2 Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
Applied rewrites60.3%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-+.f6416.4
Applied rewrites16.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 2.9e+93) (* R (+ phi2 (* -1.0 phi1))) (* (* lambda2 (sqrt (+ 0.5 (* 0.5 (cos (* -1.0 (+ phi1 phi2))))))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.9e+93) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = (lambda2 * sqrt((0.5 + (0.5 * cos((-1.0 * (phi1 + 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) :: tmp
if (lambda2 <= 2.9d+93) then
tmp = r * (phi2 + ((-1.0d0) * phi1))
else
tmp = (lambda2 * sqrt((0.5d0 + (0.5d0 * cos(((-1.0d0) * (phi1 + phi2))))))) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.9e+93) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = (lambda2 * Math.sqrt((0.5 + (0.5 * Math.cos((-1.0 * (phi1 + phi2))))))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 2.9e+93: tmp = R * (phi2 + (-1.0 * phi1)) else: tmp = (lambda2 * math.sqrt((0.5 + (0.5 * math.cos((-1.0 * (phi1 + phi2))))))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 2.9e+93) tmp = Float64(R * Float64(phi2 + Float64(-1.0 * phi1))); else tmp = Float64(Float64(lambda2 * sqrt(Float64(0.5 + Float64(0.5 * cos(Float64(-1.0 * Float64(phi1 + phi2))))))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 2.9e+93) tmp = R * (phi2 + (-1.0 * phi1)); else tmp = (lambda2 * sqrt((0.5 + (0.5 * cos((-1.0 * (phi1 + phi2))))))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 2.9e+93], N[(R * N[(phi2 + N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(lambda2 * N[Sqrt[N[(0.5 + N[(0.5 * N[Cos[N[(-1.0 * N[(phi1 + phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 2.9 \cdot 10^{+93}:\\
\;\;\;\;R \cdot \left(\phi_2 + -1 \cdot \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\lambda_2 \cdot \sqrt{0.5 + 0.5 \cdot \cos \left(-1 \cdot \left(\phi_1 + \phi_2\right)\right)}\right) \cdot R\\
\end{array}
\end{array}
if lambda2 < 2.8999999999999998e93Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6425.6
Applied rewrites25.6%
Taylor expanded in R around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 2.8999999999999998e93 < lambda2 Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.3
Applied rewrites96.1%
Applied rewrites60.3%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-+.f6416.4
Applied rewrites16.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= R 1.12e+76) (* R (+ phi2 (* -1.0 phi1))) (* -1.0 (* phi1 (* phi2 (fma -1.0 (/ R phi1) (/ R phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1.12e+76) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = -1.0 * (phi1 * (phi2 * fma(-1.0, (R / phi1), (R / phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= 1.12e+76) tmp = Float64(R * Float64(phi2 + Float64(-1.0 * phi1))); else tmp = Float64(-1.0 * Float64(phi1 * Float64(phi2 * fma(-1.0, Float64(R / phi1), Float64(R / phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, 1.12e+76], N[(R * N[(phi2 + N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(phi1 * N[(phi2 * N[(-1.0 * N[(R / phi1), $MachinePrecision] + N[(R / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq 1.12 \cdot 10^{+76}:\\
\;\;\;\;R \cdot \left(\phi_2 + -1 \cdot \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\phi_1 \cdot \left(\phi_2 \cdot \mathsf{fma}\left(-1, \frac{R}{\phi_1}, \frac{R}{\phi_2}\right)\right)\right)\\
\end{array}
\end{array}
if R < 1.12000000000000005e76Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6425.6
Applied rewrites25.6%
Taylor expanded in R around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.12000000000000005e76 < R Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6427.6
Applied rewrites27.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= R 1e+85) (* R (+ phi2 (* -1.0 phi1))) (* -1.0 (* phi1 (+ R (/ phi2 (/ phi1 (- R))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1e+85) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = -1.0 * (phi1 * (R + (phi2 / (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 (r <= 1d+85) then
tmp = r * (phi2 + ((-1.0d0) * phi1))
else
tmp = (-1.0d0) * (phi1 * (r + (phi2 / (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 (R <= 1e+85) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = -1.0 * (phi1 * (R + (phi2 / (phi1 / -R))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if R <= 1e+85: tmp = R * (phi2 + (-1.0 * phi1)) else: tmp = -1.0 * (phi1 * (R + (phi2 / (phi1 / -R)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= 1e+85) tmp = Float64(R * Float64(phi2 + Float64(-1.0 * phi1))); else tmp = Float64(-1.0 * Float64(phi1 * Float64(R + Float64(phi2 / Float64(phi1 / Float64(-R)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (R <= 1e+85) tmp = R * (phi2 + (-1.0 * phi1)); else tmp = -1.0 * (phi1 * (R + (phi2 / (phi1 / -R)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, 1e+85], N[(R * N[(phi2 + N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(phi1 * N[(R + N[(phi2 / N[(phi1 / (-R)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq 10^{+85}:\\
\;\;\;\;R \cdot \left(\phi_2 + -1 \cdot \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\phi_1 \cdot \left(R + \frac{\phi_2}{\frac{\phi_1}{-R}}\right)\right)\\
\end{array}
\end{array}
if R < 1e85Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6425.6
Applied rewrites25.6%
Taylor expanded in R around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1e85 < R Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-flip-revN/A
lower-/.f64N/A
lower-/.f6428.7
Applied rewrites28.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= R 1e+85) (* R (+ phi2 (* -1.0 phi1))) (* -1.0 (* phi1 (fma phi2 (/ (- R) phi1) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1e+85) {
tmp = R * (phi2 + (-1.0 * phi1));
} else {
tmp = -1.0 * (phi1 * fma(phi2, (-R / phi1), R));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= 1e+85) tmp = Float64(R * Float64(phi2 + Float64(-1.0 * phi1))); else tmp = Float64(-1.0 * Float64(phi1 * fma(phi2, Float64(Float64(-R) / phi1), R))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, 1e+85], N[(R * N[(phi2 + N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(phi1 * N[(phi2 * N[((-R) / phi1), $MachinePrecision] + R), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq 10^{+85}:\\
\;\;\;\;R \cdot \left(\phi_2 + -1 \cdot \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\phi_1 \cdot \mathsf{fma}\left(\phi_2, \frac{-R}{\phi_1}, R\right)\right)\\
\end{array}
\end{array}
if R < 1e85Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6425.6
Applied rewrites25.6%
Taylor expanded in R around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1e85 < R Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-/.f32N/A
lower-unsound-/.f32N/A
lower-fma.f64N/A
lower-unsound-/.f6428.8
Applied rewrites28.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (+ phi2 (* -1.0 phi1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (phi2 + (-1.0 * phi1));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = r * (phi2 + ((-1.0d0) * phi1))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (phi2 + (-1.0 * phi1));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (phi2 + (-1.0 * phi1))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(phi2 + Float64(-1.0 * phi1))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (phi2 + (-1.0 * phi1)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(phi2 + N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(\phi_2 + -1 \cdot \phi_1\right)
\end{array}
Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
div-flipN/A
lower-unsound-/.f64N/A
mul-1-negN/A
lower-unsound-/.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6428.6
Applied rewrites28.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6425.6
Applied rewrites25.6%
Taylor expanded in R around -inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.0022) (* R (* -1.0 phi1)) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.0022) {
tmp = R * (-1.0 * phi1);
} else {
tmp = R * phi2;
}
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 (phi1 <= (-0.0022d0)) then
tmp = r * ((-1.0d0) * phi1)
else
tmp = r * phi2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.0022) {
tmp = R * (-1.0 * phi1);
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.0022: tmp = R * (-1.0 * phi1) else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.0022) tmp = Float64(R * Float64(-1.0 * phi1)); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.0022) tmp = R * (-1.0 * phi1); else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.0022], N[(R * N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.0022:\\
\;\;\;\;R \cdot \left(-1 \cdot \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi1 < -0.00220000000000000013Initial program 60.3%
Taylor expanded in phi1 around -inf
lower-*.f6417.5
Applied rewrites17.5%
if -0.00220000000000000013 < phi1 Initial program 60.3%
Taylor expanded in phi2 around inf
lower-*.f6417.3
Applied rewrites17.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -5e-312) (* (- phi2) R) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -5e-312) {
tmp = -phi2 * R;
} else {
tmp = R * phi2;
}
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 <= (-5d-312)) then
tmp = -phi2 * r
else
tmp = r * phi2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -5e-312) {
tmp = -phi2 * R;
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -5e-312: tmp = -phi2 * R else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -5e-312) tmp = Float64(Float64(-phi2) * R); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -5e-312) tmp = -phi2 * R; else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -5e-312], N[((-phi2) * R), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\left(-\phi_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi2 < -5.0000000000022e-312Initial program 60.3%
Taylor expanded in phi2 around -inf
lower-*.f64N/A
lower-*.f6418.2
Applied rewrites18.2%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6418.2
Applied rewrites18.2%
if -5.0000000000022e-312 < phi2 Initial program 60.3%
Taylor expanded in phi2 around inf
lower-*.f6417.3
Applied rewrites17.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R phi2))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi2;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = r * phi2
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi2;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * phi2
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * phi2) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * phi2; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * phi2), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \phi_2
\end{array}
Initial program 60.3%
Taylor expanded in phi2 around inf
lower-*.f6417.3
Applied rewrites17.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R phi1))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = r * phi1
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi1;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * phi1
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * phi1) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * phi1; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * phi1), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \phi_1
\end{array}
Initial program 60.3%
Taylor expanded in phi1 around inf
lower-*.f6417.8
Applied rewrites17.8%
herbie shell --seed 2025154
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Equirectangular approximation to distance on a great circle"
:precision binary64
(* R (sqrt (+ (* (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))) (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0)))) (* (- phi1 phi2) (- phi1 phi2))))))