Absolute Value Expression Evaluator at a Given Input
With x set to 4, |2*x − 5| + 3 gives 6, because the bars turn 3 into its distance from zero before adding 3. Type an expression and a value for x to get the result in one step. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Expression
- |2*x - 5| + 3
- X
- 4
- Result
- 6
This absolute value expression evaluator substitutes a numeric input for x, applies ordinary arithmetic, and turns every quantity between absolute value bars into its nonnegative magnitude. It is designed for quick checks of homework, worked examples, formulas, and program-generated expressions. Enter explicit multiplication with *, use parentheses when needed, and receive the evaluated numeric result without symbolic rearrangement or equation solving. The same deterministic calculation works for positive, negative, fractional, and exponential numeric inputs.
Enter the expression and the value of x
Write an arithmetic expression that contains at least one pair of absolute value bars, and use x wherever the supplied input should be substituted. Use * for multiplication, / for division, ^ for powers, and parentheses to make grouping explicit. Both lowercase x and uppercase X are accepted, while other variable names are not.
Decimal numbers and scientific notation are supported, so expressions such as |1.5*x - 2| or |2e3/x| can be evaluated directly. The evaluator intentionally requires explicit operators: write 2*x rather than 2x, and write 3*(x + 1) rather than 3(x + 1). This convention prevents an expression from being interpreted in an unexpected way and makes copied results easier to audit.
An empty expression, an unsupported character, a missing input, or an expression longer than the published limit is rejected with a clear input error instead of producing a guessed result.
Apply the nonnegative-magnitude rule
Absolute value reports distance from zero, so its result is never negative. After substitution and arithmetic inside a pair of bars, the evaluator changes a negative intermediate value to its positive magnitude and leaves zero or a positive intermediate value unchanged. Arithmetic outside the bars is then applied normally, which means |x| - 10 can certainly have a negative final result even though the absolute-value portion itself is nonnegative.
Standard precedence is used: powers bind before multiplication and division, which bind before addition and subtraction; parentheses and bars establish explicit groups. Several separate absolute-value terms may appear in one expression, such as |x - 2| + |x + 2|. Division by zero and any operation that produces a non-finite numeric value are rejected rather than returned as Infinity or NaN.
Read and reuse the numeric result
The response repeats the original expression and the supplied x value alongside one numeric result. Repeating the inputs is useful when you evaluate a list of cases, store answers in an audit record, or compare results from the two sides of a piecewise definition. This capability evaluates; it does not solve an equation, simplify a symbolic formula, draw a graph, or explain every algebraic step.
If an expression contains an equality such as |x| = 4, use an equation-solving tool instead. For classroom checking, calculate your own intermediate value inside the bars and compare it with the returned result. Because there is no network access, randomness, clock input, or hidden state, identical valid inputs produce identical outputs across repeated runs.
What you can do with it
Check an algebra exercise
Substitute the assigned x value and confirm that a signed intermediate quantity becomes a nonnegative magnitude inside the bars.
Test a piecewise formula
Evaluate representative inputs on either side of a breakpoint before converting an absolute-value formula into piecewise form.
Validate generated expressions
Run deterministic spot checks on expressions produced by a worksheet, tutoring application, or calculation pipeline.
FAQ
What does the evaluator return?
It returns the original expression, the supplied x value, and the final numeric result after applying absolute value and arithmetic.
Can the final result be negative?
Yes. Each value inside bars becomes nonnegative, but subtraction or other arithmetic outside the bars can make the complete expression negative.
Which operators are supported?
Use +, -, *, /, and ^, together with parentheses, absolute value bars, numeric literals, and the variable x.
Does it solve absolute value equations?
No. It evaluates an expression at one supplied input. An expression containing an equals sign belongs in an equation solver.
How should multiplication be written?
Use an explicit asterisk, such as 2*x or 3*(x + 1). Implicit forms such as 2x are rejected.
Related tools
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/absolute-value-evaluate \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"expression":"|2*x - 5| + 3","x":4}'const res = await fetch("https://api.kit.forhosting.com/algebra/absolute-value-evaluate", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"expression": "|2*x - 5| + 3",
"x": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/algebra/absolute-value-evaluate",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"expression": "|2*x - 5| + 3",
"x": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/algebra/absolute-value-evaluate", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"expression":"|2*x - 5| + 3","x":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"expression":"|2*x - 5| + 3","x":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/algebra/absolute-value-evaluate", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"expression": "|2*x - 5| + 3",
"x": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "algebra.absolute_value_evaluate",
"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_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. |
Technical notes
Enter the expression and the value of x
For example, |2*x - 5| + 3 at x = 4 first replaces x with 4.
Apply the nonnegative-magnitude rule
Thus |2*x - 5| at x = 4 becomes |3| and evaluates to 3, while the same expression at x = 1 becomes |-3| and also evaluates to 3.
Read and reuse the numeric result
For automated use, send one expression and one finite x value per request, then consume the result field as a JSON number. Calls through the API use the displayed base price of $0.002; the browser version uses the same deterministic algorithm.
Technical questions
What does an API request cost?
Each API request costs $0.002. The calculation can also run locally in the browser.