Search code examples
pythonti-nspire

Can TI NSpire CX II python call built-in functions?


Texas Instruments recently added direct python programming to their TI Nspire CX II models.

The calculator's built-in functions already consists of a list of very powerful math APIs. For example, can you invoke in python the isPrime() built-in function?

I am aware, this function can easily be re-created as a python module in NSpire. But there are more built-ins functions aside from this. Is there a way for Nspire's python to invoke these built-ins?


Solution

  • After installing Ndless and khicas into my two calculators TI Nspire CX CAS II and TI Nspire CX CAS, in the khicas documentation describes something like:

    Unlike adaptations of Micro-Python by calculator manufacturers (including Casio), the Python syntax in Xcas is fully integrated. You can therefore use all Xcas commands and data types in your programs. This corresponds approximatively to importing Python modules math, cmath, random, scipy, numpy, turtle, giacpy. There is also a small pixelised graphic commands set (set_pixel(x,y,c), set_pixel() to synchronize display, clearscreen(), draw_line(x1,y1,x2,y2,c), draw_polygon([[x1,y1],[x2,y2],...],c), draw_rectangle(x,y,w,h,c), draw_circle(x,y,r,c), the color+width+filled c parameter is optional, draw_arc(x,y,rx,ry,t1,t2,c) draws an ellipsis arc). And you can somewhat replace matplotlib with graphic commands of χ CAS (point, line, segment, circle, barplot, histogram and all ...plot... commands). Plus you have natural access to data types like rationnals or expressions, and you can run CAS commands on them. The complete list of commands available on the calculator is given in appendix. For documentation on commands not listed in the catalog categories, please refer to Xcas documentation.

    At present for TI Nspire CX CAS II, its python environment could not call the nspire's built-in math functions.