
(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
(let* ((t_0 (* y (- z x))) (t_1 (* x (- 1.0 y))))
(if (<= y -1.25e-7)
t_0
(if (<= y 9e-148)
t_1
(if (<= y 4e-138) (* y z) (if (<= y 0.65) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = y * (z - x);
double t_1 = x * (1.0 - y);
double tmp;
if (y <= -1.25e-7) {
tmp = t_0;
} else if (y <= 9e-148) {
tmp = t_1;
} else if (y <= 4e-138) {
tmp = y * z;
} else if (y <= 0.65) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = y * (z - x)
t_1 = x * (1.0d0 - y)
if (y <= (-1.25d-7)) then
tmp = t_0
else if (y <= 9d-148) then
tmp = t_1
else if (y <= 4d-138) then
tmp = y * z
else if (y <= 0.65d0) then
tmp = t_1
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 - x);
double t_1 = x * (1.0 - y);
double tmp;
if (y <= -1.25e-7) {
tmp = t_0;
} else if (y <= 9e-148) {
tmp = t_1;
} else if (y <= 4e-138) {
tmp = y * z;
} else if (y <= 0.65) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z - x) t_1 = x * (1.0 - y) tmp = 0 if y <= -1.25e-7: tmp = t_0 elif y <= 9e-148: tmp = t_1 elif y <= 4e-138: tmp = y * z elif y <= 0.65: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z - x)) t_1 = Float64(x * Float64(1.0 - y)) tmp = 0.0 if (y <= -1.25e-7) tmp = t_0; elseif (y <= 9e-148) tmp = t_1; elseif (y <= 4e-138) tmp = Float64(y * z); elseif (y <= 0.65) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z - x); t_1 = x * (1.0 - y); tmp = 0.0; if (y <= -1.25e-7) tmp = t_0; elseif (y <= 9e-148) tmp = t_1; elseif (y <= 4e-138) tmp = y * z; elseif (y <= 0.65) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.25e-7], t$95$0, If[LessEqual[y, 9e-148], t$95$1, If[LessEqual[y, 4e-138], N[(y * z), $MachinePrecision], If[LessEqual[y, 0.65], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z - x\right)\\
t_1 := x \cdot \left(1 - y\right)\\
\mathbf{if}\;y \leq -1.25 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-148}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-138}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 0.65:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.24999999999999994e-7 or 0.650000000000000022 < y Initial program 100.0%
Taylor expanded in y around inf 0
Simplified0
if -1.24999999999999994e-7 < y < 9.00000000000000029e-148 or 4.00000000000000027e-138 < y < 0.650000000000000022Initial program 100.0%
Taylor expanded in x around inf 0
Simplified0
if 9.00000000000000029e-148 < y < 4.00000000000000027e-138Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
(FPCore (x y z)
:precision binary64
(if (<= y -1.18e-7)
(* y z)
(if (<= y 9e-148)
x
(if (<= y 4e-138) (* y z) (if (<= y 6.5e-12) x (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.18e-7) {
tmp = y * z;
} else if (y <= 9e-148) {
tmp = x;
} else if (y <= 4e-138) {
tmp = y * z;
} else if (y <= 6.5e-12) {
tmp = x;
} else {
tmp = 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 (y <= (-1.18d-7)) then
tmp = y * z
else if (y <= 9d-148) then
tmp = x
else if (y <= 4d-138) then
tmp = y * z
else if (y <= 6.5d-12) then
tmp = x
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.18e-7) {
tmp = y * z;
} else if (y <= 9e-148) {
tmp = x;
} else if (y <= 4e-138) {
tmp = y * z;
} else if (y <= 6.5e-12) {
tmp = x;
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.18e-7: tmp = y * z elif y <= 9e-148: tmp = x elif y <= 4e-138: tmp = y * z elif y <= 6.5e-12: tmp = x else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.18e-7) tmp = Float64(y * z); elseif (y <= 9e-148) tmp = x; elseif (y <= 4e-138) tmp = Float64(y * z); elseif (y <= 6.5e-12) tmp = x; else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.18e-7) tmp = y * z; elseif (y <= 9e-148) tmp = x; elseif (y <= 4e-138) tmp = y * z; elseif (y <= 6.5e-12) tmp = x; else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.18e-7], N[(y * z), $MachinePrecision], If[LessEqual[y, 9e-148], x, If[LessEqual[y, 4e-138], N[(y * z), $MachinePrecision], If[LessEqual[y, 6.5e-12], x, N[(y * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.18 \cdot 10^{-7}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-148}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-138}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-12}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if y < -1.18e-7 or 9.00000000000000029e-148 < y < 4.00000000000000027e-138 or 6.5000000000000002e-12 < y Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
if -1.18e-7 < y < 9.00000000000000029e-148 or 4.00000000000000027e-138 < y < 6.5000000000000002e-12Initial program 100.0%
Taylor expanded in y around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (- z x)))) (if (<= y -4000000.0) t_0 (if (<= y 1.0) (+ x (* y z)) t_0))))
double code(double x, double y, double z) {
double t_0 = y * (z - x);
double tmp;
if (y <= -4000000.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = x + (y * z);
} 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 - x)
if (y <= (-4000000.0d0)) then
tmp = t_0
else if (y <= 1.0d0) then
tmp = x + (y * z)
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 - x);
double tmp;
if (y <= -4000000.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = x + (y * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z - x) tmp = 0 if y <= -4000000.0: tmp = t_0 elif y <= 1.0: tmp = x + (y * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z - x)) tmp = 0.0 if (y <= -4000000.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(x + Float64(y * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z - x); tmp = 0.0; if (y <= -4000000.0) tmp = t_0; elseif (y <= 1.0) tmp = x + (y * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4000000.0], t$95$0, If[LessEqual[y, 1.0], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z - x\right)\\
\mathbf{if}\;y \leq -4000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4e6 or 1 < y Initial program 100.0%
Taylor expanded in y around inf 0
Simplified0
if -4e6 < y < 1Initial program 100.0%
Taylor expanded in z around inf 0
Simplified0
(FPCore (x y z) :precision binary64 (if (<= z -4.8e+128) (* y z) (if (<= z 3.2e+24) (* x (- 1.0 y)) (* y z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.8e+128) {
tmp = y * z;
} else if (z <= 3.2e+24) {
tmp = x * (1.0 - y);
} else {
tmp = 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 (z <= (-4.8d+128)) then
tmp = y * z
else if (z <= 3.2d+24) then
tmp = x * (1.0d0 - y)
else
tmp = y * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.8e+128) {
tmp = y * z;
} else if (z <= 3.2e+24) {
tmp = x * (1.0 - y);
} else {
tmp = y * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.8e+128: tmp = y * z elif z <= 3.2e+24: tmp = x * (1.0 - y) else: tmp = y * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.8e+128) tmp = Float64(y * z); elseif (z <= 3.2e+24) tmp = Float64(x * Float64(1.0 - y)); else tmp = Float64(y * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.8e+128) tmp = y * z; elseif (z <= 3.2e+24) tmp = x * (1.0 - y); else tmp = y * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.8e+128], N[(y * z), $MachinePrecision], If[LessEqual[z, 3.2e+24], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], N[(y * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+128}:\\
\;\;\;\;y \cdot z\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+24}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot z\\
\end{array}
\end{array}
if z < -4.8000000000000004e128 or 3.1999999999999997e24 < z Initial program 100.0%
Taylor expanded in x around 0 0
Simplified0
if -4.8000000000000004e128 < z < 3.1999999999999997e24Initial program 100.0%
Taylor expanded in x around inf 0
Simplified0
(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 0
Simplified0
herbie shell --seed 2024110
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))