
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (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) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot t}{a - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (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) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot t}{a - z}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* (/ (- y z) (- a z)) t)))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) / (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 - z) / (a - z)) * t)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) / (a - z)) * t);
}
def code(x, y, z, t, a): return x + (((y - z) / (a - z)) * t)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) / Float64(a - z)) * t)) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) / (a - z)) * t); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y - z}{a - z} \cdot t
\end{array}
Initial program 86.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6498.4
Applied rewrites98.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.7e-169) (not (<= z 2.35e-154))) (fma (- 1.0 (/ y z)) t x) (+ x (/ (* (- y z) t) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.7e-169) || !(z <= 2.35e-154)) {
tmp = fma((1.0 - (y / z)), t, x);
} else {
tmp = x + (((y - z) * t) / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.7e-169) || !(z <= 2.35e-154)) tmp = fma(Float64(1.0 - Float64(y / z)), t, x); else tmp = Float64(x + Float64(Float64(Float64(y - z) * t) / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.7e-169], N[Not[LessEqual[z, 2.35e-154]], $MachinePrecision]], N[(N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.7 \cdot 10^{-169} \lor \neg \left(z \leq 2.35 \cdot 10^{-154}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{y}{z}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a}\\
\end{array}
\end{array}
if z < -4.6999999999999999e-169 or 2.3500000000000001e-154 < z Initial program 84.1%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-/l*N/A
div-subN/A
*-inversesN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-/l*N/A
*-lft-identityN/A
associate-+l-N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-+.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6485.3
Applied rewrites85.3%
Taylor expanded in x around 0
Applied rewrites86.7%
if -4.6999999999999999e-169 < z < 2.3500000000000001e-154Initial program 98.0%
Taylor expanded in a around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6492.1
Applied rewrites92.1%
Final simplification87.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.32e-21) (not (<= a 1.6e-129))) (fma (/ z (- a z)) (- t) x) (+ (- x (/ (* t y) z)) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.32e-21) || !(a <= 1.6e-129)) {
tmp = fma((z / (a - z)), -t, x);
} else {
tmp = (x - ((t * y) / z)) + t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.32e-21) || !(a <= 1.6e-129)) tmp = fma(Float64(z / Float64(a - z)), Float64(-t), x); else tmp = Float64(Float64(x - Float64(Float64(t * y) / z)) + t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.32e-21], N[Not[LessEqual[a, 1.6e-129]], $MachinePrecision]], N[(N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision] * (-t) + x), $MachinePrecision], N[(N[(x - N[(N[(t * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.32 \cdot 10^{-21} \lor \neg \left(a \leq 1.6 \cdot 10^{-129}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - z}, -t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - \frac{t \cdot y}{z}\right) + t\\
\end{array}
\end{array}
if a < -1.32e-21 or 1.6000000000000001e-129 < a Initial program 82.7%
Taylor expanded in y 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.f6483.3
Applied rewrites83.3%
if -1.32e-21 < a < 1.6000000000000001e-129Initial program 92.2%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-/l*N/A
div-subN/A
*-inversesN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-/l*N/A
*-lft-identityN/A
associate-+l-N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-+.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6492.3
Applied rewrites92.3%
Final simplification87.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.7e-169) (not (<= z 2.35e-154))) (fma (- 1.0 (/ y z)) t x) (fma (- y z) (/ t a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.7e-169) || !(z <= 2.35e-154)) {
tmp = fma((1.0 - (y / z)), t, x);
} else {
tmp = fma((y - z), (t / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.7e-169) || !(z <= 2.35e-154)) tmp = fma(Float64(1.0 - Float64(y / z)), t, x); else tmp = fma(Float64(y - z), Float64(t / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.7e-169], N[Not[LessEqual[z, 2.35e-154]], $MachinePrecision]], N[(N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.7 \cdot 10^{-169} \lor \neg \left(z \leq 2.35 \cdot 10^{-154}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{y}{z}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a}, x\right)\\
\end{array}
\end{array}
if z < -4.6999999999999999e-169 or 2.3500000000000001e-154 < z Initial program 84.1%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-/l*N/A
div-subN/A
*-inversesN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-/l*N/A
*-lft-identityN/A
associate-+l-N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-+.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6485.3
Applied rewrites85.3%
Taylor expanded in x around 0
Applied rewrites86.7%
if -4.6999999999999999e-169 < z < 2.3500000000000001e-154Initial program 98.0%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6488.3
Applied rewrites88.3%
Final simplification87.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.7e-169) (not (<= z 2.35e-154))) (fma (- 1.0 (/ y z)) t x) (+ x (/ (* t y) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.7e-169) || !(z <= 2.35e-154)) {
tmp = fma((1.0 - (y / z)), t, x);
} else {
tmp = x + ((t * y) / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.7e-169) || !(z <= 2.35e-154)) tmp = fma(Float64(1.0 - Float64(y / z)), t, x); else tmp = Float64(x + Float64(Float64(t * y) / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.7e-169], N[Not[LessEqual[z, 2.35e-154]], $MachinePrecision]], N[(N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], N[(x + N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.7 \cdot 10^{-169} \lor \neg \left(z \leq 2.35 \cdot 10^{-154}\right):\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{y}{z}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t \cdot y}{a}\\
\end{array}
\end{array}
if z < -4.6999999999999999e-169 or 2.3500000000000001e-154 < z Initial program 84.1%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate-/l*N/A
div-subN/A
*-inversesN/A
distribute-rgt-out--N/A
*-commutativeN/A
associate-/l*N/A
*-lft-identityN/A
associate-+l-N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-+.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6485.3
Applied rewrites85.3%
Taylor expanded in x around 0
Applied rewrites86.7%
if -4.6999999999999999e-169 < z < 2.3500000000000001e-154Initial program 98.0%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f6484.0
Applied rewrites84.0%
Final simplification86.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.4e+20) (not (<= z 6.5e+25))) (+ t x) (fma (/ y a) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.4e+20) || !(z <= 6.5e+25)) {
tmp = t + x;
} else {
tmp = fma((y / a), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.4e+20) || !(z <= 6.5e+25)) tmp = Float64(t + x); else tmp = fma(Float64(y / a), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.4e+20], N[Not[LessEqual[z, 6.5e+25]], $MachinePrecision]], N[(t + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+20} \lor \neg \left(z \leq 6.5 \cdot 10^{+25}\right):\\
\;\;\;\;t + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\end{array}
\end{array}
if z < -3.4e20 or 6.50000000000000005e25 < z Initial program 75.5%
Taylor expanded in z around inf
lower-+.f6488.6
Applied rewrites88.6%
if -3.4e20 < z < 6.50000000000000005e25Initial program 97.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6468.6
Applied rewrites68.6%
Final simplification78.4%
(FPCore (x y z t a) :precision binary64 (if (<= y -5.5e+117) (fma (/ t x) x x) (+ t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -5.5e+117) {
tmp = fma((t / x), x, x);
} else {
tmp = t + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (y <= -5.5e+117) tmp = fma(Float64(t / x), x, x); else tmp = Float64(t + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -5.5e+117], N[(N[(t / x), $MachinePrecision] * x + x), $MachinePrecision], N[(t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{x}, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t + x\\
\end{array}
\end{array}
if y < -5.49999999999999965e117Initial program 80.8%
Taylor expanded in z around inf
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in x around inf
Applied rewrites56.0%
if -5.49999999999999965e117 < y Initial program 87.9%
Taylor expanded in z around inf
lower-+.f6471.1
Applied rewrites71.1%
(FPCore (x y z t a) :precision binary64 (+ t x))
double code(double x, double y, double z, double t, double a) {
return t + 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 = t + x
end function
public static double code(double x, double y, double z, double t, double a) {
return t + x;
}
def code(x, y, z, t, a): return t + x
function code(x, y, z, t, a) return Float64(t + x) end
function tmp = code(x, y, z, t, a) tmp = t + x; end
code[x_, y_, z_, t_, a_] := N[(t + x), $MachinePrecision]
\begin{array}{l}
\\
t + x
\end{array}
Initial program 86.8%
Taylor expanded in z around inf
lower-+.f6467.0
Applied rewrites67.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* (/ (- y z) (- a z)) t))))
(if (< t -1.0682974490174067e-39)
t_1
(if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) / (a - z)) * t);
double tmp;
if (t < -1.0682974490174067e-39) {
tmp = t_1;
} else if (t < 3.9110949887586375e-141) {
tmp = x + (((y - z) * t) / (a - z));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = x + (((y - z) / (a - z)) * t)
if (t < (-1.0682974490174067d-39)) then
tmp = t_1
else if (t < 3.9110949887586375d-141) then
tmp = x + (((y - z) * t) / (a - z))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) / (a - z)) * t);
double tmp;
if (t < -1.0682974490174067e-39) {
tmp = t_1;
} else if (t < 3.9110949887586375e-141) {
tmp = x + (((y - z) * t) / (a - z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x + (((y - z) / (a - z)) * t) tmp = 0 if t < -1.0682974490174067e-39: tmp = t_1 elif t < 3.9110949887586375e-141: tmp = x + (((y - z) * t) / (a - z)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - z) / Float64(a - z)) * t)) tmp = 0.0 if (t < -1.0682974490174067e-39) tmp = t_1; elseif (t < 3.9110949887586375e-141) tmp = Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (((y - z) / (a - z)) * t); tmp = 0.0; if (t < -1.0682974490174067e-39) tmp = t_1; elseif (t < 3.9110949887586375e-141) tmp = x + (((y - z) * t) / (a - z)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[Less[t, -1.0682974490174067e-39], t$95$1, If[Less[t, 3.9110949887586375e-141], N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y - z}{a - z} \cdot t\\
\mathbf{if}\;t < -1.0682974490174067 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t < 3.9110949887586375 \cdot 10^{-141}:\\
\;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024320
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"
:precision binary64
:alt
(! :herbie-platform default (if (< t -10682974490174067/10000000000000000000000000000000000000000000000000000000) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 312887599100691/80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t)))))
(+ x (/ (* (- y z) t) (- a z))))