
(FPCore (x y z) :precision binary64 (+ x (* y (- z x))))
double code(double x, double y, double z) {
return x + (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 = x + (y * (z - x))
end function
public static double code(double x, double y, double z) {
return x + (y * (z - x));
}
def code(x, y, z): return x + (y * (z - x))
function code(x, y, z) return Float64(x + Float64(y * Float64(z - x))) end
function tmp = code(x, y, z) tmp = x + (y * (z - x)); end
code[x_, y_, z_] := N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z - x\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* y (- z x))))
double code(double x, double y, double z) {
return x + (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 = x + (y * (z - x))
end function
public static double code(double x, double y, double z) {
return x + (y * (z - x));
}
def code(x, y, z): return x + (y * (z - x))
function code(x, y, z) return Float64(x + Float64(y * Float64(z - x))) end
function tmp = code(x, y, z) tmp = x + (y * (z - x)); end
code[x_, y_, z_] := N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z - x\right)
\end{array}
(FPCore (x y z) :precision binary64 (+ x (* y (- z x))))
double code(double x, double y, double z) {
return x + (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 = x + (y * (z - x))
end function
public static double code(double x, double y, double z) {
return x + (y * (z - x));
}
def code(x, y, z): return x + (y * (z - x))
function code(x, y, z) return Float64(x + Float64(y * Float64(z - x))) end
function tmp = code(x, y, z) tmp = x + (y * (z - x)); end
code[x_, y_, z_] := N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z - x\right)
\end{array}
Initial program 100.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.6e-69) (not (<= z 6.6e-65))) (+ x (* y z)) (- x (* x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.6e-69) || !(z <= 6.6e-65)) {
tmp = x + (y * z);
} else {
tmp = x - (x * y);
}
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 ((z <= (-6.6d-69)) .or. (.not. (z <= 6.6d-65))) then
tmp = x + (y * z)
else
tmp = x - (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.6e-69) || !(z <= 6.6e-65)) {
tmp = x + (y * z);
} else {
tmp = x - (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.6e-69) or not (z <= 6.6e-65): tmp = x + (y * z) else: tmp = x - (x * y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.6e-69) || !(z <= 6.6e-65)) tmp = Float64(x + Float64(y * z)); else tmp = Float64(x - Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.6e-69) || ~((z <= 6.6e-65))) tmp = x + (y * z); else tmp = x - (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.6e-69], N[Not[LessEqual[z, 6.6e-65]], $MachinePrecision]], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.6 \cdot 10^{-69} \lor \neg \left(z \leq 6.6 \cdot 10^{-65}\right):\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot y\\
\end{array}
\end{array}
if z < -6.6000000000000001e-69 or 6.6000000000000002e-65 < z Initial program 100.0%
Taylor expanded in z around inf 86.8%
if -6.6000000000000001e-69 < z < 6.6000000000000002e-65Initial program 100.0%
Taylor expanded in x around inf 88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
sub-neg88.3%
distribute-rgt-in88.3%
*-un-lft-identity88.3%
distribute-lft-neg-in88.3%
unsub-neg88.3%
Applied egg-rr88.3%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -7.5e-69) (not (<= z 1.6e-64))) (+ x (* y z)) (* x (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7.5e-69) || !(z <= 1.6e-64)) {
tmp = x + (y * z);
} else {
tmp = x * (1.0 - y);
}
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 ((z <= (-7.5d-69)) .or. (.not. (z <= 1.6d-64))) then
tmp = x + (y * z)
else
tmp = x * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -7.5e-69) || !(z <= 1.6e-64)) {
tmp = x + (y * z);
} else {
tmp = x * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7.5e-69) or not (z <= 1.6e-64): tmp = x + (y * z) else: tmp = x * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7.5e-69) || !(z <= 1.6e-64)) tmp = Float64(x + Float64(y * z)); else tmp = Float64(x * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -7.5e-69) || ~((z <= 1.6e-64))) tmp = x + (y * z); else tmp = x * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7.5e-69], N[Not[LessEqual[z, 1.6e-64]], $MachinePrecision]], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{-69} \lor \neg \left(z \leq 1.6 \cdot 10^{-64}\right):\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -7.5e-69 or 1.59999999999999988e-64 < z Initial program 100.0%
Taylor expanded in z around inf 86.8%
if -7.5e-69 < z < 1.59999999999999988e-64Initial program 100.0%
Taylor expanded in x around inf 88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.2e-13) (not (<= y 9e+18))) (* x (- y)) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.2e-13) || !(y <= 9e+18)) {
tmp = x * -y;
} else {
tmp = 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 <= (-3.2d-13)) .or. (.not. (y <= 9d+18))) then
tmp = x * -y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.2e-13) || !(y <= 9e+18)) {
tmp = x * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.2e-13) or not (y <= 9e+18): tmp = x * -y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.2e-13) || !(y <= 9e+18)) tmp = Float64(x * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.2e-13) || ~((y <= 9e+18))) tmp = x * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.2e-13], N[Not[LessEqual[y, 9e+18]], $MachinePrecision]], N[(x * (-y)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-13} \lor \neg \left(y \leq 9 \cdot 10^{+18}\right):\\
\;\;\;\;x \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -3.2e-13 or 9e18 < y Initial program 100.0%
Taylor expanded in x around inf 51.3%
mul-1-neg51.3%
unsub-neg51.3%
Simplified51.3%
Taylor expanded in y around inf 51.3%
neg-mul-151.3%
Simplified51.3%
if -3.2e-13 < y < 9e18Initial program 100.0%
Taylor expanded in y around 0 71.3%
Final simplification60.2%
(FPCore (x y z) :precision binary64 (if (<= z -4.1e+273) (* x y) (* x (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.1e+273) {
tmp = x * y;
} else {
tmp = x * (1.0 - y);
}
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 (z <= (-4.1d+273)) then
tmp = x * y
else
tmp = x * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.1e+273) {
tmp = x * y;
} else {
tmp = x * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.1e+273: tmp = x * y else: tmp = x * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.1e+273) tmp = Float64(x * y); else tmp = Float64(x * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.1e+273) tmp = x * y; else tmp = x * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.1e+273], N[(x * y), $MachinePrecision], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{+273}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -4.09999999999999991e273Initial program 100.0%
Taylor expanded in x around inf 1.6%
mul-1-neg1.6%
unsub-neg1.6%
Simplified1.6%
Taylor expanded in y around inf 1.5%
neg-mul-11.5%
Simplified1.5%
neg-sub01.5%
sub-neg1.5%
add-sqr-sqrt0.4%
sqrt-unprod8.7%
sqr-neg8.7%
sqrt-unprod8.3%
add-sqr-sqrt30.5%
Applied egg-rr30.5%
+-lft-identity30.5%
Simplified30.5%
if -4.09999999999999991e273 < z Initial program 100.0%
Taylor expanded in x around inf 63.9%
mul-1-neg63.9%
unsub-neg63.9%
Simplified63.9%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
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 x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 33.3%
herbie shell --seed 2024181
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))