
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x - y) / (z - y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
def code(x, y, z, t): return ((x - y) / (z - y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x - y) / Float64(z - y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x - y) / (z - y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y} \cdot t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x - y) / (z - y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x - y) / (z - y)) * t;
}
def code(x, y, z, t): return ((x - y) / (z - y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x - y) / Float64(z - y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x - y) / (z - y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y} \cdot t
\end{array}
(FPCore (x y z t) :precision binary64 (/ t (/ (- y z) (- y x))))
double code(double x, double y, double z, double t) {
return t / ((y - z) / (y - x));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t / ((y - z) / (y - x))
end function
public static double code(double x, double y, double z, double t) {
return t / ((y - z) / (y - x));
}
def code(x, y, z, t): return t / ((y - z) / (y - x))
function code(x, y, z, t) return Float64(t / Float64(Float64(y - z) / Float64(y - x))) end
function tmp = code(x, y, z, t) tmp = t / ((y - z) / (y - x)); end
code[x_, y_, z_, t_] := N[(t / N[(N[(y - z), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{t}{\frac{y - z}{y - x}}
\end{array}
Initial program 97.2%
*-commutative97.2%
associate-*r/82.9%
associate-/l*97.2%
sub-neg97.2%
+-commutative97.2%
neg-sub097.2%
associate-+l-97.2%
sub0-neg97.2%
neg-mul-197.2%
associate-/r*97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (/ (- y x) y))) (t_2 (* (- x y) (/ t z))))
(if (<= z -4.7e+49)
t_2
(if (<= z 2.4e-152)
t_1
(if (<= z 4e-104) (/ (* t x) z) (if (<= z 1.14e+61) t_1 t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = t * ((y - x) / y);
double t_2 = (x - y) * (t / z);
double tmp;
if (z <= -4.7e+49) {
tmp = t_2;
} else if (z <= 2.4e-152) {
tmp = t_1;
} else if (z <= 4e-104) {
tmp = (t * x) / z;
} else if (z <= 1.14e+61) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = t * ((y - x) / y)
t_2 = (x - y) * (t / z)
if (z <= (-4.7d+49)) then
tmp = t_2
else if (z <= 2.4d-152) then
tmp = t_1
else if (z <= 4d-104) then
tmp = (t * x) / z
else if (z <= 1.14d+61) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = t * ((y - x) / y);
double t_2 = (x - y) * (t / z);
double tmp;
if (z <= -4.7e+49) {
tmp = t_2;
} else if (z <= 2.4e-152) {
tmp = t_1;
} else if (z <= 4e-104) {
tmp = (t * x) / z;
} else if (z <= 1.14e+61) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = t * ((y - x) / y) t_2 = (x - y) * (t / z) tmp = 0 if z <= -4.7e+49: tmp = t_2 elif z <= 2.4e-152: tmp = t_1 elif z <= 4e-104: tmp = (t * x) / z elif z <= 1.14e+61: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(Float64(y - x) / y)) t_2 = Float64(Float64(x - y) * Float64(t / z)) tmp = 0.0 if (z <= -4.7e+49) tmp = t_2; elseif (z <= 2.4e-152) tmp = t_1; elseif (z <= 4e-104) tmp = Float64(Float64(t * x) / z); elseif (z <= 1.14e+61) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * ((y - x) / y); t_2 = (x - y) * (t / z); tmp = 0.0; if (z <= -4.7e+49) tmp = t_2; elseif (z <= 2.4e-152) tmp = t_1; elseif (z <= 4e-104) tmp = (t * x) / z; elseif (z <= 1.14e+61) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - y), $MachinePrecision] * N[(t / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.7e+49], t$95$2, If[LessEqual[z, 2.4e-152], t$95$1, If[LessEqual[z, 4e-104], N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.14e+61], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y - x}{y}\\
t_2 := \left(x - y\right) \cdot \frac{t}{z}\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{+49}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\
\;\;\;\;\frac{t \cdot x}{z}\\
\mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if z < -4.6999999999999997e49 or 1.13999999999999996e61 < z Initial program 97.0%
Taylor expanded in z around inf 72.5%
associate-/l*79.1%
associate-/r/77.1%
Simplified77.1%
if -4.6999999999999997e49 < z < 2.4e-152 or 3.99999999999999971e-104 < z < 1.13999999999999996e61Initial program 99.2%
Taylor expanded in z around 0 83.5%
associate-*r/83.5%
neg-mul-183.5%
neg-sub083.5%
associate--r-83.5%
neg-sub083.5%
+-commutative83.5%
sub-neg83.5%
Simplified83.5%
if 2.4e-152 < z < 3.99999999999999971e-104Initial program 73.8%
Taylor expanded in y around 0 99.6%
Final simplification81.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (/ (- y x) y))) (t_2 (/ t (/ z (- x y)))))
(if (<= z -4.6e+38)
t_2
(if (<= z 2.4e-152)
t_1
(if (<= z 4e-104) (/ (* t x) z) (if (<= z 1.14e+61) t_1 t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = t * ((y - x) / y);
double t_2 = t / (z / (x - y));
double tmp;
if (z <= -4.6e+38) {
tmp = t_2;
} else if (z <= 2.4e-152) {
tmp = t_1;
} else if (z <= 4e-104) {
tmp = (t * x) / z;
} else if (z <= 1.14e+61) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = t * ((y - x) / y)
t_2 = t / (z / (x - y))
if (z <= (-4.6d+38)) then
tmp = t_2
else if (z <= 2.4d-152) then
tmp = t_1
else if (z <= 4d-104) then
tmp = (t * x) / z
else if (z <= 1.14d+61) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = t * ((y - x) / y);
double t_2 = t / (z / (x - y));
double tmp;
if (z <= -4.6e+38) {
tmp = t_2;
} else if (z <= 2.4e-152) {
tmp = t_1;
} else if (z <= 4e-104) {
tmp = (t * x) / z;
} else if (z <= 1.14e+61) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = t * ((y - x) / y) t_2 = t / (z / (x - y)) tmp = 0 if z <= -4.6e+38: tmp = t_2 elif z <= 2.4e-152: tmp = t_1 elif z <= 4e-104: tmp = (t * x) / z elif z <= 1.14e+61: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(Float64(y - x) / y)) t_2 = Float64(t / Float64(z / Float64(x - y))) tmp = 0.0 if (z <= -4.6e+38) tmp = t_2; elseif (z <= 2.4e-152) tmp = t_1; elseif (z <= 4e-104) tmp = Float64(Float64(t * x) / z); elseif (z <= 1.14e+61) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * ((y - x) / y); t_2 = t / (z / (x - y)); tmp = 0.0; if (z <= -4.6e+38) tmp = t_2; elseif (z <= 2.4e-152) tmp = t_1; elseif (z <= 4e-104) tmp = (t * x) / z; elseif (z <= 1.14e+61) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t / N[(z / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.6e+38], t$95$2, If[LessEqual[z, 2.4e-152], t$95$1, If[LessEqual[z, 4e-104], N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.14e+61], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \frac{y - x}{y}\\
t_2 := \frac{t}{\frac{z}{x - y}}\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{+38}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-152}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-104}:\\
\;\;\;\;\frac{t \cdot x}{z}\\
\mathbf{elif}\;z \leq 1.14 \cdot 10^{+61}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if z < -4.6000000000000002e38 or 1.13999999999999996e61 < z Initial program 97.1%
Taylor expanded in z around inf 72.2%
associate-/l*78.6%
Simplified78.6%
if -4.6000000000000002e38 < z < 2.4e-152 or 3.99999999999999971e-104 < z < 1.13999999999999996e61Initial program 99.2%
Taylor expanded in z around 0 83.9%
associate-*r/83.9%
neg-mul-183.9%
neg-sub083.9%
associate--r-83.9%
neg-sub083.9%
+-commutative83.9%
sub-neg83.9%
Simplified83.9%
if 2.4e-152 < z < 3.99999999999999971e-104Initial program 73.8%
Taylor expanded in y around 0 99.6%
Final simplification82.4%
(FPCore (x y z t) :precision binary64 (if (<= y -2.7e+62) t (if (<= y 7e+45) (* (- x y) (/ t z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e+62) {
tmp = t;
} else if (y <= 7e+45) {
tmp = (x - y) * (t / z);
} else {
tmp = t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-2.7d+62)) then
tmp = t
else if (y <= 7d+45) then
tmp = (x - y) * (t / z)
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e+62) {
tmp = t;
} else if (y <= 7e+45) {
tmp = (x - y) * (t / z);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.7e+62: tmp = t elif y <= 7e+45: tmp = (x - y) * (t / z) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.7e+62) tmp = t; elseif (y <= 7e+45) tmp = Float64(Float64(x - y) * Float64(t / z)); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -2.7e+62) tmp = t; elseif (y <= 7e+45) tmp = (x - y) * (t / z); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.7e+62], t, If[LessEqual[y, 7e+45], N[(N[(x - y), $MachinePrecision] * N[(t / z), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+62}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+45}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if y < -2.7e62 or 7.00000000000000046e45 < y Initial program 99.8%
Taylor expanded in y around inf 69.2%
if -2.7e62 < y < 7.00000000000000046e45Initial program 95.4%
Taylor expanded in z around inf 68.2%
associate-/l*68.6%
associate-/r/69.5%
Simplified69.5%
Final simplification69.4%
(FPCore (x y z t) :precision binary64 (if (<= y -1.45e-20) t (if (<= y 7e-34) (* x (/ t z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e-20) {
tmp = t;
} else if (y <= 7e-34) {
tmp = x * (t / z);
} else {
tmp = t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-1.45d-20)) then
tmp = t
else if (y <= 7d-34) then
tmp = x * (t / z)
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e-20) {
tmp = t;
} else if (y <= 7e-34) {
tmp = x * (t / z);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.45e-20: tmp = t elif y <= 7e-34: tmp = x * (t / z) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.45e-20) tmp = t; elseif (y <= 7e-34) tmp = Float64(x * Float64(t / z)); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.45e-20) tmp = t; elseif (y <= 7e-34) tmp = x * (t / z); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.45e-20], t, If[LessEqual[y, 7e-34], N[(x * N[(t / z), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-20}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-34}:\\
\;\;\;\;x \cdot \frac{t}{z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if y < -1.45e-20 or 7e-34 < y Initial program 99.8%
Taylor expanded in y around inf 59.7%
if -1.45e-20 < y < 7e-34Initial program 94.0%
Taylor expanded in y around 0 66.3%
associate-/l*67.2%
associate-/r/69.6%
Simplified69.6%
Final simplification64.1%
(FPCore (x y z t) :precision binary64 (* t (/ (- x y) (- z y))))
double code(double x, double y, double z, double t) {
return t * ((x - y) / (z - y));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t * ((x - y) / (z - y))
end function
public static double code(double x, double y, double z, double t) {
return t * ((x - y) / (z - y));
}
def code(x, y, z, t): return t * ((x - y) / (z - y))
function code(x, y, z, t) return Float64(t * Float64(Float64(x - y) / Float64(z - y))) end
function tmp = code(x, y, z, t) tmp = t * ((x - y) / (z - y)); end
code[x_, y_, z_, t_] := N[(t * N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t \cdot \frac{x - y}{z - y}
\end{array}
Initial program 97.2%
Final simplification97.2%
(FPCore (x y z t) :precision binary64 t)
double code(double x, double y, double z, double t) {
return t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t
end function
public static double code(double x, double y, double z, double t) {
return t;
}
def code(x, y, z, t): return t
function code(x, y, z, t) return t end
function tmp = code(x, y, z, t) tmp = t; end
code[x_, y_, z_, t_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 97.2%
Taylor expanded in y around inf 37.4%
Final simplification37.4%
(FPCore (x y z t) :precision binary64 (/ t (/ (- z y) (- x y))))
double code(double x, double y, double z, double t) {
return t / ((z - y) / (x - y));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t / ((z - y) / (x - y))
end function
public static double code(double x, double y, double z, double t) {
return t / ((z - y) / (x - y));
}
def code(x, y, z, t): return t / ((z - y) / (x - y))
function code(x, y, z, t) return Float64(t / Float64(Float64(z - y) / Float64(x - y))) end
function tmp = code(x, y, z, t) tmp = t / ((z - y) / (x - y)); end
code[x_, y_, z_, t_] := N[(t / N[(N[(z - y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{t}{\frac{z - y}{x - y}}
\end{array}
herbie shell --seed 2023279
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
:precision binary64
:herbie-target
(/ t (/ (- z y) (- x y)))
(* (/ (- x y) (- z y)) t))