Is There Any Way to Plot Secant Line and Tangent Line given a point in a function?

Hi all,

I wonder if there is any way to draw (automatically):

  1. a secant line
  2. a tangent line

with known function and a point at that function, is it possible?

I use pyplot backend, but I want to know other backend plotting / package that can plot them nicely. Or perhaps by using function is able too?

using Plots, LaTeXStrings

a, b = -3,3

h(x) = x^2

plot(h, a, b; legend=:outerright, label=L"\sin \frac{1}{x}", framestyle=:zerolines, 
	xlims = (-3,3), xticks = -3:1:3, 
	ylims = (-2,2), yticks = -2:1:2, 
	size=(720, 360))

Capture d’écran_2022-09-25_15-57-58

See my answer here:

1 Like

Thank you, it works well