
(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 (fma y (- z x) x))
double code(double x, double y, double z) {
return fma(y, (z - x), x);
}
function code(x, y, z) return fma(y, Float64(z - x), x) end
code[x_, y_, z_] := N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, z - x, x\right)
\end{array}
Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.2e-25) (not (<= z 3.05e-95))) (+ x (* y z)) (* x (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.2e-25) || !(z <= 3.05e-95)) {
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 <= (-8.2d-25)) .or. (.not. (z <= 3.05d-95))) 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 <= -8.2e-25) || !(z <= 3.05e-95)) {
tmp = x + (y * z);
} else {
tmp = x * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.2e-25) or not (z <= 3.05e-95): tmp = x + (y * z) else: tmp = x * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.2e-25) || !(z <= 3.05e-95)) 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 <= -8.2e-25) || ~((z <= 3.05e-95))) tmp = x + (y * z); else tmp = x * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.2e-25], N[Not[LessEqual[z, 3.05e-95]], $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 -8.2 \cdot 10^{-25} \lor \neg \left(z \leq 3.05 \cdot 10^{-95}\right):\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -8.19999999999999974e-25 or 3.0499999999999997e-95 < z Initial program 100.0%
Taylor expanded in z around inf 88.6%
if -8.19999999999999974e-25 < z < 3.0499999999999997e-95Initial program 100.0%
Taylor expanded in x around inf 91.9%
mul-1-neg91.9%
unsub-neg91.9%
Simplified91.9%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.76e-25) (not (<= z 3.05e-95))) (+ x (* y z)) (- x (* y x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.76e-25) || !(z <= 3.05e-95)) {
tmp = x + (y * z);
} else {
tmp = x - (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 ((z <= (-1.76d-25)) .or. (.not. (z <= 3.05d-95))) then
tmp = x + (y * z)
else
tmp = x - (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.76e-25) || !(z <= 3.05e-95)) {
tmp = x + (y * z);
} else {
tmp = x - (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.76e-25) or not (z <= 3.05e-95): tmp = x + (y * z) else: tmp = x - (y * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.76e-25) || !(z <= 3.05e-95)) tmp = Float64(x + Float64(y * z)); else tmp = Float64(x - Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.76e-25) || ~((z <= 3.05e-95))) tmp = x + (y * z); else tmp = x - (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.76e-25], N[Not[LessEqual[z, 3.05e-95]], $MachinePrecision]], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.76 \cdot 10^{-25} \lor \neg \left(z \leq 3.05 \cdot 10^{-95}\right):\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot x\\
\end{array}
\end{array}
if z < -1.7600000000000001e-25 or 3.0499999999999997e-95 < z Initial program 100.0%
Taylor expanded in z around inf 88.6%
if -1.7600000000000001e-25 < z < 3.0499999999999997e-95Initial program 100.0%
Taylor expanded in x around inf 91.9%
mul-1-neg91.9%
unsub-neg91.9%
Simplified91.9%
sub-neg91.9%
distribute-rgt-in92.0%
*-un-lft-identity92.0%
distribute-lft-neg-in92.0%
unsub-neg92.0%
Applied egg-rr92.0%
Final simplification89.8%
(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%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (* x (- 1.0 y)))
double code(double x, double y, double z) {
return x * (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 * (1.0d0 - y)
end function
public static double code(double x, double y, double z) {
return x * (1.0 - y);
}
def code(x, y, z): return x * (1.0 - y)
function code(x, y, z) return Float64(x * Float64(1.0 - y)) end
function tmp = code(x, y, z) tmp = x * (1.0 - y); end
code[x_, y_, z_] := N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
Final simplification59.6%
(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.8%
Final simplification33.8%
herbie shell --seed 2023325
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))