
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / ((y - z) * (y - t))); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / ((y - z) * (y - t))); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ (/ x (- y z)) (- y t))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - z)) / (y - t));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 - ((x / (y - z)) / (y - t))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - z)) / (y - t));
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return 1.0 - ((x / (y - z)) / (y - t))
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(Float64(x / Float64(y - z)) / Float64(y - t))) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - ((x / (y - z)) / (y - t));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \frac{\frac{x}{y - z}}{y - t}
\end{array}
Initial program 99.2%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.5
Applied rewrites98.5%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ (/ x (- y t)) (- y z))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - t)) / (y - z));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 - ((x / (y - t)) / (y - z))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - t)) / (y - z));
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return 1.0 - ((x / (y - t)) / (y - z))
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(Float64(x / Float64(y - t)) / Float64(y - z))) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - ((x / (y - t)) / (y - z));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \frac{\frac{x}{y - t}}{y - z}
\end{array}
Initial program 99.2%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.4
Applied rewrites98.4%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 - (x / ((y - z) * (y - t)))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - (x / ((y - z) * (y - t)));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
Initial program 99.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (<= z -7.5e-87)
(- 1.0 (/ (/ x (- z)) (- y t)))
(if (<= z 1.12e-154)
(- 1.0 (/ (/ x y) (- y t)))
(- (/ x (* (- y z) t)) -1.0))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.5e-87) {
tmp = 1.0 - ((x / -z) / (y - t));
} else if (z <= 1.12e-154) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-7.5d-87)) then
tmp = 1.0d0 - ((x / -z) / (y - t))
else if (z <= 1.12d-154) then
tmp = 1.0d0 - ((x / y) / (y - t))
else
tmp = (x / ((y - z) * t)) - (-1.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.5e-87) {
tmp = 1.0 - ((x / -z) / (y - t));
} else if (z <= 1.12e-154) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if z <= -7.5e-87: tmp = 1.0 - ((x / -z) / (y - t)) elif z <= 1.12e-154: tmp = 1.0 - ((x / y) / (y - t)) else: tmp = (x / ((y - z) * t)) - -1.0 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -7.5e-87) tmp = Float64(1.0 - Float64(Float64(x / Float64(-z)) / Float64(y - t))); elseif (z <= 1.12e-154) tmp = Float64(1.0 - Float64(Float64(x / y) / Float64(y - t))); else tmp = Float64(Float64(x / Float64(Float64(y - z) * t)) - -1.0); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (z <= -7.5e-87)
tmp = 1.0 - ((x / -z) / (y - t));
elseif (z <= 1.12e-154)
tmp = 1.0 - ((x / y) / (y - t));
else
tmp = (x / ((y - z) * t)) - -1.0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[z, -7.5e-87], N[(1.0 - N[(N[(x / (-z)), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.12e-154], N[(1.0 - N[(N[(x / y), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{-87}:\\
\;\;\;\;1 - \frac{\frac{x}{-z}}{y - t}\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{-154}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot t} - -1\\
\end{array}
\end{array}
if z < -7.5000000000000002e-87Initial program 99.2%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.5
Applied rewrites98.5%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6478.6
Applied rewrites78.6%
if -7.5000000000000002e-87 < z < 1.12e-154Initial program 99.2%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.5
Applied rewrites98.5%
Taylor expanded in y around inf
lower-/.f6472.0
Applied rewrites72.0%
if 1.12e-154 < z Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (<= z -7.5e-87)
(+ (/ x (* (- y t) z)) 1.0)
(if (<= z 1.12e-154)
(- 1.0 (/ (/ x y) (- y t)))
(- (/ x (* (- y z) t)) -1.0))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.5e-87) {
tmp = (x / ((y - t) * z)) + 1.0;
} else if (z <= 1.12e-154) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-7.5d-87)) then
tmp = (x / ((y - t) * z)) + 1.0d0
else if (z <= 1.12d-154) then
tmp = 1.0d0 - ((x / y) / (y - t))
else
tmp = (x / ((y - z) * t)) - (-1.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.5e-87) {
tmp = (x / ((y - t) * z)) + 1.0;
} else if (z <= 1.12e-154) {
tmp = 1.0 - ((x / y) / (y - t));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if z <= -7.5e-87: tmp = (x / ((y - t) * z)) + 1.0 elif z <= 1.12e-154: tmp = 1.0 - ((x / y) / (y - t)) else: tmp = (x / ((y - z) * t)) - -1.0 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -7.5e-87) tmp = Float64(Float64(x / Float64(Float64(y - t) * z)) + 1.0); elseif (z <= 1.12e-154) tmp = Float64(1.0 - Float64(Float64(x / y) / Float64(y - t))); else tmp = Float64(Float64(x / Float64(Float64(y - z) * t)) - -1.0); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (z <= -7.5e-87)
tmp = (x / ((y - t) * z)) + 1.0;
elseif (z <= 1.12e-154)
tmp = 1.0 - ((x / y) / (y - t));
else
tmp = (x / ((y - z) * t)) - -1.0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[z, -7.5e-87], N[(N[(x / N[(N[(y - t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[z, 1.12e-154], N[(1.0 - N[(N[(x / y), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{-87}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot z} + 1\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{-154}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot t} - -1\\
\end{array}
\end{array}
if z < -7.5000000000000002e-87Initial program 99.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.0
Applied rewrites79.0%
if -7.5000000000000002e-87 < z < 1.12e-154Initial program 99.2%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.5
Applied rewrites98.5%
Taylor expanded in y around inf
lower-/.f6472.0
Applied rewrites72.0%
if 1.12e-154 < z Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (<= t -4e-209)
(+ (/ x (* (- y t) z)) 1.0)
(if (<= t 1.8e-83)
(- 1.0 (/ (/ x y) (- y z)))
(- (/ x (* (- y z) t)) -1.0))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4e-209) {
tmp = (x / ((y - t) * z)) + 1.0;
} else if (t <= 1.8e-83) {
tmp = 1.0 - ((x / y) / (y - z));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-4d-209)) then
tmp = (x / ((y - t) * z)) + 1.0d0
else if (t <= 1.8d-83) then
tmp = 1.0d0 - ((x / y) / (y - z))
else
tmp = (x / ((y - z) * t)) - (-1.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4e-209) {
tmp = (x / ((y - t) * z)) + 1.0;
} else if (t <= 1.8e-83) {
tmp = 1.0 - ((x / y) / (y - z));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if t <= -4e-209: tmp = (x / ((y - t) * z)) + 1.0 elif t <= 1.8e-83: tmp = 1.0 - ((x / y) / (y - z)) else: tmp = (x / ((y - z) * t)) - -1.0 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (t <= -4e-209) tmp = Float64(Float64(x / Float64(Float64(y - t) * z)) + 1.0); elseif (t <= 1.8e-83) tmp = Float64(1.0 - Float64(Float64(x / y) / Float64(y - z))); else tmp = Float64(Float64(x / Float64(Float64(y - z) * t)) - -1.0); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= -4e-209)
tmp = (x / ((y - t) * z)) + 1.0;
elseif (t <= 1.8e-83)
tmp = 1.0 - ((x / y) / (y - z));
else
tmp = (x / ((y - z) * t)) - -1.0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[t, -4e-209], N[(N[(x / N[(N[(y - t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[t, 1.8e-83], N[(1.0 - N[(N[(x / y), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4 \cdot 10^{-209}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot z} + 1\\
\mathbf{elif}\;t \leq 1.8 \cdot 10^{-83}:\\
\;\;\;\;1 - \frac{\frac{x}{y}}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot t} - -1\\
\end{array}
\end{array}
if t < -4.0000000000000002e-209Initial program 99.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.0
Applied rewrites79.0%
if -4.0000000000000002e-209 < t < 1.80000000000000006e-83Initial program 99.2%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.4
Applied rewrites98.4%
Taylor expanded in y around inf
lower-/.f6472.0
Applied rewrites72.0%
if 1.80000000000000006e-83 < t Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (<= t -2.9e-116)
(+ (/ x (* (- y t) z)) 1.0)
(if (<= t 1.8e-83)
(- 1.0 (/ x (* (- y z) y)))
(- (/ x (* (- y z) t)) -1.0))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.9e-116) {
tmp = (x / ((y - t) * z)) + 1.0;
} else if (t <= 1.8e-83) {
tmp = 1.0 - (x / ((y - z) * y));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-2.9d-116)) then
tmp = (x / ((y - t) * z)) + 1.0d0
else if (t <= 1.8d-83) then
tmp = 1.0d0 - (x / ((y - z) * y))
else
tmp = (x / ((y - z) * t)) - (-1.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -2.9e-116) {
tmp = (x / ((y - t) * z)) + 1.0;
} else if (t <= 1.8e-83) {
tmp = 1.0 - (x / ((y - z) * y));
} else {
tmp = (x / ((y - z) * t)) - -1.0;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if t <= -2.9e-116: tmp = (x / ((y - t) * z)) + 1.0 elif t <= 1.8e-83: tmp = 1.0 - (x / ((y - z) * y)) else: tmp = (x / ((y - z) * t)) - -1.0 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (t <= -2.9e-116) tmp = Float64(Float64(x / Float64(Float64(y - t) * z)) + 1.0); elseif (t <= 1.8e-83) tmp = Float64(1.0 - Float64(x / Float64(Float64(y - z) * y))); else tmp = Float64(Float64(x / Float64(Float64(y - z) * t)) - -1.0); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= -2.9e-116)
tmp = (x / ((y - t) * z)) + 1.0;
elseif (t <= 1.8e-83)
tmp = 1.0 - (x / ((y - z) * y));
else
tmp = (x / ((y - z) * t)) - -1.0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[t, -2.9e-116], N[(N[(x / N[(N[(y - t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[t, 1.8e-83], N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{-116}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot z} + 1\\
\mathbf{elif}\;t \leq 1.8 \cdot 10^{-83}:\\
\;\;\;\;1 - \frac{x}{\left(y - z\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot t} - -1\\
\end{array}
\end{array}
if t < -2.8999999999999998e-116Initial program 99.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.0
Applied rewrites79.0%
if -2.8999999999999998e-116 < t < 1.80000000000000006e-83Initial program 99.2%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6472.6
Applied rewrites72.6%
if 1.80000000000000006e-83 < t Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ x (* (- y z) t)) -1.0)))
(if (<= t -2.9e-116)
t_1
(if (<= t 1.8e-83) (- 1.0 (/ x (* (- y z) y))) t_1))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = (x / ((y - z) * t)) - -1.0;
double tmp;
if (t <= -2.9e-116) {
tmp = t_1;
} else if (t <= 1.8e-83) {
tmp = 1.0 - (x / ((y - z) * y));
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x / ((y - z) * t)) - (-1.0d0)
if (t <= (-2.9d-116)) then
tmp = t_1
else if (t <= 1.8d-83) then
tmp = 1.0d0 - (x / ((y - z) * y))
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = (x / ((y - z) * t)) - -1.0;
double tmp;
if (t <= -2.9e-116) {
tmp = t_1;
} else if (t <= 1.8e-83) {
tmp = 1.0 - (x / ((y - z) * y));
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = (x / ((y - z) * t)) - -1.0 tmp = 0 if t <= -2.9e-116: tmp = t_1 elif t <= 1.8e-83: tmp = 1.0 - (x / ((y - z) * y)) else: tmp = t_1 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(Float64(x / Float64(Float64(y - z) * t)) - -1.0) tmp = 0.0 if (t <= -2.9e-116) tmp = t_1; elseif (t <= 1.8e-83) tmp = Float64(1.0 - Float64(x / Float64(Float64(y - z) * y))); else tmp = t_1; end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = (x / ((y - z) * t)) - -1.0;
tmp = 0.0;
if (t <= -2.9e-116)
tmp = t_1;
elseif (t <= 1.8e-83)
tmp = 1.0 - (x / ((y - z) * y));
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[t, -2.9e-116], t$95$1, If[LessEqual[t, 1.8e-83], N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x}{\left(y - z\right) \cdot t} - -1\\
\mathbf{if}\;t \leq -2.9 \cdot 10^{-116}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.8 \cdot 10^{-83}:\\
\;\;\;\;1 - \frac{x}{\left(y - z\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.8999999999999998e-116 or 1.80000000000000006e-83 < t Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
if -2.8999999999999998e-116 < t < 1.80000000000000006e-83Initial program 99.2%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6472.6
Applied rewrites72.6%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -4.3e-13) (- 1.0 (/ x (* (- y t) y))) (if (<= y 1.05e-95) (- (/ x (* (- y z) t)) -1.0) 1.0)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.3e-13) {
tmp = 1.0 - (x / ((y - t) * y));
} else if (y <= 1.05e-95) {
tmp = (x / ((y - z) * t)) - -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-4.3d-13)) then
tmp = 1.0d0 - (x / ((y - t) * y))
else if (y <= 1.05d-95) then
tmp = (x / ((y - z) * t)) - (-1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.3e-13) {
tmp = 1.0 - (x / ((y - t) * y));
} else if (y <= 1.05e-95) {
tmp = (x / ((y - z) * t)) - -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if y <= -4.3e-13: tmp = 1.0 - (x / ((y - t) * y)) elif y <= 1.05e-95: tmp = (x / ((y - z) * t)) - -1.0 else: tmp = 1.0 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -4.3e-13) tmp = Float64(1.0 - Float64(x / Float64(Float64(y - t) * y))); elseif (y <= 1.05e-95) tmp = Float64(Float64(x / Float64(Float64(y - z) * t)) - -1.0); else tmp = 1.0; end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= -4.3e-13)
tmp = 1.0 - (x / ((y - t) * y));
elseif (y <= 1.05e-95)
tmp = (x / ((y - z) * t)) - -1.0;
else
tmp = 1.0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -4.3e-13], N[(1.0 - N[(x / N[(N[(y - t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e-95], N[(N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision], 1.0]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-13}:\\
\;\;\;\;1 - \frac{x}{\left(y - t\right) \cdot y}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-95}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot t} - -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.2999999999999999e-13Initial program 99.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6472.3
Applied rewrites72.3%
if -4.2999999999999999e-13 < y < 1.05e-95Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
if 1.05e-95 < y Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites75.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -1.45e-6) (- 1.0 (/ x (* y y))) (if (<= y 1.05e-95) (- (/ x (* (- y z) t)) -1.0) 1.0)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e-6) {
tmp = 1.0 - (x / (y * y));
} else if (y <= 1.05e-95) {
tmp = (x / ((y - z) * t)) - -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-1.45d-6)) then
tmp = 1.0d0 - (x / (y * y))
else if (y <= 1.05d-95) then
tmp = (x / ((y - z) * t)) - (-1.0d0)
else
tmp = 1.0d0
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e-6) {
tmp = 1.0 - (x / (y * y));
} else if (y <= 1.05e-95) {
tmp = (x / ((y - z) * t)) - -1.0;
} else {
tmp = 1.0;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if y <= -1.45e-6: tmp = 1.0 - (x / (y * y)) elif y <= 1.05e-95: tmp = (x / ((y - z) * t)) - -1.0 else: tmp = 1.0 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (y <= -1.45e-6) tmp = Float64(1.0 - Float64(x / Float64(y * y))); elseif (y <= 1.05e-95) tmp = Float64(Float64(x / Float64(Float64(y - z) * t)) - -1.0); else tmp = 1.0; end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (y <= -1.45e-6)
tmp = 1.0 - (x / (y * y));
elseif (y <= 1.05e-95)
tmp = (x / ((y - z) * t)) - -1.0;
else
tmp = 1.0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[y, -1.45e-6], N[(1.0 - N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e-95], N[(N[(x / N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision], 1.0]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-6}:\\
\;\;\;\;1 - \frac{x}{y \cdot y}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-95}:\\
\;\;\;\;\frac{x}{\left(y - z\right) \cdot t} - -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.4500000000000001e-6Initial program 99.2%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6456.6
Applied rewrites56.6%
if -1.4500000000000001e-6 < y < 1.05e-95Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
if 1.05e-95 < y Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites75.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- 1.0 (/ x (* (- y z) (- y t))))))
(if (<= t_1 0.999)
(- 1.0 (/ x (* t z)))
(if (<= t_1 2.0) 1.0 (/ (- t (/ x z)) t)))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = 1.0 - (x / ((y - z) * (y - t)));
double tmp;
if (t_1 <= 0.999) {
tmp = 1.0 - (x / (t * z));
} else if (t_1 <= 2.0) {
tmp = 1.0;
} else {
tmp = (t - (x / z)) / t;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = 1.0d0 - (x / ((y - z) * (y - t)))
if (t_1 <= 0.999d0) then
tmp = 1.0d0 - (x / (t * z))
else if (t_1 <= 2.0d0) then
tmp = 1.0d0
else
tmp = (t - (x / z)) / t
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = 1.0 - (x / ((y - z) * (y - t)));
double tmp;
if (t_1 <= 0.999) {
tmp = 1.0 - (x / (t * z));
} else if (t_1 <= 2.0) {
tmp = 1.0;
} else {
tmp = (t - (x / z)) / t;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = 1.0 - (x / ((y - z) * (y - t))) tmp = 0 if t_1 <= 0.999: tmp = 1.0 - (x / (t * z)) elif t_1 <= 2.0: tmp = 1.0 else: tmp = (t - (x / z)) / t return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) tmp = 0.0 if (t_1 <= 0.999) tmp = Float64(1.0 - Float64(x / Float64(t * z))); elseif (t_1 <= 2.0) tmp = 1.0; else tmp = Float64(Float64(t - Float64(x / z)) / t); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = 1.0 - (x / ((y - z) * (y - t)));
tmp = 0.0;
if (t_1 <= 0.999)
tmp = 1.0 - (x / (t * z));
elseif (t_1 <= 2.0)
tmp = 1.0;
else
tmp = (t - (x / z)) / t;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.999], N[(1.0 - N[(x / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.0], 1.0, N[(N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := 1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}\\
\mathbf{if}\;t\_1 \leq 0.999:\\
\;\;\;\;1 - \frac{x}{t \cdot z}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{t - \frac{x}{z}}{t}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t)))) < 0.998999999999999999Initial program 99.2%
Taylor expanded in y around 0
lower-*.f6462.1
Applied rewrites62.1%
if 0.998999999999999999 < (-.f64 #s(literal 1 binary64) (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t)))) < 2Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites75.2%
if 2 < (-.f64 #s(literal 1 binary64) (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t)))) Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
Taylor expanded in t around 0
lower-/.f64N/A
add-flipN/A
mul-1-negN/A
lower--.f64N/A
associate-*r/N/A
mul-1-negN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower--.f6478.1
Applied rewrites78.1%
Taylor expanded in y around 0
Applied rewrites61.5%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (let* ((t_1 (/ x (* (- y z) (- y t)))) (t_2 (- 1.0 (/ x (* t z))))) (if (<= t_1 -5000.0) t_2 (if (<= t_1 2e-9) 1.0 t_2))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = x / ((y - z) * (y - t));
double t_2 = 1.0 - (x / (t * z));
double tmp;
if (t_1 <= -5000.0) {
tmp = t_2;
} else if (t_1 <= 2e-9) {
tmp = 1.0;
} else {
tmp = t_2;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x / ((y - z) * (y - t))
t_2 = 1.0d0 - (x / (t * z))
if (t_1 <= (-5000.0d0)) then
tmp = t_2
else if (t_1 <= 2d-9) then
tmp = 1.0d0
else
tmp = t_2
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = x / ((y - z) * (y - t));
double t_2 = 1.0 - (x / (t * z));
double tmp;
if (t_1 <= -5000.0) {
tmp = t_2;
} else if (t_1 <= 2e-9) {
tmp = 1.0;
} else {
tmp = t_2;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = x / ((y - z) * (y - t)) t_2 = 1.0 - (x / (t * z)) tmp = 0 if t_1 <= -5000.0: tmp = t_2 elif t_1 <= 2e-9: tmp = 1.0 else: tmp = t_2 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(x / Float64(Float64(y - z) * Float64(y - t))) t_2 = Float64(1.0 - Float64(x / Float64(t * z))) tmp = 0.0 if (t_1 <= -5000.0) tmp = t_2; elseif (t_1 <= 2e-9) tmp = 1.0; else tmp = t_2; end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = x / ((y - z) * (y - t));
t_2 = 1.0 - (x / (t * z));
tmp = 0.0;
if (t_1 <= -5000.0)
tmp = t_2;
elseif (t_1 <= 2e-9)
tmp = 1.0;
else
tmp = t_2;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(x / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5000.0], t$95$2, If[LessEqual[t$95$1, 2e-9], 1.0, t$95$2]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}\\
t_2 := 1 - \frac{x}{t \cdot z}\\
\mathbf{if}\;t\_1 \leq -5000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))) < -5e3 or 2.00000000000000012e-9 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))) Initial program 99.2%
Taylor expanded in y around 0
lower-*.f6462.1
Applied rewrites62.1%
if -5e3 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))) < 2.00000000000000012e-9Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites75.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (let* ((t_1 (/ x (* (- y z) (- y t)))) (t_2 (- (/ x (* t y)) -1.0))) (if (<= t_1 -2e+29) t_2 (if (<= t_1 1.0) 1.0 t_2))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = x / ((y - z) * (y - t));
double t_2 = (x / (t * y)) - -1.0;
double tmp;
if (t_1 <= -2e+29) {
tmp = t_2;
} else if (t_1 <= 1.0) {
tmp = 1.0;
} else {
tmp = t_2;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x / ((y - z) * (y - t))
t_2 = (x / (t * y)) - (-1.0d0)
if (t_1 <= (-2d+29)) then
tmp = t_2
else if (t_1 <= 1.0d0) then
tmp = 1.0d0
else
tmp = t_2
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = x / ((y - z) * (y - t));
double t_2 = (x / (t * y)) - -1.0;
double tmp;
if (t_1 <= -2e+29) {
tmp = t_2;
} else if (t_1 <= 1.0) {
tmp = 1.0;
} else {
tmp = t_2;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = x / ((y - z) * (y - t)) t_2 = (x / (t * y)) - -1.0 tmp = 0 if t_1 <= -2e+29: tmp = t_2 elif t_1 <= 1.0: tmp = 1.0 else: tmp = t_2 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(x / Float64(Float64(y - z) * Float64(y - t))) t_2 = Float64(Float64(x / Float64(t * y)) - -1.0) tmp = 0.0 if (t_1 <= -2e+29) tmp = t_2; elseif (t_1 <= 1.0) tmp = 1.0; else tmp = t_2; end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = x / ((y - z) * (y - t));
t_2 = (x / (t * y)) - -1.0;
tmp = 0.0;
if (t_1 <= -2e+29)
tmp = t_2;
elseif (t_1 <= 1.0)
tmp = 1.0;
else
tmp = t_2;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / N[(t * y), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+29], t$95$2, If[LessEqual[t$95$1, 1.0], 1.0, t$95$2]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}\\
t_2 := \frac{x}{t \cdot y} - -1\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+29}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))) < -1.99999999999999983e29 or 1 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))) Initial program 99.2%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6479.2
Applied rewrites79.2%
associate-/l/79.2
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-/.f6479.2
Applied rewrites79.2%
Taylor expanded in y around inf
lower-*.f6457.0
Applied rewrites57.0%
if -1.99999999999999983e29 < (/.f64 x (*.f64 (-.f64 y z) (-.f64 y t))) < 1Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites75.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 1.0)
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return 1.0;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return 1.0
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return 1.0 end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := 1.0
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1
\end{array}
Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites75.2%
herbie shell --seed 2025136
(FPCore (x y z t)
:name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, A"
:precision binary64
(- 1.0 (/ x (* (- y z) (- y t)))))