Simple Tangent Line Grapher

Description

Here is a Sage interact that plots a tangent line to a given function. The xbegin and xend sliders control the endpoints of the graphed curve, and x0 controls the point at which the tangent is calculated.

Sage Cell

Code

pretty_print(html('<h2>Tangent line grapher</h2>'))
@interact
def tangent_line(f = input_box(default=sin(x)), xbegin = slider(0,10,1/10,0), xend = slider(0,10,1/10,10), x0 = slider(0, 1, 1/100, 1/2)):
    prange = [xbegin, xend]
    x0i = xbegin + x0*(xend-xbegin)
    var('x')
    df = diff(f)
    tanf = f(x=x0i) + df(x=x0i)*(x-x0i)
    fplot = plot(f, prange[0], prange[1])
    print('Tangent line is y = ' + tanf._repr_())
    tanplot = plot(tanf, prange[0], prange[1], rgbcolor = (1,0,0))
    fmax = f.find_local_maximum(prange[0], prange[1])[0]
    fmin = f.find_local_minimum(prange[0], prange[1])[0]
    show(fplot + tanplot, xmin = prange[0], xmax = prange[1], ymax = fmax, ymin = fmin)

Options

none

Tags

Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.

Attribute

Permalink:

Author:

Date: 19 Jul 2020 02:56

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License