
(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 7 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 (<= y -2.2e-22) (* y z) (if (<= y 3e-35) x (if (<= y 4.5e+204) (* y z) (* x (- y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.2e-22) {
tmp = y * z;
} else if (y <= 3e-35) {
tmp = x;
} else if (y <= 4.5e+204) {
tmp = 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 <= (-2.2d-22)) then
tmp = y * z
else if (y <= 3d-35) then
tmp = x
else if (y <= 4.5d+204) then
tmp = 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 <= -2.2e-22) {
tmp = y * z;
} else if (y <= 3e-35) {
tmp = x;
} else if (y <= 4.5e+204) {
tmp = y * z;
} else {
tmp = x * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.2e-22: tmp = y * z elif y <= 3e-35: tmp = x elif y <= 4.5e+204: tmp = y * z else: tmp = x * -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.2e-22) tmp = Float64(y * z); elseif (y <= 3e-35) tmp = x; elseif (y <= 4.5e+204) tmp = 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 <= -2.2e-22) tmp = y * z; elseif (y <= 3e-35) tmp = x; elseif (y <= 4.5e+204) tmp = y * z; else tmp = x * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.2e-22], N[(y * z), $MachinePrecision], If[LessEqual[y, 3e-35], x, If[LessEqual[y, 4.5e+204], N[(y * z), $MachinePrecision], N[(x * (-y)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-22}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-35}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+204}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-y\right)\\
\end{array}
\end{array}
if y < -2.2000000000000001e-22 or 2.99999999999999989e-35 < y < 4.50000000000000002e204Initial program 100.0%
Taylor expanded in z around inf 61.4%
Taylor expanded in x around 0 58.6%
if -2.2000000000000001e-22 < y < 2.99999999999999989e-35Initial program 100.0%
Taylor expanded in y around 0 75.6%
if 4.50000000000000002e204 < y Initial program 100.0%
Taylor expanded in x around inf 66.0%
mul-1-neg66.0%
unsub-neg66.0%
Simplified66.0%
Taylor expanded in y around inf 66.0%
mul-1-neg66.0%
distribute-rgt-neg-out66.0%
Simplified66.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.3e-25) (not (<= z 8.5e-60))) (+ x (* y z)) (* x (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.3e-25) || !(z <= 8.5e-60)) {
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 <= (-3.3d-25)) .or. (.not. (z <= 8.5d-60))) 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 <= -3.3e-25) || !(z <= 8.5e-60)) {
tmp = x + (y * z);
} else {
tmp = x * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.3e-25) or not (z <= 8.5e-60): tmp = x + (y * z) else: tmp = x * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.3e-25) || !(z <= 8.5e-60)) 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 <= -3.3e-25) || ~((z <= 8.5e-60))) tmp = x + (y * z); else tmp = x * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.3e-25], N[Not[LessEqual[z, 8.5e-60]], $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 -3.3 \cdot 10^{-25} \lor \neg \left(z \leq 8.5 \cdot 10^{-60}\right):\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -3.2999999999999998e-25 or 8.50000000000000044e-60 < z Initial program 100.0%
Taylor expanded in z around inf 88.8%
if -3.2999999999999998e-25 < z < 8.50000000000000044e-60Initial program 100.0%
Taylor expanded in x around inf 93.1%
mul-1-neg93.1%
unsub-neg93.1%
Simplified93.1%
Final simplification90.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05e+34) (not (<= z 1.2e+131))) (* y z) (* x (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e+34) || !(z <= 1.2e+131)) {
tmp = 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 <= (-1.05d+34)) .or. (.not. (z <= 1.2d+131))) then
tmp = 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 <= -1.05e+34) || !(z <= 1.2e+131)) {
tmp = y * z;
} else {
tmp = x * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05e+34) or not (z <= 1.2e+131): tmp = y * z else: tmp = x * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05e+34) || !(z <= 1.2e+131)) tmp = 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 <= -1.05e+34) || ~((z <= 1.2e+131))) tmp = y * z; else tmp = x * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05e+34], N[Not[LessEqual[z, 1.2e+131]], $MachinePrecision]], N[(y * z), $MachinePrecision], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+34} \lor \neg \left(z \leq 1.2 \cdot 10^{+131}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -1.05000000000000009e34 or 1.2e131 < z Initial program 100.0%
Taylor expanded in z around inf 93.1%
Taylor expanded in x around 0 69.8%
if -1.05000000000000009e34 < z < 1.2e131Initial program 100.0%
Taylor expanded in x around inf 83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
Final simplification77.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.4e-25) (not (<= y 4e-35))) (* y z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e-25) || !(y <= 4e-35)) {
tmp = y * z;
} 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.4d-25)) .or. (.not. (y <= 4d-35))) then
tmp = y * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e-25) || !(y <= 4e-35)) {
tmp = y * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.4e-25) or not (y <= 4e-35): tmp = y * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.4e-25) || !(y <= 4e-35)) tmp = Float64(y * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.4e-25) || ~((y <= 4e-35))) tmp = y * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.4e-25], N[Not[LessEqual[y, 4e-35]], $MachinePrecision]], N[(y * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{-25} \lor \neg \left(y \leq 4 \cdot 10^{-35}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -6.4000000000000002e-25 or 4.00000000000000003e-35 < y Initial program 100.0%
Taylor expanded in z around inf 58.6%
Taylor expanded in x around 0 56.5%
if -6.4000000000000002e-25 < y < 4.00000000000000003e-35Initial program 100.0%
Taylor expanded in y around 0 75.6%
Final simplification65.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 38.1%
(FPCore (x y z) :precision binary64 0.0)
double code(double x, double y, double z) {
return 0.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.0d0
end function
public static double code(double x, double y, double z) {
return 0.0;
}
def code(x, y, z): return 0.0
function code(x, y, z) return 0.0 end
function tmp = code(x, y, z) tmp = 0.0; end
code[x_, y_, z_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 61.9%
mul-1-neg61.9%
unsub-neg61.9%
Simplified61.9%
Taylor expanded in y around inf 26.8%
mul-1-neg26.8%
distribute-rgt-neg-out26.8%
Simplified26.8%
add-log-exp19.8%
add-sqr-sqrt19.7%
sqrt-unprod19.8%
exp-prod19.7%
add-sqr-sqrt12.1%
sqrt-unprod12.3%
sqr-neg12.3%
sqrt-unprod4.7%
add-sqr-sqrt4.9%
pow-flip4.9%
exp-prod1.6%
rgt-mult-inverse2.5%
metadata-eval2.5%
metadata-eval2.5%
Applied egg-rr2.5%
herbie shell --seed 2024160
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))