Cubic Function Graph Plotter
Cubic Function Graph Plotter
This is a program that enables the user to input the coefficients of a cubic function and draw its graph. The cubic function takes the form f(x)=ax3+bx2+cx+d. We need to create the cubic function with some modifications and the coordinates in computer screen starts from top left therefore instead of x we used a certain number to minus x. !s we define the width of the graph as "# so we used $%x so that the graph starts plotting from the center. &n '( the cubic function takes the following form) Private Function f(x As Variant) f = a * (5 - x) ^ $n# Function To draw the graph we use built%in function *+et. &n this program ,ou need to insert four text boxes for the user to enter the four coefficients a picture box and two command buttons one is to draw the graph and the other one to clear the inputs. -ame the picture box as pic.graph the draw button cmd.draw and the clear button as cmd./lear. ! b * (5 - x) ^ " ! c * (5 - x) ! #
0im x !s 0ouble *ri1ate 2unction f(x !s 'ariant) 3 -eed to make some transformation as the left coordinates in '( start from left 3 our graph starts from center f = a 4 ($ % x) 5 3 + b 4 ($ % x) 5 2 + c 4 ($ % x) + d 6nd 2unction *ri1ate +ub cmd./lear./lick() pic.graph./ls txt.a.Text = 77 txt.b.Text = 77 txt.c.Text = 77 txt. 0im a b c d !s &ntegerd.Text = 77 6nd +ub *ri1ate +ub cmd.draw./lick() 0im , !s 0ouble 0im w !s 0ouble a = 'al(txt.a.Text) b = 'al(txt.b.Text) c = 'al(txt.c.Text) d = 'al(txt.d.Text) 38sing a scale of #.$ cm to represent i unit to draw the graph 3 -eed to make some transformation as the coordinates in '( start from top left 2or w = # To "# +tep #.###" , = f(w) pic.graph.*+et (w $ % ,) -ext w 6nd +ub %he Co#e