100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}\begin{array}{l}
\mathbf{if}\;i \le -8.271685620893127920309681666849172655568 \cdot 10^{-30}:\\
\;\;\;\;\left(100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{i}\right) \cdot n\\
\mathbf{elif}\;i \le -1.07124828629959371703623408587100365571 \cdot 10^{-106}:\\
\;\;\;\;\frac{100 \cdot \left(\left({\left(\log 1 \cdot n + 1 \cdot i\right)}^{3} + {\left(0.5 \cdot \left(i \cdot i - \log 1 \cdot \left(i \cdot i\right)\right)\right)}^{3}\right) \cdot n\right)}{\left(\left(0.5 \cdot \left(i \cdot i - \log 1 \cdot \left(i \cdot i\right)\right)\right) \cdot \left(0.5 \cdot \left(i \cdot i - \log 1 \cdot \left(i \cdot i\right)\right) - \left(\log 1 \cdot n + 1 \cdot i\right)\right) + \left(\log 1 \cdot n + 1 \cdot i\right) \cdot \left(\log 1 \cdot n + 1 \cdot i\right)\right) \cdot i}\\
\mathbf{elif}\;i \le 1.666826687406822778561223565520064088172 \cdot 10^{-69}:\\
\;\;\;\;100 \cdot \left(\frac{\left(\log 1 \cdot n + 1 \cdot i\right) + \log \left(e^{0.5 \cdot \left(i \cdot i - \log 1 \cdot \left(i \cdot i\right)\right)}\right)}{i} \cdot n\right)\\
\mathbf{elif}\;i \le 176217786659469.75:\\
\;\;\;\;\frac{100 \cdot \left(\left({\left(\log 1 \cdot n + 1 \cdot i\right)}^{3} + {\left(0.5 \cdot \left(i \cdot i - \log 1 \cdot \left(i \cdot i\right)\right)\right)}^{3}\right) \cdot n\right)}{\left(\left(0.5 \cdot \left(i \cdot i - \log 1 \cdot \left(i \cdot i\right)\right)\right) \cdot \left(0.5 \cdot \left(i \cdot i - \log 1 \cdot \left(i \cdot i\right)\right) - \left(\log 1 \cdot n + 1 \cdot i\right)\right) + \left(\log 1 \cdot n + 1 \cdot i\right) \cdot \left(\log 1 \cdot n + 1 \cdot i\right)\right) \cdot i}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(\frac{\frac{\left({\left(1 + \frac{i}{n}\right)}^{n} \cdot {\left(1 + \frac{i}{n}\right)}^{n}\right) \cdot {\left(1 + \frac{i}{n}\right)}^{n} - 1 \cdot \left(1 \cdot 1\right)}{{\left(1 + \frac{i}{n}\right)}^{n} \cdot {\left(1 + \frac{i}{n}\right)}^{n} + \left(1 \cdot 1 + {\left(1 + \frac{i}{n}\right)}^{n} \cdot 1\right)}}{i} \cdot n\right)\\
\end{array}double f(double i, double n) {
double r15785208 = 100.0;
double r15785209 = 1.0;
double r15785210 = i;
double r15785211 = n;
double r15785212 = r15785210 / r15785211;
double r15785213 = r15785209 + r15785212;
double r15785214 = pow(r15785213, r15785211);
double r15785215 = r15785214 - r15785209;
double r15785216 = r15785215 / r15785212;
double r15785217 = r15785208 * r15785216;
return r15785217;
}
double f(double i, double n) {
double r15785218 = i;
double r15785219 = -8.271685620893128e-30;
bool r15785220 = r15785218 <= r15785219;
double r15785221 = 100.0;
double r15785222 = 1.0;
double r15785223 = n;
double r15785224 = r15785218 / r15785223;
double r15785225 = r15785222 + r15785224;
double r15785226 = pow(r15785225, r15785223);
double r15785227 = r15785226 - r15785222;
double r15785228 = r15785227 / r15785218;
double r15785229 = r15785221 * r15785228;
double r15785230 = r15785229 * r15785223;
double r15785231 = -1.0712482862995937e-106;
bool r15785232 = r15785218 <= r15785231;
double r15785233 = log(r15785222);
double r15785234 = r15785233 * r15785223;
double r15785235 = r15785222 * r15785218;
double r15785236 = r15785234 + r15785235;
double r15785237 = 3.0;
double r15785238 = pow(r15785236, r15785237);
double r15785239 = 0.5;
double r15785240 = r15785218 * r15785218;
double r15785241 = r15785233 * r15785240;
double r15785242 = r15785240 - r15785241;
double r15785243 = r15785239 * r15785242;
double r15785244 = pow(r15785243, r15785237);
double r15785245 = r15785238 + r15785244;
double r15785246 = r15785245 * r15785223;
double r15785247 = r15785221 * r15785246;
double r15785248 = r15785243 - r15785236;
double r15785249 = r15785243 * r15785248;
double r15785250 = r15785236 * r15785236;
double r15785251 = r15785249 + r15785250;
double r15785252 = r15785251 * r15785218;
double r15785253 = r15785247 / r15785252;
double r15785254 = 1.6668266874068228e-69;
bool r15785255 = r15785218 <= r15785254;
double r15785256 = exp(r15785243);
double r15785257 = log(r15785256);
double r15785258 = r15785236 + r15785257;
double r15785259 = r15785258 / r15785218;
double r15785260 = r15785259 * r15785223;
double r15785261 = r15785221 * r15785260;
double r15785262 = 176217786659469.75;
bool r15785263 = r15785218 <= r15785262;
double r15785264 = r15785226 * r15785226;
double r15785265 = r15785264 * r15785226;
double r15785266 = r15785222 * r15785222;
double r15785267 = r15785222 * r15785266;
double r15785268 = r15785265 - r15785267;
double r15785269 = r15785226 * r15785222;
double r15785270 = r15785266 + r15785269;
double r15785271 = r15785264 + r15785270;
double r15785272 = r15785268 / r15785271;
double r15785273 = r15785272 / r15785218;
double r15785274 = r15785273 * r15785223;
double r15785275 = r15785221 * r15785274;
double r15785276 = r15785263 ? r15785253 : r15785275;
double r15785277 = r15785255 ? r15785261 : r15785276;
double r15785278 = r15785232 ? r15785253 : r15785277;
double r15785279 = r15785220 ? r15785230 : r15785278;
return r15785279;
}




Bits error versus i




Bits error versus n
Results
| Original | 42.3 |
|---|---|
| Target | 42.8 |
| Herbie | 22.0 |
if i < -8.271685620893128e-30Initial program 28.9
rmApplied associate-/r/29.4
Applied associate-*r*29.4
if -8.271685620893128e-30 < i < -1.0712482862995937e-106 or 1.6668266874068228e-69 < i < 176217786659469.75Initial program 50.6
rmApplied associate-/r/50.5
Taylor expanded around 0 23.1
Simplified23.1
rmApplied associate-*l/21.0
Applied associate-*r/21.2
rmApplied flip3-+21.3
Applied associate-*l/17.8
Applied associate-*r/17.8
Applied associate-/l/17.7
Simplified17.7
if -1.0712482862995937e-106 < i < 1.6668266874068228e-69Initial program 49.8
rmApplied associate-/r/49.4
Taylor expanded around 0 16.6
Simplified16.6
rmApplied add-log-exp16.6
if 176217786659469.75 < i Initial program 31.9
rmApplied associate-/r/31.9
rmApplied flip3--32.0
Simplified32.0
Final simplification22.0
herbie shell --seed 2019173
(FPCore (i n)
:name "Compound Interest"
:herbie-target
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))