
(FPCore (x y z t a) :precision binary64 (+ x (* (- y z) (/ (- t x) (- a z)))))
double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y - z) * ((t - x) / (a - z)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
def code(x, y, z, t, a): return x + ((y - z) * ((t - x) / (a - z)))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y - z) * ((t - x) / (a - z))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (* (- y z) (/ (- t x) (- a z)))))
double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y - z) * ((t - x) / (a - z)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
def code(x, y, z, t, a): return x + ((y - z) * ((t - x) / (a - z)))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y - z) * ((t - x) / (a - z))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* (- y z) (/ (- t x) (- a z)))))
double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y - z) * ((t - x) / (a - z)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y - z) * ((t - x) / (a - z)));
}
def code(x, y, z, t, a): return x + ((y - z) * ((t - x) / (a - z)))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y - z) * ((t - x) / (a - z))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\end{array}
Initial program 77.6%
(FPCore (x y z t a) :precision binary64 (if (<= (+ x (* (- y z) (/ (- t x) (- a z)))) 2e+297) (+ x (- y z)) (* (- y z) (- y z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x + ((y - z) * ((t - x) / (a - z)))) <= 2e+297) {
tmp = x + (y - z);
} else {
tmp = (y - z) * (y - z);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x + ((y - z) * ((t - x) / (a - z)))) <= 2d+297) then
tmp = x + (y - z)
else
tmp = (y - z) * (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x + ((y - z) * ((t - x) / (a - z)))) <= 2e+297) {
tmp = x + (y - z);
} else {
tmp = (y - z) * (y - z);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x + ((y - z) * ((t - x) / (a - z)))) <= 2e+297: tmp = x + (y - z) else: tmp = (y - z) * (y - z) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z)))) <= 2e+297) tmp = Float64(x + Float64(y - z)); else tmp = Float64(Float64(y - z) * Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x + ((y - z) * ((t - x) / (a - z)))) <= 2e+297) tmp = x + (y - z); else tmp = (y - z) * (y - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+297], N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq 2 \cdot 10^{+297}:\\
\;\;\;\;x + \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \left(y - z\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 2e297Initial program 76.9%
Taylor expanded in x around 0
Applied rewrites18.4%
if 2e297 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) Initial program 85.7%
Taylor expanded in x around 0
Applied rewrites85.7%
Taylor expanded in x around inf
Applied rewrites1.7%
Taylor expanded in x around 0
Applied rewrites56.7%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.5e+87) (+ x (- y z)) (* (- y z) (/ (- t x) (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.5e+87) {
tmp = x + (y - z);
} else {
tmp = (y - z) * ((t - x) / (a - z));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (a <= (-1.5d+87)) then
tmp = x + (y - z)
else
tmp = (y - z) * ((t - x) / (a - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.5e+87) {
tmp = x + (y - z);
} else {
tmp = (y - z) * ((t - x) / (a - z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -1.5e+87: tmp = x + (y - z) else: tmp = (y - z) * ((t - x) / (a - z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.5e+87) tmp = Float64(x + Float64(y - z)); else tmp = Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -1.5e+87) tmp = x + (y - z); else tmp = (y - z) * ((t - x) / (a - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.5e+87], N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.5 \cdot 10^{+87}:\\
\;\;\;\;x + \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{t - x}{a - z}\\
\end{array}
\end{array}
if a < -1.4999999999999999e87Initial program 84.5%
Taylor expanded in x around 0
Applied rewrites35.0%
if -1.4999999999999999e87 < a Initial program 76.2%
Taylor expanded in x around 0
Applied rewrites59.1%
(FPCore (x y z t a) :precision binary64 (+ x (- y z)))
double code(double x, double y, double z, double t, double a) {
return x + (y - z);
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (y - z)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y - z);
}
def code(x, y, z, t, a): return x + (y - z)
function code(x, y, z, t, a) return Float64(x + Float64(y - z)) end
function tmp = code(x, y, z, t, a) tmp = x + (y - z); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right)
\end{array}
Initial program 77.6%
Taylor expanded in x around 0
Applied rewrites18.0%
(FPCore (x y z t a) :precision binary64 (- y z))
double code(double x, double y, double z, double t, double a) {
return y - z;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = y - z
end function
public static double code(double x, double y, double z, double t, double a) {
return y - z;
}
def code(x, y, z, t, a): return y - z
function code(x, y, z, t, a) return Float64(y - z) end
function tmp = code(x, y, z, t, a) tmp = y - z; end
code[x_, y_, z_, t_, a_] := N[(y - z), $MachinePrecision]
\begin{array}{l}
\\
y - z
\end{array}
Initial program 77.6%
Taylor expanded in x around 0
Applied rewrites52.8%
Taylor expanded in x around 0
Applied rewrites3.1%
(FPCore (x y z t a) :precision binary64 (- a z))
double code(double x, double y, double z, double t, double a) {
return a - z;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = a - z
end function
public static double code(double x, double y, double z, double t, double a) {
return a - z;
}
def code(x, y, z, t, a): return a - z
function code(x, y, z, t, a) return Float64(a - z) end
function tmp = code(x, y, z, t, a) tmp = a - z; end
code[x_, y_, z_, t_, a_] := N[(a - z), $MachinePrecision]
\begin{array}{l}
\\
a - z
\end{array}
Initial program 77.6%
Taylor expanded in x around 0
Applied rewrites52.8%
Taylor expanded in x around inf
Applied rewrites2.7%
herbie shell --seed 2024321
(FPCore (x y z t a)
:name "Numeric.Signal:interpolate from hsignal-0.2.7.1"
:precision binary64
:pre (TRUE)
(+ x (* (- y z) (/ (- t x) (- a z)))))