
(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 7 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 (/ (- z t) (/ y x))))
double code(double x, double y, double z, double t) {
return t + ((z - t) / (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 + ((z - t) / (y / x))
end function
public static double code(double x, double y, double z, double t) {
return t + ((z - t) / (y / x));
}
def code(x, y, z, t): return t + ((z - t) / (y / x))
function code(x, y, z, t) return Float64(t + Float64(Float64(z - t) / Float64(y / x))) end
function tmp = code(x, y, z, t) tmp = t + ((z - t) / (y / x)); end
code[x_, y_, z_, t_] := N[(t + N[(N[(z - t), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \frac{z - t}{\frac{y}{x}}
\end{array}
Initial program 97.6%
*-commutative97.6%
clear-num97.6%
un-div-inv98.0%
Applied egg-rr98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (if (or (<= t -112000000000.0) (not (<= t 68000000.0))) (- t (/ t (/ y x))) (+ t (/ z (/ y x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -112000000000.0) || !(t <= 68000000.0)) {
tmp = t - (t / (y / x));
} else {
tmp = t + (z / (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 ((t <= (-112000000000.0d0)) .or. (.not. (t <= 68000000.0d0))) then
tmp = t - (t / (y / x))
else
tmp = t + (z / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -112000000000.0) || !(t <= 68000000.0)) {
tmp = t - (t / (y / x));
} else {
tmp = t + (z / (y / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -112000000000.0) or not (t <= 68000000.0): tmp = t - (t / (y / x)) else: tmp = t + (z / (y / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -112000000000.0) || !(t <= 68000000.0)) tmp = Float64(t - Float64(t / Float64(y / x))); else tmp = Float64(t + Float64(z / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -112000000000.0) || ~((t <= 68000000.0))) tmp = t - (t / (y / x)); else tmp = t + (z / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -112000000000.0], N[Not[LessEqual[t, 68000000.0]], $MachinePrecision]], N[(t - N[(t / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t + N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -112000000000 \lor \neg \left(t \leq 68000000\right):\\
\;\;\;\;t - \frac{t}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;t + \frac{z}{\frac{y}{x}}\\
\end{array}
\end{array}
if t < -1.12e11 or 6.8e7 < t Initial program 99.8%
remove-double-neg99.8%
unsub-neg99.8%
associate-*l/90.3%
associate-*r/91.5%
fma-neg91.5%
remove-double-neg91.5%
Simplified91.5%
Taylor expanded in z around 0 85.4%
mul-1-neg85.4%
associate-/l*91.2%
unsub-neg91.2%
associate-/r/84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in x around 0 85.4%
associate-/l*91.2%
Simplified91.2%
if -1.12e11 < t < 6.8e7Initial program 95.4%
Taylor expanded in z around inf 85.2%
associate-*l/87.1%
*-commutative87.1%
Simplified87.1%
clear-num87.1%
div-inv87.8%
Applied egg-rr87.8%
Final simplification89.5%
(FPCore (x y z t) :precision binary64 (if (<= z -7.8e-18) (+ t (/ z (/ y x))) (if (<= z 1.15e+27) (- t (* x (/ t y))) (+ t (/ (* z x) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.8e-18) {
tmp = t + (z / (y / x));
} else if (z <= 1.15e+27) {
tmp = t - (x * (t / y));
} else {
tmp = t + ((z * x) / 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 (z <= (-7.8d-18)) then
tmp = t + (z / (y / x))
else if (z <= 1.15d+27) then
tmp = t - (x * (t / y))
else
tmp = t + ((z * x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.8e-18) {
tmp = t + (z / (y / x));
} else if (z <= 1.15e+27) {
tmp = t - (x * (t / y));
} else {
tmp = t + ((z * x) / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.8e-18: tmp = t + (z / (y / x)) elif z <= 1.15e+27: tmp = t - (x * (t / y)) else: tmp = t + ((z * x) / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.8e-18) tmp = Float64(t + Float64(z / Float64(y / x))); elseif (z <= 1.15e+27) tmp = Float64(t - Float64(x * Float64(t / y))); else tmp = Float64(t + Float64(Float64(z * x) / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.8e-18) tmp = t + (z / (y / x)); elseif (z <= 1.15e+27) tmp = t - (x * (t / y)); else tmp = t + ((z * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.8e-18], N[(t + N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e+27], N[(t - N[(x * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t + N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-18}:\\
\;\;\;\;t + \frac{z}{\frac{y}{x}}\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+27}:\\
\;\;\;\;t - x \cdot \frac{t}{y}\\
\mathbf{else}:\\
\;\;\;\;t + \frac{z \cdot x}{y}\\
\end{array}
\end{array}
if z < -7.8000000000000001e-18Initial program 99.7%
Taylor expanded in z around inf 77.8%
associate-*l/88.8%
*-commutative88.8%
Simplified88.8%
clear-num88.8%
div-inv88.9%
Applied egg-rr88.9%
if -7.8000000000000001e-18 < z < 1.15e27Initial program 97.0%
remove-double-neg97.0%
unsub-neg97.0%
associate-*l/92.1%
associate-*r/94.8%
fma-neg94.8%
remove-double-neg94.8%
Simplified94.8%
Taylor expanded in z around 0 81.9%
mul-1-neg81.9%
associate-/l*88.4%
unsub-neg88.4%
associate-/r/83.4%
*-commutative83.4%
Simplified83.4%
if 1.15e27 < z Initial program 96.9%
Taylor expanded in z around inf 91.8%
Final simplification86.8%
(FPCore (x y z t) :precision binary64 (+ t (* (- z t) (/ x y))))
double code(double x, double y, double z, double t) {
return t + ((z - t) * (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 - t) * (x / y))
end function
public static double code(double x, double y, double z, double t) {
return t + ((z - t) * (x / y));
}
def code(x, y, z, t): return t + ((z - t) * (x / y))
function code(x, y, z, t) return Float64(t + Float64(Float64(z - t) * Float64(x / y))) end
function tmp = code(x, y, z, t) tmp = t + ((z - t) * (x / y)); end
code[x_, y_, z_, t_] := N[(t + N[(N[(z - t), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \left(z - t\right) \cdot \frac{x}{y}
\end{array}
Initial program 97.6%
Final simplification97.6%
(FPCore (x y z t) :precision binary64 (+ t (* z (/ x y))))
double code(double x, double y, double z, double t) {
return t + (z * (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 * (x / y))
end function
public static double code(double x, double y, double z, double t) {
return t + (z * (x / y));
}
def code(x, y, z, t): return t + (z * (x / y))
function code(x, y, z, t) return Float64(t + Float64(z * Float64(x / y))) end
function tmp = code(x, y, z, t) tmp = t + (z * (x / y)); end
code[x_, y_, z_, t_] := N[(t + N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + z \cdot \frac{x}{y}
\end{array}
Initial program 97.6%
Taylor expanded in z around inf 71.5%
associate-*l/74.2%
*-commutative74.2%
Simplified74.2%
Final simplification74.2%
(FPCore (x y z t) :precision binary64 (+ t (/ z (/ y x))))
double code(double x, double y, double z, double t) {
return t + (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 + (z / (y / x))
end function
public static double code(double x, double y, double z, double t) {
return t + (z / (y / x));
}
def code(x, y, z, t): return t + (z / (y / x))
function code(x, y, z, t) return Float64(t + Float64(z / Float64(y / x))) end
function tmp = code(x, y, z, t) tmp = t + (z / (y / x)); end
code[x_, y_, z_, t_] := N[(t + N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + \frac{z}{\frac{y}{x}}
\end{array}
Initial program 97.6%
Taylor expanded in z around inf 71.5%
associate-*l/74.2%
*-commutative74.2%
Simplified74.2%
clear-num74.2%
div-inv74.6%
Applied egg-rr74.6%
Final simplification74.6%
(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.6%
remove-double-neg97.6%
unsub-neg97.6%
associate-*l/92.2%
associate-*r/92.5%
fma-neg92.5%
remove-double-neg92.5%
Simplified92.5%
Taylor expanded in x around 0 36.6%
Final simplification36.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 2023297
(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))