User manual · Calculations

f(x) calculator: define and evaluate your own functions

Free f(x) calculator: define a function such as f(x) := x² + 1, evaluate f(3), f(a + h) or f(g(2)), use up to five variables and keep your functions saved.

By Hira Noor, mathematicianUpdated
Try

Use x as the variable. Trigonometric functions use radians. Inputs outside the domain show as not defined.

Leave blank for a single column.

A number, fraction or expression such as pi/6.

Negative steps count down. At most 1,000 rows.

Result

Table of values: 5 rows, x = 1 to 5 in steps of 1

Table of values

5 rows, x = 1 to 5 in steps of 1

Smallest f(x) in the table
2 at x = 1
Largest f(x) in the table
26 at x = 5
Roots and sign changes of f
0 exact zeros, 0 sign changes with a root
Exact values
5 of 5 values are exact rationals

The table evaluates f(x) = x² + 1 at 5 values of x from 1 to 5. Over these points f ranges from 2 to 26.

Turning points and sign changes are read from the table, so features between rows can be missed. A smaller step shows more detail.

Graph of f(x)
51015202511.522.533.544.55xyf(x)Table values of f
Values from x = 1 to 5, step 1
xf(x) = x² + 1
12
25
310
417
526
Step-by-step working (4 steps)
  1. Row 1: x = 1

    f(1) = (1)² + 1 = 2

  2. Row 2: x = 2

    f(2) = (2)² + 1 = 5

  3. Row 3: x = 3

    f(3) = (3)² + 1 = 10

  4. Rows 4 to 5

    Each remaining row substitutes its x-value into f(x) the same way.

This is the function table calculator, started with this page’s first example. Its own page adds more presets, the formulas and worked examples.

Short answerTo use the f(x) calculator, type the function once with :=, such as f(x) := x^2 + 1, then type f(3) and press Enter: the answer is 10, because 3² + 1 = 10. The scientific calculator keeps the definition, so f(-2), f(1/2) and f(f(2)) work in any later line. The table above evaluates the same f(x) at x = 1 to 5 and writes out the substitution for f(1), f(2) and f(3). Functions can take up to five variables, can call each other, and stay saved in your browser.

Try it in one click: define f(x) = x² + 1, a table of f(x) from −3 to 3 or a function with a domain limit. Jump to: f(a + h), several variables, composite functions, undefined inputs or rules for names. Looking for FX as in foreign exchange? Use the currency converter.

How to evaluate f(x) at a value

Evaluating a function means replacing every x in its formula with the input and working out the result. In function notation, f(3) is read “f of 3” and means the output of f when x = 3. The calculator does the substitution for you once the function is defined.

  1. Define the function: f(x) := x^2 + 1

    Type the name, the variable in parentheses, := and the formula, then press Enter. The line shows that f is defined; nothing is calculated yet.

  2. Call it with a value: f(3)

    Press Enter to get 10. The calculator substitutes 3 for x: 3² + 1 = 9 + 1 = 10.

  3. Reuse it: f(-2), f(1/2), f(2.5)

    Each line gives 5, 1.25 and 7.25. Negative inputs need no extra brackets: f(−2) squares the whole −2, so the result is 4 + 1 = 5.

Evaluating two functions at several inputs
FunctionCallSubstitutionResult
f(x) := x^2 + 1f(3)3² + 110
f(x) := x^2 + 1f(-2)(−2)² + 15
f(x) := x^2 + 1f(1/2)(1/2)² + 11.25
p(x) := 3x^2 - 2x + 5p(-1)3(−1)² − 2(−1) + 510
p(x) := 3x^2 - 2x + 5p(2)3(2)² − 2(2) + 513

To get one value from the table at the top of the page instead, set Start x and End x to the same number: f(3) with start and end at 3 gives a single row, f(3) = (3)² + 1 = 10, with the substitution written out.

f(a + h) versus f(a) + h

