Function iteration calculator
The function iteration calculator repeatedly applies the same real-valued expression to a starting number and returns every point in the resulting orbit.
Run — free
Enter an expression in x, choose x_0, and specify how many iterations to perform. The result includes the initial value, each successive output, and the final value. It is useful for studying recurrence relations, fixed points, cycles, convergence, divergence, and the first steps of simple dynamical systems without calculating each substitution by hand.
Enter the function and starting value
Write the rule as an expression in x, such as x^2 - 1, cos(x), or 0.5*x + 3. The calculator supports parentheses, decimal and scientific-notation numbers, the operators +, -, *, /, and ^, and the constants pi and e. Supported one-argument functions include abs, sqrt, sin, cos, tan, exp, ln, log, floor, ceil, and round. Multiplication must be explicit, so write 2*x rather than 2x. Next, provide a finite real starting value. This is x_0, the first member of the orbit, not the result of the first application. Finally, choose an iteration count from zero through one thousand. A count of zero is meaningful: it returns the starting point alone and can help confirm that the input has been interpreted correctly. Expressions are parsed as mathematics rather than executed as code, so names, syntax, and operations outside the documented grammar are rejected with a clear input error.
Read the orbit in the correct order
If the entered rule is f and the starting value is x_0, the calculator computes x_1 = f(x_0), then x_2 = f(x_1), and continues until x_n. The orbit array therefore contains n + 1 values: the starting value at index zero followed by one value for each requested application. The final_value field repeats the last member for convenient use in scripts, while iterations records how many applications were actually requested. This distinction prevents a common off-by-one mistake. For example, requesting three iterations does not return three total points; it returns x_0, x_1, x_2, and x_3. Values are normalized to fifteen significant digits to reduce distracting binary floating-point tails while retaining useful precision. That normalization does not turn numerical iteration into symbolic algebra, and rounding can influence extremely sensitive systems after many steps. Treat long chaotic orbits as numerical approximations, especially when nearby starting values separate rapidly.
Interpret convergence, cycles, and failures
Successive values often reveal the qualitative behavior of a recurrence. When later entries settle near one number, that number may be an attracting fixed point: substituting it into the function produces approximately the same value. Alternation between a small set of repeating values suggests a cycle, while steadily increasing magnitudes may indicate divergence. A finite list cannot prove any of those behaviors by itself, but it provides evidence and a practical starting point for analysis. Compare orbits from several nearby initial values when investigating stability. The calculator stops with an input error if an operation produces Infinity or NaN, as can happen after division by zero, a square root of a negative number, or logarithm of an invalid value. That error identifies the iteration where the real-valued orbit ceased to exist. The fixed limits on expression length and iteration count also keep browser and API execution predictable. No network request, randomness, clock, or hidden state affects the calculation, so identical valid input produces identical output.
What you can do with it
Explore a recurrence relation
Generate x_0 through x_n for a rule such as x^2 - 1 without repeating substitutions manually.
Look for fixed-point convergence
Inspect whether successive outputs settle near a value that is unchanged by another application.
Compare nearby starting values
Run the same nonlinear function from close initial conditions and compare how their numerical orbits develop.
FAQ
Does the orbit include the starting value?
Yes. The first entry is x_0, followed by one output for every requested iteration.
Which expression syntax is supported?
Use x, numbers, pi, e, parentheses, +, -, *, /, ^, and the documented one-argument functions. Multiplication must be written explicitly.
What happens if an iteration is undefined?
The calculation stops and returns an invalid-input error naming the iteration that produced a non-finite value.
Why can a chaotic orbit differ from a theoretical exact result?
This is numerical floating-point iteration. Small rounding differences can grow rapidly in sensitive dynamical systems.
How much does an API calculation cost?
Each API request costs $0.002. The same deterministic calculator is also available in the browser.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/algebra/function-iteration \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"function":"x^2 - 1","start":1.5,"iterations":4}'const res = await fetch("https://api.kit.forhosting.com/algebra/function-iteration", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"function": "x^2 - 1",
"start": 1.5,
"iterations": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/algebra/function-iteration",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"function": "x^2 - 1",
"start": 1.5,
"iterations": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/algebra/function-iteration", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"function":"x^2 - 1","start":1.5,"iterations":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"function":"x^2 - 1","start":1.5,"iterations":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/algebra/function-iteration", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"function": "x^2 - 1",
"start": 1.5,
"iterations": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "algebra.function_iteration",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_iterations | 1000 |
max_expression_chars | 500 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |