Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: bwang on December 28, 2009, 09:28:25 pm

Title: A symbolic library for the Nspire non-CAS
Post by: bwang on December 28, 2009, 09:28:25 pm
A combination of boredom, need, and a sudden urge to test the speed of Nspire Basic has caused me to write a symbolic manipulator/CAS for the regular TI-Nspire. It does factorization, expansion, differentiation, and several other things right now, with varying degrees of success and slowness. It most notably DOES NOT support implied multiplication.

Comments/suggestions about the program, its bugs, and its terrible speed (especially the differentiator) are all welcome.

How do you insert images in posts? Clicking the "Insert Image" button just gives me a pair of img tags.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: DJ Omnimaga on December 28, 2009, 10:15:50 pm
Mhmm sounds interesting, I might give this a try when I put my Nspire back in Nspire mode instead of 84+

To insert images you must upload them the same way you upload zip files (like you did with nspire_alg.zip)
Title: Re: A symbolic library for the Nspire non-CAS
Post by: Builderboy on December 29, 2009, 01:15:31 am
Haha, nice to see you finally posted that ;)

Just goes to show, while nSpire Basic might be horrible lacking in the graphics/input department, it does have a very full and functional math department.  Then again, who uses their calculators for Math anymore! :P
Title: Re: A symbolic library for the Nspire non-CAS
Post by: simplethinker on December 29, 2009, 11:09:13 am
How do you insert images in posts? Clicking the "Insert Image" button just gives me a pair of img tags.
Attaching an image to a post will add a thumbnail to the bottom of the post, which can be clicked on to enlarge (it also has a link to download the image).  I don't know of a way to insert the picture anywhere in the post, so to do that you would have to use a website like photobucket or mediafire to host it, then use the forum image tags.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: Silver Shadow on December 30, 2009, 07:01:04 am
I've just tried the lib and it works great! I didn't know you could do that in basic...
By the way, you provide a "hacked" version of one of the TI's libs. What does the "hack" actually change?
Title: Re: A symbolic library for the Nspire non-CAS
Post by: vadko on January 25, 2010, 06:49:49 am
Is there a new version or future plans for a new one?

-Had a previous doubt that was solved as I was hitting 'post'
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on February 02, 2010, 04:16:43 pm
The hacked numtheory lib removes a bunch of error checking and Disp statements. The original had several functions unusable for programming due to a Disp statement in the function before the return statement.

EDIT: It seems like there might be actually people who are using this thing. Does anyone have any interesting feature requests.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: Silver Shadow on February 03, 2010, 03:02:20 pm
Quote
Does anyone have any interesting feature requests.
Not really, just make the existing ones better.

And I also have another question: if I keep TI's original lib, which of your functions will be affected?
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on February 04, 2010, 01:47:40 am
A lot of them. I think the affected ones will mainly be in gfp.tns (in particular, the modinv function). I don't remember if anything else uses numtheory functions. Maybe I should recode the affected functions...
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on February 04, 2010, 02:27:40 am
New version. Hacked numtheory renamed to nt.tns.
Also fixes a nasty display bug in the integrator.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on April 13, 2010, 04:24:44 pm
Hi I've decided to take it on myself to continue work on this library. and Intend to add functionality and speed up execution and optimizing and although I don't yet fully understand the code base yet I would like suggestions on what I should improve
Title: Re: A symbolic library for the Nspire non-CAS
Post by: Silver Shadow on April 14, 2010, 02:05:57 am
It would be cool if someone made an asm version or something, since Ndless2 will be coming out. It would allow for better speed and more functions.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: DJ Omnimaga on April 14, 2010, 02:22:50 am
who uses their calculators for Math anymore! :P
Maths? What are those?
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on April 14, 2010, 06:38:47 am
That post seems vaguely familar
Title: Re: A symbolic library for the Nspire non-CAS
Post by: Eeems on April 14, 2010, 10:27:14 am
Hmm...im getting a wierd sense of deja'vou
Title: Re: A symbolic library for the Nspire non-CAS
Post by: DJ Omnimaga on April 14, 2010, 12:20:29 pm
Maybe most Omnimaga people don't know either or totally forgot? :O

Altough I agree a bit with Builderboy lol. Sometimes we buy a calc but end up using it more often for games than school. :P
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on April 14, 2010, 12:40:01 pm
I was going to write a CAS in C for the Nspire, but I couldn't find any input or output functions :(
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on April 14, 2010, 04:14:08 pm
I was going to write a CAS in C for the Nspire, but I couldn't find any input or output functions :(

