:=, 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.
Define the function:
f(x) := x^2 + 1Type the name, the variable in parentheses,
:=and the formula, then press Enter. The line shows that f is defined; nothing is calculated yet.Call it with a value:
f(3)Press Enter to get 10. The calculator substitutes 3 for x: 3² + 1 = 9 + 1 = 10.
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.
| Function | Call | Substitution | Result |
|---|---|---|---|
f(x) := x^2 + 1 | f(3) | 3² + 1 | 10 |
f(x) := x^2 + 1 | f(-2) | (−2)² + 1 | 5 |
f(x) := x^2 + 1 | f(1/2) | (1/2)² + 1 | 1.25 |
p(x) := 3x^2 - 2x + 5 | p(-1) | 3(−1)² − 2(−1) + 5 | 10 |
p(x) := 3x^2 - 2x + 5 | p(2) | 3(2)² − 2(2) + 5 | 13 |
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.001The 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.
| Definition | Call | Result |
|---|---|---|
f(x) := x^2 + 1 | f(3) | 10 |
area(r) := π r^2 | area(2) | 12.56637061 |
hyp(a, b) := sqrt(a^2 + b^2) | hyp(5, 12) | 13 |
ctof(c) := c × 9/5 + 32 | ctof(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.
| Definition | Call | Result |
|---|---|---|
w(x, y) := x^2 + x y | w(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) → 2The 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:
| Definition | Call | What 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) → 12The 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) → 15If 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) := 2gives the error “"sin" is a built-in function and cannot be redefined”. Constant names such aspiande, andans, 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 asarea(r) := π r^2is 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).