
(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 5 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%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y 4.6e+46) (not (<= y 6.5e+86))) (+ x (* y z)) (* x (- y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= 4.6e+46) || !(y <= 6.5e+86)) {
tmp = x + (y * z);
} else {
tmp = 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 ((y <= 4.6d+46) .or. (.not. (y <= 6.5d+86))) then
tmp = x + (y * z)
else
tmp = x * -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= 4.6e+46) || !(y <= 6.5e+86)) {
tmp = x + (y * z);
} else {
tmp = x * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 4.6e+46) or not (y <= 6.5e+86): tmp = x + (y * z) else: tmp = x * -y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 4.6e+46) || !(y <= 6.5e+86)) tmp = Float64(x + Float64(y * z)); else tmp = Float64(x * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= 4.6e+46) || ~((y <= 6.5e+86))) tmp = x + (y * z); else tmp = x * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 4.6e+46], N[Not[LessEqual[y, 6.5e+86]], $MachinePrecision]], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.6 \cdot 10^{+46} \lor \neg \left(y \leq 6.5 \cdot 10^{+86}\right):\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-y\right)\\
\end{array}
\end{array}
if y < 4.6000000000000001e46 or 6.49999999999999996e86 < y Initial program 100.0%
Taylor expanded in z around inf 86.5%
if 4.6000000000000001e46 < y < 6.49999999999999996e86Initial program 100.0%
Taylor expanded in z around 0 80.0%
mul-1-neg80.0%
distribute-rgt-neg-out80.0%
Simplified80.0%
Taylor expanded in y around inf 80.0%
associate-*r*80.0%
neg-mul-180.0%
Simplified80.0%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.8e+223) (not (<= x 5.2e-31))) (- x (* x y)) (+ x (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e+223) || !(x <= 5.2e-31)) {
tmp = x - (x * y);
} else {
tmp = x + (y * 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 ((x <= (-5.8d+223)) .or. (.not. (x <= 5.2d-31))) then
tmp = x - (x * y)
else
tmp = x + (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e+223) || !(x <= 5.2e-31)) {
tmp = x - (x * y);
} else {
tmp = x + (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.8e+223) or not (x <= 5.2e-31): tmp = x - (x * y) else: tmp = x + (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.8e+223) || !(x <= 5.2e-31)) tmp = Float64(x - Float64(x * y)); else tmp = Float64(x + Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.8e+223) || ~((x <= 5.2e-31))) tmp = x - (x * y); else tmp = x + (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.8e+223], N[Not[LessEqual[x, 5.2e-31]], $MachinePrecision]], N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+223} \lor \neg \left(x \leq 5.2 \cdot 10^{-31}\right):\\
\;\;\;\;x - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot z\\
\end{array}
\end{array}
if x < -5.8000000000000004e223 or 5.19999999999999991e-31 < x Initial program 100.0%
Taylor expanded in z around 0 92.3%
mul-1-neg92.3%
distribute-rgt-neg-out92.3%
Simplified92.3%
Taylor expanded in x around 0 92.3%
neg-mul-192.3%
+-commutative92.3%
distribute-rgt1-in92.3%
cancel-sign-sub-inv92.3%
Simplified92.3%
if -5.8000000000000004e223 < x < 5.19999999999999991e-31Initial program 100.0%
Taylor expanded in z around inf 86.6%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.2e-6) (not (<= y 48.0))) (* x (- y)) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e-6) || !(y <= 48.0)) {
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 <= (-6.2d-6)) .or. (.not. (y <= 48.0d0))) 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 <= -6.2e-6) || !(y <= 48.0)) {
tmp = x * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.2e-6) or not (y <= 48.0): tmp = x * -y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.2e-6) || !(y <= 48.0)) tmp = Float64(x * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.2e-6) || ~((y <= 48.0))) tmp = x * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.2e-6], N[Not[LessEqual[y, 48.0]], $MachinePrecision]], N[(x * (-y)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-6} \lor \neg \left(y \leq 48\right):\\
\;\;\;\;x \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -6.1999999999999999e-6 or 48 < y Initial program 100.0%
Taylor expanded in z around 0 49.2%
mul-1-neg49.2%
distribute-rgt-neg-out49.2%
Simplified49.2%
Taylor expanded in y around inf 49.0%
associate-*r*49.0%
neg-mul-149.0%
Simplified49.0%
if -6.1999999999999999e-6 < y < 48Initial program 100.0%
Taylor expanded in z around 0 71.9%
mul-1-neg71.9%
distribute-rgt-neg-out71.9%
Simplified71.9%
Taylor expanded in y around 0 71.3%
Final simplification60.8%
(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 z around 0 61.3%
mul-1-neg61.3%
distribute-rgt-neg-out61.3%
Simplified61.3%
Taylor expanded in y around 0 39.1%
Final simplification39.1%
herbie shell --seed 2023185
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))