
(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 12 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
(let* ((t_1 (* (/ t (- z a)) (- z y)))
(t_2 (* t (- z y)))
(t_3 (/ t_2 (- z a))))
(if (<= t_3 -5e+199) t_1 (if (<= t_3 2e+212) (- x (/ t_2 (- a z))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t / (z - a)) * (z - y);
double t_2 = t * (z - y);
double t_3 = t_2 / (z - a);
double tmp;
if (t_3 <= -5e+199) {
tmp = t_1;
} else if (t_3 <= 2e+212) {
tmp = x - (t_2 / (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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = (t / (z - a)) * (z - y)
t_2 = t * (z - y)
t_3 = t_2 / (z - a)
if (t_3 <= (-5d+199)) then
tmp = t_1
else if (t_3 <= 2d+212) then
tmp = x - (t_2 / (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 = (t / (z - a)) * (z - y);
double t_2 = t * (z - y);
double t_3 = t_2 / (z - a);
double tmp;
if (t_3 <= -5e+199) {
tmp = t_1;
} else if (t_3 <= 2e+212) {
tmp = x - (t_2 / (a - z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (t / (z - a)) * (z - y) t_2 = t * (z - y) t_3 = t_2 / (z - a) tmp = 0 if t_3 <= -5e+199: tmp = t_1 elif t_3 <= 2e+212: tmp = x - (t_2 / (a - z)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(t / Float64(z - a)) * Float64(z - y)) t_2 = Float64(t * Float64(z - y)) t_3 = Float64(t_2 / Float64(z - a)) tmp = 0.0 if (t_3 <= -5e+199) tmp = t_1; elseif (t_3 <= 2e+212) tmp = Float64(x - Float64(t_2 / Float64(a - z))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (t / (z - a)) * (z - y); t_2 = t * (z - y); t_3 = t_2 / (z - a); tmp = 0.0; if (t_3 <= -5e+199) tmp = t_1; elseif (t_3 <= 2e+212) tmp = x - (t_2 / (a - z)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -5e+199], t$95$1, If[LessEqual[t$95$3, 2e+212], N[(x - N[(t$95$2 / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{z - a} \cdot \left(z - y\right)\\
t_2 := t \cdot \left(z - y\right)\\
t_3 := \frac{t\_2}{z - a}\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{+199}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+212}:\\
\;\;\;\;x - \frac{t\_2}{a - z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < -4.9999999999999998e199 or 1.9999999999999998e212 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) Initial program 52.7%
Taylor expanded in x around 0
associate-/l*N/A
div-subN/A
distribute-lft-out--N/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6494.2
Applied rewrites94.2%
if -4.9999999999999998e199 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < 1.9999999999999998e212Initial program 99.9%
Final simplification98.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ t (- z a)) (- z y))) (t_2 (/ (* t (- z y)) (- z a))))
(if (<= t_2 -5e+60)
t_1
(if (<= t_2 1e+74) (- x (/ (* (- z) t) (- z a))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (t / (z - a)) * (z - y);
double t_2 = (t * (z - y)) / (z - a);
double tmp;
if (t_2 <= -5e+60) {
tmp = t_1;
} else if (t_2 <= 1e+74) {
tmp = x - ((-z * t) / (z - a));
} 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) :: t_2
real(8) :: tmp
t_1 = (t / (z - a)) * (z - y)
t_2 = (t * (z - y)) / (z - a)
if (t_2 <= (-5d+60)) then
tmp = t_1
else if (t_2 <= 1d+74) then
tmp = x - ((-z * t) / (z - a))
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 = (t / (z - a)) * (z - y);
double t_2 = (t * (z - y)) / (z - a);
double tmp;
if (t_2 <= -5e+60) {
tmp = t_1;
} else if (t_2 <= 1e+74) {
tmp = x - ((-z * t) / (z - a));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (t / (z - a)) * (z - y) t_2 = (t * (z - y)) / (z - a) tmp = 0 if t_2 <= -5e+60: tmp = t_1 elif t_2 <= 1e+74: tmp = x - ((-z * t) / (z - a)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(t / Float64(z - a)) * Float64(z - y)) t_2 = Float64(Float64(t * Float64(z - y)) / Float64(z - a)) tmp = 0.0 if (t_2 <= -5e+60) tmp = t_1; elseif (t_2 <= 1e+74) tmp = Float64(x - Float64(Float64(Float64(-z) * t) / Float64(z - a))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (t / (z - a)) * (z - y); t_2 = (t * (z - y)) / (z - a); tmp = 0.0; if (t_2 <= -5e+60) tmp = t_1; elseif (t_2 <= 1e+74) tmp = x - ((-z * t) / (z - a)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t * N[(z - y), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+60], t$95$1, If[LessEqual[t$95$2, 1e+74], N[(x - N[(N[((-z) * t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{z - a} \cdot \left(z - y\right)\\
t_2 := \frac{t \cdot \left(z - y\right)}{z - a}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+74}:\\
\;\;\;\;x - \frac{\left(-z\right) \cdot t}{z - a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < -4.99999999999999975e60 or 9.99999999999999952e73 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) Initial program 65.0%
Taylor expanded in x around 0
associate-/l*N/A
div-subN/A
distribute-lft-out--N/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6479.8
Applied rewrites79.8%
if -4.99999999999999975e60 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < 9.99999999999999952e73Initial program 99.6%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6486.3
Applied rewrites86.3%
Final simplification83.7%
(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 2024230
(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))))