<jupyter_start><jupyter_text>Maclaurin series  e^x![e^c](http://wiki.ubc.ca/images/math/2/b/8/2b87b0346524eed99d4f665c5f3f653d.png) Exec. e^2<jupyter_code>import math
def maclaurin_exp(k, threshold):
  prev_value = 0
  current_value = 1
  i = 1
  
  while current_value > threshold:
    prev_value += current_value
    current_value = (k**i) / math.factorial(i)
    i = i+1

  return prev_value
exp_2 = maclaurin_exp(2, 0.00001)
print(exp_2)<jupyter_output>7.389046015712681<jupyter_text>---e^2 with errors<jupyter_code>def maclaurin_exp_error(k, threshold, true_value):
  prev_value = 0
  current_value = 1
  i = 1
  
  while current_value > threshold:
    prev_value_a = prev_value
    prev_value += current_value
    current_value = (k**i) / math.factorial(i)
    
    error_t = ((true_value - prev_value) / true_value) * 100
    error_a = ((prev_value - prev_value_a) / prev_value) * 100
    print("%i | %f | %f | %f" % (i, prev_value, error_t, error_a))
    
    i = i+1
maclaurin_exp_error(2, 0.00001, exp_2)<jupyter_output>1 | 1.000000 | 86.466453 | 100.000000
2 | 3.000000 | 59.399360 | 66.666667
3 | 5.000000 | 32.332266 | 40.000000
4 | 6.333333 | 14.287537 | 21.052632
5 | 7.000000 | 5.265172 | 9.523810
6 | 7.266667 | 1.656227 | 3.669725
7 | 7.355556 | 0.453245 | 1.208459
8 | 7.380952 | 0.109536 | 0.344086
9 | 7.387302 | 0.023608 | 0.085948
10 | 7.388713 | 0.004513 | 0.019096
11 | 7.388995 | 0.000694 | 0.003819
12 | 7.389046 | 0.000000 | 0.000694
{'fraction_non_alphanumeric': 0.13894592744695414, 'fraction_numerical': 0.23819301848049282, 'mean_word_length': 3.4846625766871164, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '531218', 'license': 'MIT', 'n_tokens_mistral': 875, 'n_tokens_neox': 638, 'n_words': 122, 'path': 'maclaurin_series/maclaurin_series.ipynb', 'repo_name': 'miltonolaf/snippets.ipynb', 'size': '1461'}