WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

DifferenceQuotient [f,{x,h}]

gives the difference quotient .

DifferenceQuotient [f,{x,n,h}]

gives a multiple difference quotient with step h.

DifferenceQuotient [f,{x1,n1,h1},{x2,n2,h2},]

computes the partial difference quotient with respect to x1,x2,.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Basic Uses  
Univariate Difference Quotients  
Multivariate Difference Quotients  
Options  
Assumptions  
Applications  
Derivatives from First Principles  
Approximate Derivatives  
Differential Equations  
Extrapolation  
Properties & Relations  
Interactive Examples  
Neat Examples  
See Also
Related Guides
History
Cite this Page

DifferenceQuotient [f,{x,h}]

gives the difference quotient .

DifferenceQuotient [f,{x,n,h}]

gives a multiple difference quotient with step h.

DifferenceQuotient [f,{x1,n1,h1},{x2,n2,h2},]

computes the partial difference quotient with respect to x1,x2,.

Details and Options

Examples

open all close all

Basic Examples  (1)

Compute the difference quotient for a function:

Wolfram Language code: dq = DifferenceQuotient[x Sin[x], {x, h}]

Obtain the limit as h approaches 0:

Wolfram Language code: Limit[%, h -> 0]

This limit is the derivative of the function:

Wolfram Language code: der = D[x Sin[x], x]
Wolfram Language code: Plot[{der, dq /. {h -> 0.5}, dq /. {h -> 0.3}}, {x, 0, 2π}]

Scope  (16)

Basic Uses  (4)

Compute a forward difference quotient with step h:

Wolfram Language code: DifferenceQuotient[f[x], {x, h}]

Backward difference quotient:

Wolfram Language code: DifferenceQuotient[f[x], {x, -h}]

Symmetric difference quotient:

Wolfram Language code: DifferenceQuotient[f[x - h], {x, 2h}]

Compute the second difference quotient with step h:

Wolfram Language code: DifferenceQuotient[f[x], {x, 2, h}]

Third difference quotient:

Wolfram Language code: DifferenceQuotient[f[x], {x, 3, h}]

Partial difference quotient with steps r and s:

Wolfram Language code: DifferenceQuotient[f[x, y], {x, r}, {y, s}]

DifferenceQuotient threads over lists:

Wolfram Language code: DifferenceQuotient[{f[x], g[x]}, {x, h}]

Univariate Difference Quotients  (8)

DifferenceQuotient of a constant is 0:

Wolfram Language code: DifferenceQuotient[c, {x, h}]

DifferenceQuotient of a polynomial function is a polynomial function:

Wolfram Language code: DifferenceQuotient[x ^ 3, {x, h}]

Each successive difference quotient will lower the degree in x by one:

Wolfram Language code: Table[DifferenceQuotient[x ^ 4, {x, n, h}], {n, 4}]

Rational functions:

Wolfram Language code: DifferenceQuotient[(x + 1) / (x + 3), {x, h}]

Difference quotients of rational functions will stay as rational functions:

Wolfram Language code: Table[DifferenceQuotient[(x + 1) / (x + 3), {x, n, h}], {n, 2}]

Trigonometric functions:

Wolfram Language code: DifferenceQuotient[Sin[x], {x, h}]
Wolfram Language code: DifferenceQuotient[Cos[2x], {x, h}]

Exponential functions:

Wolfram Language code: Table[DifferenceQuotient[a ^ x, {x, n, h}], {n, 3}]

Polynomial exponentials:

Wolfram Language code: DifferenceQuotient[(x ^ 2 + x + 1)2 ^ x, {x, h}]

Difference quotients of PolyGamma with an integer step are rational functions:

Wolfram Language code: Block[{h = 3}, Table[DifferenceQuotient[PolyGamma[n, x], {x, h}], {n, 0, 3}]]

Similarly for HarmonicNumber and Zeta :

Wolfram Language code: DifferenceQuotient[HarmonicNumber [x, 2], {x, 3}]
Wolfram Language code: DifferenceQuotient[Zeta [2, x], {x, 3}]

FactorialPower with step h has a simple difference quotient for a matching step h:

Wolfram Language code: DifferenceQuotient[FactorialPower[x, n, h], {x, h}]

Multivariate Difference Quotients  (4)

DifferenceQuotient of a multivariate polynomial function is a polynomial function:

Wolfram Language code: DifferenceQuotient[x ^ 3 y ^ 2 + 5 x y + 11, {x, h}, {y, k}]

Difference quotients of multivariate rational functions will stay as rational functions:

Wolfram Language code: DifferenceQuotient[(x + y + 1) / (((x ^ 2 + 3)(y + 5))), {x, h}, {y, k}]

