
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (/ y z) x (- x))))
(if (<= z -1.35e+26)
t_0
(if (<= z 80000000000000.0) (/ (fma (- y z) x x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((y / z), x, -x);
double tmp;
if (z <= -1.35e+26) {
tmp = t_0;
} else if (z <= 80000000000000.0) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(y / z), x, Float64(-x)) tmp = 0.0 if (z <= -1.35e+26) tmp = t_0; elseif (z <= 80000000000000.0) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * x + (-x)), $MachinePrecision]}, If[LessEqual[z, -1.35e+26], t$95$0, If[LessEqual[z, 80000000000000.0], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{y}{z}, x, -x\right)\\
\mathbf{if}\;z \leq -1.35 \cdot 10^{+26}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 80000000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.35e26 or 8e13 < z Initial program 87.8%
Applied rewrites95.9%
Taylor expanded in y around inf
Applied rewrites72.6%
if -1.35e26 < z < 8e13Initial program 87.8%
Applied rewrites87.8%
(FPCore (x y z) :precision binary64 (if (<= x 1.6e-35) (/ (fma (- y z) x x) z) (* (/ (- 1.0 (- z y)) z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.6e-35) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = ((1.0 - (z - y)) / z) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.6e-35) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = Float64(Float64(Float64(1.0 - Float64(z - y)) / z) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.6e-35], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(1.0 - N[(z - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{-35}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(z - y\right)}{z} \cdot x\\
\end{array}
\end{array}
if x < 1.5999999999999999e-35Initial program 87.8%
Applied rewrites87.8%
if 1.5999999999999999e-35 < x Initial program 87.8%
Applied rewrites95.9%
(FPCore (x y z) :precision binary64 (if (<= x 4.4e-43) (/ (fma (- y z) x x) z) (* (/ x z) (- 1.0 (- z y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 4.4e-43) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = (x / z) * (1.0 - (z - y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 4.4e-43) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = Float64(Float64(x / z) * Float64(1.0 - Float64(z - y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 4.4e-43], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(1.0 - N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.4 \cdot 10^{-43}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - \left(z - y\right)\right)\\
\end{array}
\end{array}
if x < 4.39999999999999994e-43Initial program 87.8%
Applied rewrites87.8%
if 4.39999999999999994e-43 < x Initial program 87.8%
Applied rewrites88.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (/ y z) x (- x)))) (if (<= z -1.0) t_0 (if (<= z 1.35e-8) (/ (* x (+ 1.0 y)) z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((y / z), x, -x);
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 1.35e-8) {
tmp = (x * (1.0 + y)) / z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(y / z), x, Float64(-x)) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 1.35e-8) tmp = Float64(Float64(x * Float64(1.0 + y)) / z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * x + (-x)), $MachinePrecision]}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 1.35e-8], N[(N[(x * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{y}{z}, x, -x\right)\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-8}:\\
\;\;\;\;\frac{x \cdot \left(1 + y\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 1.35000000000000001e-8 < z Initial program 87.8%
Applied rewrites95.9%
Taylor expanded in y around inf
Applied rewrites72.6%
if -1 < z < 1.35000000000000001e-8Initial program 87.8%
Taylor expanded in z around 0
Applied rewrites61.0%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e+26) (- x) (if (<= z 160000000.0) (/ (* x (+ 1.0 y)) z) (- (/ x z) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e+26) {
tmp = -x;
} else if (z <= 160000000.0) {
tmp = (x * (1.0 + y)) / z;
} else {
tmp = (x / z) - x;
}
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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-2.1d+26)) then
tmp = -x
else if (z <= 160000000.0d0) then
tmp = (x * (1.0d0 + y)) / z
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e+26) {
tmp = -x;
} else if (z <= 160000000.0) {
tmp = (x * (1.0 + y)) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e+26: tmp = -x elif z <= 160000000.0: tmp = (x * (1.0 + y)) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e+26) tmp = Float64(-x); elseif (z <= 160000000.0) tmp = Float64(Float64(x * Float64(1.0 + y)) / z); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.1e+26) tmp = -x; elseif (z <= 160000000.0) tmp = (x * (1.0 + y)) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e+26], (-x), If[LessEqual[z, 160000000.0], N[(N[(x * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{+26}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 160000000:\\
\;\;\;\;\frac{x \cdot \left(1 + y\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if z < -2.1000000000000001e26Initial program 87.8%
Taylor expanded in z around inf
Applied rewrites38.8%
Applied rewrites38.8%
if -2.1000000000000001e26 < z < 1.6e8Initial program 87.8%
Taylor expanded in z around 0
Applied rewrites61.0%
if 1.6e8 < z Initial program 87.8%
Applied rewrites95.9%
Taylor expanded in y around 0
Applied rewrites65.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (* x y) z))) (if (<= y -3.4e+31) t_0 (if (<= y 6.5e+89) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double tmp;
if (y <= -3.4e+31) {
tmp = t_0;
} else if (y <= 6.5e+89) {
tmp = (x / z) - x;
} 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(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x * y) / z
if (y <= (-3.4d+31)) then
tmp = t_0
else if (y <= 6.5d+89) then
tmp = (x / z) - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double tmp;
if (y <= -3.4e+31) {
tmp = t_0;
} else if (y <= 6.5e+89) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * y) / z tmp = 0 if y <= -3.4e+31: tmp = t_0 elif y <= 6.5e+89: tmp = (x / z) - x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * y) / z) tmp = 0.0 if (y <= -3.4e+31) tmp = t_0; elseif (y <= 6.5e+89) tmp = Float64(Float64(x / z) - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * y) / z; tmp = 0.0; if (y <= -3.4e+31) tmp = t_0; elseif (y <= 6.5e+89) tmp = (x / z) - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -3.4e+31], t$95$0, If[LessEqual[y, 6.5e+89], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+89}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.3999999999999998e31 or 6.4999999999999996e89 < y Initial program 87.8%
Taylor expanded in y around inf
Applied rewrites38.3%
if -3.3999999999999998e31 < y < 6.4999999999999996e89Initial program 87.8%
Applied rewrites95.9%
Taylor expanded in y around 0
Applied rewrites65.7%
(FPCore (x y z) :precision binary64 (- (/ x z) x))
double code(double x, double y, double z) {
return (x / z) - x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / z) - x
end function
public static double code(double x, double y, double z) {
return (x / z) - x;
}
def code(x, y, z): return (x / z) - x
function code(x, y, z) return Float64(Float64(x / z) - x) end
function tmp = code(x, y, z) tmp = (x / z) - x; end
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z} - x
\end{array}
Initial program 87.8%
Applied rewrites95.9%
Taylor expanded in y around 0
Applied rewrites65.7%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 87.8%
Taylor expanded in z around inf
Applied rewrites38.8%
Applied rewrites38.8%
herbie shell --seed 2025153
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
(/ (* x (+ (- y z) 1.0)) z))