
(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 (+ (* (- z x) y) x))
double code(double x, double y, double z) {
return ((z - x) * y) + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((z - x) * y) + x
end function
public static double code(double x, double y, double z) {
return ((z - x) * y) + x;
}
def code(x, y, z): return ((z - x) * y) + x
function code(x, y, z) return Float64(Float64(Float64(z - x) * y) + x) end
function tmp = code(x, y, z) tmp = ((z - x) * y) + x; end
code[x_, y_, z_] := N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(z - x\right) \cdot y + x
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -7.2e+147)
(* z y)
(if (<= y -5.6e+16)
(* (- x) y)
(if (<= y -3.6e-100) (* z y) (if (<= y 4.6e-57) (* 1.0 x) (* z y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+147) {
tmp = z * y;
} else if (y <= -5.6e+16) {
tmp = -x * y;
} else if (y <= -3.6e-100) {
tmp = z * y;
} else if (y <= 4.6e-57) {
tmp = 1.0 * x;
} else {
tmp = z * 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 <= (-7.2d+147)) then
tmp = z * y
else if (y <= (-5.6d+16)) then
tmp = -x * y
else if (y <= (-3.6d-100)) then
tmp = z * y
else if (y <= 4.6d-57) then
tmp = 1.0d0 * x
else
tmp = z * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+147) {
tmp = z * y;
} else if (y <= -5.6e+16) {
tmp = -x * y;
} else if (y <= -3.6e-100) {
tmp = z * y;
} else if (y <= 4.6e-57) {
tmp = 1.0 * x;
} else {
tmp = z * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+147: tmp = z * y elif y <= -5.6e+16: tmp = -x * y elif y <= -3.6e-100: tmp = z * y elif y <= 4.6e-57: tmp = 1.0 * x else: tmp = z * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+147) tmp = Float64(z * y); elseif (y <= -5.6e+16) tmp = Float64(Float64(-x) * y); elseif (y <= -3.6e-100) tmp = Float64(z * y); elseif (y <= 4.6e-57) tmp = Float64(1.0 * x); else tmp = Float64(z * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+147) tmp = z * y; elseif (y <= -5.6e+16) tmp = -x * y; elseif (y <= -3.6e-100) tmp = z * y; elseif (y <= 4.6e-57) tmp = 1.0 * x; else tmp = z * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+147], N[(z * y), $MachinePrecision], If[LessEqual[y, -5.6e+16], N[((-x) * y), $MachinePrecision], If[LessEqual[y, -3.6e-100], N[(z * y), $MachinePrecision], If[LessEqual[y, 4.6e-57], N[(1.0 * x), $MachinePrecision], N[(z * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+147}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;y \leq -5.6 \cdot 10^{+16}:\\
\;\;\;\;\left(-x\right) \cdot y\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{-100}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-57}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if y < -7.20000000000000041e147 or -5.6e16 < y < -3.5999999999999999e-100 or 4.6e-57 < y Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6461.2
Applied rewrites61.2%
if -7.20000000000000041e147 < y < -5.6e16Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
Applied rewrites74.5%
if -3.5999999999999999e-100 < y < 4.6e-57Initial program 100.0%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6475.6
Applied rewrites75.6%
Taylor expanded in y around 0
Applied rewrites75.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- z x) y))) (if (<= y -1.0) t_0 (if (<= y 4e-15) (+ (* z y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (z - x) * y;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 4e-15) {
tmp = (z * y) + 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 = (z - x) * y
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 4d-15) then
tmp = (z * y) + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z - x) * y;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 4e-15) {
tmp = (z * y) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z - x) * y tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 4e-15: tmp = (z * y) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z - x) * y) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 4e-15) tmp = Float64(Float64(z * y) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z - x) * y; tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 4e-15) tmp = (z * y) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 4e-15], N[(N[(z * y), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z - x\right) \cdot y\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-15}:\\
\;\;\;\;z \cdot y + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 4.0000000000000003e-15 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.9
Applied rewrites98.9%
if -1 < y < 4.0000000000000003e-15Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- z x) y))) (if (<= y -3.6e-100) t_0 (if (<= y 1.65e-56) (* 1.0 x) t_0))))
double code(double x, double y, double z) {
double t_0 = (z - x) * y;
double tmp;
if (y <= -3.6e-100) {
tmp = t_0;
} else if (y <= 1.65e-56) {
tmp = 1.0 * 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 = (z - x) * y
if (y <= (-3.6d-100)) then
tmp = t_0
else if (y <= 1.65d-56) then
tmp = 1.0d0 * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z - x) * y;
double tmp;
if (y <= -3.6e-100) {
tmp = t_0;
} else if (y <= 1.65e-56) {
tmp = 1.0 * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z - x) * y tmp = 0 if y <= -3.6e-100: tmp = t_0 elif y <= 1.65e-56: tmp = 1.0 * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z - x) * y) tmp = 0.0 if (y <= -3.6e-100) tmp = t_0; elseif (y <= 1.65e-56) tmp = Float64(1.0 * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z - x) * y; tmp = 0.0; if (y <= -3.6e-100) tmp = t_0; elseif (y <= 1.65e-56) tmp = 1.0 * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -3.6e-100], t$95$0, If[LessEqual[y, 1.65e-56], N[(1.0 * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z - x\right) \cdot y\\
\mathbf{if}\;y \leq -3.6 \cdot 10^{-100}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-56}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.5999999999999999e-100 or 1.64999999999999992e-56 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6495.8
Applied rewrites95.8%
if -3.5999999999999999e-100 < y < 1.64999999999999992e-56Initial program 100.0%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6475.6
Applied rewrites75.6%
Taylor expanded in y around 0
Applied rewrites75.6%
(FPCore (x y z) :precision binary64 (if (<= z -8.8e+64) (* z y) (if (<= z 9.5e+47) (* (- 1.0 y) x) (* z y))))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.8e+64) {
tmp = z * y;
} else if (z <= 9.5e+47) {
tmp = (1.0 - y) * x;
} else {
tmp = z * 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 <= (-8.8d+64)) then
tmp = z * y
else if (z <= 9.5d+47) then
tmp = (1.0d0 - y) * x
else
tmp = z * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -8.8e+64) {
tmp = z * y;
} else if (z <= 9.5e+47) {
tmp = (1.0 - y) * x;
} else {
tmp = z * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.8e+64: tmp = z * y elif z <= 9.5e+47: tmp = (1.0 - y) * x else: tmp = z * y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.8e+64) tmp = Float64(z * y); elseif (z <= 9.5e+47) tmp = Float64(Float64(1.0 - y) * x); else tmp = Float64(z * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.8e+64) tmp = z * y; elseif (z <= 9.5e+47) tmp = (1.0 - y) * x; else tmp = z * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.8e+64], N[(z * y), $MachinePrecision], If[LessEqual[z, 9.5e+47], N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.8 \cdot 10^{+64}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+47}:\\
\;\;\;\;\left(1 - y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if z < -8.80000000000000007e64 or 9.50000000000000001e47 < z Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6475.5
Applied rewrites75.5%
if -8.80000000000000007e64 < z < 9.50000000000000001e47Initial program 100.0%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6479.7
Applied rewrites79.7%
(FPCore (x y z) :precision binary64 (if (<= y -3.6e-100) (* z y) (if (<= y 4.6e-57) (* 1.0 x) (* z y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.6e-100) {
tmp = z * y;
} else if (y <= 4.6e-57) {
tmp = 1.0 * x;
} else {
tmp = z * 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 <= (-3.6d-100)) then
tmp = z * y
else if (y <= 4.6d-57) then
tmp = 1.0d0 * x
else
tmp = z * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.6e-100) {
tmp = z * y;
} else if (y <= 4.6e-57) {
tmp = 1.0 * x;
} else {
tmp = z * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.6e-100: tmp = z * y elif y <= 4.6e-57: tmp = 1.0 * x else: tmp = z * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.6e-100) tmp = Float64(z * y); elseif (y <= 4.6e-57) tmp = Float64(1.0 * x); else tmp = Float64(z * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.6e-100) tmp = z * y; elseif (y <= 4.6e-57) tmp = 1.0 * x; else tmp = z * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.6e-100], N[(z * y), $MachinePrecision], If[LessEqual[y, 4.6e-57], N[(1.0 * x), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{-100}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-57}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if y < -3.5999999999999999e-100 or 4.6e-57 < y Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6457.1
Applied rewrites57.1%
if -3.5999999999999999e-100 < y < 4.6e-57Initial program 100.0%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6475.6
Applied rewrites75.6%
Taylor expanded in y around 0
Applied rewrites75.6%
(FPCore (x y z) :precision binary64 (* z y))
double code(double x, double y, double z) {
return z * y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z * y
end function
public static double code(double x, double y, double z) {
return z * y;
}
def code(x, y, z): return z * y
function code(x, y, z) return Float64(z * y) end
function tmp = code(x, y, z) tmp = z * y; end
code[x_, y_, z_] := N[(z * y), $MachinePrecision]
\begin{array}{l}
\\
z \cdot y
\end{array}
Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6446.4
Applied rewrites46.4%
herbie shell --seed 2024268
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))