Higher-order quotients will tend to grow in size:

Wolfram Language code: DifferenceQuotient[(x + y + 1) / (((x ^ 2 + 3)(y + 5))), {x, 2, h}, {y, 2, k}]

DifferenceQuotient of multivariate functions depending on a subset of the variables are 0:

Wolfram Language code: DifferenceQuotient[f[x], {x, h}, {y, k}]
Wolfram Language code: DifferenceQuotient[ g[y], {x, h}, {y, k}]
Wolfram Language code: DifferenceQuotient[ h[x, y], {x, h}, {y, k}, {z, p}]

DifferenceQuotient for a product of univariate functions:

Wolfram Language code: DifferenceQuotient[f[x] g[y], {x, h}, {y, k}]

This is equal to the product of the individual difference quotients:

Wolfram Language code: DifferenceQuotient[f[x], {x, h}]DifferenceQuotient[ g[y], {y, k}]

Options  (1)

Assumptions  (1)

Specify assumptions on the variable x and the step h to obtain simpler results:

Wolfram Language code: DifferenceQuotient[Abs[x], {x, h}]
Wolfram Language code: DifferenceQuotient[Abs[x], {x, h}, Assumptions -> x > 0 && h > 0]
Wolfram Language code: DifferenceQuotient[Abs[x], {x, h}, Assumptions -> x < 0 && h < 0]

Applications  (10)

Derivatives from First Principles  (3)

Compute the derivative of a polynomial from first principles:

Wolfram Language code: f[x_] := x ^ 2 + 5x + 7
Wolfram Language code: Limit[DifferenceQuotient[f[x], {x, h}], h -> 0]

Compute the derivative using D :

Wolfram Language code: f'[x]

Exponential function:

Wolfram Language code: f[x_] := E ^ (a x)
Wolfram Language code: Limit[DifferenceQuotient[f[x], {x, h}], h -> 0]
Wolfram Language code: f'[x]

Trigonometric function:

Wolfram Language code: f[x_] := Sin[2x + 1]
Wolfram Language code: Limit[DifferenceQuotient[f[x], {x, h}], h -> 0]
Wolfram Language code: f'[x]

Compute the second derivative for a power function:

Wolfram Language code: f[x_] := x ^ n
Wolfram Language code: Limit[DifferenceQuotient[f[x], {x, 2, h}], h -> 0]
Wolfram Language code: f''[x]

Third derivative for a power tower:

