# Function Plotter



## nims11 (Feb 10, 2011)

I wrote this function plotter for my Csc school project. It takes mathematical function(any function of 'x' containing brackets, basic operators(+,-,/,*,^), trigo functions, log,floor,ceil) from the user in form of a string and then evaluates it and plots it in a graph. My program supports multiple plotting of graph and allows graph manipulation options like increasing precision, zooming in/out and shifting.

i want to share this with you guyz.

The main challenge(which ) of this program was "How do i evaluate a mathematical function from a string without restricting the functions inputted by user" which i solved by writing a header file for string evaluation. it has few minor bugs which i will resolve after my board exams.

please run it and let me know of bugs and features that can be added. Should i upload the code too?(its quite shabby and even i confuse sometimes with it).

i have attached the compiled '.exe'. 
to avoid bugs, enclose the unary functions in a bracket. eg . x-sin(x) gives a wrong plot(i still need to figure out why) but writing it as x-(sin(x)) works properly.
Function Plotter


----------



## furious_gamer (Feb 10, 2011)

nims11 said:


> I wrote this function plotter for my Csc school project. It takes mathematical function(any function of 'x' containing brackets, basic operators(+,-,/,*,^), trigo functions, log,floor,ceil) from the user in form of a string and then evaluates it and plots it in a graph. My program supports multiple plotting of graph and allows graph manipulation options like increasing precision, zooming in/out and shifting.
> 
> i want to share this with you guyz.
> 
> ...



That is how programs work basically. Ever heard about precedence, then you shouldn't have asked this question.

Read This


----------



## nims11 (Feb 10, 2011)

Precedence not a problem. i have well defined it in my code. The problem is that i have not considered '-' as an operator because it can conflict with negative numbers. wherever '-' was used as an operator, i replaced it with(+-). like a-b was evaluated as a+(-b). Everything works fine until a unary function is introduced after a '-'.
even x+sin(x) or x*sin(x) or x-x^2 works fine but program fails when evaluating functions like - .....-sin(x).....


----------



## Sid (Feb 12, 2011)

Hi,

Tried out the application. Will need the code to understand how you are evaluating the given function.

I tried out giving the input as : x + sin(-x) : which gave the correct plot. Now as this is equivalent to : x - sin(x). 

Therefore kinda unsure why it fails to plot the correct values. 

So if you upload the code, please add the comments. Secondly, i want to know if you have read about expression evaluation using binary trees. This comes under infix, postfix, prefix expression evaluation. If you haven't used this technique of solving the expression, I suggest you read up on that and implement it.


----------



## arpanmukherjee1 (Feb 12, 2011)

is it 16bit prog?? 

i get memory read error on 16 bit dos.


----------



## nims11 (Feb 13, 2011)

Nope its a 32-bit program. i wrote it and compiled under Dev-C++


----------



## arpanmukherjee1 (Feb 13, 2011)

nims11 said:


> Nope its a 32-bit program. i wrote it and compiled under Dev-C++



either the file i d/n is corrupted or my both os xp and win 7 r out their minds


----------



## nims11 (Feb 13, 2011)

Let me comment my source code and i will upload it 2mrw


----------



## Sid (Feb 13, 2011)

arpanmukherjee1 said:


> either the file i d/n is corrupted or my both os xp and win 7 r out their minds



I managed to run it on Win X64 Home Premium....


----------



## arpanmukherjee1 (Feb 13, 2011)

nims11 said:


> Let me comment my source code and i will upload it 2mrw



ok . will try to compile with dev-c++ and VC++.

my c++ and c# programs always work. no issues with other exe's or any virus (that i know of). 

most proably the file was changed. 

you should zip/rar the exe and then upload it again. never leave exe on sharing site , it may become contaminated.


----------

