Torpedo Data Computer
Background: 

History: The problem of aiming a torpedo has occupied military engineers since Robert Whitehead developed the modern torpedo in the 1860s. These early torpedoes ran at a preset depth on a straight course (consequently they are frequently referred to as "straight runners"). This was the state of the art in torpedo guidance until the development of the homing torpedo during the latter part of World War II. The vast majority of submarine torpedoes during World War II were straight running, and these continued in use for many years after World War II. In fact, two World War II-era straight running torpedoes — fired by the British nuclear-powered submarine HMS Conqueror — sank ARA General Belgrano in 1982.
During World War I, computing a target intercept course for a torpedo was a manual process where the fire control party was aided by various slide rules (the U.S. examples were the Mark VIII Angle Solver (colloquially called the "banjo", for its shape), and the "Is/Was" circular sliderule (Nasmith Director), for predicting where a target will be based on where it is now and was) or mechanical calculator/sights. These were often "woefully inaccurate", which helps explain why torpedo spreads were advised.
During World War II, Germany, Japan, and the United States each developed analog computers to automate the process of computing the required torpedo course.
In 1932, the Bureau of Ordnance (BuOrd) initiated development of the TDC with Arma Corporation and Ford Instruments. This culminated in the "very complicated" Mark 1 in 1938. This was retrofitted into older boats, beginning with Dolphin and up through the newest Salmons.
The first submarine designed to use the TDC was Tambor, launched in 1940 with the Mark III, located in the conning tower. (This differed from earlier outfits.) It proved to be the best torpedo fire control system of World War II.
In 1943, the Torpedo Data Computer Mark IV was developed to support the Mark 18 torpedo.
Both the Mk III and Mk IV TDC were developed by Arma Corporation (now American Bosch Arma).

The problem of aiming a straight-running torpedo: A straight-running torpedo has a gyroscope-based control system that ensures that the torpedo will run a straight course. The torpedo can run on a course different from that of the submarine by adjusting a parameter called the gyro angle, which sets the course of the torpedo relative to the course of the submarine (see Figure 2). The primary role of the TDC is to determine the gyro angle setting required to ensure that the torpedo will strike the target.
Determining the gyro angle required the real-time solution of a complex trigonometric equation (see Equation 1 for a simplified example). The TDC provided a continuous solution to this equation using data updates from the submarine's navigation sensors and the TDC's target tracker. The TDC was also able to automatically update all torpedo gyro angle settings simultaneously with a fire control solution, which improved the accuracy over systems that required manual updating of the torpedo's course.
The TDC enables the submarine to launch the torpedo on a course different from that of the submarine, which is important tactically. Otherwise, the submarine would need to be pointed at the projected intercept point in order to launch a torpedo. Requiring the entire vessel to be pointed in order to launch a torpedo would be time consuming, require precise submarine course control, and would needlessly complicate the torpedo firing process. The TDC with target tracking gives the submarine the ability to maneuver independently of the required target intercept course for the torpedo.
As is shown in Figure 2, in general, the torpedo does not actually move in a straight path immediately after launch and it does not instantly accelerate to full speed, which are referred to as torpedo ballistic characteristics. The ballistic characteristics are described by three parameters: reach, turning radius, and corrected torpedo speed. Also, the target bearing angle is different from the point of view of the periscope versus the point of view of the torpedo, which is referred to as torpedo tube parallax. These factors are a significant complication in the calculation of the gyro angle, and the TDC must compensate for their effects.
Straight running torpedoes were usually launched in salvo (i.e. multiple launches in a short period of time) or a spread (i.e. multiple launches with slight angle offsets) to increase the probability of striking the target given the inaccuracies present in the measurement of angles, target range, target speed, torpedo track angle, and torpedo speed.
Salvos and spreads were also launched to strike tough targets multiple times to ensure their destruction. The TDC supported the firing of torpedo salvos by allowing short time offsets between firings and torpedo spreads by adding small angle offsets to each torpedo's gyro angle. Before the sinking of South Korea's ROKS Cheonan by North Korea in 2010, the last warship sunk by a submarine torpedo attack, ARA General Belgrano in 1982, was struck by two torpedoes from a three torpedo spread.

