# Using Apple Basic for math

I was fooling around on Apple Basic today and I noticed that if you type print and a simple equation, such as 2+2=4 and it can tell you if it is right. For example if you type print 3+2=5, it replies "1" because it is correct. If you type print 2+2=5, it replies "0" because the equation is incorrect. Does anyone know if Basic can be used for complex Algbraic equations with variables?

Do you know where I can find these books/info online about using BASIC for math?

Thanks

I believe that if you enter a command w/o a line number, it will be executed. IF you have a line number it will be stored, and won't run until you do "RUN" it.

I've uploaded a 200 page applesoft programming book but it has not been put online yet.

Time for you to search the universe, Grasshopper. Start with Google, Ebay, and the Apple II Webring.

Here is an Ebay auction that would fulfill an initial need (though you might do better with a later Apple published manual).

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&category=14906&item=5173883188&rd=1

Mutant_Pie

I know how to use variables with the input command, but i don't know how to make the computer input the varible instead of me, such as typing in 5+x=7 and making BASIC solve for x. Does your book say anything about that?

Here are some acceptable forms for your problem;

10 LET X=7-5

or

10 X=7-5

In both of those examples, you are setting the value for the variable "X". Of course, the real power of variables is their interaction, testing and then reporting on that interaction. For example;

10 TEXT: HOME

15 Y=7: Z=5: X=Y-Z

20 X=X+2: PRINT X: IF X=20 THEN END

25 GOTO 20

The above program, when typed in, then RUN in Applesoft Basic, assigns the value for two variables Y, Z, then sets X equal to the difference between Y and Z (the value 2), then increase X by 2, prints it, tests if equals 20, if not then it continues. The result should be a count up from 4 (Y-Z+2) in increments of 2 until it reaches 20, then the program ends.

In BASIC, "+" adds, "-" subtracts, "*" multiplies, and "\" divides. Have fun.

Mutant_Pie

Thanks, this has helped some. I noticed something wierd. If you type "graph" into basic, some colors flash across the screen and disappear. Can you graph on basic?

The Applesoft BASIC interpreter is not perfect. It will recognize the first letters of an entry that comprise a recognized command. GR is the command to display the LORES (low resolution) graphics screen. APH were probably read as an error. The colors you saw were random bits of data stored in the memory section that is displayed as the LORES screen. When the GR command is given, it first displays what is there, then clears it to black.

If you want a program to display a graph, you have to write it.

Mutant_Pie

Cool! Thanks

What you are doing is known as immediate execution mode.

I'm not sure if you can use the higher functions in that mode, but you should test it and find out.

Yes, (AppleSoft) BASIC can handle complex algebraic functions, including the use of variables. Trigonometric functions too.

You need the Apple issued Basic programming books. They will help you a lot.

Mutant_Pie