
(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 8 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 99.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2e+96) (not (<= z 2.25e+91))) (+ x (* y (/ (- z t) z))) (+ x (* y (/ t (- a z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2e+96) || !(z <= 2.25e+91)) {
tmp = x + (y * ((z - t) / z));
} else {
tmp = x + (y * (t / (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 <= (-2d+96)) .or. (.not. (z <= 2.25d+91))) then
tmp = x + (y * ((z - t) / z))
else
tmp = x + (y * (t / (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 <= -2e+96) || !(z <= 2.25e+91)) {
tmp = x + (y * ((z - t) / z));
} else {
tmp = x + (y * (t / (a - z)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -2e+96) or not (z <= 2.25e+91): tmp = x + (y * ((z - t) / z)) else: tmp = x + (y * (t / (a - z))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2e+96) || !(z <= 2.25e+91)) tmp = Float64(x + Float64(y * Float64(Float64(z - t) / z))); else tmp = Float64(x + Float64(y * Float64(t / Float64(a - z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -2e+96) || ~((z <= 2.25e+91))) tmp = x + (y * ((z - t) / z)); else tmp = x + (y * (t / (a - z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2e+96], N[Not[LessEqual[z, 2.25e+91]], $MachinePrecision]], N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+96} \lor \neg \left(z \leq 2.25 \cdot 10^{+91}\right):\\
\;\;\;\;x + y \cdot \frac{z - t}{z}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t}{a - z}\\
\end{array}
\end{array}
if z < -2.0000000000000001e96 or 2.25e91 < z Initial program 99.9%
Taylor expanded in a around 0 88.6%
if -2.0000000000000001e96 < z < 2.25e91Initial program 98.5%
Taylor expanded in t around inf 83.9%
associate-*r/83.9%
mul-1-neg83.9%
distribute-lft-neg-out83.9%
*-commutative83.9%
*-lft-identity83.9%
times-frac87.7%
/-rgt-identity87.7%
distribute-neg-frac87.7%
distribute-neg-frac287.7%
neg-sub087.7%
sub-neg87.7%
+-commutative87.7%
associate--r+87.7%
neg-sub087.7%
remove-double-neg87.7%
Simplified87.7%
Final simplification88.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.8e+100) (not (<= z 3.3e+90))) (+ x y) (+ x (* y (/ t (- a z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.8e+100) || !(z <= 3.3e+90)) {
tmp = x + y;
} else {
tmp = x + (y * (t / (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 <= (-2.8d+100)) .or. (.not. (z <= 3.3d+90))) then
tmp = x + y
else
tmp = x + (y * (t / (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 <= -2.8e+100) || !(z <= 3.3e+90)) {
tmp = x + y;
} else {
tmp = x + (y * (t / (a - z)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -2.8e+100) or not (z <= 3.3e+90): tmp = x + y else: tmp = x + (y * (t / (a - z))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.8e+100) || !(z <= 3.3e+90)) tmp = Float64(x + y); else tmp = Float64(x + Float64(y * Float64(t / Float64(a - z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -2.8e+100) || ~((z <= 3.3e+90))) tmp = x + y; else tmp = x + (y * (t / (a - z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.8e+100], N[Not[LessEqual[z, 3.3e+90]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(x + N[(y * N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+100} \lor \neg \left(z \leq 3.3 \cdot 10^{+90}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t}{a - z}\\
\end{array}
\end{array}
if z < -2.7999999999999998e100 or 3.30000000000000008e90 < z Initial program 99.9%
Taylor expanded in z around inf 79.6%
+-commutative79.6%
Simplified79.6%
if -2.7999999999999998e100 < z < 3.30000000000000008e90Initial program 98.5%
Taylor expanded in t around inf 83.8%
associate-*r/83.8%
mul-1-neg83.8%
distribute-lft-neg-out83.8%
*-commutative83.8%
*-lft-identity83.8%
times-frac87.6%
/-rgt-identity87.6%
distribute-neg-frac87.6%
distribute-neg-frac287.6%
neg-sub087.6%
sub-neg87.6%
+-commutative87.6%
associate--r+87.6%
neg-sub087.6%
remove-double-neg87.6%
Simplified87.6%
Final simplification85.0%
(FPCore (x y z t a) :precision binary64 (if (<= t -6.1e-58) (+ x (* y (/ t (- a z)))) (if (<= t 3.6e+103) (+ x (/ y (- 1.0 (/ a z)))) (+ x (* t (/ y (- a z)))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -6.1e-58) {
tmp = x + (y * (t / (a - z)));
} else if (t <= 3.6e+103) {
tmp = x + (y / (1.0 - (a / z)));
} else {
tmp = x + (t * (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 (t <= (-6.1d-58)) then
tmp = x + (y * (t / (a - z)))
else if (t <= 3.6d+103) then
tmp = x + (y / (1.0d0 - (a / z)))
else
tmp = x + (t * (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 (t <= -6.1e-58) {
tmp = x + (y * (t / (a - z)));
} else if (t <= 3.6e+103) {
tmp = x + (y / (1.0 - (a / z)));
} else {
tmp = x + (t * (y / (a - z)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -6.1e-58: tmp = x + (y * (t / (a - z))) elif t <= 3.6e+103: tmp = x + (y / (1.0 - (a / z))) else: tmp = x + (t * (y / (a - z))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -6.1e-58) tmp = Float64(x + Float64(y * Float64(t / Float64(a - z)))); elseif (t <= 3.6e+103) tmp = Float64(x + Float64(y / Float64(1.0 - Float64(a / z)))); else tmp = Float64(x + Float64(t * Float64(y / Float64(a - z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -6.1e-58) tmp = x + (y * (t / (a - z))); elseif (t <= 3.6e+103) tmp = x + (y / (1.0 - (a / z))); else tmp = x + (t * (y / (a - z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -6.1e-58], N[(x + N[(y * N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.6e+103], N[(x + N[(y / N[(1.0 - N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.1 \cdot 10^{-58}:\\
\;\;\;\;x + y \cdot \frac{t}{a - z}\\
\mathbf{elif}\;t \leq 3.6 \cdot 10^{+103}:\\
\;\;\;\;x + \frac{y}{1 - \frac{a}{z}}\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot \frac{y}{a - z}\\
\end{array}
\end{array}
if t < -6.1000000000000003e-58Initial program 99.8%
Taylor expanded in t around inf 79.0%
associate-*r/79.0%
mul-1-neg79.0%
distribute-lft-neg-out79.0%
*-commutative79.0%
*-lft-identity79.0%
times-frac91.9%
/-rgt-identity91.9%
distribute-neg-frac91.9%
distribute-neg-frac291.9%
neg-sub091.9%
sub-neg91.9%
+-commutative91.9%
associate--r+91.9%
neg-sub091.9%
remove-double-neg91.9%
Simplified91.9%
if -6.1000000000000003e-58 < t < 3.60000000000000017e103Initial program 99.6%
clear-num99.2%
un-div-inv99.2%
Applied egg-rr99.2%
Taylor expanded in t around 0 91.0%
div-sub91.0%
*-inverses91.0%
Simplified91.0%
if 3.60000000000000017e103 < t Initial program 96.0%
Taylor expanded in t around inf 88.0%
associate-*r/88.0%
mul-1-neg88.0%
distribute-lft-neg-out88.0%
*-commutative88.0%
*-lft-identity88.0%
times-frac88.1%
/-rgt-identity88.1%
distribute-neg-frac88.1%
distribute-neg-frac288.1%
neg-sub088.1%
sub-neg88.1%
+-commutative88.1%
associate--r+88.1%
neg-sub088.1%
remove-double-neg88.1%
Simplified88.1%
clear-num88.1%
un-div-inv88.1%
Applied egg-rr88.1%
associate-/r/91.9%
Simplified91.9%
Final simplification91.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.8e+63) (not (<= z 2.1e+36))) (+ x y) (+ x (* y (/ t a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.8e+63) || !(z <= 2.1e+36)) {
tmp = x + y;
} 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 ((z <= (-4.8d+63)) .or. (.not. (z <= 2.1d+36))) then
tmp = x + y
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 ((z <= -4.8e+63) || !(z <= 2.1e+36)) {
tmp = x + y;
} else {
tmp = x + (y * (t / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -4.8e+63) or not (z <= 2.1e+36): tmp = x + y else: tmp = x + (y * (t / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.8e+63) || !(z <= 2.1e+36)) tmp = Float64(x + y); 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 ((z <= -4.8e+63) || ~((z <= 2.1e+36))) tmp = x + y; else tmp = x + (y * (t / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.8e+63], N[Not[LessEqual[z, 2.1e+36]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(x + N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+63} \lor \neg \left(z \leq 2.1 \cdot 10^{+36}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t}{a}\\
\end{array}
\end{array}
if z < -4.8e63 or 2.10000000000000004e36 < z Initial program 100.0%
Taylor expanded in z around inf 77.1%
+-commutative77.1%
Simplified77.1%
if -4.8e63 < z < 2.10000000000000004e36Initial program 98.4%
Taylor expanded in z around 0 73.6%
Final simplification75.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.4e-88) (not (<= z 3.2e-125))) (+ x y) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.4e-88) || !(z <= 3.2e-125)) {
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 ((z <= (-4.4d-88)) .or. (.not. (z <= 3.2d-125))) 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 ((z <= -4.4e-88) || !(z <= 3.2e-125)) {
tmp = x + y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -4.4e-88) or not (z <= 3.2e-125): tmp = x + y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.4e-88) || !(z <= 3.2e-125)) tmp = Float64(x + y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -4.4e-88) || ~((z <= 3.2e-125))) tmp = x + y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.4e-88], N[Not[LessEqual[z, 3.2e-125]], $MachinePrecision]], N[(x + y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{-88} \lor \neg \left(z \leq 3.2 \cdot 10^{-125}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.4000000000000001e-88 or 3.1999999999999998e-125 < z Initial program 99.9%
Taylor expanded in z around inf 66.7%
+-commutative66.7%
Simplified66.7%
if -4.4000000000000001e-88 < z < 3.1999999999999998e-125Initial program 97.3%
Taylor expanded in x around inf 55.4%
Final simplification62.9%
(FPCore (x y z t a) :precision binary64 (if (<= y -1.45e+228) y x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.45e+228) {
tmp = 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 (y <= (-1.45d+228)) then
tmp = 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 (y <= -1.45e+228) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= -1.45e+228: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= -1.45e+228) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= -1.45e+228) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.45e+228], y, x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+228}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.45000000000000001e228Initial program 99.9%
Taylor expanded in z around inf 42.2%
+-commutative42.2%
Simplified42.2%
Taylor expanded in y around inf 42.2%
if -1.45000000000000001e228 < y Initial program 98.9%
Taylor expanded in x around inf 53.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 99.0%
Taylor expanded in x around inf 49.5%
(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 2024163
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"
:precision binary64
:alt
(! :herbie-platform default (+ x (/ y (/ (- z a) (- z t)))))
(+ x (* y (/ (- z t) (- z a)))))