
(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 (* (/ (- 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}
Initial program 98.9%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.95e+144) (not (<= y 3.7e+154))) (* t (- 1.0 (/ x y))) (* (- x y) (/ t (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.95e+144) || !(y <= 3.7e+154)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / (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 ((y <= (-1.95d+144)) .or. (.not. (y <= 3.7d+154))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = (x - y) * (t / (z - y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.95e+144) || !(y <= 3.7e+154)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.95e+144) or not (y <= 3.7e+154): tmp = t * (1.0 - (x / y)) else: tmp = (x - y) * (t / (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.95e+144) || !(y <= 3.7e+154)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(Float64(x - y) * Float64(t / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.95e+144) || ~((y <= 3.7e+154))) tmp = t * (1.0 - (x / y)); else tmp = (x - y) * (t / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.95e+144], N[Not[LessEqual[y, 3.7e+154]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(t / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+144} \lor \neg \left(y \leq 3.7 \cdot 10^{+154}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\
\end{array}
\end{array}
if y < -1.95000000000000009e144 or 3.69999999999999994e154 < y Initial program 99.9%
Taylor expanded in y around -inf 96.5%
mul-1-neg96.5%
Simplified96.5%
Taylor expanded in z around 0 95.4%
if -1.95000000000000009e144 < y < 3.69999999999999994e154Initial program 98.6%
*-commutative98.6%
associate-*r/92.1%
associate-*l/91.0%
Simplified91.0%
Final simplification92.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3e-18) (not (<= y 2.3e-58))) (* t (- 1.0 (/ x y))) (* t (/ x z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3e-18) || !(y <= 2.3e-58)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * (x / z);
}
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 <= (-3d-18)) .or. (.not. (y <= 2.3d-58))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = t * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3e-18) || !(y <= 2.3e-58)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * (x / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3e-18) or not (y <= 2.3e-58): tmp = t * (1.0 - (x / y)) else: tmp = t * (x / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3e-18) || !(y <= 2.3e-58)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(t * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -3e-18) || ~((y <= 2.3e-58))) tmp = t * (1.0 - (x / y)); else tmp = t * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3e-18], N[Not[LessEqual[y, 2.3e-58]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{-18} \lor \neg \left(y \leq 2.3 \cdot 10^{-58}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.99999999999999983e-18 or 2.2999999999999999e-58 < y Initial program 99.8%
Taylor expanded in y around -inf 76.5%
mul-1-neg76.5%
Simplified76.5%
Taylor expanded in z around 0 76.3%
if -2.99999999999999983e-18 < y < 2.2999999999999999e-58Initial program 97.7%
Taylor expanded in y around 0 71.1%
Final simplification74.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.9e-18) (not (<= y 1.3e+79))) (* t (- 1.0 (/ x y))) (* (- x y) (/ t z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.9e-18) || !(y <= 1.3e+79)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / z);
}
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.9d-18)) .or. (.not. (y <= 1.3d+79))) then
tmp = t * (1.0d0 - (x / y))
else
tmp = (x - y) * (t / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.9e-18) || !(y <= 1.3e+79)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = (x - y) * (t / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.9e-18) or not (y <= 1.3e+79): tmp = t * (1.0 - (x / y)) else: tmp = (x - y) * (t / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.9e-18) || !(y <= 1.3e+79)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(Float64(x - y) * Float64(t / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2.9e-18) || ~((y <= 1.3e+79))) tmp = t * (1.0 - (x / y)); else tmp = (x - y) * (t / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.9e-18], N[Not[LessEqual[y, 1.3e+79]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(t / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-18} \lor \neg \left(y \leq 1.3 \cdot 10^{+79}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\
\end{array}
\end{array}
if y < -2.9e-18 or 1.30000000000000007e79 < y Initial program 99.9%
Taylor expanded in y around -inf 85.7%
mul-1-neg85.7%
Simplified85.7%
Taylor expanded in z around 0 85.2%
if -2.9e-18 < y < 1.30000000000000007e79Initial program 98.1%
*-commutative98.1%
associate-*r/94.0%
associate-*l/93.9%
Simplified93.9%
Taylor expanded in z around inf 74.3%
associate-/l*77.3%
associate-/r/74.2%
Simplified74.2%
Final simplification79.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -4.7e-18) (not (<= y 3.5e+104))) (* t (- 1.0 (/ x y))) (* t (/ x (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4.7e-18) || !(y <= 3.5e+104)) {
tmp = t * (1.0 - (x / 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 ((y <= (-4.7d-18)) .or. (.not. (y <= 3.5d+104))) then
tmp = t * (1.0d0 - (x / 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 ((y <= -4.7e-18) || !(y <= 3.5e+104)) {
tmp = t * (1.0 - (x / y));
} else {
tmp = t * (x / (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -4.7e-18) or not (y <= 3.5e+104): tmp = t * (1.0 - (x / y)) else: tmp = t * (x / (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -4.7e-18) || !(y <= 3.5e+104)) tmp = Float64(t * Float64(1.0 - Float64(x / y))); else tmp = Float64(t * Float64(x / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -4.7e-18) || ~((y <= 3.5e+104))) tmp = t * (1.0 - (x / y)); else tmp = t * (x / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4.7e-18], N[Not[LessEqual[y, 3.5e+104]], $MachinePrecision]], N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{-18} \lor \neg \left(y \leq 3.5 \cdot 10^{+104}\right):\\
\;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{x}{z - y}\\
\end{array}
\end{array}
if y < -4.6999999999999996e-18 or 3.5000000000000002e104 < y Initial program 99.9%
Taylor expanded in y around -inf 87.1%
mul-1-neg87.1%
Simplified87.1%
Taylor expanded in z around 0 86.6%
if -4.6999999999999996e-18 < y < 3.5000000000000002e104Initial program 98.2%
Taylor expanded in x around inf 79.9%
Final simplification82.7%
(FPCore (x y z t) :precision binary64 (if (<= y -4.4e-18) t (if (<= y 2.5e+105) (* t (/ x z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.4e-18) {
tmp = t;
} else if (y <= 2.5e+105) {
tmp = t * (x / 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 <= (-4.4d-18)) then
tmp = t
else if (y <= 2.5d+105) then
tmp = t * (x / 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 <= -4.4e-18) {
tmp = t;
} else if (y <= 2.5e+105) {
tmp = t * (x / z);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.4e-18: tmp = t elif y <= 2.5e+105: tmp = t * (x / z) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.4e-18) tmp = t; elseif (y <= 2.5e+105) tmp = Float64(t * Float64(x / z)); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.4e-18) tmp = t; elseif (y <= 2.5e+105) tmp = t * (x / z); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.4e-18], t, If[LessEqual[y, 2.5e+105], N[(t * N[(x / z), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.4 \cdot 10^{-18}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+105}:\\
\;\;\;\;t \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if y < -4.3999999999999997e-18 or 2.50000000000000023e105 < y Initial program 99.9%
*-commutative99.9%
associate-*r/75.1%
associate-*l/72.1%
Simplified72.1%
Taylor expanded in y around inf 72.4%
if -4.3999999999999997e-18 < y < 2.50000000000000023e105Initial program 98.2%
Taylor expanded in y around 0 64.6%
Final simplification67.9%
(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 98.9%
*-commutative98.9%
associate-*r/86.0%
associate-*l/83.6%
Simplified83.6%
Taylor expanded in y around inf 36.1%
Final simplification36.1%
(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 2023301
(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))