
(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - x) * (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
def code(x, y, z, t): return x + ((y - x) * (z / t))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) * (z / t)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \frac{z}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - x) * (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
def code(x, y, z, t): return x + ((y - x) * (z / t))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) * (z / t)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \frac{z}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (fma (- y x) (/ z t) x))
double code(double x, double y, double z, double t) {
return fma((y - x), (z / t), x);
}
function code(x, y, z, t) return fma(Float64(y - x), Float64(z / t), x) end
code[x_, y_, z_, t_] := N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)
\end{array}
Initial program 97.6%
+-commutative97.6%
fma-def97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (/ z t))))
(if (<= (/ z t) -5e-50)
t_1
(if (<= (/ z t) 1e-87) x (if (<= (/ z t) 5e+54) t_1 (* x (/ (- z) t)))))))
double code(double x, double y, double z, double t) {
double t_1 = y * (z / t);
double tmp;
if ((z / t) <= -5e-50) {
tmp = t_1;
} else if ((z / t) <= 1e-87) {
tmp = x;
} else if ((z / t) <= 5e+54) {
tmp = t_1;
} else {
tmp = x * (-z / t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = y * (z / t)
if ((z / t) <= (-5d-50)) then
tmp = t_1
else if ((z / t) <= 1d-87) then
tmp = x
else if ((z / t) <= 5d+54) then
tmp = t_1
else
tmp = x * (-z / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * (z / t);
double tmp;
if ((z / t) <= -5e-50) {
tmp = t_1;
} else if ((z / t) <= 1e-87) {
tmp = x;
} else if ((z / t) <= 5e+54) {
tmp = t_1;
} else {
tmp = x * (-z / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (z / t) tmp = 0 if (z / t) <= -5e-50: tmp = t_1 elif (z / t) <= 1e-87: tmp = x elif (z / t) <= 5e+54: tmp = t_1 else: tmp = x * (-z / t) return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(z / t)) tmp = 0.0 if (Float64(z / t) <= -5e-50) tmp = t_1; elseif (Float64(z / t) <= 1e-87) tmp = x; elseif (Float64(z / t) <= 5e+54) tmp = t_1; else tmp = Float64(x * Float64(Float64(-z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (z / t); tmp = 0.0; if ((z / t) <= -5e-50) tmp = t_1; elseif ((z / t) <= 1e-87) tmp = x; elseif ((z / t) <= 5e+54) tmp = t_1; else tmp = x * (-z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z / t), $MachinePrecision], -5e-50], t$95$1, If[LessEqual[N[(z / t), $MachinePrecision], 1e-87], x, If[LessEqual[N[(z / t), $MachinePrecision], 5e+54], t$95$1, N[(x * N[((-z) / t), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z}{t}\\
\mathbf{if}\;\frac{z}{t} \leq -5 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{z}{t} \leq 10^{-87}:\\
\;\;\;\;x\\
\mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{+54}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-z}{t}\\
\end{array}
\end{array}
if (/.f64 z t) < -4.99999999999999968e-50 or 1.00000000000000002e-87 < (/.f64 z t) < 5.00000000000000005e54Initial program 96.9%
Taylor expanded in z around inf 74.2%
*-commutative74.2%
sub-div77.6%
associate-/r/85.2%
Applied egg-rr85.2%
Taylor expanded in y around inf 50.0%
associate-*r/57.0%
Simplified57.0%
if -4.99999999999999968e-50 < (/.f64 z t) < 1.00000000000000002e-87Initial program 98.0%
Taylor expanded in z around 0 82.0%
if 5.00000000000000005e54 < (/.f64 z t) Initial program 98.2%
Taylor expanded in z around inf 89.2%
Taylor expanded in y around 0 89.2%
neg-mul-189.2%
+-commutative89.2%
sub-neg89.2%
div-sub93.1%
Simplified93.1%
Taylor expanded in y around 0 62.0%
associate-*r/62.0%
mul-1-neg62.0%
distribute-rgt-neg-in62.0%
associate-*r/68.5%
Simplified68.5%
Final simplification70.0%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ z t) -1e-7) (not (<= (/ z t) 4e-67))) (* z (/ (- y x) t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -1e-7) || !((z / t) <= 4e-67)) {
tmp = z * ((y - x) / t);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((z / t) <= (-1d-7)) .or. (.not. ((z / t) <= 4d-67))) then
tmp = z * ((y - x) / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -1e-7) || !((z / t) <= 4e-67)) {
tmp = z * ((y - x) / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z / t) <= -1e-7) or not ((z / t) <= 4e-67): tmp = z * ((y - x) / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z / t) <= -1e-7) || !(Float64(z / t) <= 4e-67)) tmp = Float64(z * Float64(Float64(y - x) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z / t) <= -1e-7) || ~(((z / t) <= 4e-67))) tmp = z * ((y - x) / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z / t), $MachinePrecision], -1e-7], N[Not[LessEqual[N[(z / t), $MachinePrecision], 4e-67]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -1 \cdot 10^{-7} \lor \neg \left(\frac{z}{t} \leq 4 \cdot 10^{-67}\right):\\
\;\;\;\;z \cdot \frac{y - x}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 z t) < -9.9999999999999995e-8 or 3.99999999999999977e-67 < (/.f64 z t) Initial program 97.1%
Taylor expanded in z around inf 84.9%
Taylor expanded in y around 0 84.9%
neg-mul-184.9%
+-commutative84.9%
sub-neg84.9%
div-sub88.6%
Simplified88.6%
if -9.9999999999999995e-8 < (/.f64 z t) < 3.99999999999999977e-67Initial program 98.2%
Taylor expanded in z around 0 78.6%
Final simplification83.9%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ z t) -4e+67) (not (<= (/ z t) 50000.0))) (* z (/ (- y x) t)) (+ x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -4e+67) || !((z / t) <= 50000.0)) {
tmp = z * ((y - x) / t);
} else {
tmp = x + (y * (z / t));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((z / t) <= (-4d+67)) .or. (.not. ((z / t) <= 50000.0d0))) then
tmp = z * ((y - x) / t)
else
tmp = x + (y * (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -4e+67) || !((z / t) <= 50000.0)) {
tmp = z * ((y - x) / t);
} else {
tmp = x + (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z / t) <= -4e+67) or not ((z / t) <= 50000.0): tmp = z * ((y - x) / t) else: tmp = x + (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z / t) <= -4e+67) || !(Float64(z / t) <= 50000.0)) tmp = Float64(z * Float64(Float64(y - x) / t)); else tmp = Float64(x + Float64(y * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z / t) <= -4e+67) || ~(((z / t) <= 50000.0))) tmp = z * ((y - x) / t); else tmp = x + (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z / t), $MachinePrecision], -4e+67], N[Not[LessEqual[N[(z / t), $MachinePrecision], 50000.0]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -4 \cdot 10^{+67} \lor \neg \left(\frac{z}{t} \leq 50000\right):\\
\;\;\;\;z \cdot \frac{y - x}{t}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if (/.f64 z t) < -3.99999999999999993e67 or 5e4 < (/.f64 z t) Initial program 96.5%
Taylor expanded in z around inf 90.1%
Taylor expanded in y around 0 90.1%
neg-mul-190.1%
+-commutative90.1%
sub-neg90.1%
div-sub94.7%
Simplified94.7%
if -3.99999999999999993e67 < (/.f64 z t) < 5e4Initial program 98.5%
Taylor expanded in y around inf 91.5%
associate-*r/94.8%
Simplified94.8%
Final simplification94.7%
(FPCore (x y z t) :precision binary64 (if (<= (/ z t) -400.0) (/ z (/ t (- y x))) (if (<= (/ z t) 50000.0) (+ x (* y (/ z t))) (* z (/ (- y x) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= -400.0) {
tmp = z / (t / (y - x));
} else if ((z / t) <= 50000.0) {
tmp = x + (y * (z / t));
} else {
tmp = z * ((y - x) / t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z / t) <= (-400.0d0)) then
tmp = z / (t / (y - x))
else if ((z / t) <= 50000.0d0) then
tmp = x + (y * (z / t))
else
tmp = z * ((y - x) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= -400.0) {
tmp = z / (t / (y - x));
} else if ((z / t) <= 50000.0) {
tmp = x + (y * (z / t));
} else {
tmp = z * ((y - x) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z / t) <= -400.0: tmp = z / (t / (y - x)) elif (z / t) <= 50000.0: tmp = x + (y * (z / t)) else: tmp = z * ((y - x) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z / t) <= -400.0) tmp = Float64(z / Float64(t / Float64(y - x))); elseif (Float64(z / t) <= 50000.0) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(z * Float64(Float64(y - x) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z / t) <= -400.0) tmp = z / (t / (y - x)); elseif ((z / t) <= 50000.0) tmp = x + (y * (z / t)); else tmp = z * ((y - x) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z / t), $MachinePrecision], -400.0], N[(z / N[(t / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 50000.0], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -400:\\
\;\;\;\;\frac{z}{\frac{t}{y - x}}\\
\mathbf{elif}\;\frac{z}{t} \leq 50000:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y - x}{t}\\
\end{array}
\end{array}
if (/.f64 z t) < -400Initial program 95.3%
Taylor expanded in z around inf 85.9%
Taylor expanded in y around 0 85.9%
neg-mul-185.9%
+-commutative85.9%
sub-neg85.9%
div-sub90.8%
Simplified90.8%
associate-*r/88.1%
associate-/l*93.5%
Applied egg-rr93.5%
if -400 < (/.f64 z t) < 5e4Initial program 98.4%
Taylor expanded in y around inf 95.1%
associate-*r/97.2%
Simplified97.2%
if 5e4 < (/.f64 z t) Initial program 98.4%
Taylor expanded in z around inf 89.0%
Taylor expanded in y around 0 89.0%
neg-mul-189.0%
+-commutative89.0%
sub-neg89.0%
div-sub92.2%
Simplified92.2%
Final simplification95.1%
(FPCore (x y z t) :precision binary64 (if (<= (/ z t) -400.0) (/ z (/ t (- y x))) (if (<= (/ z t) 0.4) (+ x (* y (/ z t))) (/ (- y x) (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= -400.0) {
tmp = z / (t / (y - x));
} else if ((z / t) <= 0.4) {
tmp = x + (y * (z / t));
} else {
tmp = (y - x) / (t / z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z / t) <= (-400.0d0)) then
tmp = z / (t / (y - x))
else if ((z / t) <= 0.4d0) then
tmp = x + (y * (z / t))
else
tmp = (y - x) / (t / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= -400.0) {
tmp = z / (t / (y - x));
} else if ((z / t) <= 0.4) {
tmp = x + (y * (z / t));
} else {
tmp = (y - x) / (t / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z / t) <= -400.0: tmp = z / (t / (y - x)) elif (z / t) <= 0.4: tmp = x + (y * (z / t)) else: tmp = (y - x) / (t / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z / t) <= -400.0) tmp = Float64(z / Float64(t / Float64(y - x))); elseif (Float64(z / t) <= 0.4) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(Float64(y - x) / Float64(t / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z / t) <= -400.0) tmp = z / (t / (y - x)); elseif ((z / t) <= 0.4) tmp = x + (y * (z / t)); else tmp = (y - x) / (t / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z / t), $MachinePrecision], -400.0], N[(z / N[(t / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 0.4], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -400:\\
\;\;\;\;\frac{z}{\frac{t}{y - x}}\\
\mathbf{elif}\;\frac{z}{t} \leq 0.4:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{\frac{t}{z}}\\
\end{array}
\end{array}
if (/.f64 z t) < -400Initial program 95.3%
Taylor expanded in z around inf 85.9%
Taylor expanded in y around 0 85.9%
neg-mul-185.9%
+-commutative85.9%
sub-neg85.9%
div-sub90.8%
Simplified90.8%
associate-*r/88.1%
associate-/l*93.5%
Applied egg-rr93.5%
if -400 < (/.f64 z t) < 0.40000000000000002Initial program 98.3%
Taylor expanded in y around inf 95.0%
associate-*r/97.2%
Simplified97.2%
if 0.40000000000000002 < (/.f64 z t) Initial program 98.5%
Taylor expanded in z around inf 87.7%
*-commutative87.7%
sub-div90.9%
associate-/r/98.0%
Applied egg-rr98.0%
Final simplification96.5%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ z t) -5e-50) (not (<= (/ z t) 1e-87))) (* y (/ z t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -5e-50) || !((z / t) <= 1e-87)) {
tmp = y * (z / t);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((z / t) <= (-5d-50)) .or. (.not. ((z / t) <= 1d-87))) then
tmp = y * (z / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -5e-50) || !((z / t) <= 1e-87)) {
tmp = y * (z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z / t) <= -5e-50) or not ((z / t) <= 1e-87): tmp = y * (z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z / t) <= -5e-50) || !(Float64(z / t) <= 1e-87)) tmp = Float64(y * Float64(z / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z / t) <= -5e-50) || ~(((z / t) <= 1e-87))) tmp = y * (z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z / t), $MachinePrecision], -5e-50], N[Not[LessEqual[N[(z / t), $MachinePrecision], 1e-87]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -5 \cdot 10^{-50} \lor \neg \left(\frac{z}{t} \leq 10^{-87}\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 z t) < -4.99999999999999968e-50 or 1.00000000000000002e-87 < (/.f64 z t) Initial program 97.4%
Taylor expanded in z around inf 79.7%
*-commutative79.7%
sub-div83.3%
associate-/r/89.9%
Applied egg-rr89.9%
Taylor expanded in y around inf 49.0%
associate-*r/54.8%
Simplified54.8%
if -4.99999999999999968e-50 < (/.f64 z t) < 1.00000000000000002e-87Initial program 98.0%
Taylor expanded in z around 0 82.0%
Final simplification66.3%
(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - x) * (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
def code(x, y, z, t): return x + ((y - x) * (z / t))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) * (z / t)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \frac{z}{t}
\end{array}
Initial program 97.6%
Final simplification97.6%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 97.6%
Taylor expanded in z around 0 39.4%
Final simplification39.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- y x) (/ z t))) (t_2 (+ x (/ (- y x) (/ t z)))))
(if (< t_1 -1013646692435.8867)
t_2
(if (< t_1 0.0) (+ x (/ (* (- y x) z) t)) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (y - x) * (z / t);
double t_2 = x + ((y - x) / (t / z));
double tmp;
if (t_1 < -1013646692435.8867) {
tmp = t_2;
} else if (t_1 < 0.0) {
tmp = x + (((y - x) * z) / t);
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y - x) * (z / t)
t_2 = x + ((y - x) / (t / z))
if (t_1 < (-1013646692435.8867d0)) then
tmp = t_2
else if (t_1 < 0.0d0) then
tmp = x + (((y - x) * z) / t)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (y - x) * (z / t);
double t_2 = x + ((y - x) / (t / z));
double tmp;
if (t_1 < -1013646692435.8867) {
tmp = t_2;
} else if (t_1 < 0.0) {
tmp = x + (((y - x) * z) / t);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (y - x) * (z / t) t_2 = x + ((y - x) / (t / z)) tmp = 0 if t_1 < -1013646692435.8867: tmp = t_2 elif t_1 < 0.0: tmp = x + (((y - x) * z) / t) else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y - x) * Float64(z / t)) t_2 = Float64(x + Float64(Float64(y - x) / Float64(t / z))) tmp = 0.0 if (t_1 < -1013646692435.8867) tmp = t_2; elseif (t_1 < 0.0) tmp = Float64(x + Float64(Float64(Float64(y - x) * z) / t)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (y - x) * (z / t); t_2 = x + ((y - x) / (t / z)); tmp = 0.0; if (t_1 < -1013646692435.8867) tmp = t_2; elseif (t_1 < 0.0) tmp = x + (((y - x) * z) / t); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, -1013646692435.8867], t$95$2, If[Less[t$95$1, 0.0], N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y - x\right) \cdot \frac{z}{t}\\
t_2 := x + \frac{y - x}{\frac{t}{z}}\\
\mathbf{if}\;t_1 < -1013646692435.8867:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 < 0:\\
\;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
herbie shell --seed 2023290
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
:precision binary64
:herbie-target
(if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) 0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))
(+ x (* (- y x) (/ z t))))