
(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 8 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 (+ (/ y (/ (- a t) (- z t))) x))
double code(double x, double y, double z, double t, double a) {
return (y / ((a - t) / (z - 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 = (y / ((a - t) / (z - t))) + x
end function
public static double code(double x, double y, double z, double t, double a) {
return (y / ((a - t) / (z - t))) + x;
}
def code(x, y, z, t, a): return (y / ((a - t) / (z - t))) + x
function code(x, y, z, t, a) return Float64(Float64(y / Float64(Float64(a - t) / Float64(z - t))) + x) end
function tmp = code(x, y, z, t, a) tmp = (y / ((a - t) / (z - t))) + x; end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{\frac{a - t}{z - t}} + x
\end{array}
Initial program 83.8%
+-commutative83.8%
associate-/l*97.7%
fma-define97.7%
Simplified97.7%
fma-undefine97.7%
clear-num97.6%
un-div-inv98.4%
Applied egg-rr98.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -6e+21) (not (<= z 3.5e-18))) (- x (* z (/ y (- t a)))) (+ x (* y (/ t (- t a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -6e+21) || !(z <= 3.5e-18)) {
tmp = x - (z * (y / (t - a)));
} else {
tmp = x + (y * (t / (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 <= (-6d+21)) .or. (.not. (z <= 3.5d-18))) then
tmp = x - (z * (y / (t - a)))
else
tmp = x + (y * (t / (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 <= -6e+21) || !(z <= 3.5e-18)) {
tmp = x - (z * (y / (t - a)));
} else {
tmp = x + (y * (t / (t - a)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -6e+21) or not (z <= 3.5e-18): tmp = x - (z * (y / (t - a))) else: tmp = x + (y * (t / (t - a))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -6e+21) || !(z <= 3.5e-18)) tmp = Float64(x - Float64(z * Float64(y / Float64(t - a)))); else tmp = Float64(x + Float64(y * Float64(t / Float64(t - a)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -6e+21) || ~((z <= 3.5e-18))) tmp = x - (z * (y / (t - a))); else tmp = x + (y * (t / (t - a))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -6e+21], N[Not[LessEqual[z, 3.5e-18]], $MachinePrecision]], N[(x - N[(z * N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(t / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+21} \lor \neg \left(z \leq 3.5 \cdot 10^{-18}\right):\\
\;\;\;\;x - z \cdot \frac{y}{t - a}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{t}{t - a}\\
\end{array}
\end{array}
if z < -6e21 or 3.4999999999999999e-18 < z Initial program 81.9%
*-commutative81.9%
associate-*r/96.6%
*-commutative96.6%
Applied egg-rr96.6%
Taylor expanded in z around inf 88.9%
if -6e21 < z < 3.4999999999999999e-18Initial program 85.4%
+-commutative85.4%
associate-/l*99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around 0 79.8%
mul-1-neg79.8%
unsub-neg79.8%
*-commutative79.8%
*-lft-identity79.8%
times-frac94.3%
/-rgt-identity94.3%
Simplified94.3%
Final simplification91.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -9.2e+120) (not (<= t 4.6e-101))) (- x (* y (+ (/ z t) -1.0))) (- x (* z (/ y (- t a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -9.2e+120) || !(t <= 4.6e-101)) {
tmp = x - (y * ((z / t) + -1.0));
} else {
tmp = x - (z * (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 ((t <= (-9.2d+120)) .or. (.not. (t <= 4.6d-101))) then
tmp = x - (y * ((z / t) + (-1.0d0)))
else
tmp = x - (z * (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 ((t <= -9.2e+120) || !(t <= 4.6e-101)) {
tmp = x - (y * ((z / t) + -1.0));
} else {
tmp = x - (z * (y / (t - a)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -9.2e+120) or not (t <= 4.6e-101): tmp = x - (y * ((z / t) + -1.0)) else: tmp = x - (z * (y / (t - a))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -9.2e+120) || !(t <= 4.6e-101)) tmp = Float64(x - Float64(y * Float64(Float64(z / t) + -1.0))); else tmp = Float64(x - Float64(z * Float64(y / Float64(t - a)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -9.2e+120) || ~((t <= 4.6e-101))) tmp = x - (y * ((z / t) + -1.0)); else tmp = x - (z * (y / (t - a))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -9.2e+120], N[Not[LessEqual[t, 4.6e-101]], $MachinePrecision]], N[(x - N[(y * N[(N[(z / t), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.2 \cdot 10^{+120} \lor \neg \left(t \leq 4.6 \cdot 10^{-101}\right):\\
\;\;\;\;x - y \cdot \left(\frac{z}{t} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t - a}\\
\end{array}
\end{array}
if t < -9.1999999999999997e120 or 4.5999999999999999e-101 < t Initial program 76.2%
+-commutative76.2%
associate-/l*99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in a around 0 65.1%
mul-1-neg65.1%
unsub-neg65.1%
associate-/l*83.8%
div-sub83.8%
sub-neg83.8%
*-inverses83.8%
metadata-eval83.8%
Simplified83.8%
if -9.1999999999999997e120 < t < 4.5999999999999999e-101Initial program 90.9%
*-commutative90.9%
associate-*r/97.7%
*-commutative97.7%
Applied egg-rr97.7%
Taylor expanded in z around inf 89.1%
Final simplification86.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -4.5e+123) (not (<= t 2.4e+138))) (+ y x) (- x (* z (/ y (- t a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -4.5e+123) || !(t <= 2.4e+138)) {
tmp = y + x;
} else {
tmp = x - (z * (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 ((t <= (-4.5d+123)) .or. (.not. (t <= 2.4d+138))) then
tmp = y + x
else
tmp = x - (z * (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 ((t <= -4.5e+123) || !(t <= 2.4e+138)) {
tmp = y + x;
} else {
tmp = x - (z * (y / (t - a)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -4.5e+123) or not (t <= 2.4e+138): tmp = y + x else: tmp = x - (z * (y / (t - a))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -4.5e+123) || !(t <= 2.4e+138)) tmp = Float64(y + x); else tmp = Float64(x - Float64(z * Float64(y / Float64(t - a)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -4.5e+123) || ~((t <= 2.4e+138))) tmp = y + x; else tmp = x - (z * (y / (t - a))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -4.5e+123], N[Not[LessEqual[t, 2.4e+138]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(x - N[(z * N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.5 \cdot 10^{+123} \lor \neg \left(t \leq 2.4 \cdot 10^{+138}\right):\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t - a}\\
\end{array}
\end{array}
if t < -4.49999999999999983e123 or 2.4000000000000001e138 < t Initial program 69.4%
+-commutative69.4%
associate-/l*100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in t around inf 83.3%
+-commutative83.3%
Simplified83.3%
if -4.49999999999999983e123 < t < 2.4000000000000001e138Initial program 89.8%
*-commutative89.8%
associate-*r/97.8%
*-commutative97.8%
Applied egg-rr97.8%
Taylor expanded in z around inf 85.3%
Final simplification84.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -6.6e+55) (not (<= t 4.6e-101))) (+ y x) (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -6.6e+55) || !(t <= 4.6e-101)) {
tmp = y + x;
} else {
tmp = x + (z * (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 ((t <= (-6.6d+55)) .or. (.not. (t <= 4.6d-101))) then
tmp = y + x
else
tmp = x + (z * (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 ((t <= -6.6e+55) || !(t <= 4.6e-101)) {
tmp = y + x;
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -6.6e+55) or not (t <= 4.6e-101): tmp = y + x else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -6.6e+55) || !(t <= 4.6e-101)) tmp = Float64(y + x); else tmp = Float64(x + Float64(z * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -6.6e+55) || ~((t <= 4.6e-101))) tmp = y + x; else tmp = x + (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -6.6e+55], N[Not[LessEqual[t, 4.6e-101]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.6 \cdot 10^{+55} \lor \neg \left(t \leq 4.6 \cdot 10^{-101}\right):\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -6.6e55 or 4.5999999999999999e-101 < t Initial program 75.9%
+-commutative75.9%
associate-/l*99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in t around inf 73.1%
+-commutative73.1%
Simplified73.1%
if -6.6e55 < t < 4.5999999999999999e-101Initial program 92.5%
*-commutative92.5%
associate-*r/97.5%
*-commutative97.5%
Applied egg-rr97.5%
Taylor expanded in z around inf 90.6%
Taylor expanded in a around inf 84.2%
Final simplification78.4%
(FPCore (x y z t a) :precision binary64 (if (<= a -3.1e+161) x (if (<= a 1.2e+155) (+ y x) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -3.1e+161) {
tmp = x;
} else if (a <= 1.2e+155) {
tmp = y + x;
} 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 <= (-3.1d+161)) then
tmp = x
else if (a <= 1.2d+155) then
tmp = y + x
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 <= -3.1e+161) {
tmp = x;
} else if (a <= 1.2e+155) {
tmp = y + x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -3.1e+161: tmp = x elif a <= 1.2e+155: tmp = y + x else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -3.1e+161) tmp = x; elseif (a <= 1.2e+155) tmp = Float64(y + x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -3.1e+161) tmp = x; elseif (a <= 1.2e+155) tmp = y + x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -3.1e+161], x, If[LessEqual[a, 1.2e+155], N[(y + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.1 \cdot 10^{+161}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 1.2 \cdot 10^{+155}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -3.10000000000000007e161 or 1.2000000000000001e155 < a Initial program 80.3%
+-commutative80.3%
associate-/l*99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in y around 0 60.6%
if -3.10000000000000007e161 < a < 1.2000000000000001e155Initial program 85.2%
+-commutative85.2%
associate-/l*96.8%
fma-define96.8%
Simplified96.8%
Taylor expanded in t around inf 64.3%
+-commutative64.3%
Simplified64.3%
(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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{a - t}
\end{array}
Initial program 83.8%
associate-/l*97.7%
Simplified97.7%
(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 83.8%
+-commutative83.8%
associate-/l*97.7%
fma-define97.7%
Simplified97.7%
Taylor expanded in y around 0 48.0%
(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 2024151
(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))))