Last edited by AHelper on 31 Aug 2016 10:25:13 pm; edited 15 times in total

<notice> gCAS2 is finishing up its transition to a new parser. I still am finding some expressions that don't work (less crashing, more errors reported, thankfully). The library contains z80 optimized functions as well as C ones.

The first section here is of me writing gCAS version 1. it was a standalone program that got the CAS push for my OS. After i wrote it, i noticed that the way i made the nodes was going to be very unoptimized for algorithms. So, i rewrote it from scratch as gCAS2. it runs on GlassOS and on linux (not maintained unless needed). For GlassOS, it comes in two parts: libgcas2.so and gCAS2. The library contains the cas backend and can be used by any program. gCAS2 is a graphical frontend to be used to interface with it to do interactive math.

Congrats to Graph3DP for using gCAS2 as its math backend

<old>Well, I began writing a CAS this morning. I had read very little on the topic. Regardless of this setback, I already have a library that can parse input, create a listing of it, and finally make a node tree. I have algorithms written, but I haven't used them yet (to solve the tree and get an answer).

Here is a screenshot of the library parsing a function.

This runs nicely on

[nikky] the free market will decide who gets to be on the channel and who isn't
Array(16).join("wat" - 1) + " Batman!"
CC20: Air

It handles variables specially and has special algorithms for expanding (distributing), simplifying stuff, powers, etc.. Functions will be done later on. It allows externally defined variables, so everything looks good for the future.

(A calc library in under 12 hours o_O)

[nikky] the free market will decide who gets to be on the channel and who isn't
Array(16).join("wat" - 1) + " Batman!"
CC20: Air

Last edited by AHelper on 31 Aug 2016 10:25:13 pm; edited 1 time in total

Heh, day 2 and mCAS is working much better. It is solving stuff better, yet it is still lacking powers, functions, and parentheses. I am handling variables much better as I can now store values to them (just numbers for now, later it will be anything that you want) and delete them. Here is the latest build working with base powers and variables:

(The tree dump line is a recursive printout of the assembled node tree)

Current size for x86: 22k
Memory usage is still very low

[nikky] the free market will decide who gets to be on the channel and who isn't
Array(16).join("wat" - 1) + " Batman!"
CC20: Air

Last edited by AHelper on 31 Aug 2016 10:25:13 pm; edited 1 time in total

They are AFAIK -_- Hence the little (R)

I am working on some random function research, so I may get to it later today... maybe some more alg's for evaluating stuffs

<edit>

Ok, now parenthesis work! Please look at the tree dump lines to see how the logic flow is changed

(Watch the change in paren. placement in the tree)

Next are functions which simply need me to handle creating the node and upwards. Parsing them are already supported.

Also, I hope that I will compile this for the TI84 in 24 hours just to see is run just as well as on linux. Now, this will never run with TIOS since I need ~7kb of ram (without optimizing anything so far and ONLY when I stress it)..

[nikky] the free market will decide who gets to be on the channel and who isn't
Array(16).join("wat" - 1) + " Batman!"
CC20: Air

Last edited by AHelper on 31 Aug 2016 10:25:13 pm; edited 1 time in total

Yay, mCAS runs on a TI84!!! Enjoy typing in fun expressions and see it spit out answers. It has no error checking when parsing what you type, so if you try to break it, it will break. Anywho, here's an unofficial post of GlassOS (unsigned of course):

I have the above version running on my calc. I hope it doesn't die at school! (pull battery, hold [del], put back in) works at resetting the OS. There is still no on feature, so it sucks the batteries @15mHz mode since I am too lazy to slow it down in getc functions and such...

Seems pretty nice. However I would maybe tell Critor about this project because of its name, since he already used the name mCAS for a CAS program intended to be used with the regular TI-Nspire models. (To save money)

Last edited by AHelper on 31 Aug 2016 10:25:13 pm; edited 1 time in total

one should always bring > 1 calculators to school, preferably including a 68k somewhere...

<edit>

Here's mCAS running on a TI84...

<edit>

Well, running it for a day did expose an odd error... It seems like the parenthesis aren't splitting right (I need to see it with debug output). Typing in Code:

(5!/(3!*(5-3)!)*3*3

gives a random answer, but putting the *3*3 in front gives the right answer... Seems like floating point alg. failures since I get negative numbers :-S Other than that, I realized how much I need a scrolling list widget for the GUI and that putchar needs scrolling, not flipping. When trying to crash it, it just pukes on the screen, but it didn't stop it... Other than that, solid. I need to enable the X variable button because hitting alpha-x-alpha+2 takes a little too long... Also the getc needs to allow holding down the modifier keys as a 'temp hold'. Should be that hard to do...

Anyways, a great way to find areas that need fixing

[nikky] the free market will decide who gets to be on the channel and who isn't
Array(16).join("wat" - 1) + " Batman!"
CC20: Air

That's looking great! I have my own personal way of evaluating expressions that is very memory efficient, and just requires the modification of the expression string. If you're interested, i can write up some information about this method.

I will rewrite gCAS's node layout to be less memory-intensive. This should make the code overall smaller since I will have to manipulate stuff less (no pointers to structs in a struct, just a struct with the variables in it).

I was trying to get distributing working, but just made a huge memory leak somewhere even though my code should work (again, I need to restructure stuff)

As for functions... There will be two kinds that I will make (optimized). The first one is a 1-2 parameter node function, such as sin(, cos(, sqrt(, etc. These can be put anywhere in the evaluation string (I will parse them). The second will be one line functions (In TIOS, think like disp vs. tan), but I don't know of anything just yet...

Lastly, I badly need a listwidget (for GlassOS to draw the scrollback) and an updated textbox so that entering things will be less painful (like hitting tan( will actually type out tan( in the textbox).

Fun stuff for a z80, considering that the IEEE math functions aren't that far off... i found them to be precise within 3~4 digits. That shouldn't be a big issue for right now...

[nikky] the free market will decide who gets to be on the channel and who isn't
Array(16).join("wat" - 1) + " Batman!"
CC20: Air

First, note that gCAS has a lot of unused PC-side functions included, nor is it optimized at all

The current gCAS size is: 15881 bytes

Some of the space was wasted on me not linking IEEE math functions, others on debug functions, and the rest on bad code (filthy switch() blocks). Expect the size of this to go way down later this week when I rewrite the node system.

[nikky] the free market will decide who gets to be on the channel and who isn't
Array(16).join("wat" - 1) + " Batman!"
CC20: Air

And hence why I like to glare at SDCC. No problem with regards to leaving that out, I didn't think it was intentional. Best of luck with your optimizations! Feature-wise, it supports the four arithmetic functions, factorial, and parentheses?

Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.