Function Repository Resource:

TangentLine

Source Notebook

Compute properties of the tangent line to a curve at a given point

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["TangentLine"][expr,{x,a},{y,b}]

returns an association of properties of the tangent line to expr, viewed as an equation in x and y, at the point {x,y}={a,b}.

ResourceFunction["TangentLine"][expr,{x,a},{y,b},prop]

returns the value of the tangent line property prop. prop can also be a list of properties.

ResourceFunction["TangentLine"][expr,{x,a},y]

returns information relating to one, among possibly several, of the tangent lines to expr at x=a.

ResourceFunction["TangentLine"][expr,x,{y,b}]

returns information relating to one, among possibly several, of the tangent lines to expr at y=b.

Details

Allowed values of prop are:
"SlopeInterceptEquation"equation of the tangent line in slope-intercept form
"StandardFormEquation"equation of the tangent line in standard form
"PointSlopeEquation"equation of the tangent line in point-slope form
"Slope"slope of the tangent line
"PointOfTangency"point at which tangent line is computed
"HorizontalIntercept"horizontal intercept for the tangent line equation
"VerticalIntercept"vertical intercept for the tangent line equation
"Plot"plot of the tangent line equation
Allassociation of information returning all allowed properties
If expr does not have head Equal, then expr is treated as an expression defining y in terms of x. In other words, ResourceFunction["TangentLine"][expr,{x,a},y,] is equivalent to ResourceFunction["TangentLine"][y==expr,{x,a},y,] if expr has a head other than Equal.
If only one coordinate of the intersection point is given, the other coordinate is inferred. For expressions that are multivalued at the given value of x or y, information on only one of potentially several tangent lines is returned.

Examples

Basic Examples (2) 

Compute the slope-intercept equation of the tangent line to a curve at a given point:

In[1]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][
 y == x^2 + 3, {x, 2}, y, "SlopeInterceptEquation"]
Out[1]=

Visualize this result:

In[2]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][y == x^2 + 3, {x, 2}, y, "Plot"]
Out[2]=

Compute the slope of this tangent line:

In[3]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][y == x^2 + 3, {x, 2}, y, "Slope"]
Out[3]=

Compute the horizontal intercept of this tangent line:

In[4]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][
 y == x^2 + 3, {x, 2}, y, "HorizontalIntercept"]
Out[4]=

Get the standard-form equation of this tangent line:

In[5]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][
 y == x^2 + 3, {x, 2}, y, "StandardFormEquation"]
Out[5]=

Get an Association of properties of a tangent line to a curve:

In[6]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sin[10 x], {x, 2}, y]
Out[6]=

Get just the point-slope equation of this tangent line:

In[7]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sin[10 x], {x, 2}, y, "PointSlopeEquation"]
Out[7]=

Scope (1) 

The first argument to TangentLine can be an implicit definition of a curve:

In[8]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][x^2 + y^3 == 5, {x, 2.4}, y]
Out[8]=

Properties and Relations (2) 

If a tangent line is parallel to a coordinate axis, its intercept with that axis is None:

In[9]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][x^2 + 3, {x, 0}, y, "HorizontalIntercept"]
Out[9]=

Requesting tangent line information about a point that is not on the curve will result in an error message:

In[10]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][
 y == x Sin[x], {x, 2}, {y, 3}, "SlopeInterceptEquation"]
Out[10]=

Possible Issues (3) 

If one coordinate is not specified, information on only one of the possible tangent lines at the given coordinate value is returned:

In[11]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Sin[x], x, {y, 1/2}]
Out[11]=

Vertical tangent lines have infinite slope. Some of their properties may not be defined:

In[12]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][x^2 + y^2 == 1, {x, 1}, {y, 0}]
Out[12]=

If a function has a cusp or a discontinuity at the given point, no tangent line is returned:

In[13]:=
ResourceFunction[
 "TangentLine", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][Abs[x], {x, 0}, y]
Out[13]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 5.1.0 – 04 August 2023
  • 5.0.0 – 23 March 2023
  • 4.0.1 – 28 March 2022
  • 4.0.0 – 26 May 2021
  • 3.0.0 – 24 January 2020
  • 2.0.0 – 06 September 2019
  • 1.0.0 – 23 August 2019

Related Resources

Author Notes

To view the full source code for TangentLine, evaluate the following:

In[1]:=
SystemOpen[
 FileNameJoin[{DirectoryName[FindFile["ResourceFunctionHelpers`"]], "Lines.wl"}]]

License Information