# Expression Manipulator v0.2 (bug fixes, functions)

• 05-26-2003
ygfperson
Expression Manipulator v0.2 (bug fixes, functions)
Here's the source code. I'll upload an executable a short while later (in the morning, likely).

New Features:
- functions: 6 constant trig functions, log functions, and any number of user-defined functions
- new subtraction rules
- all known bugs fixed

Features:
- 4 regular functions plus raising to a power
- boundless limits on name sizes and recursion
- simplification functions

Usage:
Code:

`sin(cos(0))*3+4(5-x)^3`
Output:
Code:

```3*sin(cos(0)) + 4*[5 + -1*x]^3 = 3*sin(cos(0)) + 4*[5 + -1*x]^3 3*sin(cos(0)) + 4*[5 + -1*x]^3 = 3*sin(cos(0)) + 4*[5 + -1*x]^3 3*sin(cos(0)) + 500 + -300*x + 60*x^2 + -4*x^3 = 3*sin(cos(0)) + 500 + -300*x + 60*x^2 + -4*x^3 2.52441 + 500 + -300*x + 60*x^2 + -4*x^3 = 2.52441 + 500 + -300*x + 60*x^2 + -4*x^3```
6 trig functions:
sin, cos, tan, cot, sec, csc
2 log functions:
log - base 10
ln - base e

f() is defined to be f(x) = x+y, although it could be any expression.
Code:

```f(3)g(3) would become (3+y)*g(3)```
Comments? Questions? Suggestions? (Just fyi, terms aren't combined at the end, though nothing prevents them from being combined)
• 05-26-2003
ygfperson
Here's the executable, source code, and all:
• 05-26-2003
Prelude
I take it you've removed the bugs you wanted me to look at? ;)
• 05-26-2003
Silvercord
I keep trying to type in equations but it closes the window and there are no discernable results (what am I doing wrong? I tried typing expressions similar to the example you gave). I've been looking through the source, it looks really cool I wish I'd written it. Did it take ya a long time to write? What was this project for? Fun? School? Get laid?
• 05-26-2003
ygfperson
Quote:

Originally posted by Prelude
I take it you've removed the bugs you wanted me to look at? ;)
lol... yeah...

Turns out I was using a reference where I should have used a local copy of the variable. My substitute function inputted a const reference to compare each copy in the vector with; but that reference was replaced during the for-loop, crashing the program.

Quote:

I keep trying to type in equations but it closes the window and there are no discernable results
You need to run the program from a command prompt. Windows closes the window before you have a chance to see what the result was.
Quote:

I've been looking through the source, it looks really cool I wish I'd written it. Did it take ya a long time to write?
Around 2 or 3 months... but I only worked on weekends and for a few hours at a time.
Quote: