
(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 16 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 (* R (hypot (* (- lambda1 lambda2) (cos (* (+ phi1 phi2) 0.5))) (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * hypot(((lambda1 - lambda2) * cos(((phi1 + phi2) * 0.5))), (phi1 - phi2));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.hypot(((lambda1 - lambda2) * Math.cos(((phi1 + phi2) * 0.5))), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.hypot(((lambda1 - lambda2) * math.cos(((phi1 + phi2) * 0.5))), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) * 0.5))), Float64(phi1 - phi2))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * hypot(((lambda1 - lambda2) * cos(((phi1 + phi2) * 0.5))), (phi1 - phi2)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right), \phi_1 - \phi_2\right)
\end{array}
Initial program 59.4%
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -5.2e-7) (* R (hypot (* (cos (* 0.5 phi1)) (- lambda1 lambda2)) (- phi1 phi2))) (* R (hypot (* (cos (* 0.5 phi2)) (- lambda1 lambda2)) (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -5.2e-7) {
tmp = R * hypot((cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2));
} else {
tmp = R * hypot((cos((0.5 * phi2)) * (lambda1 - lambda2)), (phi1 - phi2));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -5.2e-7) {
tmp = R * Math.hypot((Math.cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2));
} else {
tmp = R * Math.hypot((Math.cos((0.5 * phi2)) * (lambda1 - lambda2)), (phi1 - phi2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -5.2e-7: tmp = R * math.hypot((math.cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2)) else: tmp = R * math.hypot((math.cos((0.5 * phi2)) * (lambda1 - lambda2)), (phi1 - phi2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -5.2e-7) tmp = Float64(R * hypot(Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2)), Float64(phi1 - phi2))); else tmp = Float64(R * hypot(Float64(cos(Float64(0.5 * phi2)) * Float64(lambda1 - lambda2)), Float64(phi1 - phi2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -5.2e-7) tmp = R * hypot((cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2)); else tmp = R * hypot((cos((0.5 * phi2)) * (lambda1 - lambda2)), (phi1 - phi2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -5.2e-7], N[(R * N[Sqrt[N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -5.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -5.19999999999999998e-7Initial program 59.4%
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift--.f6490.3
Applied rewrites90.3%
if -5.19999999999999998e-7 < phi1 Initial program 59.4%
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift--.f6490.2
Applied rewrites90.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (hypot (* (cos (* 0.5 phi1)) (- lambda1 lambda2)) (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * hypot((cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.hypot((Math.cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.hypot((math.cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * hypot(Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2)), Float64(phi1 - phi2))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * hypot((cos((0.5 * phi1)) * (lambda1 - lambda2)), (phi1 - phi2)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \mathsf{hypot}\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)
\end{array}
Initial program 59.4%
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift--.f6490.3
Applied rewrites90.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -1.32e+151) (* R (hypot (* lambda1 (cos (* 0.5 phi1))) (- phi1 phi2))) (* R (hypot (* 1.0 (- lambda1 lambda2)) (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.32e+151) {
tmp = R * hypot((lambda1 * cos((0.5 * phi1))), (phi1 - phi2));
} else {
tmp = R * hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.32e+151) {
tmp = R * Math.hypot((lambda1 * Math.cos((0.5 * phi1))), (phi1 - phi2));
} else {
tmp = R * Math.hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -1.32e+151: tmp = R * math.hypot((lambda1 * math.cos((0.5 * phi1))), (phi1 - phi2)) else: tmp = R * math.hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -1.32e+151) tmp = Float64(R * hypot(Float64(lambda1 * cos(Float64(0.5 * phi1))), Float64(phi1 - phi2))); else tmp = Float64(R * hypot(Float64(1.0 * Float64(lambda1 - lambda2)), Float64(phi1 - phi2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -1.32e+151) tmp = R * hypot((lambda1 * cos((0.5 * phi1))), (phi1 - phi2)); else tmp = R * hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1.32e+151], N[(R * N[Sqrt[N[(lambda1 * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(1.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.32 \cdot 10^{+151}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 \cdot \cos \left(0.5 \cdot \phi_1\right), \phi_1 - \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(1 \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\
\end{array}
\end{array}
if lambda1 < -1.31999999999999992e151Initial program 59.4%
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift--.f6490.3
Applied rewrites90.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
lift-*.f6474.3
Applied rewrites74.3%
if -1.31999999999999992e151 < lambda1 Initial program 59.4%
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift--.f6490.3
Applied rewrites90.3%
Taylor expanded in phi1 around 0
Applied rewrites84.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (hypot (* 1.0 (- lambda1 lambda2)) (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * hypot(Float64(1.0 * Float64(lambda1 - lambda2)), Float64(phi1 - phi2))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * hypot((1.0 * (lambda1 - lambda2)), (phi1 - phi2)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(1.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \mathsf{hypot}\left(1 \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)
\end{array}
Initial program 59.4%
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift--.f6490.3
Applied rewrites90.3%
Taylor expanded in phi1 around 0
Applied rewrites84.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= R 1.05e+30)
(- (* R phi2) (* R phi1))
(if (<= R 3.1e+179)
(* phi1 (- (/ (* R phi2) phi1) R))
(* phi2 (* R (- 1.0 (/ phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1.05e+30) {
tmp = (R * phi2) - (R * phi1);
} else if (R <= 3.1e+179) {
tmp = phi1 * (((R * phi2) / phi1) - R);
} else {
tmp = phi2 * (R * (1.0 - (phi1 / 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 (r <= 1.05d+30) then
tmp = (r * phi2) - (r * phi1)
else if (r <= 3.1d+179) then
tmp = phi1 * (((r * phi2) / phi1) - r)
else
tmp = phi2 * (r * (1.0d0 - (phi1 / phi2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1.05e+30) {
tmp = (R * phi2) - (R * phi1);
} else if (R <= 3.1e+179) {
tmp = phi1 * (((R * phi2) / phi1) - R);
} else {
tmp = phi2 * (R * (1.0 - (phi1 / phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if R <= 1.05e+30: tmp = (R * phi2) - (R * phi1) elif R <= 3.1e+179: tmp = phi1 * (((R * phi2) / phi1) - R) else: tmp = phi2 * (R * (1.0 - (phi1 / phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= 1.05e+30) tmp = Float64(Float64(R * phi2) - Float64(R * phi1)); elseif (R <= 3.1e+179) tmp = Float64(phi1 * Float64(Float64(Float64(R * phi2) / phi1) - R)); else tmp = Float64(phi2 * Float64(R * Float64(1.0 - Float64(phi1 / phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (R <= 1.05e+30) tmp = (R * phi2) - (R * phi1); elseif (R <= 3.1e+179) tmp = phi1 * (((R * phi2) / phi1) - R); else tmp = phi2 * (R * (1.0 - (phi1 / phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, 1.05e+30], N[(N[(R * phi2), $MachinePrecision] - N[(R * phi1), $MachinePrecision]), $MachinePrecision], If[LessEqual[R, 3.1e+179], N[(phi1 * N[(N[(N[(R * phi2), $MachinePrecision] / phi1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision], N[(phi2 * N[(R * N[(1.0 - N[(phi1 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq 1.05 \cdot 10^{+30}:\\
\;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\
\mathbf{elif}\;R \leq 3.1 \cdot 10^{+179}:\\
\;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\
\mathbf{else}:\\
\;\;\;\;\phi_2 \cdot \left(R \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\
\end{array}
\end{array}
if R < 1.05e30Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi2 around 0
lower--.f64N/A
lift-*.f64N/A
lower-*.f6429.0
Applied rewrites29.0%
if 1.05e30 < R < 3.1e179Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower--.f64N/A
lift-/.f64N/A
lift-*.f6429.2
Applied rewrites29.2%
if 3.1e179 < R Initial program 59.4%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in R around 0
lower-*.f64N/A
lower--.f64N/A
lower-/.f6428.0
Applied rewrites28.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= R 1.05e+30)
(- (* R phi2) (* R phi1))
(if (<= R 3.1e+179)
(- (* phi1 (* R (- 1.0 (/ phi2 phi1)))))
(* phi2 (* R (- 1.0 (/ phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1.05e+30) {
tmp = (R * phi2) - (R * phi1);
} else if (R <= 3.1e+179) {
tmp = -(phi1 * (R * (1.0 - (phi2 / phi1))));
} else {
tmp = phi2 * (R * (1.0 - (phi1 / 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 (r <= 1.05d+30) then
tmp = (r * phi2) - (r * phi1)
else if (r <= 3.1d+179) then
tmp = -(phi1 * (r * (1.0d0 - (phi2 / phi1))))
else
tmp = phi2 * (r * (1.0d0 - (phi1 / phi2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1.05e+30) {
tmp = (R * phi2) - (R * phi1);
} else if (R <= 3.1e+179) {
tmp = -(phi1 * (R * (1.0 - (phi2 / phi1))));
} else {
tmp = phi2 * (R * (1.0 - (phi1 / phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if R <= 1.05e+30: tmp = (R * phi2) - (R * phi1) elif R <= 3.1e+179: tmp = -(phi1 * (R * (1.0 - (phi2 / phi1)))) else: tmp = phi2 * (R * (1.0 - (phi1 / phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= 1.05e+30) tmp = Float64(Float64(R * phi2) - Float64(R * phi1)); elseif (R <= 3.1e+179) tmp = Float64(-Float64(phi1 * Float64(R * Float64(1.0 - Float64(phi2 / phi1))))); else tmp = Float64(phi2 * Float64(R * Float64(1.0 - Float64(phi1 / phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (R <= 1.05e+30) tmp = (R * phi2) - (R * phi1); elseif (R <= 3.1e+179) tmp = -(phi1 * (R * (1.0 - (phi2 / phi1)))); else tmp = phi2 * (R * (1.0 - (phi1 / phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, 1.05e+30], N[(N[(R * phi2), $MachinePrecision] - N[(R * phi1), $MachinePrecision]), $MachinePrecision], If[LessEqual[R, 3.1e+179], (-N[(phi1 * N[(R * N[(1.0 - N[(phi2 / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(phi2 * N[(R * N[(1.0 - N[(phi1 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq 1.05 \cdot 10^{+30}:\\
\;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\
\mathbf{elif}\;R \leq 3.1 \cdot 10^{+179}:\\
\;\;\;\;-\phi_1 \cdot \left(R \cdot \left(1 - \frac{\phi_2}{\phi_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\phi_2 \cdot \left(R \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\
\end{array}
\end{array}
if R < 1.05e30Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi2 around 0
lower--.f64N/A
lift-*.f64N/A
lower-*.f6429.0
Applied rewrites29.0%
if 1.05e30 < R < 3.1e179Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in R around 0
lower-*.f64N/A
lower--.f64N/A
lower-/.f6427.4
Applied rewrites27.4%
if 3.1e179 < R Initial program 59.4%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in R around 0
lower-*.f64N/A
lower--.f64N/A
lower-/.f6428.0
Applied rewrites28.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= R 7.5e+58) (- (* R phi2) (* R phi1)) (- (* phi1 (* phi2 (- (/ R phi2) (/ R phi1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 7.5e+58) {
tmp = (R * phi2) - (R * phi1);
} else {
tmp = -(phi1 * (phi2 * ((R / phi2) - (R / phi1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 <= 7.5d+58) then
tmp = (r * phi2) - (r * phi1)
else
tmp = -(phi1 * (phi2 * ((r / phi2) - (r / phi1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 7.5e+58) {
tmp = (R * phi2) - (R * phi1);
} else {
tmp = -(phi1 * (phi2 * ((R / phi2) - (R / phi1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if R <= 7.5e+58: tmp = (R * phi2) - (R * phi1) else: tmp = -(phi1 * (phi2 * ((R / phi2) - (R / phi1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= 7.5e+58) tmp = Float64(Float64(R * phi2) - Float64(R * phi1)); else tmp = Float64(-Float64(phi1 * Float64(phi2 * Float64(Float64(R / phi2) - Float64(R / phi1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (R <= 7.5e+58) tmp = (R * phi2) - (R * phi1); else tmp = -(phi1 * (phi2 * ((R / phi2) - (R / phi1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, 7.5e+58], N[(N[(R * phi2), $MachinePrecision] - N[(R * phi1), $MachinePrecision]), $MachinePrecision], (-N[(phi1 * N[(phi2 * N[(N[(R / phi2), $MachinePrecision] - N[(R / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq 7.5 \cdot 10^{+58}:\\
\;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\
\mathbf{else}:\\
\;\;\;\;-\phi_1 \cdot \left(\phi_2 \cdot \left(\frac{R}{\phi_2} - \frac{R}{\phi_1}\right)\right)\\
\end{array}
\end{array}
if R < 7.5000000000000001e58Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi2 around 0
lower--.f64N/A
lift-*.f64N/A
lower-*.f6429.0
Applied rewrites29.0%
if 7.5000000000000001e58 < R Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6428.1
Applied rewrites28.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -4e-55) (- (* R (* phi1 (- 1.0 (/ phi2 phi1))))) (* phi2 (* phi1 (- (/ R phi1) (/ R phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -4e-55) {
tmp = -(R * (phi1 * (1.0 - (phi2 / phi1))));
} else {
tmp = phi2 * (phi1 * ((R / phi1) - (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 <= (-4d-55)) then
tmp = -(r * (phi1 * (1.0d0 - (phi2 / phi1))))
else
tmp = phi2 * (phi1 * ((r / phi1) - (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 <= -4e-55) {
tmp = -(R * (phi1 * (1.0 - (phi2 / phi1))));
} else {
tmp = phi2 * (phi1 * ((R / phi1) - (R / phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -4e-55: tmp = -(R * (phi1 * (1.0 - (phi2 / phi1)))) else: tmp = phi2 * (phi1 * ((R / phi1) - (R / phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -4e-55) tmp = Float64(-Float64(R * Float64(phi1 * Float64(1.0 - Float64(phi2 / phi1))))); else tmp = Float64(phi2 * Float64(phi1 * Float64(Float64(R / phi1) - Float64(R / phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -4e-55) tmp = -(R * (phi1 * (1.0 - (phi2 / phi1)))); else tmp = phi2 * (phi1 * ((R / phi1) - (R / phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -4e-55], (-N[(R * N[(phi1 * N[(1.0 - N[(phi2 / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(phi2 * N[(phi1 * N[(N[(R / phi1), $MachinePrecision] - N[(R / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -4 \cdot 10^{-55}:\\
\;\;\;\;-R \cdot \left(\phi_1 \cdot \left(1 - \frac{\phi_2}{\phi_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\phi_2 \cdot \left(\phi_1 \cdot \left(\frac{R}{\phi_1} - \frac{R}{\phi_2}\right)\right)\\
\end{array}
\end{array}
if phi1 < -3.99999999999999998e-55Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in R around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6426.9
Applied rewrites26.9%
if -3.99999999999999998e-55 < phi1 Initial program 59.4%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6428.3
Applied rewrites28.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* R (* phi2 (- 1.0 (/ phi1 phi2))))))
(if (<= phi2 -5.2e+44)
t_0
(if (<= phi2 6.2e+106) (* phi1 (- (/ (* R phi2) phi1) R)) t_0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * (phi2 * (1.0 - (phi1 / phi2)));
double tmp;
if (phi2 <= -5.2e+44) {
tmp = t_0;
} else if (phi2 <= 6.2e+106) {
tmp = phi1 * (((R * phi2) / phi1) - R);
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = r * (phi2 * (1.0d0 - (phi1 / phi2)))
if (phi2 <= (-5.2d+44)) then
tmp = t_0
else if (phi2 <= 6.2d+106) then
tmp = phi1 * (((r * phi2) / phi1) - r)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * (phi2 * (1.0 - (phi1 / phi2)));
double tmp;
if (phi2 <= -5.2e+44) {
tmp = t_0;
} else if (phi2 <= 6.2e+106) {
tmp = phi1 * (((R * phi2) / phi1) - R);
} else {
tmp = t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = R * (phi2 * (1.0 - (phi1 / phi2))) tmp = 0 if phi2 <= -5.2e+44: tmp = t_0 elif phi2 <= 6.2e+106: tmp = phi1 * (((R * phi2) / phi1) - R) else: tmp = t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * Float64(phi2 * Float64(1.0 - Float64(phi1 / phi2)))) tmp = 0.0 if (phi2 <= -5.2e+44) tmp = t_0; elseif (phi2 <= 6.2e+106) tmp = Float64(phi1 * Float64(Float64(Float64(R * phi2) / phi1) - R)); else tmp = t_0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = R * (phi2 * (1.0 - (phi1 / phi2))); tmp = 0.0; if (phi2 <= -5.2e+44) tmp = t_0; elseif (phi2 <= 6.2e+106) tmp = phi1 * (((R * phi2) / phi1) - R); else tmp = t_0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(R * N[(phi2 * N[(1.0 - N[(phi1 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -5.2e+44], t$95$0, If[LessEqual[phi2, 6.2e+106], N[(phi1 * N[(N[(N[(R * phi2), $MachinePrecision] / phi1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := R \cdot \left(\phi_2 \cdot \left(1 - \frac{\phi_1}{\phi_2}\right)\right)\\
\mathbf{if}\;\phi_2 \leq -5.2 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 6.2 \cdot 10^{+106}:\\
\;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -5.1999999999999998e44 or 6.1999999999999999e106 < phi2 Initial program 59.4%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in R around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6427.5
Applied rewrites27.5%
if -5.1999999999999998e44 < phi2 < 6.1999999999999999e106Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower--.f64N/A
lift-/.f64N/A
lift-*.f6429.2
Applied rewrites29.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= R 1.05e+30) (- (* R phi2) (* R phi1)) (* phi1 (- (/ (* R phi2) phi1) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (R <= 1.05e+30) {
tmp = (R * phi2) - (R * phi1);
} else {
tmp = 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 <= 1.05d+30) then
tmp = (r * phi2) - (r * phi1)
else
tmp = 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 <= 1.05e+30) {
tmp = (R * phi2) - (R * phi1);
} else {
tmp = phi1 * (((R * phi2) / phi1) - R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if R <= 1.05e+30: tmp = (R * phi2) - (R * phi1) else: tmp = phi1 * (((R * phi2) / phi1) - R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (R <= 1.05e+30) tmp = Float64(Float64(R * phi2) - Float64(R * phi1)); else tmp = Float64(phi1 * Float64(Float64(Float64(R * phi2) / phi1) - R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (R <= 1.05e+30) tmp = (R * phi2) - (R * phi1); else tmp = phi1 * (((R * phi2) / phi1) - R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[R, 1.05e+30], N[(N[(R * phi2), $MachinePrecision] - N[(R * phi1), $MachinePrecision]), $MachinePrecision], N[(phi1 * N[(N[(N[(R * phi2), $MachinePrecision] / phi1), $MachinePrecision] - R), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;R \leq 1.05 \cdot 10^{+30}:\\
\;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\
\mathbf{else}:\\
\;\;\;\;\phi_1 \cdot \left(\frac{R \cdot \phi_2}{\phi_1} - R\right)\\
\end{array}
\end{array}
if R < 1.05e30Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi2 around 0
lower--.f64N/A
lift-*.f64N/A
lower-*.f6429.0
Applied rewrites29.0%
if 1.05e30 < R Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower--.f64N/A
lift-/.f64N/A
lift-*.f6429.2
Applied rewrites29.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -1e-261) (- (* R phi2) (* R phi1)) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1e-261) {
tmp = (R * phi2) - (R * 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 <= (-1d-261)) then
tmp = (r * phi2) - (r * 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 <= -1e-261) {
tmp = (R * phi2) - (R * phi1);
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -1e-261: tmp = (R * phi2) - (R * phi1) else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -1e-261) tmp = Float64(Float64(R * phi2) - Float64(R * phi1)); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -1e-261) tmp = (R * phi2) - (R * phi1); else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -1e-261], N[(N[(R * phi2), $MachinePrecision] - N[(R * phi1), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1 \cdot 10^{-261}:\\
\;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi1 < -9.99999999999999984e-262Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
Taylor expanded in phi2 around 0
lower--.f64N/A
lift-*.f64N/A
lower-*.f6429.0
Applied rewrites29.0%
if -9.99999999999999984e-262 < phi1 Initial program 59.4%
Taylor expanded in phi2 around inf
lower-*.f6418.0
Applied rewrites18.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 0.31) (* R (- phi1)) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.31) {
tmp = R * -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 (phi2 <= 0.31d0) then
tmp = r * -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 (phi2 <= 0.31) {
tmp = R * -phi1;
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.31: tmp = R * -phi1 else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.31) tmp = Float64(R * Float64(-phi1)); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.31) tmp = R * -phi1; else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.31], N[(R * (-phi1)), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.31:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi2 < 0.309999999999999998Initial program 59.4%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f6417.1
Applied rewrites17.1%
if 0.309999999999999998 < phi2 Initial program 59.4%
Taylor expanded in phi2 around inf
lower-*.f6418.0
Applied rewrites18.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -4e-310) (- (* R phi2)) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -4e-310) {
tmp = -(R * phi2);
} 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 <= (-4d-310)) then
tmp = -(r * phi2)
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 <= -4e-310) {
tmp = -(R * phi2);
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -4e-310: tmp = -(R * phi2) else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -4e-310) tmp = Float64(-Float64(R * phi2)); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -4e-310) tmp = -(R * phi2); else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -4e-310], (-N[(R * phi2), $MachinePrecision]), N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -4 \cdot 10^{-310}:\\
\;\;\;\;-R \cdot \phi_2\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi2 < -3.999999999999988e-310Initial program 59.4%
Taylor expanded in phi2 around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6417.0
Applied rewrites17.0%
if -3.999999999999988e-310 < phi2 Initial program 59.4%
Taylor expanded in phi2 around inf
lower-*.f6418.0
Applied rewrites18.0%
(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 59.4%
Taylor expanded in phi2 around inf
lower-*.f6418.0
Applied rewrites18.0%
(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 59.4%
Taylor expanded in phi1 around inf
lower-*.f6417.7
Applied rewrites17.7%
herbie shell --seed 2025142
(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))))))