
(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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\end{array}
(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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\end{array}
Initial program 97.0%
Final simplification97.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.6e-13) (not (<= z 185000000000.0))) (+ x (* y (- 1.0 (/ t z)))) (+ x (* t (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.6e-13) || !(z <= 185000000000.0)) {
tmp = x + (y * (1.0 - (t / z)));
} else {
tmp = x + (t * (y / 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 ((z <= (-3.6d-13)) .or. (.not. (z <= 185000000000.0d0))) then
tmp = x + (y * (1.0d0 - (t / z)))
else
tmp = x + (t * (y / a))
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.6e-13) || !(z <= 185000000000.0)) {
tmp = x + (y * (1.0 - (t / z)));
} else {
tmp = x + (t * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -3.6e-13) or not (z <= 185000000000.0): tmp = x + (y * (1.0 - (t / z))) else: tmp = x + (t * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.6e-13) || !(z <= 185000000000.0)) tmp = Float64(x + Float64(y * Float64(1.0 - Float64(t / z)))); else tmp = Float64(x + Float64(t * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -3.6e-13) || ~((z <= 185000000000.0))) tmp = x + (y * (1.0 - (t / z))); else tmp = x + (t * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.6e-13], N[Not[LessEqual[z, 185000000000.0]], $MachinePrecision]], N[(x + N[(y * N[(1.0 - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{-13} \lor \neg \left(z \leq 185000000000\right):\\
\;\;\;\;x + y \cdot \left(1 - \frac{t}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -3.5999999999999998e-13 or 1.85e11 < z Initial program 100.0%
Taylor expanded in a around 0 67.7%
associate-/l*87.7%
div-sub87.7%
*-inverses87.7%
Simplified87.7%
if -3.5999999999999998e-13 < z < 1.85e11Initial program 93.5%
Taylor expanded in z around 0 81.4%
associate-/l*81.6%
Simplified81.6%
Final simplification84.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -2.3e-39) (not (<= t 9.5e+90))) (+ x (* t (/ y (- a z)))) (- x (* y (/ z (- a z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -2.3e-39) || !(t <= 9.5e+90)) {
tmp = x + (t * (y / (a - z)));
} else {
tmp = x - (y * (z / (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 ((t <= (-2.3d-39)) .or. (.not. (t <= 9.5d+90))) then
tmp = x + (t * (y / (a - z)))
else
tmp = x - (y * (z / (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 ((t <= -2.3e-39) || !(t <= 9.5e+90)) {
tmp = x + (t * (y / (a - z)));
} else {
tmp = x - (y * (z / (a - z)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -2.3e-39) or not (t <= 9.5e+90): tmp = x + (t * (y / (a - z))) else: tmp = x - (y * (z / (a - z))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -2.3e-39) || !(t <= 9.5e+90)) tmp = Float64(x + Float64(t * Float64(y / Float64(a - z)))); else tmp = Float64(x - Float64(y * Float64(z / Float64(a - z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -2.3e-39) || ~((t <= 9.5e+90))) tmp = x + (t * (y / (a - z))); else tmp = x - (y * (z / (a - z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -2.3e-39], N[Not[LessEqual[t, 9.5e+90]], $MachinePrecision]], N[(x + N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.3 \cdot 10^{-39} \lor \neg \left(t \leq 9.5 \cdot 10^{+90}\right):\\
\;\;\;\;x + t \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{a - z}\\
\end{array}
\end{array}
if t < -2.30000000000000008e-39 or 9.4999999999999994e90 < t Initial program 94.5%
Taylor expanded in t around inf 84.0%
mul-1-neg84.0%
associate-/l*89.4%
Simplified89.4%
if -2.30000000000000008e-39 < t < 9.4999999999999994e90Initial program 98.7%
Taylor expanded in t around 0 80.8%
associate-/l*92.6%
Simplified92.6%
Final simplification91.3%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.7e-14) (+ x (* y (- 1.0 (/ t z)))) (if (<= z 4e-45) (+ x (/ (* y t) a)) (- x (* y (/ z (- a z)))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.7e-14) {
tmp = x + (y * (1.0 - (t / z)));
} else if (z <= 4e-45) {
tmp = x + ((y * t) / a);
} else {
tmp = x - (y * (z / (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 (z <= (-3.7d-14)) then
tmp = x + (y * (1.0d0 - (t / z)))
else if (z <= 4d-45) then
tmp = x + ((y * t) / a)
else
tmp = x - (y * (z / (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 (z <= -3.7e-14) {
tmp = x + (y * (1.0 - (t / z)));
} else if (z <= 4e-45) {
tmp = x + ((y * t) / a);
} else {
tmp = x - (y * (z / (a - z)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -3.7e-14: tmp = x + (y * (1.0 - (t / z))) elif z <= 4e-45: tmp = x + ((y * t) / a) else: tmp = x - (y * (z / (a - z))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.7e-14) tmp = Float64(x + Float64(y * Float64(1.0 - Float64(t / z)))); elseif (z <= 4e-45) tmp = Float64(x + Float64(Float64(y * t) / a)); else tmp = Float64(x - Float64(y * Float64(z / Float64(a - z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -3.7e-14) tmp = x + (y * (1.0 - (t / z))); elseif (z <= 4e-45) tmp = x + ((y * t) / a); else tmp = x - (y * (z / (a - z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.7e-14], N[(x + N[(y * N[(1.0 - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4e-45], N[(x + N[(N[(y * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-14}:\\
\;\;\;\;x + y \cdot \left(1 - \frac{t}{z}\right)\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-45}:\\
\;\;\;\;x + \frac{y \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{a - z}\\
\end{array}
\end{array}
if z < -3.70000000000000001e-14Initial program 100.0%
Taylor expanded in a around 0 66.0%
associate-/l*89.3%
div-sub89.3%
*-inverses89.3%
Simplified89.3%
if -3.70000000000000001e-14 < z < 3.99999999999999994e-45Initial program 92.7%
Taylor expanded in z around 0 83.4%
if 3.99999999999999994e-45 < z Initial program 99.9%
Taylor expanded in t around 0 75.3%
associate-/l*87.4%
Simplified87.4%
Final simplification86.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3e+22) (not (<= z 9500000000000.0))) (+ x y) (+ x (* t (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3e+22) || !(z <= 9500000000000.0)) {
tmp = x + y;
} else {
tmp = x + (t * (y / 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 ((z <= (-3d+22)) .or. (.not. (z <= 9500000000000.0d0))) then
tmp = x + y
else
tmp = x + (t * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3e+22) || !(z <= 9500000000000.0)) {
tmp = x + y;
} else {
tmp = x + (t * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -3e+22) or not (z <= 9500000000000.0): tmp = x + y else: tmp = x + (t * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3e+22) || !(z <= 9500000000000.0)) tmp = Float64(x + y); else tmp = Float64(x + Float64(t * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -3e+22) || ~((z <= 9500000000000.0))) tmp = x + y; else tmp = x + (t * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3e+22], N[Not[LessEqual[z, 9500000000000.0]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(x + N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+22} \lor \neg \left(z \leq 9500000000000\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -3e22 or 9.5e12 < z Initial program 100.0%
Taylor expanded in z around inf 80.0%
if -3e22 < z < 9.5e12Initial program 93.9%
Taylor expanded in z around 0 78.5%
associate-/l*79.5%
Simplified79.5%
Final simplification79.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.35e+62) x (if (<= a 8.8e+220) (+ x y) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.35e+62) {
tmp = x;
} else if (a <= 8.8e+220) {
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 <= (-1.35d+62)) then
tmp = x
else if (a <= 8.8d+220) 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 <= -1.35e+62) {
tmp = x;
} else if (a <= 8.8e+220) {
tmp = x + y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -1.35e+62: tmp = x elif a <= 8.8e+220: tmp = x + y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.35e+62) tmp = x; elseif (a <= 8.8e+220) 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 <= -1.35e+62) tmp = x; elseif (a <= 8.8e+220) tmp = x + y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.35e+62], x, If[LessEqual[a, 8.8e+220], N[(x + y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.35 \cdot 10^{+62}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 8.8 \cdot 10^{+220}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -1.35e62 or 8.79999999999999957e220 < a Initial program 98.2%
Taylor expanded in z around 0 75.0%
*-commutative75.0%
associate-/l*86.2%
Simplified86.2%
Taylor expanded in x around inf 71.7%
if -1.35e62 < a < 8.79999999999999957e220Initial program 96.6%
Taylor expanded in z around inf 68.2%
Final simplification69.0%
(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 97.0%
Taylor expanded in z around 0 62.0%
*-commutative62.0%
associate-/l*61.7%
Simplified61.7%
Taylor expanded in x around inf 52.2%
Final simplification52.2%
(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 2024130
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"
:precision binary64
:alt
(+ x (/ y (/ (- z a) (- z t))))
(+ x (* y (/ (- z t) (- z a)))))