Solve functions (Xsolve)
Syntax: Xsolve_<parameter>
Solver What-If Analysis similar to Goal Seek with each API call to solve for a particular input value. For example, Xsolve can be used to determine the sum assured for a life insurance policy given a target policy premium.
If a Spark service has multiple solves, they will be executed in alphabetical order.
Sample file
If you have Coherent Assistant installed, you can use the Solver feature to run and trace
Xsolves within the workbook.Upload the file to Spark and test in the API Tester.
Copy the structure into your workbook and tie it into the existing calculations.
Include any additional
Xsolveparameters if required.
Xsolve parameters
Run if
TRUE or FALSE value. Determines whether or not this solve should be executed.
Target cell
Link to the formulated cell that needs to reach the Target value. This is recommended to be defined as a difference between the desired Target value of 0.
This must be a link to a cell on the same worksheet or a Named Range.
Equivalent to Goal Seek Set cell.
Target value
Value of the Target cell to achieve. This is best set to 0.
Equivalent to Goal Seek Target to value.
By changing
Link to the cell that has to change in order to for the Target cell to reach the Target value.
This must be a link to a cell on the same worksheet or a Named Range.
Equivalent to Goal Seek By changing cell.
Solve algorithm
SECANT or BRENT. We recommend using BRENT as it is able to solve more complex workbooks accurately.
Max change
Maximum acceptable value of |Solve result(i) - Solve result(i-1)| within Max iterations, default 1.
Max iterations
Maximum iterations for the number of solve, default 25.
Initial guess
Initial guess to help reach the Target value sooner.
Lower bound
For the BRENT algorithm, the bounds of the solve can be defined at the start of the solve. When this is provided, the Initial guess is ignored.
Upper bound
For the BRENT algorithm, the bounds of the solve can be defined at the start of the solve. When this is provided, the Initial guess is ignored.
Solve started
TRUE or FALSE value.
Spark will write this into the cell during execution. This enables downstream calculations to use this value.
Solve target
Provided in order to help assess how close the solve was in reaching the target, given the solve can conclude within the Max change.
Spark will write this into the cell during execution. This enables downstream calculations to use this value.
Solve iteration
Spark will write this into the cell during execution. This enables downstream calculations to use this value.
Solve result
Successful solve value or #N/A.
Spark will write this into the cell during execution. This enables downstream calculations to use this value.
Solve successful
TRUE or FALSE value.
Spark will write this into the cell during execution. This can be useful in taking the initial solve result and applying a transformation on the solved result. For example, IF the solve is successful, take the By changing value and ROUND the result.
Errors
#CALC!is returned for theSolve resultif:The
Target value,Initial guess,Max change, orMax iterationsare not proper numbers.The maximum iterations is reached.
#NUM!will be returned for theSolve resultif the solve algorithm encounters a zero-slope error.
Trace solve iterations
The Xsolve iterations can be shown by using the request_meta debug_solve.
Open the API Tester for the service.
In API request (inputs), select Raw view.
In the
request_meta, add a comma,to the end of the last entry and then add"debug_solve": true.Submit the API call.
In API response (outputs), select Raw view. Under
response_data,outputs,additional_outputscontains asolve_logarray with a list of the solve iterations.
BRENT algorithm
The implementation aligns with Brent's method.
Bound the independent variable between
0andInitial guess * 100. This can be overridden using theLower boundandUpper boundparameters.Convergence condition
|Solve result(i) - Solve result(i-1)|.
SECANT algorithm
The implementation is inspired by the Secant method. The attached Excel file traces how the algorithm determines a root for a cubic equation.
The solve uses
Initial guessandInitial guess * 1.5as the starting points.Convergence condition
|Solve result(i) - Solve result(i-1)|.
Last updated