These two look alike but are different. f(a + h) adds h to the input before the function acts; f(a) + h works out f(a) first and adds h to the output. With f(x) = x² + 1, a = 2 and h = 0.5, f(2 + 0.5) gives 7.25 while f(2) + 0.5 gives 5.5.

f(a + h) is the building block of the difference quotient, (f(a + h) − f(a)) / h, the slope of the line through two points on the graph. Define it once and try smaller values of h:

dq(a, h) := (f(a + h) - f(a))/h
dq(2, 0.1)     → 4.1
dq(2, 0.001)   → 4.001
The difference quotient of f(x) = x² + 1 at a = 2 approaches 4, the derivative 2a

The calculator evaluates with numbers, so it does not expand f(a + h) into 2ah + h² + … symbolically. For an exact derivative, use the derivative calculator.

Defining a function

Write the name, the parameters in parentheses, :=, and the formula. Separate parameters with commas (with semicolons if you use the decimal comma setting). The formula can use the parameters, numbers, constants such as π, built-in functions, stored variables and custom functions you defined earlier.

Example definitions and calls (degree mode)
DefinitionCallResult
f(x) := x^2 + 1f(3)10
area(r) := π r^2area(2)12.56637061
hyp(a, b) := sqrt(a^2 + b^2)hyp(5, 12)13
ctof(c) := c × 9/5 + 32ctof(37)98.6
dist(x1, y1, x2, y2) := sqrt((x2 - x1)^2 + (y2 - y1)^2)dist(1, 2, 4, 6)5
side(a, b, C) := sqrt(a^2 + b^2 - 2a b cos(C))side(3, 4, 90)5

The last example is the law of cosines. Its cos reads the angle in the current angle unit when the function is called, so side(3, 4, 90) treats 90 as degrees in degree mode.

Functions of two or more variables

List every input between the parentheses, then pass the values in the same order. A function can have up to five parameters, and each one must have a different name.

Functions with several inputs
DefinitionCallResult
w(x, y) := x^2 + x yw(2, 3)10
vol(r, h) := π r^2 h (cylinder volume)vol(3, 5)141.3716694
A(P, r, t) := P(1 + r/100)^t (compound interest)A(1000, 5, 10)1628.894627

Composite functions: f(g(x))

A composite function feeds the output of one function into another. Define both, then nest the calls; the inner function is evaluated first. With f(x) := x^2 + 1 and g(x) := 2x - 3:

f(g(2))          → 2      g(2) = 1, then f(1) = 2
g(f(2))          → 7      f(2) = 5, then g(5) = 7
fg(x) := f(g(x))
fg(2)            → 2
(f ∘ g)(2) and (g ∘ f)(2) give different answers

The order matters: f(g(x)) is usually not the same function as g(f(x)). Defining the composite as its own function, as in fg(x) := f(g(x)), lets you evaluate (f ∘ g)(x) at any value in one call.

Domain and undefined inputs

The domain of a function is the set of inputs it accepts. When an input is outside the domain, the calculator stops with a message instead of returning a wrong number:

Inputs outside the domain (real mode)
DefinitionCallWhat you see
r(x) := sqrt(x - 2)r(6) and r(1)2, then “The square root of a negative number is not real”
h(x) := 1/(x - 1)h(3) and h(1)0.5, then “Division by zero”
L(x) := ln(x)L(0)“ln(0) is undefined”

So the domain of r is x ≥ 2, h is defined everywhere except x = 1, and L needs x > 0. In complex mode, square roots and logarithms of negative numbers return complex results instead (see complex numbers). A function table marks every undefined row, which is a quick way to see where the domain starts.

Calling a function

A custom function works anywhere a number does. Arguments can be expressions, calls can be nested, and implicit multiplication applies just as it does to built-in functions:

f(f(2))                  → 26
2f(1) + 1                → 5
area(sqrt(2))            → 6.283185307
ctof(-40)                → −40
integral(f(x), x, 0, 3)  → 12
Calls using the definitions above

