
(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 11 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 96.4%
clear-num96.3%
un-div-inv96.5%
Applied egg-rr96.5%
Final simplification96.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* y (/ z t)))))
(if (<= (/ z t) -2e+173)
(+ x (/ z (/ t y)))
(if (<= (/ z t) -5e+139)
(/ (* x z) (- t))
(if (<= (/ z t) 5e+36)
t_1
(if (<= (/ z t) 2e+81)
(* x (/ (- z) t))
(if (<= (/ z t) 2e+169) t_1 (* (/ x t) (- z)))))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (y * (z / t));
double tmp;
if ((z / t) <= -2e+173) {
tmp = x + (z / (t / y));
} else if ((z / t) <= -5e+139) {
tmp = (x * z) / -t;
} else if ((z / t) <= 5e+36) {
tmp = t_1;
} else if ((z / t) <= 2e+81) {
tmp = x * (-z / t);
} else if ((z / t) <= 2e+169) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = x + (y * (z / t))
if ((z / t) <= (-2d+173)) then
tmp = x + (z / (t / y))
else if ((z / t) <= (-5d+139)) then
tmp = (x * z) / -t
else if ((z / t) <= 5d+36) then
tmp = t_1
else if ((z / t) <= 2d+81) then
tmp = x * (-z / t)
else if ((z / t) <= 2d+169) then
tmp = t_1
else
tmp = (x / t) * -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (y * (z / t));
double tmp;
if ((z / t) <= -2e+173) {
tmp = x + (z / (t / y));
} else if ((z / t) <= -5e+139) {
tmp = (x * z) / -t;
} else if ((z / t) <= 5e+36) {
tmp = t_1;
} else if ((z / t) <= 2e+81) {
tmp = x * (-z / t);
} else if ((z / t) <= 2e+169) {
tmp = t_1;
} else {
tmp = (x / t) * -z;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (y * (z / t)) tmp = 0 if (z / t) <= -2e+173: tmp = x + (z / (t / y)) elif (z / t) <= -5e+139: tmp = (x * z) / -t elif (z / t) <= 5e+36: tmp = t_1 elif (z / t) <= 2e+81: tmp = x * (-z / t) elif (z / t) <= 2e+169: tmp = t_1 else: tmp = (x / t) * -z return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(y * Float64(z / t))) tmp = 0.0 if (Float64(z / t) <= -2e+173) tmp = Float64(x + Float64(z / Float64(t / y))); elseif (Float64(z / t) <= -5e+139) tmp = Float64(Float64(x * z) / Float64(-t)); elseif (Float64(z / t) <= 5e+36) tmp = t_1; elseif (Float64(z / t) <= 2e+81) tmp = Float64(x * Float64(Float64(-z) / t)); elseif (Float64(z / t) <= 2e+169) tmp = t_1; else tmp = Float64(Float64(x / t) * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (y * (z / t)); tmp = 0.0; if ((z / t) <= -2e+173) tmp = x + (z / (t / y)); elseif ((z / t) <= -5e+139) tmp = (x * z) / -t; elseif ((z / t) <= 5e+36) tmp = t_1; elseif ((z / t) <= 2e+81) tmp = x * (-z / t); elseif ((z / t) <= 2e+169) tmp = t_1; else tmp = (x / t) * -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z / t), $MachinePrecision], -2e+173], N[(x + N[(z / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], -5e+139], N[(N[(x * z), $MachinePrecision] / (-t)), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 5e+36], t$95$1, If[LessEqual[N[(z / t), $MachinePrecision], 2e+81], N[(x * N[((-z) / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 2e+169], t$95$1, N[(N[(x / t), $MachinePrecision] * (-z)), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + y \cdot \frac{z}{t}\\
\mathbf{if}\;\frac{z}{t} \leq -2 \cdot 10^{+173}:\\
\;\;\;\;x + \frac{z}{\frac{t}{y}}\\
\mathbf{elif}\;\frac{z}{t} \leq -5 \cdot 10^{+139}:\\
\;\;\;\;\frac{x \cdot z}{-t}\\
\mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{+36}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+81}:\\
\;\;\;\;x \cdot \frac{-z}{t}\\
\mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+169}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t} \cdot \left(-z\right)\\
\end{array}
\end{array}
if (/.f64 z t) < -2e173Initial program 83.1%
Taylor expanded in y around inf 77.6%
associate-*r/64.9%
Simplified64.9%
associate-*r/77.6%
*-commutative77.6%
associate-/l*77.6%
Applied egg-rr77.6%
if -2e173 < (/.f64 z t) < -5.0000000000000003e139Initial program 100.0%
Taylor expanded in x around inf 86.0%
+-commutative86.0%
distribute-rgt1-in86.0%
mul-1-neg86.0%
cancel-sign-sub-inv86.0%
associate-*l/86.1%
associate-/l*86.0%
Simplified86.0%
clear-num85.7%
associate-/r/86.0%
clear-num86.0%
Applied egg-rr86.0%
Taylor expanded in t around 0 86.1%
associate-*r/86.1%
neg-mul-186.1%
distribute-rgt-neg-in86.1%
associate-*r/86.0%
Simplified86.0%
frac-2neg86.0%
remove-double-neg86.0%
associate-*r/86.1%
Applied egg-rr86.1%
if -5.0000000000000003e139 < (/.f64 z t) < 4.99999999999999977e36 or 1.99999999999999984e81 < (/.f64 z t) < 1.99999999999999987e169Initial program 99.0%
Taylor expanded in y around inf 84.9%
associate-*r/89.0%
Simplified89.0%
if 4.99999999999999977e36 < (/.f64 z t) < 1.99999999999999984e81Initial program 99.9%
Taylor expanded in x around inf 75.0%
+-commutative75.0%
distribute-rgt1-in75.0%
mul-1-neg75.0%
cancel-sign-sub-inv75.0%
associate-*l/67.4%
associate-/l*66.6%
Simplified66.6%
clear-num66.9%
associate-/r/66.6%
clear-num66.8%
Applied egg-rr66.8%
Taylor expanded in t around 0 67.4%
associate-*r/67.4%
neg-mul-167.4%
distribute-rgt-neg-in67.4%
associate-*r/66.9%
Simplified66.9%
Taylor expanded in z around 0 67.4%
mul-1-neg67.4%
associate-*l/75.0%
*-commutative75.0%
distribute-rgt-neg-in75.0%
distribute-neg-frac75.0%
Simplified75.0%
if 1.99999999999999987e169 < (/.f64 z t) Initial program 86.7%
Taylor expanded in x around inf 62.1%
+-commutative62.1%
distribute-rgt1-in62.1%
mul-1-neg62.1%
cancel-sign-sub-inv62.1%
associate-*l/71.8%
associate-/l*75.2%
Simplified75.2%
clear-num75.1%
associate-/r/75.2%
clear-num75.2%
Applied egg-rr75.2%
Taylor expanded in t around 0 71.8%
associate-*r/71.8%
neg-mul-171.8%
distribute-rgt-neg-in71.8%
associate-*r/75.2%
Simplified75.2%
Final simplification85.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* y (/ z t)))))
(if (<= (/ z t) 5e+36)
t_1
(if (<= (/ z t) 2e+81)
(* x (/ (- z) t))
(if (<= (/ z t) 2e+169) t_1 (* (/ x t) (- z)))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (y * (z / t));
double tmp;
if ((z / t) <= 5e+36) {
tmp = t_1;
} else if ((z / t) <= 2e+81) {
tmp = x * (-z / t);
} else if ((z / t) <= 2e+169) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = x + (y * (z / t))
if ((z / t) <= 5d+36) then
tmp = t_1
else if ((z / t) <= 2d+81) then
tmp = x * (-z / t)
else if ((z / t) <= 2d+169) then
tmp = t_1
else
tmp = (x / t) * -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (y * (z / t));
double tmp;
if ((z / t) <= 5e+36) {
tmp = t_1;
} else if ((z / t) <= 2e+81) {
tmp = x * (-z / t);
} else if ((z / t) <= 2e+169) {
tmp = t_1;
} else {
tmp = (x / t) * -z;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (y * (z / t)) tmp = 0 if (z / t) <= 5e+36: tmp = t_1 elif (z / t) <= 2e+81: tmp = x * (-z / t) elif (z / t) <= 2e+169: tmp = t_1 else: tmp = (x / t) * -z return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(y * Float64(z / t))) tmp = 0.0 if (Float64(z / t) <= 5e+36) tmp = t_1; elseif (Float64(z / t) <= 2e+81) tmp = Float64(x * Float64(Float64(-z) / t)); elseif (Float64(z / t) <= 2e+169) tmp = t_1; else tmp = Float64(Float64(x / t) * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (y * (z / t)); tmp = 0.0; if ((z / t) <= 5e+36) tmp = t_1; elseif ((z / t) <= 2e+81) tmp = x * (-z / t); elseif ((z / t) <= 2e+169) tmp = t_1; else tmp = (x / t) * -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z / t), $MachinePrecision], 5e+36], t$95$1, If[LessEqual[N[(z / t), $MachinePrecision], 2e+81], N[(x * N[((-z) / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 2e+169], t$95$1, N[(N[(x / t), $MachinePrecision] * (-z)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + y \cdot \frac{z}{t}\\
\mathbf{if}\;\frac{z}{t} \leq 5 \cdot 10^{+36}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+81}:\\
\;\;\;\;x \cdot \frac{-z}{t}\\
\mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+169}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t} \cdot \left(-z\right)\\
\end{array}
\end{array}
if (/.f64 z t) < 4.99999999999999977e36 or 1.99999999999999984e81 < (/.f64 z t) < 1.99999999999999987e169Initial program 97.4%
Taylor expanded in y around inf 82.0%
associate-*r/84.3%
Simplified84.3%
if 4.99999999999999977e36 < (/.f64 z t) < 1.99999999999999984e81Initial program 99.9%
Taylor expanded in x around inf 75.0%
+-commutative75.0%
distribute-rgt1-in75.0%
mul-1-neg75.0%
cancel-sign-sub-inv75.0%
associate-*l/67.4%
associate-/l*66.6%
Simplified66.6%
clear-num66.9%
associate-/r/66.6%
clear-num66.8%
Applied egg-rr66.8%
Taylor expanded in t around 0 67.4%
associate-*r/67.4%
neg-mul-167.4%
distribute-rgt-neg-in67.4%
associate-*r/66.9%
Simplified66.9%
Taylor expanded in z around 0 67.4%
mul-1-neg67.4%
associate-*l/75.0%
*-commutative75.0%
distribute-rgt-neg-in75.0%
distribute-neg-frac75.0%
Simplified75.0%
if 1.99999999999999987e169 < (/.f64 z t) Initial program 86.7%
Taylor expanded in x around inf 62.1%
+-commutative62.1%
distribute-rgt1-in62.1%
mul-1-neg62.1%
cancel-sign-sub-inv62.1%
associate-*l/71.8%
associate-/l*75.2%
Simplified75.2%
clear-num75.1%
associate-/r/75.2%
clear-num75.2%
Applied egg-rr75.2%
Taylor expanded in t around 0 71.8%
associate-*r/71.8%
neg-mul-171.8%
distribute-rgt-neg-in71.8%
associate-*r/75.2%
Simplified75.2%
Final simplification82.9%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ z t) -50000000000000.0) (not (<= (/ z t) 1e-9))) (* z (- (/ y t) (/ x t))) (+ x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -50000000000000.0) || !((z / t) <= 1e-9)) {
tmp = z * ((y / t) - (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) <= (-50000000000000.0d0)) .or. (.not. ((z / t) <= 1d-9))) then
tmp = z * ((y / t) - (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) <= -50000000000000.0) || !((z / t) <= 1e-9)) {
tmp = z * ((y / t) - (x / t));
} else {
tmp = x + (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z / t) <= -50000000000000.0) or not ((z / t) <= 1e-9): tmp = z * ((y / t) - (x / t)) else: tmp = x + (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z / t) <= -50000000000000.0) || !(Float64(z / t) <= 1e-9)) tmp = Float64(z * Float64(Float64(y / t) - Float64(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) <= -50000000000000.0) || ~(((z / t) <= 1e-9))) tmp = z * ((y / t) - (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], -50000000000000.0], N[Not[LessEqual[N[(z / t), $MachinePrecision], 1e-9]], $MachinePrecision]], N[(z * N[(N[(y / t), $MachinePrecision] - N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -50000000000000 \lor \neg \left(\frac{z}{t} \leq 10^{-9}\right):\\
\;\;\;\;z \cdot \left(\frac{y}{t} - \frac{x}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if (/.f64 z t) < -5e13 or 1.00000000000000006e-9 < (/.f64 z t) Initial program 93.8%
Taylor expanded in z around inf 89.8%
if -5e13 < (/.f64 z t) < 1.00000000000000006e-9Initial program 98.7%
Taylor expanded in y around inf 95.4%
associate-*r/97.0%
Simplified97.0%
Final simplification93.6%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ z t) -2000000000000.0) (not (<= (/ z t) 10000000.0))) (* x (/ (- z) t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (((z / t) <= -2000000000000.0) || !((z / t) <= 10000000.0)) {
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) <= (-2000000000000.0d0)) .or. (.not. ((z / t) <= 10000000.0d0))) 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) <= -2000000000000.0) || !((z / t) <= 10000000.0)) {
tmp = x * (-z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z / t) <= -2000000000000.0) or not ((z / t) <= 10000000.0): tmp = x * (-z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z / t) <= -2000000000000.0) || !(Float64(z / t) <= 10000000.0)) 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) <= -2000000000000.0) || ~(((z / t) <= 10000000.0))) tmp = x * (-z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z / t), $MachinePrecision], -2000000000000.0], N[Not[LessEqual[N[(z / t), $MachinePrecision], 10000000.0]], $MachinePrecision]], N[(x * N[((-z) / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -2000000000000 \lor \neg \left(\frac{z}{t} \leq 10000000\right):\\
\;\;\;\;x \cdot \frac{-z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 z t) < -2e12 or 1e7 < (/.f64 z t) Initial program 93.7%
Taylor expanded in x around inf 52.8%
+-commutative52.8%
distribute-rgt1-in52.8%
mul-1-neg52.8%
cancel-sign-sub-inv52.8%
associate-*l/51.9%
associate-/l*52.6%
Simplified52.6%
clear-num52.6%
associate-/r/52.6%
clear-num52.6%
Applied egg-rr52.6%
Taylor expanded in t around 0 51.2%
associate-*r/51.2%
neg-mul-151.2%
distribute-rgt-neg-in51.2%
associate-*r/52.0%
Simplified52.0%
Taylor expanded in z around 0 51.2%
mul-1-neg51.2%
associate-*l/52.1%
*-commutative52.1%
distribute-rgt-neg-in52.1%
distribute-neg-frac52.1%
Simplified52.1%
if -2e12 < (/.f64 z t) < 1e7Initial program 98.7%
Taylor expanded in z around 0 72.3%
Final simplification62.8%
(FPCore (x y z t) :precision binary64 (if (<= (/ z t) -2000000000000.0) (* x (/ (- z) t)) (if (<= (/ z t) 10000000.0) x (* (/ x t) (- z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= -2000000000000.0) {
tmp = x * (-z / t);
} else if ((z / t) <= 10000000.0) {
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) <= (-2000000000000.0d0)) then
tmp = x * (-z / t)
else if ((z / t) <= 10000000.0d0) 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) <= -2000000000000.0) {
tmp = x * (-z / t);
} else if ((z / t) <= 10000000.0) {
tmp = x;
} else {
tmp = (x / t) * -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z / t) <= -2000000000000.0: tmp = x * (-z / t) elif (z / t) <= 10000000.0: tmp = x else: tmp = (x / t) * -z return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z / t) <= -2000000000000.0) tmp = Float64(x * Float64(Float64(-z) / t)); elseif (Float64(z / t) <= 10000000.0) tmp = x; else tmp = Float64(Float64(x / t) * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z / t) <= -2000000000000.0) tmp = x * (-z / t); elseif ((z / t) <= 10000000.0) tmp = x; else tmp = (x / t) * -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z / t), $MachinePrecision], -2000000000000.0], N[(x * N[((-z) / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 10000000.0], x, N[(N[(x / t), $MachinePrecision] * (-z)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -2000000000000:\\
\;\;\;\;x \cdot \frac{-z}{t}\\
\mathbf{elif}\;\frac{z}{t} \leq 10000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t} \cdot \left(-z\right)\\
\end{array}
\end{array}
if (/.f64 z t) < -2e12Initial program 93.3%
Taylor expanded in x around inf 52.5%
+-commutative52.5%
distribute-rgt1-in52.5%
mul-1-neg52.5%
cancel-sign-sub-inv52.5%
associate-*l/47.4%
associate-/l*47.4%
Simplified47.4%
clear-num47.4%
associate-/r/47.4%
clear-num47.4%
Applied egg-rr47.4%
Taylor expanded in t around 0 47.0%
associate-*r/47.0%
neg-mul-147.0%
distribute-rgt-neg-in47.0%
associate-*r/47.1%
Simplified47.1%
Taylor expanded in z around 0 47.0%
mul-1-neg47.0%
associate-*l/52.1%
*-commutative52.1%
distribute-rgt-neg-in52.1%
distribute-neg-frac52.1%
Simplified52.1%
if -2e12 < (/.f64 z t) < 1e7Initial program 98.7%
Taylor expanded in z around 0 72.3%
if 1e7 < (/.f64 z t) Initial program 94.0%
Taylor expanded in x around inf 53.0%
+-commutative53.0%
distribute-rgt1-in53.0%
mul-1-neg53.0%
cancel-sign-sub-inv53.0%
associate-*l/55.9%
associate-/l*57.2%
Simplified57.2%
clear-num57.1%
associate-/r/57.1%
clear-num57.2%
Applied egg-rr57.2%
Taylor expanded in t around 0 55.0%
associate-*r/55.0%
neg-mul-155.0%
distribute-rgt-neg-in55.0%
associate-*r/56.3%
Simplified56.3%
Final simplification63.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.2e+36) (not (<= y 7e-140))) (+ x (* y (/ z t))) (- x (* x (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.2e+36) || !(y <= 7e-140)) {
tmp = x + (y * (z / t));
} 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 ((y <= (-3.2d+36)) .or. (.not. (y <= 7d-140))) then
tmp = x + (y * (z / t))
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 ((y <= -3.2e+36) || !(y <= 7e-140)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (x * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.2e+36) or not (y <= 7e-140): tmp = x + (y * (z / t)) else: tmp = x - (x * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.2e+36) || !(y <= 7e-140)) tmp = Float64(x + Float64(y * Float64(z / t))); 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 ((y <= -3.2e+36) || ~((y <= 7e-140))) tmp = x + (y * (z / t)); else tmp = x - (x * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.2e+36], N[Not[LessEqual[y, 7e-140]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+36} \lor \neg \left(y \leq 7 \cdot 10^{-140}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \frac{z}{t}\\
\end{array}
\end{array}
if y < -3.1999999999999999e36 or 6.9999999999999996e-140 < y Initial program 98.8%
Taylor expanded in y around inf 83.8%
associate-*r/89.6%
Simplified89.6%
if -3.1999999999999999e36 < y < 6.9999999999999996e-140Initial program 92.9%
Taylor expanded in x around inf 83.5%
*-commutative83.5%
mul-1-neg83.5%
unsub-neg83.5%
distribute-lft-out--83.5%
*-rgt-identity83.5%
Simplified83.5%
Final simplification87.1%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.36e+38) (not (<= y 5.1e-142))) (+ x (* y (/ z t))) (- x (* z (/ x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.36e+38) || !(y <= 5.1e-142)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (z * (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 ((y <= (-1.36d+38)) .or. (.not. (y <= 5.1d-142))) then
tmp = x + (y * (z / t))
else
tmp = x - (z * (x / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.36e+38) || !(y <= 5.1e-142)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (z * (x / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.36e+38) or not (y <= 5.1e-142): tmp = x + (y * (z / t)) else: tmp = x - (z * (x / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.36e+38) || !(y <= 5.1e-142)) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(x - Float64(z * Float64(x / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.36e+38) || ~((y <= 5.1e-142))) tmp = x + (y * (z / t)); else tmp = x - (z * (x / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.36e+38], N[Not[LessEqual[y, 5.1e-142]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.36 \cdot 10^{+38} \lor \neg \left(y \leq 5.1 \cdot 10^{-142}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{x}{t}\\
\end{array}
\end{array}
if y < -1.36000000000000002e38 or 5.1000000000000001e-142 < y Initial program 98.8%
Taylor expanded in y around inf 83.8%
associate-*r/89.6%
Simplified89.6%
if -1.36000000000000002e38 < y < 5.1000000000000001e-142Initial program 92.9%
Taylor expanded in x around inf 83.5%
+-commutative83.5%
distribute-rgt1-in83.5%
mul-1-neg83.5%
cancel-sign-sub-inv83.5%
associate-*l/85.2%
associate-/l*86.2%
Simplified86.2%
clear-num86.2%
associate-/r/85.2%
clear-num85.3%
Applied egg-rr85.3%
Final simplification87.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -3.1e+36) (not (<= y 1.55e-140))) (+ x (* y (/ z t))) (- x (/ z (/ t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.1e+36) || !(y <= 1.55e-140)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (z / (t / 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 ((y <= (-3.1d+36)) .or. (.not. (y <= 1.55d-140))) then
tmp = x + (y * (z / t))
else
tmp = x - (z / (t / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.1e+36) || !(y <= 1.55e-140)) {
tmp = x + (y * (z / t));
} else {
tmp = x - (z / (t / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -3.1e+36) or not (y <= 1.55e-140): tmp = x + (y * (z / t)) else: tmp = x - (z / (t / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -3.1e+36) || !(y <= 1.55e-140)) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(x - Float64(z / Float64(t / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -3.1e+36) || ~((y <= 1.55e-140))) tmp = x + (y * (z / t)); else tmp = x - (z / (t / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.1e+36], N[Not[LessEqual[y, 1.55e-140]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z / N[(t / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+36} \lor \neg \left(y \leq 1.55 \cdot 10^{-140}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z}{\frac{t}{x}}\\
\end{array}
\end{array}
if y < -3.0999999999999999e36 or 1.55e-140 < y Initial program 98.8%
Taylor expanded in y around inf 83.8%
associate-*r/89.6%
Simplified89.6%
if -3.0999999999999999e36 < y < 1.55e-140Initial program 92.9%
Taylor expanded in x around inf 83.5%
+-commutative83.5%
distribute-rgt1-in83.5%
mul-1-neg83.5%
cancel-sign-sub-inv83.5%
associate-*l/85.2%
associate-/l*86.2%
Simplified86.2%
Final simplification88.2%
(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 96.4%
Final simplification96.4%
(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 96.4%
Taylor expanded in z around 0 39.6%
Final simplification39.6%
(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 2023185
(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))))