<jupyter_start><jupyter_text>Sagemath Computer Project 2  Derivatives in Sagemath Consider the function  $f(x)=\frac{x^{2}+1}{\cos\left(x^{4}+7\right)}$Let's find the derivative of this function.<jupyter_code>var('x')
f(x) = (x^2 + 1) / cos(x^4 + 7)
show(f)
show(derivative(f, x))<jupyter_output><empty_output><jupyter_text>Problem 1 Using sagemath find the derivatives of the following functions. $f(x)=\frac{x-5}{(x+3)^{4}}$$h(x)=x\cdot\left(3x+7\right)^{5}$$g(x)=\ln(3x+1)$$j(x)=\sin\left(\sqrt[3]{3x}\right)$  Indefinite Integrals in Sagemath Now let's compute the indefinite integral $\int\cos(x)\:dx$<jupyter_code>f(x) = cos(x)
f_int(x) = integrate(f, x)
show(f_int)<jupyter_output><empty_output><jupyter_text>Let's plot the function function to get a better look.<jupyter_code>f(x) = cos(x)
plot(f, (x, -2, 8))<jupyter_output><empty_output><jupyter_text>Problem 2 Using Sagemath evaluate the following integrals. (a) $\int\frac{x^{2}+x}{x}dx$(b) $\int\left(x^{2}+7\right)^{2}dx$(c) $\int_{-1}^{1}x^{3}\left(1+x^{4}\right)^{3}dx$(d) $\int e^{4x}dx$ (e) $\int\frac{e^{x}}{\left(1+e^{x}\right)^{2}}dx$  Definite Integrals in Sagemath  Now let's compute the definite integral   $\int_{-1}^{1}\cos(x)\:dx$  In this case we use the integrate function, and include the limits of integration.<jupyter_code>f(x) = cos(x)
f_integral = integrate(f, (x, -1, 1))
show(f_integral)<jupyter_output><empty_output><jupyter_text>This gives us 2*sin(1).  Let's get a numerical approximation, by appending the .numerical_approx().<jupyter_code>(2*sin(1)).numerical_approx()<jupyter_output><empty_output><jupyter_text>Problem 3 Evaluate the following indefinite integral using Sagemath.  $\int_{0}^{2}x^{2}\:dx$ Then plot the function on a graph. Lastly, describe in words what the numeric value of the definite integral represents.   Recursive functions in SageMath Iteration in SagemathConsider a recursively defined iteration.  $x_{0}=4$ $x_{k}=3x_{k-1}-10$ The “next” element in the sequence is equal to the previous times three and minus ten.To calculate by hand takes a good deal of effort.  $x_{1}=3*4-10=2$  $x_{2}=3*2-10=-4$  $x_{3}=3*(-4)-10=-22$ What if we want to find $x_{50}$? We can use Sagemath to help us to evaluate $x_{50.}$ Defining a sequence recursively.  Suppose $x_{0}=4$ and $x_{k}=3x_{k-1}-10$<jupyter_code># we define a function x
def x(k):
    if k==0:
        return 4
    else: 
        return 3*x(k-1)-10
# Let's check our previous calculations 
show(x(1))
show(x(2))
show(x(3))<jupyter_output><empty_output><jupyter_text>We can use this to find $x_{50.}$<jupyter_code>x(50)<jupyter_output><empty_output><jupyter_text>Wow!  That would have taken a long time to compute.  Now let's list out the first 50 iterates.<jupyter_code>[(i,x(i)) for i in range(51)] #note we have to go up to 51 in order to see k = 50.<jupyter_output><empty_output><jupyter_text>Problem 4  Give the first 50 iterates of the following recursively defined function. $x_{k}=x_{k-1}^{3}+x_{k-1}-1$;  $x_{0}=2$  Newton's Method Newton's Method gives an approximation of the root of a function, given an initial guess. The computational process is iterative, and we can use sagemath to evaluate for large iterates, like $x_{100} ![newton_method.JPG](attachment:newton_method.JPG) Recall Newton's Method Algorithm![newton_iteration.JPG](attachment:newton_iteration.JPG)<jupyter_code>Provided our initial guess is well chosen, each step in the iterative process should get us an approximation closer to the true root.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1544784580498866, 'fraction_numerical': 0.032879818594104306, 'mean_word_length': 6.058, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '430740', 'license': 'CC0-1.0', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1268, 'n_words': 358, 'path': 'sagemath_proj2_calc_spring2020.ipynb', 'repo_name': 'Mary-Wall/Calculus_Sagemath', 'size': '3528'}