<jupyter_start><jupyter_text>計算 sin(x)<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
x = float(input('x (0.0 <= x <= 2PI)  ='))
list1 = []
for k in range(1,15):
    sum = 0
    for i in range(k):
        factorial = 1.0
        for j in range(2*i + 1):
            factorial *= j + 1
        sum +=  ( ( (-1)**i) * (x**(2*i+1) ) ) / factorial
    list1.append(sum)

len(list1)
b = [i for i in range(1,15)]
len(b)
plt.plot(b,list1)
plt.show()<jupyter_output><empty_output><jupyter_text>相比numpy裡的sin(x)套件<jupyter_code>print("sin(x) = " , np.sin(x))<jupyter_output>sin(x) =  0.0015926529164868282
{'fraction_non_alphanumeric': 0.18494271685761046, 'fraction_numerical': 0.06873977086743044, 'mean_word_length': 3.4671532846715327, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, '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': '489618', 'license': 'MIT', 'n_tokens_mistral': 299, 'n_tokens_neox': 280, 'n_words': 52, 'path': 'NCCU Applications of mathematics softwares/lesson_6_4.ipynb', 'repo_name': 'kkzzo1o1/kkzzo1o1', 'size': '611'}