```python
from ipywidgets import interactive, interact
import matplotlib.pyplot as plt
import numpy as np
import ipywidgets as widgets
import sympy as sym
import seaborn as sns
import plotly.graph_objects as go
from plotly.offline import init_notebook_mode, iplot
from numba import jit

init_notebook_mode(connected=True)
jit(nopython=True, parallel=True)
sns.set()

```







```python


class plot():
    
    def __init__(self, preWidgetN):
        
        self.N = preWidgetN
        
        x,y,n ,k = sym.symbols('x, y,n,k', real=True)
        X=np.linspace(0, 10, 100)
        
        f = sym.Sum((-1)**k*(x**(2*k+1))/(sym.factorial(2*k+1)),(k,0, n))
        #f = sym.Sum((-1)**k*(x**(2*k))/(sym.factorial(2*k)),(k,0, n))
        #print(sym.latex(f))
        f = f.subs(n, self.N.value)
        f = sym.lambdify(x, f)
        self.trace1 = go.Scatter(x=X, y=np.sin(X),
                            mode='lines+markers',
                            name='sin'
                               )
        self.trace2 = go.Scatter(x=X, y=f(X),
                            mode='lines',
                            name=r'$\sum_{k=0}^{%s} \frac{\left(-1\right)^{k} x^{2 k + 1}}{\left(2 k + 1\right)!}$' %(self.N.value)
                               )
        
        layout = go.Layout(template='plotly_dark')

        self.fig = go.FigureWidget(data=[self.trace1, self.trace2], 
                                   layout = layout,
                                   layout_yaxis_range=[-3 , 3]
                                  )


    def sineSeries(self, change):

        x,y,n ,k = sym.symbols('x, y,n,k', real=True)
        X=np.linspace(0, 10, 100)
        f = sym.Sum((-1)**k*(x**(2*k+1))/(sym.factorial(2*k+1)),(k,0, n))
        #f = sym.Sum((-1)**k*(x**(2*k))/(sym.factorial(2*k)),(k,0, n))
        f = f.subs(n, self.N.value)
        f = sym.lambdify(x, f)




        with self.fig.batch_update():
            self.fig.data[1].x = X
            self.fig.data[1].y = f(X)
            self.fig.data[1].name = r'$\sum_{k=0}^{%s} \frac{\left(-1\right)^{k} x^{2 k + 1}}{\left(2 k + 1\right)!}$' %(self.N.value)

        return 
    
    def show(self):
        self.N.observe(self.sineSeries, names='value')
        display(self.N, self.fig)
        return
```


```python
N = widgets.IntSlider(min=0, max=20, step=1, value=0, description='partial sum order')

p = plot(N)

p.show()
```


    IntSlider(value=0, description='partial sum order', max=20)



    FigureWidget({
        'data': [{'mode': 'lines+markers',
                  'name': 'sin',
                  'type': 'scat…



```python

```

ecc5719530c0343604e9c0013abe6e3ca037e4ed
ipynb
Jupyter Notebook
.ipynb_checkpoints/interactive_sinus-checkpoint.ipynb
zolabar/Interactive-Calculus
5b4b01124eba7a981e4e9df7afcb6ab33cd7341f
MIT
2022-03-11T01:26:50.000Z
2022-03-11T01:26:50.000Z
.ipynb_checkpoints/interactive_sinus-checkpoint.ipynb
zolabar/Interactive-Calculus
5b4b01124eba7a981e4e9df7afcb6ab33cd7341f
MIT
.ipynb_checkpoints/interactive_sinus-checkpoint.ipynb
zolabar/Interactive-Calculus
5b4b01124eba7a981e4e9df7afcb6ab33cd7341f
MIT
Qwen/Qwen-72B
1. YES
2. YES