
(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
(let* ((t_0 (* (- x) y)))
(if (<= y -1.35e+191)
t_0
(if (<= y -1.6e-114)
(* z y)
(if (<= y 1.0)
(* 1.0 x)
(if (<= y 2.6e+123) t_0 (if (<= y 1.5e+253) (* z y) t_0)))))))
double code(double x, double y, double z) {
double t_0 = -x * y;
double tmp;
if (y <= -1.35e+191) {
tmp = t_0;
} else if (y <= -1.6e-114) {
tmp = z * y;
} else if (y <= 1.0) {
tmp = 1.0 * x;
} else if (y <= 2.6e+123) {
tmp = t_0;
} else if (y <= 1.5e+253) {
tmp = z * y;
} 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 * y
if (y <= (-1.35d+191)) then
tmp = t_0
else if (y <= (-1.6d-114)) then
tmp = z * y
else if (y <= 1.0d0) then
tmp = 1.0d0 * x
else if (y <= 2.6d+123) then
tmp = t_0
else if (y <= 1.5d+253) then
tmp = z * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -x * y;
double tmp;
if (y <= -1.35e+191) {
tmp = t_0;
} else if (y <= -1.6e-114) {
tmp = z * y;
} else if (y <= 1.0) {
tmp = 1.0 * x;
} else if (y <= 2.6e+123) {
tmp = t_0;
} else if (y <= 1.5e+253) {
tmp = z * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -x * y tmp = 0 if y <= -1.35e+191: tmp = t_0 elif y <= -1.6e-114: tmp = z * y elif y <= 1.0: tmp = 1.0 * x elif y <= 2.6e+123: tmp = t_0 elif y <= 1.5e+253: tmp = z * y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-x) * y) tmp = 0.0 if (y <= -1.35e+191) tmp = t_0; elseif (y <= -1.6e-114) tmp = Float64(z * y); elseif (y <= 1.0) tmp = Float64(1.0 * x); elseif (y <= 2.6e+123) tmp = t_0; elseif (y <= 1.5e+253) tmp = Float64(z * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -x * y; tmp = 0.0; if (y <= -1.35e+191) tmp = t_0; elseif (y <= -1.6e-114) tmp = z * y; elseif (y <= 1.0) tmp = 1.0 * x; elseif (y <= 2.6e+123) tmp = t_0; elseif (y <= 1.5e+253) tmp = z * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-x) * y), $MachinePrecision]}, If[LessEqual[y, -1.35e+191], t$95$0, If[LessEqual[y, -1.6e-114], N[(z * y), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 * x), $MachinePrecision], If[LessEqual[y, 2.6e+123], t$95$0, If[LessEqual[y, 1.5e+253], N[(z * y), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-x\right) \cdot y\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+191}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.6 \cdot 10^{-114}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 \cdot x\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+253}:\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.34999999999999998e191 or 1 < y < 2.59999999999999985e123 or 1.4999999999999999e253 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6497.5
Applied rewrites97.5%
Taylor expanded in z around 0
Applied rewrites75.1%
if -1.34999999999999998e191 < y < -1.6000000000000001e-114 or 2.59999999999999985e123 < y < 1.4999999999999999e253Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6465.3
Applied rewrites65.3%
if -1.6000000000000001e-114 < y < 1Initial 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--.f6478.1
Applied rewrites78.1%
Taylor expanded in y around 0
Applied rewrites77.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- z x) y))) (if (<= y -3.4e+20) t_0 (if (<= y 1.0) (+ (* z y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (z - x) * y;
double tmp;
if (y <= -3.4e+20) {
tmp = t_0;
} else if (y <= 1.0) {
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 <= (-3.4d+20)) then
tmp = t_0
else if (y <= 1.0d0) 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 <= -3.4e+20) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = (z * y) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z - x) * y tmp = 0 if y <= -3.4e+20: tmp = t_0 elif y <= 1.0: 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 <= -3.4e+20) tmp = t_0; elseif (y <= 1.0) 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 <= -3.4e+20) tmp = t_0; elseif (y <= 1.0) 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, -3.4e+20], t$95$0, If[LessEqual[y, 1.0], 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 -3.4 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;z \cdot y + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.4e20 or 1 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.9
Applied rewrites98.9%
if -3.4e20 < y < 1Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- z x) y))) (if (<= y -9e-128) t_0 (if (<= y 16500000.0) (* (- 1.0 y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (z - x) * y;
double tmp;
if (y <= -9e-128) {
tmp = t_0;
} else if (y <= 16500000.0) {
tmp = (1.0 - 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 <= (-9d-128)) then
tmp = t_0
else if (y <= 16500000.0d0) then
tmp = (1.0d0 - 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 <= -9e-128) {
tmp = t_0;
} else if (y <= 16500000.0) {
tmp = (1.0 - y) * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z - x) * y tmp = 0 if y <= -9e-128: tmp = t_0 elif y <= 16500000.0: tmp = (1.0 - 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 <= -9e-128) tmp = t_0; elseif (y <= 16500000.0) tmp = Float64(Float64(1.0 - 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 <= -9e-128) tmp = t_0; elseif (y <= 16500000.0) tmp = (1.0 - 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, -9e-128], t$95$0, If[LessEqual[y, 16500000.0], N[(N[(1.0 - 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 -9 \cdot 10^{-128}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 16500000:\\
\;\;\;\;\left(1 - y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -8.9999999999999998e-128 or 1.65e7 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6490.4
Applied rewrites90.4%
if -8.9999999999999998e-128 < y < 1.65e7Initial 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.4
Applied rewrites79.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- 1.0 y) x))) (if (<= x -3.6e-46) t_0 (if (<= x 3.8e-152) (* z y) t_0))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * x;
double tmp;
if (x <= -3.6e-46) {
tmp = t_0;
} else if (x <= 3.8e-152) {
tmp = z * y;
} 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 = (1.0d0 - y) * x
if (x <= (-3.6d-46)) then
tmp = t_0
else if (x <= 3.8d-152) then
tmp = z * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (1.0 - y) * x;
double tmp;
if (x <= -3.6e-46) {
tmp = t_0;
} else if (x <= 3.8e-152) {
tmp = z * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - y) * x tmp = 0 if x <= -3.6e-46: tmp = t_0 elif x <= 3.8e-152: tmp = z * y else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * x) tmp = 0.0 if (x <= -3.6e-46) tmp = t_0; elseif (x <= 3.8e-152) tmp = Float64(z * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (1.0 - y) * x; tmp = 0.0; if (x <= -3.6e-46) tmp = t_0; elseif (x <= 3.8e-152) tmp = z * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -3.6e-46], t$95$0, If[LessEqual[x, 3.8e-152], N[(z * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot x\\
\mathbf{if}\;x \leq -3.6 \cdot 10^{-46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-152}:\\
\;\;\;\;z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.6e-46 or 3.80000000000000012e-152 < x Initial 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--.f6482.6
Applied rewrites82.6%
if -3.6e-46 < x < 3.80000000000000012e-152Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.6e-114) (* z y) (if (<= y 2.6e-21) (* 1.0 x) (* z y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.6e-114) {
tmp = z * y;
} else if (y <= 2.6e-21) {
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 <= (-1.6d-114)) then
tmp = z * y
else if (y <= 2.6d-21) 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 <= -1.6e-114) {
tmp = z * y;
} else if (y <= 2.6e-21) {
tmp = 1.0 * x;
} else {
tmp = z * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.6e-114: tmp = z * y elif y <= 2.6e-21: tmp = 1.0 * x else: tmp = z * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.6e-114) tmp = Float64(z * y); elseif (y <= 2.6e-21) 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 <= -1.6e-114) tmp = z * y; elseif (y <= 2.6e-21) tmp = 1.0 * x; else tmp = z * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.6e-114], N[(z * y), $MachinePrecision], If[LessEqual[y, 2.6e-21], N[(1.0 * x), $MachinePrecision], N[(z * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{-114}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-21}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot y\\
\end{array}
\end{array}
if y < -1.6000000000000001e-114 or 2.60000000000000017e-21 < y Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6452.0
Applied rewrites52.0%
if -1.6000000000000001e-114 < y < 2.60000000000000017e-21Initial 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.1
Applied rewrites79.1%
Taylor expanded in y around 0
Applied rewrites79.1%
(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-*.f6439.7
Applied rewrites39.7%
herbie shell --seed 2024257
(FPCore (x y z)
:name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
:precision binary64
(+ x (* y (- z x))))