user8080124
user8080124

Reputation:

using the eval function in the TI-Nspire math library

I am trying to understand how to use the TI-Nspire CAS system through Lua. I am trying to emulate the solve(x+5/3,x) functionality found in the TI-Nspire CX CAS gui.

I looked through the API Docs found here : https://education.ti.com/download/en/ed-tech/59108CCE54484B76AF68879C217D47B2/7EFB09CED41C4190AFF8F60283B6727A/TI-NspireLuaScriptingAPIReferenceGuide.pdf

I believe what I am looking for is the eval function on page 51 although I can't find much online to sample from. The examples provided are not concrete ones.

math.eval(math_expression) --apilevel = 2.0
math.eval(math_expression, [exact]) --apilevel = 1.0
local expr = "f1("..mx")"
return math.eval(expr)

Iv'e tried

require "math"
local answer
answer = math.eval("f1(x+3/4,x)")
answer = math.eval(x+3/4,x)
answer = math.eval("5+9")

I keep getting the error "cannot execute during initialization."

1) How do you fix the error

2) May I have some concrete examples of using the function

Upvotes: 5

Views: 430

Answers (2)

user8080124
user8080124

Reputation:

This works!

function on.paint(gc)
    local var1
    var1 = math.eval("nsolve(x+4=8,x)")
    gc:drawString(var1, 2, 20)
end

Upvotes: 2

Piglet
Piglet

Reputation: 28940

From the TI-Nspire Lua Scripting API Reference Manual 12.1 math.eval:

Warning

math.eval is not available during script initialization

To avoid this error do not call the function befor script is initialized.

Upvotes: 2

Related Questions