Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can QBasic do graphs of log base 2 of x, etc?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
For my calculus class I am doing a project where I must present graphs of various functions, ranging from functions as simple as y = x and y = x^3 to ln(x), log base 2 of x, and the square root of a^2 - x^2. Am I going to be able to create graphlike images of these functions using QBasic, or am I barking up the wrong tree? I know I'll be able to graph sin(x) and such because I used a loop and the line function to create an imitation sin curve already. What I'm more concerned about is the log base 2, whether there will be a way to graph that or not.

Also I'm using QBasic 1.1; will that place any limitations on what I can do that getting a higher version would solve?

-Mappiq
 
using qb1.1 will limit you (i use it also) but not to the point that you can't make a graphing program. I have made simple ones but i can help you with some of your problems.
*Note - if you can't devote alot of time to this i wouldn't try it, this will be a BIG program and you will use alot of trial and error
first make the 4quadrant graph - use LINE statements - in screen 12
you will have to make your program work in opposites *sin - cos -- ^2 = SQRT
stuff like that
Then just substitute the intigers for y
use the:
y = 1
DO
'whatever the fuction is
y = y+1
LOOP UNTIL y < 100
trick

if this doesn't work i am working on program that will use the quadratic roots - if i get it working i'll send it to you
 
I know, I've already got the makings of the program and I had done all the stuff you've said. What I was wanting to know was whether certain functions (such as log base 2 of x, for example) would be possible to graph in QBasic 1.1. I know I can figure out most of the others myself, that is the one I am most worried about though because if I can't graph even one of the functions on the list then I need to try another medium.

So if anyone could give an example of how to get the log base two of a number in QBasic, if that is possible, that would be much appreciated.
 
Ok, no one ever answered my question, so I will go ahead and answer it now that I've found a way on my own so that future people asking a similar question will know. Log base 2 of x is equal to the natural log of x divided by the natural log of 2, or ln(x)/ln(2).

Therefore log base 2 of x can be easily graphed in QBasic.
 
I could readily have given you the answer, Mappiq. But that was not the question you posed.

You did not ask if was possible to evaluate numbers to the base 2, but whether you could GRAPH them. I assumed you wanted help in making a screen plot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top