
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + 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 - t)) + t
end function
public static double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + t;
}
def code(x, y, z, t): return ((x / y) * (z - t)) + t
function code(x, y, z, t) return Float64(Float64(Float64(x / y) * Float64(z - t)) + t) end
function tmp = code(x, y, z, t) tmp = ((x / y) * (z - t)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} \cdot \left(z - t\right) + t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + 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 - t)) + t
end function
public static double code(double x, double y, double z, double t) {
return ((x / y) * (z - t)) + t;
}
def code(x, y, z, t): return ((x / y) * (z - t)) + t
function code(x, y, z, t) return Float64(Float64(Float64(x / y) * Float64(z - t)) + t) end
function tmp = code(x, y, z, t) tmp = ((x / y) * (z - t)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} \cdot \left(z - t\right) + t
\end{array}
(FPCore (x y z t) :precision binary64 (+ t (* (/ x y) (- z t))))
double code(double x, double y, double z, double t) {
return t + ((x / y) * (z - 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 + ((x / y) * (z - t))
end function
public static double code(double x, double y, double z, double t) {
return t + ((x / y) * (z - t));
}
def code(x, y, z, t): return t + ((x / y) * (z - t))
function code(x, y, z, t) return Float64(t + Float64(Float64(x / y) * Float64(z - t))) end
function tmp = code(x, y, z, t) tmp = t + ((x / y) * (z - t)); end
code[x_, y_, z_, t_] := N[(t + N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \frac{x}{y} \cdot \left(z - t\right)
\end{array}
Initial program 97.5%
Final simplification97.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -4.3e-165) (not (<= x 4.5e-174))) (+ t (* x (/ (- z t) y))) (+ t (/ (* x z) y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.3e-165) || !(x <= 4.5e-174)) {
tmp = t + (x * ((z - t) / y));
} else {
tmp = t + ((x * z) / y);
}
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 ((x <= (-4.3d-165)) .or. (.not. (x <= 4.5d-174))) then
tmp = t + (x * ((z - t) / y))
else
tmp = t + ((x * z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.3e-165) || !(x <= 4.5e-174)) {
tmp = t + (x * ((z - t) / y));
} else {
tmp = t + ((x * z) / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -4.3e-165) or not (x <= 4.5e-174): tmp = t + (x * ((z - t) / y)) else: tmp = t + ((x * z) / y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -4.3e-165) || !(x <= 4.5e-174)) tmp = Float64(t + Float64(x * Float64(Float64(z - t) / y))); else tmp = Float64(t + Float64(Float64(x * z) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -4.3e-165) || ~((x <= 4.5e-174))) tmp = t + (x * ((z - t) / y)); else tmp = t + ((x * z) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4.3e-165], N[Not[LessEqual[x, 4.5e-174]], $MachinePrecision]], N[(t + N[(x * N[(N[(z - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t + N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.3 \cdot 10^{-165} \lor \neg \left(x \leq 4.5 \cdot 10^{-174}\right):\\
\;\;\;\;t + x \cdot \frac{z - t}{y}\\
\mathbf{else}:\\
\;\;\;\;t + \frac{x \cdot z}{y}\\
\end{array}
\end{array}
if x < -4.30000000000000007e-165 or 4.49999999999999964e-174 < x Initial program 97.2%
Taylor expanded in x around 0 88.8%
associate-*r/95.8%
Simplified95.8%
if -4.30000000000000007e-165 < x < 4.49999999999999964e-174Initial program 98.8%
Taylor expanded in z around inf 98.1%
Final simplification96.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.8e-88) (not (<= z 4.4e+95))) (+ t (* (/ x y) z)) (- t (/ t (/ y x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.8e-88) || !(z <= 4.4e+95)) {
tmp = t + ((x / y) * z);
} else {
tmp = t - (t / (y / x));
}
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 ((z <= (-4.8d-88)) .or. (.not. (z <= 4.4d+95))) then
tmp = t + ((x / y) * z)
else
tmp = t - (t / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.8e-88) || !(z <= 4.4e+95)) {
tmp = t + ((x / y) * z);
} else {
tmp = t - (t / (y / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.8e-88) or not (z <= 4.4e+95): tmp = t + ((x / y) * z) else: tmp = t - (t / (y / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.8e-88) || !(z <= 4.4e+95)) tmp = Float64(t + Float64(Float64(x / y) * z)); else tmp = Float64(t - Float64(t / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.8e-88) || ~((z <= 4.4e+95))) tmp = t + ((x / y) * z); else tmp = t - (t / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.8e-88], N[Not[LessEqual[z, 4.4e+95]], $MachinePrecision]], N[(t + N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(t - N[(t / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{-88} \lor \neg \left(z \leq 4.4 \cdot 10^{+95}\right):\\
\;\;\;\;t + \frac{x}{y} \cdot z\\
\mathbf{else}:\\
\;\;\;\;t - \frac{t}{\frac{y}{x}}\\
\end{array}
\end{array}
if z < -4.7999999999999999e-88 or 4.3999999999999998e95 < z Initial program 98.0%
Taylor expanded in z around inf 84.4%
associate-*l/91.7%
*-commutative91.7%
Simplified91.7%
if -4.7999999999999999e-88 < z < 4.3999999999999998e95Initial program 97.1%
Taylor expanded in z around 0 83.4%
mul-1-neg83.4%
associate-/l*88.8%
Simplified88.8%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (+ t (* (/ x y) z)))
double code(double x, double y, double z, double t) {
return t + ((x / y) * z);
}
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)
end function
public static double code(double x, double y, double z, double t) {
return t + ((x / y) * z);
}
def code(x, y, z, t): return t + ((x / y) * z)
function code(x, y, z, t) return Float64(t + Float64(Float64(x / y) * z)) end
function tmp = code(x, y, z, t) tmp = t + ((x / y) * z); end
code[x_, y_, z_, t_] := N[(t + N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \frac{x}{y} \cdot z
\end{array}
Initial program 97.5%
Taylor expanded in z around inf 73.7%
associate-*l/77.6%
*-commutative77.6%
Simplified77.6%
Final simplification77.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (* (/ x y) (- z t)) t)))
(if (< z 2.759456554562692e-282)
t_1
(if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((x / y) * (z - t)) + t;
double tmp;
if (z < 2.759456554562692e-282) {
tmp = t_1;
} else if (z < 2.326994450874436e-110) {
tmp = (x * ((z - t) / y)) + t;
} else {
tmp = t_1;
}
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) :: tmp
t_1 = ((x / y) * (z - t)) + t
if (z < 2.759456554562692d-282) then
tmp = t_1
else if (z < 2.326994450874436d-110) then
tmp = (x * ((z - t) / y)) + t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = ((x / y) * (z - t)) + t;
double tmp;
if (z < 2.759456554562692e-282) {
tmp = t_1;
} else if (z < 2.326994450874436e-110) {
tmp = (x * ((z - t) / y)) + t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((x / y) * (z - t)) + t tmp = 0 if z < 2.759456554562692e-282: tmp = t_1 elif z < 2.326994450874436e-110: tmp = (x * ((z - t) / y)) + t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(x / y) * Float64(z - t)) + t) tmp = 0.0 if (z < 2.759456554562692e-282) tmp = t_1; elseif (z < 2.326994450874436e-110) tmp = Float64(Float64(x * Float64(Float64(z - t) / y)) + t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((x / y) * (z - t)) + t; tmp = 0.0; if (z < 2.759456554562692e-282) tmp = t_1; elseif (z < 2.326994450874436e-110) tmp = (x * ((z - t) / y)) + t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x / y), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]}, If[Less[z, 2.759456554562692e-282], t$95$1, If[Less[z, 2.326994450874436e-110], N[(N[(x * N[(N[(z - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \left(z - t\right) + t\\
\mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z < 2.326994450874436 \cdot 10^{-110}:\\
\;\;\;\;x \cdot \frac{z - t}{y} + t\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2023275
(FPCore (x y z t)
:name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:precision binary64
:herbie-target
(if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))
(+ (* (/ x y) (- z t)) t))