NormFunction
Details
- NormFunction->f specifies that f[data] should be minimized in generating results.
Examples
open all close allBasic Examples (2)
Find a "best" fit for data using different norms:
data = Table[Prime[x], {x, 20}]The default is to find the best least-squares fit:
FindFit[data, a x Log[b + cx], {a, b, c}, x]FindFit[data, a x Log[b + cx], {a, b, c}, x, NormFunction -> (Norm[#, Infinity]&)]FindFit[data, a x Log[b + cx], {a, b, c}, x, NormFunction -> (Norm[#, 1]&)]Use a 2-norm for estimating local error in solving an ODE:
sol2 = First[x /. NDSolve[{x''[t] + x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 100π}, NormFunction -> (Norm[#, 2]&)]]soli = First[x /. NDSolve[{x''[t] + x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 100π}, NormFunction -> (Norm[#, ∞]&)]]The error measure makes a difference in the solution quality:
{sol2[100π], soli[100π]} - 1Scope (1)
The norm is used for space and time in PDE solutions:
sol[p_] := NDSolve[{D[u[t, x], t, t] == D[u[t, x], x, x], u[0, x] == Exp[-x ^ 2], Derivative[1, 0][u][0, x] == -Exp[-x ^ 2], u[t, -L] == u[t, L]}, u, {t, 0, 4L}, {x, -L, L}, NormFunction -> (Norm[#, p]&)]Plot the actual solution error, when using different error estimation norms:
L = 10;Table[
Plot[Evaluate[(u[40, x] /. sol[p]) - (Exp[-x ^ 2] - 2Sqrt[π])], {x, -L, L}, PlotRange -> All], {p, {1, 2, 3, ∞}}]//QuietPlot3D[Evaluate[u[t, x] /. sol[1]], {t, 0, 40}, {x, -10, 10}, Mesh -> False, PlotPoints -> 20]See Also
History
Introduced in 2003 (5.0)
Text
Wolfram Research (2003), NormFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/NormFunction.html.
CMS
Wolfram Language. 2003. "NormFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NormFunction.html.
APA
Wolfram Language. (2003). NormFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NormFunction.html
BibTeX
@misc{reference.wolfram_2026_normfunction, author="Wolfram Research", title="{NormFunction}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/NormFunction.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_normfunction, organization={Wolfram Research}, title={NormFunction}, year={2003}, url={https://reference.wolfram.com/language/ref/NormFunction.html}, note=[Accessed: 13-June-2026]}