
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
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)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\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)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
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)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\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(y / Float64(Float64(z - a) / Float64(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[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{z - a}{z - t}}
\end{array}
Initial program 87.0%
associate-/l*98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -4.7e+25) (not (<= a 6e-119))) (+ x (* y (/ t a))) (+ x (* (- z t) (/ y z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -4.7e+25) || !(a <= 6e-119)) {
tmp = x + (y * (t / a));
} else {
tmp = x + ((z - t) * (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 ((a <= (-4.7d+25)) .or. (.not. (a <= 6d-119))) then
tmp = x + (y * (t / a))
else
tmp = x + ((z - t) * (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 ((a <= -4.7e+25) || !(a <= 6e-119)) {
tmp = x + (y * (t / a));
} else {
tmp = x + ((z - t) * (y / z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (a <= -4.7e+25) or not (a <= 6e-119): tmp = x + (y * (t / a)) else: tmp = x + ((z - t) * (y / z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -4.7e+25) || !(a <= 6e-119)) tmp = Float64(x + Float64(y * Float64(t / a))); else tmp = Float64(x + Float64(Float64(z - t) * Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((a <= -4.7e+25) || ~((a <= 6e-119))) tmp = x + (y * (t / a)); else tmp = x + ((z - t) * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -4.7e+25], N[Not[LessEqual[a, 6e-119]], $MachinePrecision]], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.7 \cdot 10^{+25} \lor \neg \left(a \leq 6 \cdot 10^{-119}\right):\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{z}\\
\end{array}
\end{array}
if a < -4.6999999999999998e25 or 6.0000000000000004e-119 < a Initial program 86.7%
+-commutative86.7%
associate-*r/99.9%
fma-def99.9%
Simplified99.9%
fma-udef99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 80.3%
associate-*r/86.9%
Simplified86.9%
if -4.6999999999999998e25 < a < 6.0000000000000004e-119Initial program 87.5%
associate-*l/96.5%
Simplified96.5%
Taylor expanded in z around inf 84.5%
Final simplification85.9%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.38e+34) (+ x (/ (- t z) (/ a y))) (if (<= a 6e-119) (+ x (* (- z t) (/ y z))) (+ x (* y (/ t a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.38e+34) {
tmp = x + ((t - z) / (a / y));
} else if (a <= 6e-119) {
tmp = x + ((z - t) * (y / z));
} else {
tmp = x + (y * (t / a));
}
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.38d+34)) then
tmp = x + ((t - z) / (a / y))
else if (a <= 6d-119) then
tmp = x + ((z - t) * (y / z))
else
tmp = x + (y * (t / a))
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.38e+34) {
tmp = x + ((t - z) / (a / y));
} else if (a <= 6e-119) {
tmp = x + ((z - t) * (y / z));
} else {
tmp = x + (y * (t / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -1.38e+34: tmp = x + ((t - z) / (a / y)) elif a <= 6e-119: tmp = x + ((z - t) * (y / z)) else: tmp = x + (y * (t / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.38e+34) tmp = Float64(x + Float64(Float64(t - z) / Float64(a / y))); elseif (a <= 6e-119) tmp = Float64(x + Float64(Float64(z - t) * Float64(y / z))); else tmp = Float64(x + Float64(y * Float64(t / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -1.38e+34) tmp = x + ((t - z) / (a / y)); elseif (a <= 6e-119) tmp = x + ((z - t) * (y / z)); else tmp = x + (y * (t / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.38e+34], N[(x + N[(N[(t - z), $MachinePrecision] / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6e-119], N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.38 \cdot 10^{+34}:\\
\;\;\;\;x + \frac{t - z}{\frac{a}{y}}\\
\mathbf{elif}\;a \leq 6 \cdot 10^{-119}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\end{array}
\end{array}
if a < -1.3799999999999999e34Initial program 84.2%
+-commutative84.2%
associate-*r/99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in a around inf 78.6%
+-commutative78.6%
*-commutative78.6%
mul-1-neg78.6%
unsub-neg78.6%
*-commutative78.6%
associate-/l*87.0%
Simplified87.0%
if -1.3799999999999999e34 < a < 6.0000000000000004e-119Initial program 87.8%
associate-*l/96.6%
Simplified96.6%
Taylor expanded in z around inf 84.1%
if 6.0000000000000004e-119 < a Initial program 88.7%
+-commutative88.7%
associate-*r/100.0%
fma-def100.0%
Simplified100.0%
fma-udef100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 83.0%
associate-*r/88.6%
Simplified88.6%
Final simplification86.1%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.6e+87) (+ x y) (if (<= z 1.65e+68) (+ x (* y (/ t a))) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.6e+87) {
tmp = x + y;
} else if (z <= 1.65e+68) {
tmp = x + (y * (t / a));
} else {
tmp = x + y;
}
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 <= (-4.6d+87)) then
tmp = x + y
else if (z <= 1.65d+68) then
tmp = x + (y * (t / a))
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.6e+87) {
tmp = x + y;
} else if (z <= 1.65e+68) {
tmp = x + (y * (t / a));
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -4.6e+87: tmp = x + y elif z <= 1.65e+68: tmp = x + (y * (t / a)) else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.6e+87) tmp = Float64(x + y); elseif (z <= 1.65e+68) tmp = Float64(x + Float64(y * Float64(t / a))); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -4.6e+87) tmp = x + y; elseif (z <= 1.65e+68) tmp = x + (y * (t / a)); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.6e+87], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.65e+68], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+87}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+68}:\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -4.6000000000000003e87 or 1.65e68 < z Initial program 73.4%
+-commutative73.4%
associate-*r/99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in z around inf 83.5%
if -4.6000000000000003e87 < z < 1.65e68Initial program 94.3%
+-commutative94.3%
associate-*r/98.2%
fma-def98.2%
Simplified98.2%
fma-udef98.2%
Applied egg-rr98.2%
Taylor expanded in z around 0 75.5%
associate-*r/79.0%
Simplified79.0%
Final simplification80.5%
(FPCore (x y z t a) :precision binary64 (+ x (* (- z t) (/ y (- z a)))))
double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / (z - a)));
}
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 + ((z - t) * (y / (z - a)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / (z - a)));
}
def code(x, y, z, t, a): return x + ((z - t) * (y / (z - a)))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(z - t) * Float64(y / Float64(z - a)))) end
function tmp = code(x, y, z, t, a) tmp = x + ((z - t) * (y / (z - a))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z - t\right) \cdot \frac{y}{z - a}
\end{array}
Initial program 87.0%
associate-*l/97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x y z t a) :precision binary64 (if (<= a -6e+103) x (if (<= a 4.2e+130) (+ x y) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -6e+103) {
tmp = x;
} else if (a <= 4.2e+130) {
tmp = x + y;
} else {
tmp = 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 (a <= (-6d+103)) then
tmp = x
else if (a <= 4.2d+130) then
tmp = x + y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -6e+103) {
tmp = x;
} else if (a <= 4.2e+130) {
tmp = x + y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -6e+103: tmp = x elif a <= 4.2e+130: tmp = x + y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -6e+103) tmp = x; elseif (a <= 4.2e+130) tmp = Float64(x + y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -6e+103) tmp = x; elseif (a <= 4.2e+130) tmp = x + y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -6e+103], x, If[LessEqual[a, 4.2e+130], N[(x + y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{+103}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 4.2 \cdot 10^{+130}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -6e103 or 4.19999999999999981e130 < a Initial program 87.0%
+-commutative87.0%
associate-*r/99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around 0 74.5%
if -6e103 < a < 4.19999999999999981e130Initial program 87.1%
+-commutative87.1%
associate-*r/98.2%
fma-def98.2%
Simplified98.2%
Taylor expanded in z around inf 67.0%
Final simplification69.6%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return 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 = x
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.0%
+-commutative87.0%
associate-*r/98.8%
fma-def98.8%
Simplified98.8%
Taylor expanded in y around 0 58.7%
Final simplification58.7%
(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(y / Float64(Float64(z - a) / Float64(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[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{z - a}{z - t}}
\end{array}
herbie shell --seed 2023199
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
:precision binary64
:herbie-target
(+ x (/ y (/ (- z a) (- z t))))
(+ x (/ (* y (- z t)) (- z a))))