PDA

View Full Version : Expression Manipulator v0.2 (bug fixes, functions)



ygfperson
05-26-2003, 12:02 AM
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:


sin(cos(0))*3+4(5-x)^3

Output:


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.

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)

ygfperson
05-26-2003, 12:16 PM
Here's the executable, source code, and all:

Prelude
05-26-2003, 12:20 PM
I take it you've removed the bugs you wanted me to look at? ;)

Silvercord
05-26-2003, 02:35 PM
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?

ygfperson
05-26-2003, 04:52 PM
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.


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.

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.
What was this project for? Fun?Yes.
School?No.
Get laid?I wish. ;)