That sucks you would definitely get better performance out of a CAS in C hell you wouldn't even need to write it you would just need to build a lisp interpreter and front end for Maxima.  And lisp is easy interpretation.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on April 17, 2010, 10:47:22 pm
I'm proud to report that my optimization efforts are going well even though I don't understand how half the code works but then again my current optimization is much like peephole optimization and function in-lining thous far but it seems to have had some inpack thous far I'm going to upload a copy for people to play with tomorrow. please make sure I didn't break anything.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: DJ Omnimaga on April 17, 2010, 10:53:23 pm
mhmm could you rephrase the second part of your sentence starting on the word "peephole", especially the "thous", "in-lining" and "inpack" parts? I am confused at what you mean x.x
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on April 17, 2010, 11:41:26 pm
thous = thus and inpack = impact, maybe?
I believe there are some places where I calculate the same thing several times over (basically, I want the numerator and denominator of a rational expression, so I simplify it 3 times). I think that's a good place to start optimizing if you want big speedup for relatively little work.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: Silver Shadow on April 18, 2010, 04:10:02 am
@Eeems: it's déjà-vu not deja'vou. :P
Title: Re: A symbolic library for the Nspire non-CAS
Post by: tensuke on April 18, 2010, 06:09:56 pm
A CAS in C would be nice for those of us stuck on 1.1 :P
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on April 18, 2010, 06:55:18 pm
I actually don't fully understand how the library works yet but think there are better places to start like for example gutting parsing engine and rewriting it, refracting the way operators are handled and reducing excessive function calls. additionally I can make rather significant gains using matrix and list math for many where they are neglected for loops.  As I have said thus far I have only really done compiler like optimizations (and replacing the bubble sorts with something respectable) meaning I've reduced obviously redundant operations, remove excessive variables and copying, and operator strength reduction.

(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)
(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)
(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)(http://www.omnimaga.org/Themes/omnimaga4/images/english/modify.gif)

here's the promised working copy
Title: Re: A symbolic library for the Nspire non-CAS
Post by: DJ Omnimaga on April 18, 2010, 06:59:37 pm
I also merged your double-post. :P
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on April 25, 2010, 01:41:00 am
I'm really embarrassed the library I posted doesn't work It just explodes anyway heres a working version of the library.
and good news I think I've figured out why the differentiation function is so slow and am working to fix it I think It will be a very small modification to the pf2tree function or the pf2tree function and it will be crazy much faster. I forget which at the moment. still happy day.  :)
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on May 02, 2010, 07:18:37 pm
unfortunately I was wrong as to why the differentiation function is slow it turns out that it's because the algebraic reduction portion that it is slow.  This posses a significant challenge to optimize. although I'm working hard to figure out this portion of the library but progress is slow and i have unfortunately some how broke something in it and I don't know what so that has set me back almost a week. :( I'm going to have to start doing nightly backups.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: DJ Omnimaga on May 02, 2010, 07:25:55 pm
sorry to hear x.x
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on May 02, 2010, 09:16:58 pm
I think you can greatly increase the speed of the differentiator by writing a modified algebraic simplifier that returns the numerator and denominator in a list. Right now I calculate every expression twice to get the numerator and denominator.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on May 02, 2010, 09:23:54 pm
Where would I find this problem.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on May 02, 2010, 09:25:37 pm
Look in the algebraic simplifier. I remember it was terribly unoptimized.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on May 02, 2010, 10:38:41 pm
I'ce been playing with it but I don't understand the structure of your tree if you remember how the trees work that would be a big help because I have not been able to make heads or tails out of the out put of pf2tree() if you could explain what the 2 numbers preceding each token mean it would be greatly appreciated. Because not understanding that has been my biggest problem and has caused me to think about rewriting the whole simplifier from scratch something I was not looking foward to. I do realize that you may not remember though cause this Library is huge and I don't think i have even lookedat half of it yet.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on May 02, 2010, 10:46:23 pm
The trees are stored as lists, with the root being the first element of the list, and the lengths of the lists representing left and right subtrees being the two numbers following it.
Title: Re: A symbolic library for the Nspire non-CAS
Post by: theUnnamed on May 04, 2010, 10:43:48 am
I thank you for your help and support in my endeavors in optimizing this library.  This is nothing against your code or your talent but I think I'm going to replace your entire algebraic simplification with one of my own design. This is not because I think your design is poor it is just that I have my own simplifier halfway finished from before I started work on your library so I think that it will be easier for me to finish my simplifier then it will be for me to optimize yours because I understand mine better. :D additionally I don't want all the time I spent designing my CAS structure to go to waste although I do think I will be using your postfix notation generator because it make building my rather complicated structure far easier.

In other news what does libexpr\collect() do? And how often do you factor numbers outside of the algebraic simplifier because I was wondering if it would be worth my time to replace my\factorsmatrix() with my own version that I don't currently have typed up but is faster and deals with fractions by expressing the denominator as primes to negative exponents but is about twice the size (needed it for my own polynomial tools and wrote it totally independently of ti
Title: Re: A symbolic library for the Nspire non-CAS
Post by: bwang on May 04, 2010, 11:17:36 am
You don't need to re-code the factoring function; the library is not going to factor anything bigger, than, say 10.
I think libexpr\collect() collects terms in an expression specified by a matrix, but I could be wrong (its been 6 months since I've looked at the code).