Simulation of an Analog Computer generating a sinewave
Analog computers, long forgotten did have unique capabilities that digital computers of the time could not match. In particular they were a different way of thinking, a different paradigm.
The analog computer used 3 basic components: the op-amp, resistor and capacitor. The basic circuit is an inverter. Assuming the two resistors are the same value they connect together at the negative input of the op-amp. The op-amp has huge gain so its input is amplified and feeds back to the input to oppose the input. So if you put, say 5v into the input resistor the amplifier output will be minus 5v. The point Z is just enough to create that -5v but because of the huge gain of the amplifier it is very small so that point is called a virtual zero or virtual earth. The current in the two resistors is the same.
If you now have two input resistors then the output will be the sum of the two inputs but inverted. Z will always be a virtual zero. That is a basic adder.
If you replace the feedback resistor with a capacitor then in order to maintain the feedback current to be the same as the input current the capacitor will gradually charge up and the output voltage will therefore increase over time. This is the basic integrator but is also inverted so put in x and you will get minus Int(x) i.e. an increasing negative voltage to oppose the input positive current.
An analog computer consisted of a great many of these op-amps and programming the computer was done using patch leads to link the components together to generate the function you require.
The sinewave generator is an example of how this was done. If you consider a sinewave voltage sin x going in to the first integrator then the output is int(sin x dx) but inverted (because all analog modules invert). The integral of sin x is -cos x so the output is -cos x, inverted is cos x. This goes to another integrator. Int(cos x) is sin x, inverted is -sin x. This is then inverted by the 3rd element to give plus sin x. This is what we had to start with so we can connect the output to the input. It then becomes self-fulfilling or self-generating.
We can simulate this in Forth:
: INT1 4 / V1 +! V1 @ ; ( THIS IS THE FIRST INTEGRATOR, NOT INVERTED )
: INT2 4 / V2 +! V2 @ ; ( THIS IS THE SECOND INTEGRATOR, NOT INVERTED )
: INV 0 SWAP - ; ( INVERTER )
: FUNC INT1 INT2 INV ; ( THE WHOLE FUNCTION )
: DISP ( THIS DISPLAYS THE VALUE BY SPACING ALONG THE SCREEN BY THAT VALUE, SCALED AND PRINT AN ASTERISK )
CR 40 + 0 DO SPACE LOOP 42 EMIT
: INIT 0 V1 ! 0 V2 ! 100 ;
FUNC ( GETS ITS VALUE FROM THE STACK, LEAVES ITS ANSWER ON THE STACK )
DUP DISP ( PRINT THE * )
( THEN GO ROUND AGAIN, TAKING FUNCS OUTPUT BACK INTO FUNCS INPUT AGAIN. )
?TERMINAL UNTIL ( PRESS ESC TO END LOOP
Enter SINEWAVE and see the sinewave on screen in asterisks. Press esc key to stop.