DIGIT-ARC read-only archive · snapshot: July 23, 2026

Function Plotter

10 posts · originally from https://geek.digit.in/community/threads/function-plotter.136787/

nims11
nims11 Original post #1
Feb 10, 2011 at 5:39 PM
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 at 6:02 PM
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

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

Read This
nims11
nims11 #3
Feb 10, 2011 at 6:32 PM
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).....
S
Sid #4
Feb 12, 2011 at 2:18 PM
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 at 9:23 PM
is it 16bit prog??

i get memory read error on 16 bit dos.
nims11
nims11 #6
Feb 13, 2011 at 7:25 AM
Nope its a 32-bit program. i wrote it and compiled under Dev-C++
nims11
nims11 #8
Feb 13, 2011 at 6:40 PM
Let me comment my source code and i will upload it 2mrw
arpanmukherjee1
Feb 13, 2011 at 10:26 PM
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.