
(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 7 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 (if (<= z -1.75e+277) (fma (/ y (- a t)) (- z t) x) (+ x (/ y (/ (- a t) (- z t))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.75e+277) {
tmp = fma((y / (a - t)), (z - t), x);
} else {
tmp = x + (y / ((a - t) / (z - t)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.75e+277) tmp = fma(Float64(y / Float64(a - t)), Float64(z - t), x); else tmp = Float64(x + Float64(y / Float64(Float64(a - t) / Float64(z - t)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.75e+277], N[(N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+277}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a - t}, z - t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\
\end{array}
\end{array}
if z < -1.7500000000000001e277Initial program 80.0%
lift--.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift--.f64N/A
remove-double-negN/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -1.7500000000000001e277 < z Initial program 83.4%
lift--.f64N/A
lift--.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma y (/ z (- a t)) x)))
(if (<= z -1.85e-29)
t_1
(if (<= z 8.5e-13) (fma (/ y (- a t)) (- t) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, (z / (a - t)), x);
double tmp;
if (z <= -1.85e-29) {
tmp = t_1;
} else if (z <= 8.5e-13) {
tmp = fma((y / (a - t)), -t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(z / Float64(a - t)), x) tmp = 0.0 if (z <= -1.85e-29) tmp = t_1; elseif (z <= 8.5e-13) tmp = fma(Float64(y / Float64(a - t)), Float64(-t), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -1.85e-29], t$95$1, If[LessEqual[z, 8.5e-13], N[(N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision] * (-t) + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z}{a - t}, x\right)\\
\mathbf{if}\;z \leq -1.85 \cdot 10^{-29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a - t}, -t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.8499999999999999e-29 or 8.5000000000000001e-13 < z Initial program 81.2%
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-rgt-identityN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6496.4
Applied rewrites96.4%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6487.9
Applied rewrites87.9%
if -1.8499999999999999e-29 < z < 8.5000000000000001e-13Initial program 85.7%
Taylor expanded in z around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6494.0
Applied rewrites94.0%
(FPCore (x y z t a) :precision binary64 (if (<= t -5.8e+44) (fma y (- 1.0 (/ z t)) x) (if (<= t 4e+85) (fma y (/ z (- a t)) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -5.8e+44) {
tmp = fma(y, (1.0 - (z / t)), x);
} else if (t <= 4e+85) {
tmp = fma(y, (z / (a - t)), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -5.8e+44) tmp = fma(y, Float64(1.0 - Float64(z / t)), x); elseif (t <= 4e+85) tmp = fma(y, Float64(z / Float64(a - t)), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -5.8e+44], N[(y * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 4e+85], N[(y * N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.8 \cdot 10^{+44}:\\
\;\;\;\;\mathsf{fma}\left(y, 1 - \frac{z}{t}, x\right)\\
\mathbf{elif}\;t \leq 4 \cdot 10^{+85}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -5.8000000000000004e44Initial program 63.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
div-subN/A
*-inversesN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6494.4
Applied rewrites94.4%
if -5.8000000000000004e44 < t < 4.0000000000000001e85Initial program 91.5%
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
+-commutativeN/A
*-rgt-identityN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6488.6
Applied rewrites88.6%
if 4.0000000000000001e85 < t Initial program 74.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6487.9
Applied rewrites87.9%
(FPCore (x y z t a) :precision binary64 (if (<= t -650000000000.0) (fma y (- 1.0 (/ z t)) x) (if (<= t 2.75e-21) (fma y (/ z a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -650000000000.0) {
tmp = fma(y, (1.0 - (z / t)), x);
} else if (t <= 2.75e-21) {
tmp = fma(y, (z / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -650000000000.0) tmp = fma(y, Float64(1.0 - Float64(z / t)), x); elseif (t <= 2.75e-21) tmp = fma(y, Float64(z / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -650000000000.0], N[(y * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 2.75e-21], N[(y * N[(z / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -650000000000:\\
\;\;\;\;\mathsf{fma}\left(y, 1 - \frac{z}{t}, x\right)\\
\mathbf{elif}\;t \leq 2.75 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -6.5e11Initial program 67.4%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
div-subN/A
*-inversesN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
if -6.5e11 < t < 2.74999999999999989e-21Initial program 90.1%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
if 2.74999999999999989e-21 < t Initial program 81.6%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6485.0
Applied rewrites85.0%
(FPCore (x y z t a) :precision binary64 (if (<= t -3.2e+43) (+ y x) (if (<= t 2.75e-21) (fma y (/ z a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -3.2e+43) {
tmp = y + x;
} else if (t <= 2.75e-21) {
tmp = fma(y, (z / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -3.2e+43) tmp = Float64(y + x); elseif (t <= 2.75e-21) tmp = fma(y, Float64(z / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -3.2e+43], N[(y + x), $MachinePrecision], If[LessEqual[t, 2.75e-21], N[(y * N[(z / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{+43}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 2.75 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -3.20000000000000014e43 or 2.74999999999999989e-21 < t Initial program 74.1%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6482.4
Applied rewrites82.4%
if -3.20000000000000014e43 < t < 2.74999999999999989e-21Initial program 90.5%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6479.3
Applied rewrites79.3%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- a t)) (- z t) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (a - t)), (z - t), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(a - t)), Float64(z - t), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{a - t}, z - t, x\right)
\end{array}
Initial program 83.3%
lift--.f64N/A
lift-*.f64N/A
remove-double-negN/A
lift--.f64N/A
remove-double-negN/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.5
Applied rewrites96.5%
(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 83.3%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6460.6
Applied rewrites60.6%
(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 2024220
(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))))