To accurately compute the gyro angle for a torpedo in a general engagement scenario, the target course, speed, range, and bearing must be accurately known. During World War II, target course, range, and bearing estimates often had to be generated using periscope observations, which were highly subjective and error prone. The TDC was used to refine the estimates of the target's course, range, and bearing through a process of

estimating the target's course, speed, and range based on observations.
using the TDC to predict the target's position at a future time based on the estimates of the target's course, speed, and range.
comparing the predicted position against the actual position and correcting the estimated parameters as required to achieve agreement between the predictions and observation. Agreement between prediction and observation means that the target course, speed, and range estimates are accurate.
Estimating the target's course was generally considered the most difficult of the observation tasks. The accuracy of the result was highly dependent on the experience of the skipper. During combat, the actual course of the target was not usually determined but instead the skippers determined a related quantity called "angle on the bow." Angle on the bow is the angle formed by the target course and the line of sight to the submarine. Some skippers, like Richard O'Kane, practiced determining the angle on the bow by looking at Imperial Japanese Navy ship models mounted on a calibrated lazy Susan through an inverted binocular barrel.
To generate target position data versus time, the TDC needed to solve the equations of motion for the target relative to the submarine. The equations of motion are differential equations and the TDC used mechanical integrators to generate its solution.
The TDC needed to be positioned near other fire control equipment to minimize the amount of electromechanical interconnect. Because submarine space within the pressure hull was limited, the TDC needed to be as small as possible. On World War II submarines, the TDC and other fire control equipment was mounted in the conning tower, which was a very small space.
The packaging problem was severe and the performance of some early torpedo fire control equipment was hampered by the need to make it small. It had an array of handcranks, dials, and switches for data input and display. To generate a fire control solution, it required inputs on

submarine course and speed, which were read automatically from the submarine's gyrocompass and pitometer log
estimated target course, speed, and range information (obtained using data from the submarine's periscope, Target Bearing Transmitter (TBT), radar, and sonar)
torpedo type and speed (type was needed to deal with the different torpedo ballistics)
The TDC performed the trigonometric calculations required to compute a target intercept course for the torpedo. It also had an electromechanical interface to the torpedoes, allowing it to automatically set courses while torpedoes were still in their tubes, ready to be fired.
The TDC's target tracking capability was used by the fire control party to continuously update the fire control solution even while the submarine was maneuvering. The TDC's target tracking ability also allowed the submarine to accurately fire torpedoes even when the target was temporarily obscured by smoke or fog.

TDC functional description: Since the TDC actually performed two separate functions, generating target position estimates and computing torpedo firing angles, the TDC actually consisted of two types of analog computers:

Angle solver: This computer calculates the required gyro angle. The TDC had separate angle solvers for the forward and aft torpedo tubes.
Position keeper: This computer generates a continuously updated estimate of the target position based on earlier target position measurements.

Angle solver: The equations implemented in the angle solver can be found in the Torpedo Data Computer manual. The Submarine Torpedo Fire Control Manual discusses the calculations in a general sense and a greatly abbreviated form of that discussion is presented here.
The general torpedo fire control problem is illustrated in Figure 2. The problem is made more tractable if we assume:

The periscope is on the line formed by the torpedo running along its course
The target moves on a fixed course and speed
The torpedo moves on a fixed course and speed

As can be seen in Figure 2, these assumptions are not true in general because of the torpedo ballistic characteristics and torpedo tube parallax. Providing the details as to how to correct the torpedo gyro angle calculation for ballistics and parallax is complicated and beyond the scope of this article. Most discussions of gyro angle determination take the simpler approach of using Figure 3, which is called the torpedo fire control triangle.