
(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}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (- (/ (- x) y) -1.0))) (t_2 (/ (- t) (+ (/ z y) -1.0))))
(if (<= y -1.75e+123)
t_2
(if (<= y -4.7e-5)
t_1
(if (<= y -8.2e-28) t_2 (if (<= y 5.8e-7) (* x (/ t (- z y))) t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = t * ((-x / y) - -1.0);
double t_2 = -t / ((z / y) + -1.0);
double tmp;
if (y <= -1.75e+123) {
tmp = t_2;
} else if (y <= -4.7e-5) {
tmp = t_1;
} else if (y <= -8.2e-28) {
tmp = t_2;
} else if (y <= 5.8e-7) {
tmp = x * (t / (z - y));
} 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) :: t_2
real(8) :: tmp
t_1 = t * ((-x / y) - (-1.0d0))
t_2 = -t / ((z / y) + (-1.0d0))
if (y <= (-1.75d+123)) then
tmp = t_2
else if (y <= (-4.7d-5)) then
tmp = t_1
else if (y <= (-8.2d-28)) then
tmp = t_2
else if (y <= 5.8d-7) then
tmp = x * (t / (z - y))
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 = t * ((-x / y) - -1.0);
double t_2 = -t / ((z / y) + -1.0);
double tmp;
if (y <= -1.75e+123) {
tmp = t_2;
} else if (y <= -4.7e-5) {
tmp = t_1;
} else if (y <= -8.2e-28) {
tmp = t_2;
} else if (y <= 5.8e-7) {
tmp = x * (t / (z - y));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = t * ((-x / y) - -1.0) t_2 = -t / ((z / y) + -1.0) tmp = 0 if y <= -1.75e+123: tmp = t_2 elif y <= -4.7e-5: tmp = t_1 elif y <= -8.2e-28: tmp = t_2 elif y <= 5.8e-7: tmp = x * (t / (z - y)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(Float64(Float64(-x) / y) - -1.0)) t_2 = Float64(Float64(-t) / Float64(Float64(z / y) + -1.0)) tmp = 0.0 if (y <= -1.75e+123) tmp = t_2; elseif (y <= -4.7e-5) tmp = t_1; elseif (y <= -8.2e-28) tmp = t_2; elseif (y <= 5.8e-7) tmp = Float64(x * Float64(t / Float64(z - y))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * ((-x / y) - -1.0); t_2 = -t / ((z / y) + -1.0); tmp = 0.0; if (y <= -1.75e+123) tmp = t_2; elseif (y <= -4.7e-5) tmp = t_1; elseif (y <= -8.2e-28) tmp = t_2; elseif (y <= 5.8e-7) tmp = x * (t / (z - y)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(N[((-x) / y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-t) / N[(N[(z / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.75e+123], t$95$2, If[LessEqual[y, -4.7e-5], t$95$1, If[LessEqual[y, -8.2e-28], t$95$2, If[LessEqual[y, 5.8e-7], N[(x * N[(t / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \left(\frac{-x}{y} - -1\right)\\
t_2 := \frac{-t}{\frac{z}{y} + -1}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+123}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -4.7 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -8.2 \cdot 10^{-28}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-7}:\\
\;\;\;\;x \cdot \frac{t}{z - y}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (or (<= y -7.1e-28) (not (<= y 1.2e-5))) (* t (- (/ (- x) y) -1.0)) (* x (/ t (- z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7.1e-28) || !(y <= 1.2e-5)) {
tmp = t * ((-x / y) - -1.0);
} else {
tmp = x * (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 <= (-7.1d-28)) .or. (.not. (y <= 1.2d-5))) then
tmp = t * ((-x / y) - (-1.0d0))
else
tmp = x * (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 <= -7.1e-28) || !(y <= 1.2e-5)) {
tmp = t * ((-x / y) - -1.0);
} else {
tmp = x * (t / (z - y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -7.1e-28) or not (y <= 1.2e-5): tmp = t * ((-x / y) - -1.0) else: tmp = x * (t / (z - y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -7.1e-28) || !(y <= 1.2e-5)) tmp = Float64(t * Float64(Float64(Float64(-x) / y) - -1.0)); else tmp = Float64(x * Float64(t / Float64(z - y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -7.1e-28) || ~((y <= 1.2e-5))) tmp = t * ((-x / y) - -1.0); else tmp = x * (t / (z - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -7.1e-28], N[Not[LessEqual[y, 1.2e-5]], $MachinePrecision]], N[(t * N[(N[((-x) / y), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(t / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.1 \cdot 10^{-28} \lor \neg \left(y \leq 1.2 \cdot 10^{-5}\right):\\
\;\;\;\;t \cdot \left(\frac{-x}{y} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t}{z - y}\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y -400.0) t (if (<= y 4.7e+92) (* x (/ t (- z y))) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -400.0) {
tmp = t;
} else if (y <= 4.7e+92) {
tmp = x * (t / (z - y));
} 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 <= (-400.0d0)) then
tmp = t
else if (y <= 4.7d+92) then
tmp = x * (t / (z - y))
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 <= -400.0) {
tmp = t;
} else if (y <= 4.7e+92) {
tmp = x * (t / (z - y));
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -400.0: tmp = t elif y <= 4.7e+92: tmp = x * (t / (z - y)) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -400.0) tmp = t; elseif (y <= 4.7e+92) tmp = Float64(x * Float64(t / Float64(z - y))); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -400.0) tmp = t; elseif (y <= 4.7e+92) tmp = x * (t / (z - y)); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -400.0], t, If[LessEqual[y, 4.7e+92], N[(x * N[(t / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -400:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{+92}:\\
\;\;\;\;x \cdot \frac{t}{z - y}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y -6.2e-28) t (if (<= y 1.1e-51) (* y (/ t z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.2e-28) {
tmp = t;
} else if (y <= 1.1e-51) {
tmp = 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 <= (-6.2d-28)) then
tmp = t
else if (y <= 1.1d-51) then
tmp = 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 <= -6.2e-28) {
tmp = t;
} else if (y <= 1.1e-51) {
tmp = y * (t / z);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -6.2e-28: tmp = t elif y <= 1.1e-51: tmp = y * (t / z) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -6.2e-28) tmp = t; elseif (y <= 1.1e-51) tmp = Float64(y * Float64(t / z)); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -6.2e-28) tmp = t; elseif (y <= 1.1e-51) tmp = y * (t / z); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.2e-28], t, If[LessEqual[y, 1.1e-51], N[(y * N[(t / z), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-28}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-51}:\\
\;\;\;\;y \cdot \frac{t}{z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y -5e-28) t (if (<= y 0.36) (* x (/ t z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5e-28) {
tmp = t;
} else if (y <= 0.36) {
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 <= (-5d-28)) then
tmp = t
else if (y <= 0.36d0) 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 <= -5e-28) {
tmp = t;
} else if (y <= 0.36) {
tmp = x * (t / z);
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -5e-28: tmp = t elif y <= 0.36: tmp = x * (t / z) else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -5e-28) tmp = t; elseif (y <= 0.36) 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 <= -5e-28) tmp = t; elseif (y <= 0.36) tmp = x * (t / z); else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -5e-28], t, If[LessEqual[y, 0.36], N[(x * N[(t / z), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-28}:\\
\;\;\;\;t\\
\mathbf{elif}\;y \leq 0.36:\\
\;\;\;\;x \cdot \frac{t}{z}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
(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}
(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 2023350
(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))