Okay so I know practically nothing about creating mathematical applications in C++ but am trying to learn. Practically everything I search for isn't anything close to what I need. Basically, I need to lean how to make a calculator style app first before continuing on, however I can't find anyone to teach me. Then to top it off, I then need to step it up to where the app can solve complex expressions and equations. When I say complex I'm meaning basic algebra. Not too hard to do, still harder than basic math.

My main concern is polynomials because they are the most interesting to me. I need the user to be able to type in a complete polynomial and the application to solve it with or without the variable assignments.

Example:
// Please note I don't know how to do powers so if a number is an exponent it will have ^ before it.
a = (3x^2 − 4x + 8) + (2x^2 + 5x −12);

This simplifies to a = (5x^2 + x - 4).

The application would have to simplify the problem given. The next example x is given. I want the application to scan the user input for the variables and ask if they have given values. (This is if the user isn't smart enough to exchange them already.

x = 4;
a = (3x^2 − 4x + 8) + (2x^2 + 5x −12)
a = (5x^2 + x - 4)

Simplify;

a = (5 * 4^2 + 4 - 4)
a = (5 * 16 + 4 - 4)
a = (80 + 4 - 4)
a = (84 - 4)
a = 80;

So that's all the information I really have, I just want to learn this, so anyone willing to teach me would be awesome. You would have eternal thanks. (Oh and sorry if the step by step bugs you, it's just a habit of mine. I kind of want the application to show the steps as well.)

// Talk about starting from scratch.
#include <iostream>

using namespace std;

int main()
{
system("pause")
return 0;
}

Unless this is an assignment I would use a library to do this.

Otherwise, some creative design could likely solve the problem, you may want to work out some pseudo-code for the entire program.

It may go something like:

-order-of-operations scan, instantiation of evaluator class if required. Innermost expression is evaluated first, in groups of two "terms".

i.e.,
input: 3 + 8 / 10
evaluator: 8 / 10

-replace "terms" with result.

i.e.,
input: 3 + 0.8

-continue until evaluated.

Edited 5 Years Ago by pseudorandom21: n/a

This article has been dead for over six months. Start a new discussion instead.