Skip to content
Documentation sections

Solve for a target

POSThttps://rftools.io/api/py/v1/calculate/solve

Finds the value of one calculator input that brings one of its outputs to a target (the trace width that gives 50 Ω, the gap that gives a target differential impedance) and returns it with the forward result at exactly that value. One metered call replaces the forward calls a client would otherwise spend searching by hand.

Request body

SolveRequest
FieldDescription
slugrequiredstringThe calculator.
inputsrequiredobject of numbersEvery input except solveFor. A value given for solveFor is only the search's start point, used to break a tie between more than one solution.
solveForrequiredstringA declared numeric input of the calculator.
target.outputrequiredstringAn output key the calculator returns.
target.valuerequirednumberThe value that output should reach.
gridnumberA positive manufacturing grid; the returned value is rounded to its nearest multiple inside the range.
range[number, number]Narrows solveFor's stated bounds; required when it states none.

Response

SolveResponse
FieldDescription
valuenumberThe solved value, rounded to grid when one was given.
unroundednumberThe exact solution, before grid rounding.
reachedbooleanWhether the target was reached; false still carries the nearest value found, not a guess.
evaluationsintegerHow many forward evaluations the search used.
warningsstring[]The solve's own findings: another solution in the range, or a target not reached.
resultobjectExactly what /calculate returns for the inputs with solveFor set to value: values, warnings, errors and provenance.
slug, solveFor, target, gridechoThe request's fields, as given; grid is null when none was.

Cost and ties

Cost

One metered call, charged like /calculate after every check below, and given back if the service then fails. A target the search cannot reach still succeeds and is still charged, with reached: false and the nearest value found: the caller asked for something the service delivered.

More than one solution

Where the output crosses the target more than once inside the range, the call returns the crossing nearest the start value (the caller's own value for solveFor, else the calculator's default) and adds a warning naming the other one.

Refusals

A request that cannot be solved is refused before anything is charged, and param names the field at fault:

Solve refusals
StatusWhen
404The calculator slug does not exist.
400solveFor is not one of the calculator's declared numeric inputs (param: solveFor, with allowed).
400target.output is not one of the calculator's outputs (param: target.output, with allowed).
400grid is given and is not a finite, positive number, or has no multiple in the range.
400Any given value (an input, target.value or a range bound) is not finite.
400solveFor has no stated bound and the body gives no range, or the given range lies outside the stated bounds or is empty.
400A fixed input exceeds a limit the calculator enforces on its own running time, as for /calculate.