Torpedo Data Computer
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. Figure 3 provides an accurate model for computing the gyro angle when the gyro angle is small, usually less than 30°.
The effects of parallax and ballistics are minimal for small gyro angle launches because the course deviations they cause are usually small enough to be ignorable. U.S. submarines during World War II preferred to fire their torpedoes at small gyro angles because the TDC's fire control solutions were most accurate for small angles.
The problem of computing the gyro angle setting is a trigonometry problem that is simplified by first considering the calculation of the deflection angle, which ignores torpedo ballistics and parallax.
For small gyro angles, θGyro ≈ θBearing − θDeflection. A direct application of the law of sines to Figure 3 produces Equation 1.

where

vTarget is the velocity of the target.
vTorpedo is the velocity of the torpedo.
θBow is the angle of the target ship bow relative to the periscope line of sight.
θDeflection is the angle of the torpedo course relative to the periscope line of sight.
Range plays no role in Equation 1, which is true as long as the three assumptions are met. In fact, Equation 1 is the same equation solved by the mechanical sights of steerable torpedo tubes used on surface ships during World War I and World War II. Torpedo launches from steerable torpedo tubes meet the three stated assumptions well. However, an accurate torpedo launch from a submarine requires parallax and torpedo ballistic corrections when gyro angles are large. These corrections require knowing range accurately. When the target range was not known, torpedo launches requiring large gyro angles were not recommended.
Equation 1 is frequently modified to substitute track angle for deflection angle (track angle is defined in Figure 2, θTrack=θBow+θDeflection). This modification is illustrated with Equation 2.

where
θTrack is the angle between the target ship's course and the torpedo's course.

A number of publications state the optimum torpedo track angle as 110° for a Mk 14 (46 knot weapon). Figure 4 shows a plot of the deflection angle versus track angle when the gyro angle is 0° (i.e.., θDeflection=θBearing). Optimum track angle is defined as the point of minimum deflection angle sensitivity to track angle errors for a given target speed. This minimum occurs at the points of zero slope on the curves in Figure 4 (these points are marked by small triangles).
The curves show the solutions of Equation 2 for deflection angle as a function of target speed and track angle. Figure 4 confirms that 110° is the optimum track angle for a 16-knot (30 km/h) target, which would be a common ship speed.

Position keeper: As with the angle solver, the equations implemented in the position keeper can be found in the Torpedo Data Computer manual. Similar functions were implemented in the rangekeepers for surface ship-based fire control systems. For a general discussion of the principles behind the position keeper, see Rangekeeper.

Notes and references: 

External links: USS Pampanito: Article on the Pampanito's TDC. Archived 2012-07-17 at the Wayback Machine
Torpedo Data Computer Mk IV
A. Ben Clymer: The mechanical analog Computers of Hannibal Ford and William Newell, IEEE Annals of the history of computing
US Torpedo History: Good description of operational use of the Mk 14, Mk 18, and Mk 23
Original Manual for the Torpedo Data Computer Mark 3
Bureau of Ordnance (4 December 1941). Tactical Data for Torpedoes Mark XIV & Mark XIV-1 High & Low Power (PDF). Ordnance Data Pamphlet. Washington D.C.: Navy Department. O.D. No. 3699.
Bureau of Ordnance (10 August 1954). Tactical Data for Torpedo Mark 18 (PDF). Ordnance Data Pamphlet. Washington D.C.: Navy Department. O.D. No. 6697 Change 2.
Discussion of the torpedo ballistic and parallax corrections used by the Imperial Japanese Navy
Description of German Torpedo Calculator T.Vh.Re.S3 developed by Siemens and used on German U-Boats during World War II