
(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));
}
real(8) function code(x, y, z)
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 6 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));
}
real(8) function code(x, y, z)
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 (- z (* y (- z x))))
double code(double x, double y, double z) {
return z - (y * (z - x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z - (y * (z - x))
end function
public static double code(double x, double y, double z) {
return z - (y * (z - x));
}
def code(x, y, z): return z - (y * (z - x))
function code(x, y, z) return Float64(z - Float64(y * Float64(z - x))) end
function tmp = code(x, y, z) tmp = z - (y * (z - x)); end
code[x_, y_, z_] := N[(z - N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z - y \cdot \left(z - x\right)
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- z))))
(if (<= y -8.8e+250)
t_0
(if (<= y -1.05e-47)
(* y x)
(if (<= y 5e-35) z (if (<= y 140000000000.0) (* y x) t_0))))))
double code(double x, double y, double z) {
double t_0 = y * -z;
double tmp;
if (y <= -8.8e+250) {
tmp = t_0;
} else if (y <= -1.05e-47) {
tmp = y * x;
} else if (y <= 5e-35) {
tmp = z;
} else if (y <= 140000000000.0) {
tmp = y * x;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * -z
if (y <= (-8.8d+250)) then
tmp = t_0
else if (y <= (-1.05d-47)) then
tmp = y * x
else if (y <= 5d-35) then
tmp = z
else if (y <= 140000000000.0d0) then
tmp = y * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * -z;
double tmp;
if (y <= -8.8e+250) {
tmp = t_0;
} else if (y <= -1.05e-47) {
tmp = y * x;
} else if (y <= 5e-35) {
tmp = z;
} else if (y <= 140000000000.0) {
tmp = y * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * -z tmp = 0 if y <= -8.8e+250: tmp = t_0 elif y <= -1.05e-47: tmp = y * x elif y <= 5e-35: tmp = z elif y <= 140000000000.0: tmp = y * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(-z)) tmp = 0.0 if (y <= -8.8e+250) tmp = t_0; elseif (y <= -1.05e-47) tmp = Float64(y * x); elseif (y <= 5e-35) tmp = z; elseif (y <= 140000000000.0) tmp = Float64(y * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * -z; tmp = 0.0; if (y <= -8.8e+250) tmp = t_0; elseif (y <= -1.05e-47) tmp = y * x; elseif (y <= 5e-35) tmp = z; elseif (y <= 140000000000.0) tmp = y * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * (-z)), $MachinePrecision]}, If[LessEqual[y, -8.8e+250], t$95$0, If[LessEqual[y, -1.05e-47], N[(y * x), $MachinePrecision], If[LessEqual[y, 5e-35], z, If[LessEqual[y, 140000000000.0], N[(y * x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(-z\right)\\
\mathbf{if}\;y \leq -8.8 \cdot 10^{+250}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-47}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-35}:\\
\;\;\;\;z\\
\mathbf{elif}\;y \leq 140000000000:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -1.25e-49) (not (<= y 6.8e-35))) (* y (- x z)) z))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e-49) || !(y <= 6.8e-35)) {
tmp = y * (x - z);
} else {
tmp = z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.25d-49)) .or. (.not. (y <= 6.8d-35))) then
tmp = y * (x - z)
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e-49) || !(y <= 6.8e-35)) {
tmp = y * (x - z);
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.25e-49) or not (y <= 6.8e-35): tmp = y * (x - z) else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.25e-49) || !(y <= 6.8e-35)) tmp = Float64(y * Float64(x - z)); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.25e-49) || ~((y <= 6.8e-35))) tmp = y * (x - z); else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.25e-49], N[Not[LessEqual[y, 6.8e-35]], $MachinePrecision]], N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{-49} \lor \neg \left(y \leq 6.8 \cdot 10^{-35}\right):\\
\;\;\;\;y \cdot \left(x - z\right)\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -1050.0) (not (<= y 0.185))) (* y (- x z)) (+ z (* y x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1050.0) || !(y <= 0.185)) {
tmp = y * (x - z);
} else {
tmp = z + (y * x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1050.0d0)) .or. (.not. (y <= 0.185d0))) then
tmp = y * (x - z)
else
tmp = z + (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1050.0) || !(y <= 0.185)) {
tmp = y * (x - z);
} else {
tmp = z + (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1050.0) or not (y <= 0.185): tmp = y * (x - z) else: tmp = z + (y * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1050.0) || !(y <= 0.185)) tmp = Float64(y * Float64(x - z)); else tmp = Float64(z + Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1050.0) || ~((y <= 0.185))) tmp = y * (x - z); else tmp = z + (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1050.0], N[Not[LessEqual[y, 0.185]], $MachinePrecision]], N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision], N[(z + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1050 \lor \neg \left(y \leq 0.185\right):\\
\;\;\;\;y \cdot \left(x - z\right)\\
\mathbf{else}:\\
\;\;\;\;z + y \cdot x\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -2.5e-47) (not (<= y 9.2e-36))) (* y x) z))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.5e-47) || !(y <= 9.2e-36)) {
tmp = y * x;
} else {
tmp = z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-2.5d-47)) .or. (.not. (y <= 9.2d-36))) 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 <= -2.5e-47) || !(y <= 9.2e-36)) {
tmp = y * x;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.5e-47) or not (y <= 9.2e-36): tmp = y * x else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.5e-47) || !(y <= 9.2e-36)) tmp = Float64(y * x); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.5e-47) || ~((y <= 9.2e-36))) tmp = y * x; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.5e-47], N[Not[LessEqual[y, 9.2e-36]], $MachinePrecision]], N[(y * x), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-47} \lor \neg \left(y \leq 9.2 \cdot 10^{-36}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
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}
(FPCore (x y z) :precision binary64 (- z (* (- z x) y)))
double code(double x, double y, double z) {
return z - ((z - x) * y);
}
real(8) function code(x, y, z)
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 2023350
(FPCore (x y z)
:name "Diagrams.TwoD.Segment:bezierClip from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(- z (* (- z x) y))
(+ (* x y) (* z (- 1.0 y))))