Wolfram Language code: f[x_] := x ^ x
Wolfram Language code: Limit[DifferenceQuotient[f[x], {x, 3, h}], h -> 0]
Wolfram Language code: f'''[x]//Simplify

Compute the partial derivative with respect to x for a function of two variables:

Wolfram Language code: f[x_, y_] := Cos[x ^ 2 + E ^ (-y)]
Wolfram Language code: Plot3D[f[x, y], {x, -2, 2}, {y, -1, 1}]
Wolfram Language code: Limit[DifferenceQuotient[f[x, y], {x, h}], h -> 0]
Wolfram Language code: D[f[x, y], x]//Simplify

Partial derivative with respect to y:

Wolfram Language code: Limit[DifferenceQuotient[f[x, y], {y, k}], k -> 0]
Wolfram Language code: D[f[x, y], y]

Mixed partial derivative:

Wolfram Language code: Limit[Limit[DifferenceQuotient[f[x, y], {x, h}, {y, k}], h -> 0], k -> 0]
Wolfram Language code: D[f[x, y], x, y]

Approximate Derivatives  (3)

Approximate the derivative at a point using DifferenceQuotient :

Wolfram Language code: f[x_] := 2 x^3 - 15 x^2 + 33 x - 20
Wolfram Language code: Plot[f[x], {x, 0, 5}]

Derivative at x=2.7:

Wolfram Language code: f'[2.57]

Approximation given by DifferenceQuotient :

Wolfram Language code: DifferenceQuotient[f[x], {x, 0.01}] /. {x -> 2.57}

Approximate the derivative of a function using various difference quotients:

Wolfram Language code: f[x_] := Sin[E ^ x]
Wolfram Language code: Plot[f[x], {x, 0, π}]

Exact derivative:

Wolfram Language code: f'[2]
Wolfram Language code: N[%]

Use forward difference quotients to obtain an approximation:

Wolfram Language code: hvals = {0.1, 0.01, 0.0001, 0.0001};
Wolfram Language code: fd = Table[DifferenceQuotient[f[x], {x, h}], {h, hvals}] /. {x -> 2}

Backward difference quotients:

Wolfram Language code: bd = Table[DifferenceQuotient[f[x], {x, -h}], {h, hvals}] /. {x -> 2}

Symmetric difference quotients:

Wolfram Language code: Table[DifferenceQuotient[f[x - h], {x, 2h}], {h, {0.1, 0.01, 0.0001, 0.0001}}] /. {x -> 2}

Approximate the partial derivatives at a point using DifferenceQuotient :

Wolfram Language code: f[x_, y_] := Sin[x + y]Cos[ 3y]
Wolfram Language code: Plot3D[f[x, y], {x, 0, 5}, {y, 0, 5}]
Wolfram Language code: {D[f[x, y], {x, 2}], D[f[x, y], x, y], D[f[x, y], {y, 2}]} /. {x -> 2.3, y -> 3.8}
Wolfram Language code: {DifferenceQuotient[f[x, y], {x, 2, h}], DifferenceQuotient[f[x, y], {x, h}, {y, k}], DifferenceQuotient[f[x, y], {y, 2, k}]} /. {x -> 2.3, y -> 3.8, h -> 0.001, k -> 0.002}

Differential Equations  (3)

Discretize a differential equation using forward differences:

Wolfram Language code: deqn = {y'[x] == 2x - y[x], y[0] == 5};
Wolfram Language code: reqn = {DifferenceQuotient[y[x], {x, 1 / 10}] == 2x - y[x], y[0] == 5}//Simplify

Solve the differential equation using DSolveValue :

Wolfram Language code: dsol = DSolveValue[deqn, y[x], x]
Wolfram Language code: Plot[dsol, {x, 0, 5}]

Solve the difference equation using RSolveValue :

Wolfram Language code: rsol = RSolveValue[reqn, y[x], x]//Simplify

Compare the exact and approximate solutions:

Wolfram Language code: Table[dsol, {x, 0., 5}]
Wolfram Language code: Table[rsol, {x, 0., 5}]

Discretize a differential equation using backward differences:

Wolfram Language code: deqn = {y'[x] == 4 - 3y[x], y[0] == 5};
Wolfram Language code: reqn = {DifferenceQuotient[y[x], {x, -1 / 10}] == 4 - 3y[x], y[0] == 5}//Simplify

Solve the differential equation using DSolveValue :

Wolfram Language code: dsol = DSolveValue[deqn, y[x], x]
Wolfram Language code: Plot[dsol, {x, 0, 5}]

Solve the difference equation using RSolveValue :

Wolfram Language code: rsol = RSolveValue[reqn, y[x], x]//Simplify

Compare the exact and approximate solutions:

Wolfram Language code: Table[dsol, {x, 0., 5}]
Wolfram Language code: Table[rsol, {x, 0., 5}]

Discretize a differential equation using symbolic differences:

Wolfram Language code: deqn = {y'[x] == x - 3y[x], y[0] == 1};
Wolfram Language code: reqn = {DifferenceQuotient[y[x], {x, h}] == x - 3y[x], y[0] == 1}//Simplify

Solve the differential equation using DSolveValue :

Wolfram Language code: dsol = DSolveValue[deqn, y[x], x]//Simplify
Wolfram Language code: Plot[dsol, {x, 0, 5}]

Solve the difference equation using RSolveValue :

Wolfram Language code: rsol[h_] = RSolveValue[reqn, y[x], x]

Compare the exact and approximate solutions using forward and backward differences:

Wolfram Language code: Table[{dsol, rsol[0.1], rsol[-0.1]}, {x, 0., 5}]//TableForm

Obtain the exact solution as a limit of the approximate solution:

Wolfram Language code: Limit[rsol[h], h -> 0]//FullSimplify

Extrapolation  (1)

Richardson extrapolation is a method for sequence acceleration that can be used to improve the rate of convergence of a sequence a[h], which depends on a parameter h. Apply Richardson extrapolation to accelerate the convergence of DifferenceQuotient to the derivative of a function f[x] using the sequence a[x,h], which is defined by:

Wolfram Language code: a[x_, h_] = DifferenceQuotient[f[x], {x, h}]

Set up a scheme for Richardson extrapolation:

Wolfram Language code: r[x_, h_, k_] = (k ^ 2 a[x, h] - a[x, k h]) / (k ^ 2 - 1)//Simplify

Define the function:

Wolfram Language code: f[x_] := x Sin[E ^ (x)]

Compute the derivative at a point:

Wolfram Language code: f'[3.4]

Approximation given by DifferenceQuotient :

Wolfram Language code: a[3.4, 0.001]

Richardson extrapolation improves the derivative approximation:

Wolfram Language code: Table[r[3.4, 0.001, k], {k, {0.5, 0.3, 0.0001}}]

Properties & Relations  (6)

DifferenceQuotient gives the slope of the secant line joining two nearby points on a curve:

Wolfram Language code: f[x_] := x ^ 3 + 2x - 5
Wolfram Language code: diffquotient = DifferenceQuotient[f[x], {x, h}]
Wolfram Language code: % /. {x -> 3, h -> 2}
Wolfram Language code: secantslope = (f[5] - f[3]) / 2
Wolfram Language code: Show[Plot[f[x], {x, 1, 6}], Graphics[{Red, Line[{{2.5, 2.5}, {5.5, 155.5}}]}]]

The Limit of DifferenceQuotient is the derivative D :

Wolfram Language code: DifferenceQuotient[f[x], {x, h}]
Wolfram Language code: Limit[%, h -> 0, Analytic -> True]

An iterated Limit of a multiple difference quotient gives a mixed partial derivative:

Wolfram Language code: DifferenceQuotient[f[x, y], {x, r}, {y, s}]
Wolfram Language code: Limit[Limit[%, r -> 0, Analytic -> True], s -> 0, Analytic -> True]

DifferenceQuotient is related to DifferenceDelta as TemplateBox[{{f, (, x, )}, x, 1, h}, DifferenceDelta4]/h:

Wolfram Language code: DifferenceQuotient[f[x], {x, h}] == DifferenceDelta[f[x], {x, 1, h}] / h//Simplify
Wolfram Language code: Table[DifferenceQuotient[f[x], {x, n, h}] == DifferenceDelta[f[x], {x, n, h}] / h ^ n//Simplify, {n, 4}]//Simplify

DifferenceQuotient is related to DiscreteShift as (TemplateBox[{{f, (, x, )}, x, 1, h}, DiscreteShift4]-f(x))/h:

Wolfram Language code: DifferenceQuotient[f[x], {x, h}] == (DiscreteShift[f[x], {x, 1, h}] - f[x]) / h//Simplify

DifferenceQuotient is a linear operator:

Wolfram Language code: DifferenceQuotient[f[x] + g[x], {x, h}] == DifferenceQuotient[f[x], {x, h}] + DifferenceQuotient[g[x], {x, h}]//Together
Wolfram Language code: DifferenceQuotient[c f[x], {x, h}] == c DifferenceQuotient[f[x], {x, h}]//Together

Interactive Examples  (1)

The function parametrizes the secant line between and :

Wolfram Language code: f[x_] = 10 Exp[-(x^2 - x/4)] Sin[2 x];
Wolfram Language code: g[h_, b_][x_] = f[b] + (DifferenceQuotient[f[x], {x, h}] /. (x -> b)) (x - b);

Visualize how the secant line changes over the function, but at every point becomes tangent as :

Wolfram Language code: Manipulate[ Plot[{f[x], g[h, b][x]}, {x, -3, 3}, PlotRange -> 12, Epilog -> {AbsolutePointSize[7], Point[{{b, f[b]}, {b + h, f[b + h]}}]}], {{b, 0}, -2, 2, Appearance -> "Labeled"}, {{h, 1}, -1, 1, Appearance -> "Labeled"}, SaveDefinitions -> True]

Neat Examples  (1)

Create a table of common difference quotients:

Wolfram Language code: flist = {1, x, x ^ 2, x ^ 3, 1 / x, Sin[x], Cos[x], Sinh[x], Cosh[x], a ^ (x)};
Wolfram Language code: Grid[Transpose[{flist, DifferenceQuotient[flist, {x, h}]}], Dividers -> All, Spacings -> {4, 2}, Background -> StandardBlue, BaseStyle -> {FontFamily -> Times, FontSize -> 13}]//TraditionalForm
Wolfram Research (2016), DifferenceQuotient, Wolfram Language function, https://reference.wolfram.com/language/ref/DifferenceQuotient.html.

Text

Wolfram Research (2016), DifferenceQuotient, Wolfram Language function, https://reference.wolfram.com/language/ref/DifferenceQuotient.html.

CMS

Wolfram Language. 2016. "DifferenceQuotient." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DifferenceQuotient.html.

APA

Wolfram Language. (2016). DifferenceQuotient. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DifferenceQuotient.html

BibTeX

@misc{reference.wolfram_2026_differencequotient, author="Wolfram Research", title="{DifferenceQuotient}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/DifferenceQuotient.html}", note=[Accessed: 14-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_differencequotient, organization={Wolfram Research}, title={DifferenceQuotient}, year={2016}, url={https://reference.wolfram.com/language/ref/DifferenceQuotient.html}, note=[Accessed: 14-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /