
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
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)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
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)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
(FPCore (x y z t a) :precision binary64 (- x (/ y (/ (- t a) (- z t)))))
double code(double x, double y, double z, double t, double a) {
return x - (y / ((t - a) / (z - t)));
}
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 / ((t - a) / (z - t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - (y / ((t - a) / (z - t)));
}
def code(x, y, z, t, a): return x - (y / ((t - a) / (z - t)))
function code(x, y, z, t, a) return Float64(x - Float64(y / Float64(Float64(t - a) / Float64(z - t)))) end
function tmp = code(x, y, z, t, a) tmp = x - (y / ((t - a) / (z - t))); end
code[x_, y_, z_, t_, a_] := N[(x - N[(y / N[(N[(t - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{\frac{t - a}{z - t}}
\end{array}
Initial program 84.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6498.4
Applied rewrites98.4%
Final simplification98.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (- x (* (/ t (- a t)) y)))) (if (<= t -1.82e-59) t_1 (if (<= t 9e-21) (fma (- z t) (/ y a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((t / (a - t)) * y);
double tmp;
if (t <= -1.82e-59) {
tmp = t_1;
} else if (t <= 9e-21) {
tmp = fma((z - t), (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(Float64(t / Float64(a - t)) * y)) tmp = 0.0 if (t <= -1.82e-59) tmp = t_1; elseif (t <= 9e-21) tmp = fma(Float64(z - t), Float64(y / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.82e-59], t$95$1, If[LessEqual[t, 9e-21], N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{t}{a - t} \cdot y\\
\mathbf{if}\;t \leq -1.82 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 9 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.8199999999999999e-59 or 8.99999999999999936e-21 < t Initial program 76.5%
Taylor expanded in z around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6485.7
Applied rewrites85.7%
if -1.8199999999999999e-59 < t < 8.99999999999999936e-21Initial program 92.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6491.7
Applied rewrites91.7%
Final simplification88.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- t z) t) y x))) (if (<= t -1.22e-78) t_1 (if (<= t 1.02e-23) (fma (- z t) (/ y a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - z) / t), y, x);
double tmp;
if (t <= -1.22e-78) {
tmp = t_1;
} else if (t <= 1.02e-23) {
tmp = fma((z - t), (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - z) / t), y, x) tmp = 0.0 if (t <= -1.22e-78) tmp = t_1; elseif (t <= 1.02e-23) tmp = fma(Float64(z - t), Float64(y / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -1.22e-78], t$95$1, If[LessEqual[t, 1.02e-23], N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -1.22 \cdot 10^{-78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.02 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.2200000000000001e-78 or 1.02000000000000005e-23 < t Initial program 76.7%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
mul-1-negN/A
lower-/.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
unsub-negN/A
neg-mul-1N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6483.2
Applied rewrites83.2%
if -1.2200000000000001e-78 < t < 1.02000000000000005e-23Initial program 93.3%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6493.8
Applied rewrites93.8%
(FPCore (x y z t a) :precision binary64 (if (<= t -50.0) (+ y x) (if (<= t 2.5e-18) (fma (- z t) (/ y a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -50.0) {
tmp = y + x;
} else if (t <= 2.5e-18) {
tmp = fma((z - t), (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -50.0) tmp = Float64(y + x); elseif (t <= 2.5e-18) tmp = fma(Float64(z - t), Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -50.0], N[(y + x), $MachinePrecision], If[LessEqual[t, 2.5e-18], N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -50:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 2.5 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -50 or 2.50000000000000018e-18 < t Initial program 74.8%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6476.5
Applied rewrites76.5%
if -50 < t < 2.50000000000000018e-18Initial program 92.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6488.0
Applied rewrites88.0%
(FPCore (x y z t a) :precision binary64 (if (<= t -2.05e-12) (+ y x) (if (<= t 2.15e-18) (fma z (/ y a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -2.05e-12) {
tmp = y + x;
} else if (t <= 2.15e-18) {
tmp = fma(z, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -2.05e-12) tmp = Float64(y + x); elseif (t <= 2.15e-18) tmp = fma(z, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -2.05e-12], N[(y + x), $MachinePrecision], If[LessEqual[t, 2.15e-18], N[(z * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.05 \cdot 10^{-12}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 2.15 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -2.04999999999999995e-12 or 2.1500000000000001e-18 < t Initial program 74.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6475.5
Applied rewrites75.5%
if -2.04999999999999995e-12 < t < 2.1500000000000001e-18Initial program 93.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
(FPCore (x y z t a) :precision binary64 (fma (/ (- t z) (- t a)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((t - z) / (t - a)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(t - z) / Float64(t - a)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{t - z}{t - a}, y, x\right)
\end{array}
Initial program 84.1%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.2
Applied rewrites98.2%
Final simplification98.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.4e+120) (* (/ z a) y) (+ y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.4e+120) {
tmp = (z / a) * y;
} else {
tmp = y + x;
}
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 (z <= (-3.4d+120)) then
tmp = (z / a) * y
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.4e+120) {
tmp = (z / a) * y;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -3.4e+120: tmp = (z / a) * y else: tmp = y + x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.4e+120) tmp = Float64(Float64(z / a) * y); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -3.4e+120) tmp = (z / a) * y; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.4e+120], N[(N[(z / a), $MachinePrecision] * y), $MachinePrecision], N[(y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+120}:\\
\;\;\;\;\frac{z}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -3.39999999999999999e120Initial program 79.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.0
Applied rewrites66.0%
Taylor expanded in x around 0
Applied rewrites41.2%
Applied rewrites52.7%
if -3.39999999999999999e120 < z Initial program 85.0%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6463.4
Applied rewrites63.4%
(FPCore (x y z t a) :precision binary64 (if (<= y 2.2e+208) (+ y x) (* (/ y a) z)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 2.2e+208) {
tmp = y + x;
} else {
tmp = (y / 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 (y <= 2.2d+208) then
tmp = y + x
else
tmp = (y / 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 (y <= 2.2e+208) {
tmp = y + x;
} else {
tmp = (y / a) * z;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= 2.2e+208: tmp = y + x else: tmp = (y / a) * z return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= 2.2e+208) tmp = Float64(y + x); else tmp = Float64(Float64(y / a) * z); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= 2.2e+208) tmp = y + x; else tmp = (y / a) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, 2.2e+208], N[(y + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.2 \cdot 10^{+208}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot z\\
\end{array}
\end{array}
if y < 2.20000000000000014e208Initial program 87.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6461.8
Applied rewrites61.8%
if 2.20000000000000014e208 < y Initial program 44.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6465.1
Applied rewrites65.1%
Taylor expanded in x around 0
Applied rewrites43.0%
Applied rewrites55.9%
(FPCore (x y z t a) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a) {
return y + x;
}
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 + x
end function
public static double code(double x, double y, double z, double t, double a) {
return y + x;
}
def code(x, y, z, t, a): return y + x
function code(x, y, z, t, a) return Float64(y + x) end
function tmp = code(x, y, z, t, a) tmp = y + x; end
code[x_, y_, z_, t_, a_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 84.1%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6458.1
Applied rewrites58.1%
(FPCore (x y z t a) :precision binary64 (+ x (/ y (/ (- a t) (- z t)))))
double code(double x, double y, double z, double t, double a) {
return x + (y / ((a - t) / (z - t)));
}
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 / ((a - t) / (z - t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y / ((a - t) / (z - t)));
}
def code(x, y, z, t, a): return x + (y / ((a - t) / (z - t)))
function code(x, y, z, t, a) return Float64(x + Float64(y / Float64(Float64(a - t) / Float64(z - t)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y / ((a - t) / (z - t))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{a - t}{z - t}}
\end{array}
herbie shell --seed 2024298
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, B"
:precision binary64
:alt
(! :herbie-platform default (+ x (/ y (/ (- a t) (- z t)))))
(+ x (/ (* y (- z t)) (- a t))))