The number of arguments must match the definition: calling f(1, 2) when f has one parameter gives the error “f expects 1 argument”. Custom functions also work inside diff, integral, limit and sum.

Parameters and stored variables

Parameters are local to the function. Defining f(x) := x^2 + 1 does not touch a variable named x that you stored separately, and calling f(3) does not change it either.

Any other name in the formula must be a stored variable when you define the function, and its current value is read each time the function is called. This makes functions with a constant you want to vary easy to write:

k := 2
g(x) := k x
g(3)     → 6
k := 5
g(3)     → 15
The function uses the current value of k

If the name is not stored yet, the definition is refused with a message such as “"c" is not a parameter of t and is not defined”. Store the value first, or add it as a parameter.

Rules for names

  • Use letters, digits and underscores, starting with a letter: area, hyp, v_0. Keep digits at the end of a name (x1, f2) so they are not read as a separate number.
  • Built-in names cannot be redefined: sin(x) := 2 gives the error “"sin" is a built-in function and cannot be redefined”. Constant names such as pi and e, and ans, are reserved too.
  • Up to five parameters are allowed, and each parameter name must be different.
  • Do not use the name of a saved custom function as a parameter. After r(x) := sqrt(x - 2), a definition such as area(r) := π r^2 is refused because r is read as the function; use another letter or delete r first.
  • A function cannot call itself. Because there is no way to stop the recursion, a self-referencing definition reports that it “calls itself too deeply”.
  • To change a function, enter a new definition with the same name.

Managing saved functions

Open Variables from the toolbar to see your custom functions next to your variables and the memory M. Selecting a function inserts its name at the cursor; the delete button removes it, and Clear all removes every variable and function. Definitions are stored in your browser’s local storage on this device, so they are still there the next time you open the calculator in the same browser, but they are not shared with other devices.

Tables and graphs of f(x)

The function table calculator at the top of this page evaluates f(x) over a range of x and can compare it with a second function g(x). The graphing calculator has its own definitions: type f(x) = x^3 - x in one row and use f in the rows below it. The guide How to use a formula calculator with variables shows when to choose a function and when a variable is enough.

f(x) on a Casio or TI calculator

Handheld calculators have similar features under other names. The Casio fx-570CW and fx-991CW register f(x) and g(x) as “defining equations” that you can then evaluate, and on a TI-84 Plus you enter functions as Y1, Y2 and so on in the Y= editor. Both are limited to their fixed names; here you can name a function anything that is not built in, give it up to five variables and keep as many as you need. Key sequences differ between models, so check the guide for yours (linked under Sources).

Frequently asked questions

What does f(x) mean?

f(x) is function notation, read “f of x”. f is the name of the function, x is the input, and f(x) is the output for that input. If f(x) = x² + 1, then f(3) = 3² + 1 = 10.

How do I evaluate a function with the calculator?

Define it with :=, for example f(x) := x^2 + 1, press Enter, then type the call with your value, such as f(3), and press Enter again. The answer is 10.

Is f(a + h) the same as f(a) + h?

No. f(a + h) adds h to the input; f(a) + h adds h to the output. With f(x) = x² + 1, f(2 + 0.5) = 7.25 but f(2) + 0.5 = 5.5.

How many variables can a custom function have?

Up to five, for example vol(l, w, h) := l w h. For more inputs, store some of them as variables and use those names inside the formula.

Do my functions stay after I close the page?

Yes, in the same browser on the same device. They are kept in local storage until you delete them, use Clear all, or clear the site data.

Can I use a custom function inside diff or integral?

Yes. For example, with f(x) := x^2 + 1 defined, integral(f(x), x, 0, 3) gives 12, the integral of x² + 1 from 0 to 3.

Tools on this page

Scientific Calculator

Type or tap expressions with exact fractions, memory, variables, constants and complex mode.

Function Table Calculator

Tables of values for one or two functions with exact fractions, roots, turning points, a graph and CSV.

Graphing Calculator

Plot functions, equations, inequalities, parametric and polar curves; find roots and intersections.