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 slider 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, prange)
print('Tangent line is y = ' + tanf._repr_())
tanplot = plot(tanf, prange, prange, rgbcolor = (1,0,0))
fmax = f.find_local_maximum(prange, prange)
fmin = f.find_local_minimum(prange, prange)
show(fplot + tanplot, xmin = prange, xmax = prange, ymax = fmax, ymin = fmin)```
```

None

## Tags

Primary Tags: Single Variable Calculus: Limits and continuity

Secondary Tags: Limits and continuity: Applications - tangent lines and slopes

None

## Attribute

Author: Marshall Hampton

Date: 19 Jul 2020 02:56

Submitted by: Zane Corbiere