I do a lot of weird graphing stuff like this and there are a lot of issues with the way you're trying to do it.
Firstly, I like to have a bit of a UI, instead of setting the sync rate really low, so I changed your code to this:
`%Project Title%
`%Source File Name%
`======================
`Graph
`Graph.dba
`======================
Yfloat# as Float
MaxTime as float
MaxTime = 400
Yfloat# = 0.0
offset = 200
X as float
do
cls
if upkey() then X=X+.1
if downkey() then X=X-.1
if x<0 then x=0
if x>maxtime then x=maxtime
`This is my formula, crafted on the below websites;
`http://www.wolframalpha.com/
`http://www.mathopenref.com/graphfunctions.html
Yfloat# = abs(50*sin((0.25/4)*X))
circle X+offset, Yfloat#+offset,20
text 0,0,"Offset: "+str$(offset)
text 0,16,"Offset: "+str$(offset)
text 0,32,"Y: "+str$(yfloat#)
sync
loop
end
Just so that you can have user interactivity. Also the print command messes up stuff sometimes so I replaced it with text.
Secondly, as Kevin Picone pointed out, the trig functions used in scientific and mathematical calculations are in radians, not degrees. That means you have to multiply your radian value by 180/pi to get the result in degrees. So now your equation would look like this:
Yfloat# = abs(50*sin((0.25/4)*X*57.2957795))
If we remove the call to "cls" and use the dot function instead of the circle function, we get this:
Yfloat# as Float
MaxTime as float
MaxTime = 400
Yfloat# = 0.0
offset = 200
X as float
do
if upkey() then X=X+.1
if downkey() then X=X-.1
if x<0 then x=0
if x>maxtime then x=maxtime
`This is my formula, crafted on the below websites;
`http://www.wolframalpha.com/
`http://www.mathopenref.com/graphfunctions.html
Yfloat# = abs(50*sin((0.25/4)*X*57.2957795))
dot X+offset, Yfloat#+offset
text 0,0,"Offset: "+str$(offset)
text 0,16,"Offset: "+str$(offset)
text 0,32,"Y: "+str$(yfloat#)
sync
loop
end
The shape is exactly what we want.
The downside of this is that one pixel corresponds to exactly one unit, the y axis is flipped, and we can't translate by half a unit. All of these things can be corrected using adding, subtracting, multiplication and division. To achieve these transformations, you can either take the summarized route (affine transformations) or just think about it until you get it right.
In my graphing programs, I like to have a set of four functions: xPixelToUnit(x as float), yPixelToUnit(y as float), xUnitToPixel(x as float), and yUnitToPixel(y as float). Using this you can get mouse input on the graph and draw anything.