How difficult would making a CAS program be?

I'm just being curious about building a CAS (computer algebra system) application in console mode.
It should be able to take a simple algebraic expression like
x+3=56
and then evaluate x as 59.
My ideas were:
1) split into two parts - x+3 and 56.
2) identify the variable (x) and it's modifiers (+3)
3) create an empty string
4) copy '56' into it, and then append '-3'
5) evaluate ("56-3")

so shortly, what would be the best way to go about this?
and if it is TOO DIFFICULT and TROUBLESOME, just tell me, and I will stop thinking about it.

Thanks
> How difficult would making a CAS program be?

For simple algebraic expression like x+3=56 (symbols, arithmetic operators, paranthesized expressions, mathematical and trigonometric functions etc.), it is fairly straightforward. For instance, it wouldn't take more than a day to write up a Pratt parser to generate the abstract syntax tree which is evaluated using the interpreter pattern.

It gets exponentially heavier as one adds domains - matrices, rationals, complex, differential equations ... And the simple approach above would collapse under the weight.

Perhaps you should consider using a library - for instance SymbolicC++ (caveat: viral).
http://issc.uj.ac.za/symbolic/symbolic.html

Or if a complete program that you can just execute - for instance OpenAxiom
http://www.open-axiom.org/index.html (non-viral)

A list and more links:
http://en.wikipedia.org/wiki/List_of_computer_algebra_systems
well for single variable non polynomial equations like you presented is a piece of cake.

first off you need to receive input, a string or array of chars.
then you need to break it down using a custum made parser, thats a program that reads strings and turns it into data.
and lastly its just ordinary arithmetics to solve it.

But if you want a real challenge make a program where

input = N eqations with N variables

and output = the solution to N variables.

ofcoarse if you studied linear algebra then that should guide you, but if you didnt then improvise something, could be great practice.
Topic archived. No new replies allowed.