
(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)))) (if (<= y -1.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 <= -1.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 <= (-1.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 <= -1.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 <= -1.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 <= -1.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 <= -1.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, -1.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 -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x + y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 100.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
--lowering--.f64100.0%
Simplified100.0%
if -1 < y < 1Initial program 100.0%
Taylor expanded in z around inf
*-lowering-*.f6498.9%
Simplified98.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- 1.0 y)))) (if (<= x -1.5e-36) t_0 (if (<= x 1.05e+70) (* y (- z x)) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - y);
double tmp;
if (x <= -1.5e-36) {
tmp = t_0;
} else if (x <= 1.05e+70) {
tmp = y * (z - x);
} 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 = x * (1.0d0 - y)
if (x <= (-1.5d-36)) then
tmp = t_0
else if (x <= 1.05d+70) then
tmp = y * (z - x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - y);
double tmp;
if (x <= -1.5e-36) {
tmp = t_0;
} else if (x <= 1.05e+70) {
tmp = y * (z - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - y) tmp = 0 if x <= -1.5e-36: tmp = t_0 elif x <= 1.05e+70: tmp = y * (z - x) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - y)) tmp = 0.0 if (x <= -1.5e-36) tmp = t_0; elseif (x <= 1.05e+70) tmp = Float64(y * Float64(z - x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - y); tmp = 0.0; if (x <= -1.5e-36) tmp = t_0; elseif (x <= 1.05e+70) tmp = y * (z - x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.5e-36], t$95$0, If[LessEqual[x, 1.05e+70], N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - y\right)\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{-36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+70}:\\
\;\;\;\;y \cdot \left(z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.5000000000000001e-36 or 1.05000000000000004e70 < x Initial program 100.0%
Taylor expanded in x around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6489.6%
Simplified89.6%
if -1.5000000000000001e-36 < x < 1.05000000000000004e70Initial program 100.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
--lowering--.f6486.1%
Simplified86.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- 1.0 y)))) (if (<= x -2.7e-37) t_0 (if (<= x 9.5e-85) (* y z) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - y);
double tmp;
if (x <= -2.7e-37) {
tmp = t_0;
} else if (x <= 9.5e-85) {
tmp = 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 = x * (1.0d0 - y)
if (x <= (-2.7d-37)) then
tmp = t_0
else if (x <= 9.5d-85) then
tmp = 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 = x * (1.0 - y);
double tmp;
if (x <= -2.7e-37) {
tmp = t_0;
} else if (x <= 9.5e-85) {
tmp = y * z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - y) tmp = 0 if x <= -2.7e-37: tmp = t_0 elif x <= 9.5e-85: tmp = y * z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - y)) tmp = 0.0 if (x <= -2.7e-37) tmp = t_0; elseif (x <= 9.5e-85) tmp = Float64(y * z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - y); tmp = 0.0; if (x <= -2.7e-37) tmp = t_0; elseif (x <= 9.5e-85) tmp = y * z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.7e-37], t$95$0, If[LessEqual[x, 9.5e-85], N[(y * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - y\right)\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{-37}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-85}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.70000000000000016e-37 or 9.49999999999999964e-85 < x Initial program 100.0%
Taylor expanded in x around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6485.7%
Simplified85.7%
if -2.70000000000000016e-37 < x < 9.49999999999999964e-85Initial program 100.0%
Taylor expanded in x around 0
*-lowering-*.f6480.6%
Simplified80.6%
(FPCore (x y z) :precision binary64 (if (<= x -7.4e-37) x (if (<= x 4.9e+104) (* y z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -7.4e-37) {
tmp = x;
} else if (x <= 4.9e+104) {
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 (x <= (-7.4d-37)) then
tmp = x
else if (x <= 4.9d+104) 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 (x <= -7.4e-37) {
tmp = x;
} else if (x <= 4.9e+104) {
tmp = y * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7.4e-37: tmp = x elif x <= 4.9e+104: tmp = y * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7.4e-37) tmp = x; elseif (x <= 4.9e+104) tmp = Float64(y * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7.4e-37) tmp = x; elseif (x <= 4.9e+104) tmp = y * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7.4e-37], x, If[LessEqual[x, 4.9e+104], N[(y * z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{-37}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{+104}:\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.4e-37 or 4.89999999999999985e104 < x Initial program 100.0%
Taylor expanded in y around 0
Simplified45.4%
if -7.4e-37 < x < 4.89999999999999985e104Initial program 100.0%
Taylor expanded in x around 0
*-lowering-*.f6470.1%
Simplified70.1%
(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
Simplified30.1%
herbie shell --seed 2024191
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))