
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (- 1.0 y))))
double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
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 - y))
end function
public static double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
def code(x, y, z): return (x * y) + (z * (1.0 - y))
function code(x, y, z) return Float64(Float64(x * y) + Float64(z * Float64(1.0 - y))) end
function tmp = code(x, y, z) tmp = (x * y) + (z * (1.0 - y)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + z \cdot \left(1 - y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (- 1.0 y))))
double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
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 - y))
end function
public static double code(double x, double y, double z) {
return (x * y) + (z * (1.0 - y));
}
def code(x, y, z): return (x * y) + (z * (1.0 - y))
function code(x, y, z) return Float64(Float64(x * y) + Float64(z * Float64(1.0 - y))) end
function tmp = code(x, y, z) tmp = (x * y) + (z * (1.0 - y)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + z \cdot \left(1 - y\right)
\end{array}
(FPCore (x y z) :precision binary64 (fma (- x z) y z))
double code(double x, double y, double z) {
return fma((x - z), y, z);
}
function code(x, y, z) return fma(Float64(x - z), y, z) end
code[x_, y_, z_] := N[(N[(x - z), $MachinePrecision] * y + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - z, y, z\right)
\end{array}
Initial program 95.7%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r*N/A
associate-+r+N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -6e+23) (not (<= y 4.2e-15))) (* (- x z) y) (fma x y z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e+23) || !(y <= 4.2e-15)) {
tmp = (x - z) * y;
} else {
tmp = fma(x, y, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -6e+23) || !(y <= 4.2e-15)) tmp = Float64(Float64(x - z) * y); else tmp = fma(x, y, z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -6e+23], N[Not[LessEqual[y, 4.2e-15]], $MachinePrecision]], N[(N[(x - z), $MachinePrecision] * y), $MachinePrecision], N[(x * y + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+23} \lor \neg \left(y \leq 4.2 \cdot 10^{-15}\right):\\
\;\;\;\;\left(x - z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y, z\right)\\
\end{array}
\end{array}
if y < -6.0000000000000002e23 or 4.19999999999999962e-15 < y Initial program 92.3%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6496.5
Applied rewrites96.5%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r*N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
if -6.0000000000000002e23 < y < 4.19999999999999962e-15Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r*N/A
associate-+r+N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.5e+54) (not (<= z 2.15e+30))) (* (- 1.0 y) z) (fma x y z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e+54) || !(z <= 2.15e+30)) {
tmp = (1.0 - y) * z;
} else {
tmp = fma(x, y, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -8.5e+54) || !(z <= 2.15e+30)) tmp = Float64(Float64(1.0 - y) * z); else tmp = fma(x, y, z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.5e+54], N[Not[LessEqual[z, 2.15e+30]], $MachinePrecision]], N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], N[(x * y + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{+54} \lor \neg \left(z \leq 2.15 \cdot 10^{+30}\right):\\
\;\;\;\;\left(1 - y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y, z\right)\\
\end{array}
\end{array}
if z < -8.4999999999999995e54 or 2.15e30 < z Initial program 90.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6489.9
Applied rewrites89.9%
if -8.4999999999999995e54 < z < 2.15e30Initial program 99.3%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r*N/A
associate-+r+N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites84.9%
Final simplification87.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.6e+16) (fma x y z) (if (<= y 1.55e+263) (* z (- y)) (* y x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+16) {
tmp = fma(x, y, z);
} else if (y <= 1.55e+263) {
tmp = z * -y;
} else {
tmp = y * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.6e+16) tmp = fma(x, y, z); elseif (y <= 1.55e+263) tmp = Float64(z * Float64(-y)); else tmp = Float64(y * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.6e+16], N[(x * y + z), $MachinePrecision], If[LessEqual[y, 1.55e+263], N[(z * (-y)), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(x, y, z\right)\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+263}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if y < 1.6e16Initial program 96.8%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r*N/A
associate-+r+N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites82.3%
if 1.6e16 < y < 1.5500000000000001e263Initial program 94.9%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
if 1.5500000000000001e263 < y Initial program 80.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6480.1
Applied rewrites80.1%
Final simplification78.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -6e-13) (not (<= y 9.8e-20))) (* y x) z))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6e-13) || !(y <= 9.8e-20)) {
tmp = y * x;
} else {
tmp = z;
}
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 ((y <= (-6d-13)) .or. (.not. (y <= 9.8d-20))) then
tmp = y * x
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6e-13) || !(y <= 9.8e-20)) {
tmp = y * x;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6e-13) or not (y <= 9.8e-20): tmp = y * x else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6e-13) || !(y <= 9.8e-20)) tmp = Float64(y * x); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6e-13) || ~((y <= 9.8e-20))) tmp = y * x; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6e-13], N[Not[LessEqual[y, 9.8e-20]], $MachinePrecision]], N[(y * x), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-13} \lor \neg \left(y \leq 9.8 \cdot 10^{-20}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if y < -5.99999999999999968e-13 or 9.8000000000000003e-20 < y Initial program 92.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6452.2
Applied rewrites52.2%
if -5.99999999999999968e-13 < y < 9.8000000000000003e-20Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites68.8%
Final simplification59.2%
(FPCore (x y z) :precision binary64 (fma x y z))
double code(double x, double y, double z) {
return fma(x, y, z);
}
function code(x, y, z) return fma(x, y, z) end
code[x_, y_, z_] := N[(x * y + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, z\right)
\end{array}
Initial program 95.7%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
metadata-evalN/A
distribute-lft-neg-outN/A
distribute-lft-out--N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft1-inN/A
associate-*r*N/A
associate-+r+N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites72.6%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return 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 = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 95.7%
Taylor expanded in y around 0
Applied rewrites30.7%
Final simplification30.7%
(FPCore (x y z) :precision binary64 (- z (* (- z x) y)))
double code(double x, double y, double z) {
return z - ((z - x) * y);
}
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 = z - ((z - x) * y)
end function
public static double code(double x, double y, double z) {
return z - ((z - x) * y);
}
def code(x, y, z): return z - ((z - x) * y)
function code(x, y, z) return Float64(z - Float64(Float64(z - x) * y)) end
function tmp = code(x, y, z) tmp = z - ((z - x) * y); end
code[x_, y_, z_] := N[(z - N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z - \left(z - x\right) \cdot y
\end{array}
herbie shell --seed 2025043
(FPCore (x y z)
:name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (- z (* (- z x) y)))
(+ (* x y) (* z (- 1.0 y))))