
(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%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (<= y -4.2e+267) (* x (- y)) (if (or (<= y -8.5e-41) (not (<= y 2.3e-27))) (* y z) x)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+267) {
tmp = x * -y;
} else if ((y <= -8.5e-41) || !(y <= 2.3e-27)) {
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 <= (-4.2d+267)) then
tmp = x * -y
else if ((y <= (-8.5d-41)) .or. (.not. (y <= 2.3d-27))) 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 <= -4.2e+267) {
tmp = x * -y;
} else if ((y <= -8.5e-41) || !(y <= 2.3e-27)) {
tmp = y * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e+267: tmp = x * -y elif (y <= -8.5e-41) or not (y <= 2.3e-27): tmp = y * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e+267) tmp = Float64(x * Float64(-y)); elseif ((y <= -8.5e-41) || !(y <= 2.3e-27)) tmp = Float64(y * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.2e+267) tmp = x * -y; elseif ((y <= -8.5e-41) || ~((y <= 2.3e-27))) tmp = y * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e+267], N[(x * (-y)), $MachinePrecision], If[Or[LessEqual[y, -8.5e-41], N[Not[LessEqual[y, 2.3e-27]], $MachinePrecision]], N[(y * z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+267}:\\
\;\;\;\;x \cdot \left(-y\right)\\
\mathbf{elif}\;y \leq -8.5 \cdot 10^{-41} \lor \neg \left(y \leq 2.3 \cdot 10^{-27}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -4.20000000000000007e267Initial program 99.8%
Taylor expanded in z around 0 87.3%
mul-1-neg87.3%
distribute-lft-neg-out87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in y around inf 87.3%
associate-*r*87.3%
mul-1-neg87.3%
Simplified87.3%
if -4.20000000000000007e267 < y < -8.4999999999999996e-41 or 2.2999999999999999e-27 < y Initial program 100.0%
Taylor expanded in z around inf 66.9%
Taylor expanded in x around 0 63.6%
if -8.4999999999999996e-41 < y < 2.2999999999999999e-27Initial program 100.0%
Taylor expanded in z around inf 100.0%
Taylor expanded in x around inf 76.3%
Final simplification70.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.7e+46) (not (<= x 4.5e+119))) (- x (* x y)) (+ x (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e+46) || !(x <= 4.5e+119)) {
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 <= (-1.7d+46)) .or. (.not. (x <= 4.5d+119))) 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 <= -1.7e+46) || !(x <= 4.5e+119)) {
tmp = x - (x * y);
} else {
tmp = x + (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.7e+46) or not (x <= 4.5e+119): tmp = x - (x * y) else: tmp = x + (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.7e+46) || !(x <= 4.5e+119)) 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 <= -1.7e+46) || ~((x <= 4.5e+119))) tmp = x - (x * y); else tmp = x + (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.7e+46], N[Not[LessEqual[x, 4.5e+119]], $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 -1.7 \cdot 10^{+46} \lor \neg \left(x \leq 4.5 \cdot 10^{+119}\right):\\
\;\;\;\;x - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot z\\
\end{array}
\end{array}
if x < -1.6999999999999999e46 or 4.5000000000000002e119 < x Initial program 100.0%
Taylor expanded in z around 0 90.5%
mul-1-neg90.5%
distribute-lft-neg-out90.5%
*-commutative90.5%
Simplified90.5%
*-commutative90.5%
distribute-lft-neg-out90.5%
unsub-neg90.5%
Applied egg-rr90.5%
if -1.6999999999999999e46 < x < 4.5000000000000002e119Initial program 100.0%
Taylor expanded in z around inf 91.4%
Final simplification91.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.2e-38) (not (<= y 5.2e-28))) (* y z) x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e-38) || !(y <= 5.2e-28)) {
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.2d-38)) .or. (.not. (y <= 5.2d-28))) 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.2e-38) || !(y <= 5.2e-28)) {
tmp = y * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.2e-38) or not (y <= 5.2e-28): tmp = y * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.2e-38) || !(y <= 5.2e-28)) tmp = Float64(y * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.2e-38) || ~((y <= 5.2e-28))) tmp = y * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.2e-38], N[Not[LessEqual[y, 5.2e-28]], $MachinePrecision]], N[(y * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-38} \lor \neg \left(y \leq 5.2 \cdot 10^{-28}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -6.19999999999999966e-38 or 5.2e-28 < y Initial program 100.0%
Taylor expanded in z around inf 64.9%
Taylor expanded in x around 0 61.7%
if -6.19999999999999966e-38 < y < 5.2e-28Initial program 100.0%
Taylor expanded in z around inf 100.0%
Taylor expanded in x around inf 76.3%
Final simplification68.4%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+268) (* x (- y)) (+ x (* y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+268) {
tmp = 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 (y <= (-7.2d+268)) then
tmp = 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 (y <= -7.2e+268) {
tmp = x * -y;
} else {
tmp = x + (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+268: tmp = x * -y else: tmp = x + (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+268) tmp = Float64(x * Float64(-y)); else tmp = Float64(x + Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+268) tmp = x * -y; else tmp = x + (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+268], N[(x * (-y)), $MachinePrecision], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+268}:\\
\;\;\;\;x \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot z\\
\end{array}
\end{array}
if y < -7.19999999999999981e268Initial program 99.8%
Taylor expanded in z around 0 87.3%
mul-1-neg87.3%
distribute-lft-neg-out87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in y around inf 87.3%
associate-*r*87.3%
mul-1-neg87.3%
Simplified87.3%
if -7.19999999999999981e268 < y Initial program 100.0%
Taylor expanded in z around inf 82.4%
Final simplification82.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 z around inf 81.0%
Taylor expanded in x around inf 38.0%
Final simplification38.0%
herbie shell --seed 2024079
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))