
(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 10 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 (+ x (/ (- y x) (/ t z))))
double code(double x, double y, double z, double t) {
return x + ((y - x) / (t / z));
}
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) / (t / z))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) / (t / z));
}
def code(x, y, z, t): return x + ((y - x) / (t / z))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) / Float64(t / z))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) / (t / z)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y - x}{\frac{t}{z}}
\end{array}
Initial program 98.1%
clear-num98.0%
un-div-inv98.2%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ z t) -200.0) (not (<= (/ z t) 0.5))) (* x (/ (- z) t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -200.0) || !((z / t) <= 0.5)) {
tmp = x * (-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) <= (-200.0d0)) .or. (.not. ((z / t) <= 0.5d0))) then
tmp = x * (-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) <= -200.0) || !((z / t) <= 0.5)) {
tmp = x * (-z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z / t) <= -200.0) or not ((z / t) <= 0.5): tmp = x * (-z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z / t) <= -200.0) || !(Float64(z / t) <= 0.5)) tmp = Float64(x * Float64(Float64(-z) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z / t) <= -200.0) || ~(((z / t) <= 0.5))) tmp = x * (-z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z / t), $MachinePrecision], -200.0], N[Not[LessEqual[N[(z / t), $MachinePrecision], 0.5]], $MachinePrecision]], N[(x * N[((-z) / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -200 \lor \neg \left(\frac{z}{t} \leq 0.5\right):\\
\;\;\;\;x \cdot \frac{-z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 z t) < -200 or 0.5 < (/.f64 z t) Initial program 96.1%
Taylor expanded in x around inf 48.1%
*-commutative48.1%
associate-*r/48.1%
neg-mul-148.1%
Simplified48.1%
Taylor expanded in z around inf 44.9%
mul-1-neg44.9%
distribute-neg-frac44.9%
Simplified44.9%
if -200 < (/.f64 z t) < 0.5Initial program 99.9%
Taylor expanded in z around 0 79.3%
Final simplification62.5%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ z t) -1.5e+218) (not (<= (/ z t) 4.6e+176))) (* x (/ z t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -1.5e+218) || !((z / t) <= 4.6e+176)) {
tmp = x * (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) <= (-1.5d+218)) .or. (.not. ((z / t) <= 4.6d+176))) then
tmp = x * (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) <= -1.5e+218) || !((z / t) <= 4.6e+176)) {
tmp = x * (z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z / t) <= -1.5e+218) or not ((z / t) <= 4.6e+176): tmp = x * (z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z / t) <= -1.5e+218) || !(Float64(z / t) <= 4.6e+176)) tmp = Float64(x * Float64(z / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z / t) <= -1.5e+218) || ~(((z / t) <= 4.6e+176))) tmp = x * (z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z / t), $MachinePrecision], -1.5e+218], N[Not[LessEqual[N[(z / t), $MachinePrecision], 4.6e+176]], $MachinePrecision]], N[(x * N[(z / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -1.5 \cdot 10^{+218} \lor \neg \left(\frac{z}{t} \leq 4.6 \cdot 10^{+176}\right):\\
\;\;\;\;x \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 z t) < -1.5e218 or 4.59999999999999992e176 < (/.f64 z t) Initial program 91.1%
Taylor expanded in x around inf 47.1%
*-commutative47.1%
associate-*r/47.1%
neg-mul-147.1%
Simplified47.1%
Taylor expanded in z around inf 47.1%
mul-1-neg47.1%
distribute-neg-frac47.1%
Simplified47.1%
associate-*r/41.8%
add-sqr-sqrt27.9%
sqrt-unprod30.8%
sqr-neg30.8%
sqrt-unprod2.7%
add-sqr-sqrt13.2%
associate-/l*18.8%
Applied egg-rr18.8%
clear-num18.8%
associate-/r/20.6%
clear-num20.6%
Applied egg-rr20.6%
if -1.5e218 < (/.f64 z t) < 4.59999999999999992e176Initial program 99.8%
Taylor expanded in z around 0 52.0%
Final simplification45.6%
(FPCore (x y z t) :precision binary64 (if (<= (/ z t) -5e+220) (* x (/ z t)) (if (<= (/ z t) 2e+176) x (/ x (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= -5e+220) {
tmp = x * (z / t);
} else if ((z / t) <= 2e+176) {
tmp = x;
} else {
tmp = 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) <= (-5d+220)) then
tmp = x * (z / t)
else if ((z / t) <= 2d+176) then
tmp = x
else
tmp = 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) <= -5e+220) {
tmp = x * (z / t);
} else if ((z / t) <= 2e+176) {
tmp = x;
} else {
tmp = x / (t / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z / t) <= -5e+220: tmp = x * (z / t) elif (z / t) <= 2e+176: tmp = x else: tmp = x / (t / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z / t) <= -5e+220) tmp = Float64(x * Float64(z / t)); elseif (Float64(z / t) <= 2e+176) tmp = x; else tmp = Float64(x / Float64(t / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z / t) <= -5e+220) tmp = x * (z / t); elseif ((z / t) <= 2e+176) tmp = x; else tmp = x / (t / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z / t), $MachinePrecision], -5e+220], N[(x * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 2e+176], x, N[(x / N[(t / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -5 \cdot 10^{+220}:\\
\;\;\;\;x \cdot \frac{z}{t}\\
\mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+176}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{t}{z}}\\
\end{array}
\end{array}
if (/.f64 z t) < -5.0000000000000002e220Initial program 92.6%
Taylor expanded in x around inf 59.0%
*-commutative59.0%
associate-*r/59.0%
neg-mul-159.0%
Simplified59.0%
Taylor expanded in z around inf 59.0%
mul-1-neg59.0%
distribute-neg-frac59.0%
Simplified59.0%
associate-*r/55.1%
add-sqr-sqrt33.7%
sqrt-unprod42.9%
sqr-neg42.9%
sqrt-unprod4.8%
add-sqr-sqrt13.8%
associate-/l*21.8%
Applied egg-rr21.8%
clear-num21.8%
associate-/r/25.6%
clear-num25.6%
Applied egg-rr25.6%
if -5.0000000000000002e220 < (/.f64 z t) < 2e176Initial program 99.8%
Taylor expanded in z around 0 52.0%
if 2e176 < (/.f64 z t) Initial program 89.9%
Taylor expanded in x around inf 36.8%
*-commutative36.8%
associate-*r/36.8%
neg-mul-136.8%
Simplified36.8%
Taylor expanded in z around inf 36.8%
mul-1-neg36.8%
distribute-neg-frac36.8%
Simplified36.8%
associate-*r/30.4%
add-sqr-sqrt22.9%
sqrt-unprod20.3%
sqr-neg20.3%
sqrt-unprod0.9%
add-sqr-sqrt12.6%
associate-/l*16.3%
Applied egg-rr16.3%
Final simplification45.6%
(FPCore (x y z t) :precision binary64 (if (or (<= x -4.8e+27) (not (<= x 2e-28))) (* x (- 1.0 (/ z t))) (+ x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.8e+27) || !(x <= 2e-28)) {
tmp = x * (1.0 - (z / 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 ((x <= (-4.8d+27)) .or. (.not. (x <= 2d-28))) then
tmp = x * (1.0d0 - (z / 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 ((x <= -4.8e+27) || !(x <= 2e-28)) {
tmp = x * (1.0 - (z / t));
} else {
tmp = x + (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -4.8e+27) or not (x <= 2e-28): tmp = x * (1.0 - (z / t)) else: tmp = x + (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -4.8e+27) || !(x <= 2e-28)) tmp = Float64(x * Float64(1.0 - Float64(z / 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 ((x <= -4.8e+27) || ~((x <= 2e-28))) tmp = x * (1.0 - (z / t)); else tmp = x + (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4.8e+27], N[Not[LessEqual[x, 2e-28]], $MachinePrecision]], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+27} \lor \neg \left(x \leq 2 \cdot 10^{-28}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if x < -4.79999999999999995e27 or 1.99999999999999994e-28 < x Initial program 99.9%
Taylor expanded in x around inf 91.3%
*-commutative91.3%
mul-1-neg91.3%
unsub-neg91.3%
distribute-lft-out--91.4%
*-rgt-identity91.4%
Simplified91.4%
Taylor expanded in x around 0 91.3%
if -4.79999999999999995e27 < x < 1.99999999999999994e-28Initial program 96.6%
Taylor expanded in y around inf 86.8%
associate-*r/88.9%
Simplified88.9%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.9e+28) (not (<= x 3.7e-28))) (* x (- 1.0 (/ z t))) (+ x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.9e+28) || !(x <= 3.7e-28)) {
tmp = x * (1.0 - (z / t));
} else {
tmp = x + (y / (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 ((x <= (-1.9d+28)) .or. (.not. (x <= 3.7d-28))) then
tmp = x * (1.0d0 - (z / t))
else
tmp = x + (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.9e+28) || !(x <= 3.7e-28)) {
tmp = x * (1.0 - (z / t));
} else {
tmp = x + (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.9e+28) or not (x <= 3.7e-28): tmp = x * (1.0 - (z / t)) else: tmp = x + (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.9e+28) || !(x <= 3.7e-28)) tmp = Float64(x * Float64(1.0 - Float64(z / t))); else tmp = Float64(x + Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.9e+28) || ~((x <= 3.7e-28))) tmp = x * (1.0 - (z / t)); else tmp = x + (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.9e+28], N[Not[LessEqual[x, 3.7e-28]], $MachinePrecision]], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+28} \lor \neg \left(x \leq 3.7 \cdot 10^{-28}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if x < -1.8999999999999999e28 or 3.7000000000000002e-28 < x Initial program 99.9%
Taylor expanded in x around inf 91.3%
*-commutative91.3%
mul-1-neg91.3%
unsub-neg91.3%
distribute-lft-out--91.4%
*-rgt-identity91.4%
Simplified91.4%
Taylor expanded in x around 0 91.3%
if -1.8999999999999999e28 < x < 3.7000000000000002e-28Initial program 96.6%
clear-num96.5%
un-div-inv96.8%
Applied egg-rr96.8%
Taylor expanded in y around inf 86.8%
associate-/l*89.1%
Simplified89.1%
Final simplification90.1%
(FPCore (x y z t) :precision binary64 (if (<= x -5.6e+29) (* x (- 1.0 (/ z t))) (if (<= x 1.75e-28) (+ x (/ y (/ t z))) (- x (* x (/ z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -5.6e+29) {
tmp = x * (1.0 - (z / t));
} else if (x <= 1.75e-28) {
tmp = x + (y / (t / z));
} else {
tmp = x - (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) :: tmp
if (x <= (-5.6d+29)) then
tmp = x * (1.0d0 - (z / t))
else if (x <= 1.75d-28) then
tmp = x + (y / (t / z))
else
tmp = x - (x * (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -5.6e+29) {
tmp = x * (1.0 - (z / t));
} else if (x <= 1.75e-28) {
tmp = x + (y / (t / z));
} else {
tmp = x - (x * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -5.6e+29: tmp = x * (1.0 - (z / t)) elif x <= 1.75e-28: tmp = x + (y / (t / z)) else: tmp = x - (x * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -5.6e+29) tmp = Float64(x * Float64(1.0 - Float64(z / t))); elseif (x <= 1.75e-28) tmp = Float64(x + Float64(y / Float64(t / z))); else tmp = Float64(x - Float64(x * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -5.6e+29) tmp = x * (1.0 - (z / t)); elseif (x <= 1.75e-28) tmp = x + (y / (t / z)); else tmp = x - (x * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -5.6e+29], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.75e-28], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{+29}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-28}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \frac{z}{t}\\
\end{array}
\end{array}
if x < -5.5999999999999999e29Initial program 99.9%
Taylor expanded in x around inf 90.6%
*-commutative90.6%
mul-1-neg90.6%
unsub-neg90.6%
distribute-lft-out--90.5%
*-rgt-identity90.5%
Simplified90.5%
Taylor expanded in x around 0 90.6%
if -5.5999999999999999e29 < x < 1.75e-28Initial program 96.6%
clear-num96.5%
un-div-inv96.8%
Applied egg-rr96.8%
Taylor expanded in y around inf 86.8%
associate-/l*89.1%
Simplified89.1%
if 1.75e-28 < x Initial program 99.9%
Taylor expanded in x around inf 92.3%
*-commutative92.3%
mul-1-neg92.3%
unsub-neg92.3%
distribute-lft-out--92.3%
*-rgt-identity92.3%
Simplified92.3%
Final simplification90.1%
(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 98.1%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (* x (- 1.0 (/ z t))))
double code(double x, double y, double z, double t) {
return x * (1.0 - (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 * (1.0d0 - (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x * (1.0 - (z / t));
}
def code(x, y, z, t): return x * (1.0 - (z / t))
function code(x, y, z, t) return Float64(x * Float64(1.0 - Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x * (1.0 - (z / t)); end
code[x_, y_, z_, t_] := N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \frac{z}{t}\right)
\end{array}
Initial program 98.1%
Taylor expanded in x around inf 65.2%
*-commutative65.2%
mul-1-neg65.2%
unsub-neg65.2%
distribute-lft-out--65.2%
*-rgt-identity65.2%
Simplified65.2%
Taylor expanded in x around 0 65.2%
Final simplification65.2%
(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 98.1%
Taylor expanded in z around 0 42.1%
Final simplification42.1%
(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 2023257
(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))))