2,393 bytes added,
22:56, 6 October 2012 <span style="font-weight: bold;">math.eval</span> is a math library extension. <br>
The function calls the math server with the specified arguments and returns the result if possible, as a string.<br>
This function sends an expression or command to the TI-Nspire math server for eval-uation. The input expression must be a string that the TI-Nspire math server can interpret and evaluate. The evaluation is performed using the current document settings, which can be overriden by math.setEvalSettings. NOTE: All evaluations are performed at full precision regardless of the document settings or overrides.
Beginning with platform.apiLevel = '2.0' (OS 3.2), the evaluation is performed using the current document settings, except that all evaluations are performed at full precision in approximate mode. The current document settings can be overriden by math.setEvalSettings. <br> If the math server evaluates the expression successfully, it returns the results as a fundamental Lua data type. <br> If the math server cannot evaluate the expression because of a syntax, simplification, or semantic error, eval returns two results: nil and an error number meaningful to the math server. (The error numbers are documented in the TI-Nspire Reference Guide - Error Codes and Messages for math.eval.)<br> If the math server calculates a symbolic result, it cannot be represented as a fundamental Lua type, so eval returns nil and the string "incompatible data type." <br>
<br>
'''Example''' : To evaluate ''f1'' for a given value in x, the parameter x must be converted to a string, and then any embedded "e" must be replaced with Unicode character U+F000. <br>
<source lang="lua">local mx = tostring(x):gsub("e", string.uhar(0xF000))
local expr = "f1(" .. mx .. ")"
return math.evalStr(expr)</source>
<br>
== Syntax ==
math.'''evalStr(expression)'''<br> evaluates "expression" (can contain TI-Basic arguments) and returns a result if possible, as a string.<br>
Expression can contain everything a TI-Basic function can contain. You can seperate statements using ":". <br> It can also contain calls to user defined functions in the document, or functions in global libraries.
<br>
== Example ==
<source lang="lua">math.evalStr("sqrt(16)") -- returns "4"</source>
<br>
== See also ==
[[math.eval]]
[[Category:Extended_Standard_Library]]