Fish locomotion is the variety of types of animal locomotion used by fish, principally by swimming. This however is achieved in different groups of fish by a variety of mechanisms of propulsion in water, most often by wavelike movements of the fish's body and tail, and in various specialised fish by movements of the fins. The major forms of locomotion in fish are anguilliform, in which a wave passes evenly along a long slender body; sub-carangiform, in which the wave increases quickly in amplitude towards the tail; carangiform, in which the wave is concentrated near the tail, which oscillates rapidly; thunniform, rapid swimming with a large powerful crescent-shaped tail; and ostraciiform, with almost no oscillation except of the tail fin. More specialised fish include movement by pectoral fins with a mainly stiff body, as in the sunfish; and movement by propagating a wave along the long fins with a motionless body in fish with electric organs such as the knifefish.
Fish swim by exerting force against the surrounding water. There are exceptions, but this is normally achieved by the fish contracting muscles on either side of its body in order to generate waves of flexion that travel the length of the body from nose to tail, generally getting larger as they go along. The vector forces exerted on the water by such motion cancel out laterally, but generate a net force backwards which in turn pushes the fish forward through the water. Most fishes generate thrust using lateral movements of their body and caudal fin, but many other species move mainly using their median and paired fins. The latter group swim slowly, but can turn rapidly, as is needed when living in coral reefs for example. But they can't swim as fast as fish using their bodies and caudal fins.
There are five groups that differ in the fraction of their body that is displaced laterally:
The sub-carangiform group has a more marked increase in wave amplitude along the body with the vast majority of the work being done by the rear half of the fish. In general, the fish body is stiffer, making for higher speed but reduced maneuverability. Trout use sub-carangiform locomotion.
The carangiform group, named for the Carangidae, are stiffer and faster-moving than the previous groups. The vast majority of movement is concentrated in the very rear of the body and tail. Carangiform swimmers generally have rapidly oscillating tails.
The thunniform group contains high-speed long-distance swimmers, and is characteristic of tunas and is also found in several lamnid sharks. Here, virtually all the sideways movement is in the tail and the region connecting the main body to the tail (the peduncle). The tail itself tends to be large and crescent shaped.
Not all fish fit comfortably in the above groups. Ocean sunfish, for example, have a completely different system, the tetraodontiform mode, and many small fish use their pectoral fins for swimming as well as for steering and dynamic lift. Fish with electric organs, such as those in the knifefish (Gymnotiformes), swim by undulating their very long fins while keeping the body still, presumably so as not to disturb the electric field that they generate.
Many fish swim using combined behavior of their two pectoral fins or both their anal and dorsal fins. Different types of Median paired fin propulsion can be achieved by preferentially using one fin pair over the other, and include rajiform, diodontiform, amiiform, gymnotiform and balistiform modes.
Oscillation is viewed as pectoral-fin-based swimming and is best known as mobuliform locomotion. The motion can be described as the production of less than half a wave on the fin, similar to a bird wing flapping. Pelagic stingrays, such as the manta, cownose, eagle and bat rays use oscillatory locomotion.
In tetraodontiform locomotion, the dorsal and anal fins are flapped as a unit, either in phase or exactly opposing one another, as seen in the Tetraodontiformes (boxfishes and pufferfishes). The ocean sunfish displays an extreme example of this mode.
In labriform locomotion, seen in the wrasses (Labriformes), oscillatory movements of pectoral fins are either drag based or lift based. Propulsion is generated either as a reaction to drag produced by dragging the fins through the water in a rowing motion, or via lift mechanisms.
Bone and muscle tissues of fish are denser than water. To maintain depth fish such as sharks, but also some bony fish, increase buoyancy by means of a gas bladder or by storing oils or lipids. Fish without these features use dynamic lift instead. It is done using their pectoral fins in a manner similar to the use of wings by airplanes and birds. As these fish swim, their pectoral fins are positioned to create lift which allows the fish to maintain a certain depth. The two major drawbacks of this method are that these fish must stay moving to stay afloat and that they are incapable of swimming backwards or hovering.
Similarly to the aerodynamics of flight, powered swimming requires animals to overcome drag by producing thrust. Unlike flying, however, swimming animals often do not need to supply much vertical force because the effect of buoyancy can counter the downward pull of gravity, allowing these animals to float without much effort. While there is great diversity in fish locomotion, swimming behavior can be classified into two distinct "modes" based on the body structures involved in thrust production, Median-Paired Fin (MPF) and Body-Caudal Fin (BCF). Within each of these classifications, there are numerous specifications along a spectrum of behaviours from purely undulatory to entirely oscillatory. In undulatory swimming modes, thrust is produced by wave-like movements of the propulsive structure (usually a fin or the whole body). Oscillatory modes, on the other hand, are characterized by thrust produced by swiveling of the propulsive structure on an attachment point without any wave-like motion.
Most fish swim by generating undulatory waves that propagate down the body through the caudal fin. This form of undulatory locomotion is termed Body-Caudal Fin (BCF) swimming on the basis of the body structures used; it includes anguilliform, sub-carangiform, carangiform, and thunniform locomotory modes, as well as the oscillatory ostraciiform mode.
Similar to adaptation in avian flight, swimming behaviors in fish can be thought of as a balance of stability and maneuverability. Because BCF swimming relies on more caudal body structures that can direct powerful thrust only rearwards, this form of locomotion is particularly effective for accelerating quickly and cruising continuously. BCF swimming is, therefore, inherently stable and is often seen in fish with large migration patterns that must maximize efficiency over long periods. Propulsive forces in MPF swimming, on the other hand, are generated by multiple fins located on either side of the body that can be coordinated to execute elaborate turns. As a result, MPF swimming is well adapted for high maneuverability and is often seen in smaller fish that require elaborate escape patterns.
The habitats occupied by fishes are often related to their swimming capabilities. On coral reefs, the faster-swimming fish species typically live in wave-swept habitats subject to fast water flow speeds, while the slower fishes live in sheltered habitats with low levels of water movement.
Fish do not rely exclusively on one locomotor mode, but are rather locomotor generalists, choosing among and combining behaviors from many available behavioral techniques. At slower speeds, predominantly BCF swimmers often incorporate movement of their pectoral, anal, and dorsal fins as an additional stabilizing mechanism at slower speeds, but hold them close to their body at high speeds to improve streamlining and reducing drag. Zebrafish have even been observed to alter their locomotor behavior in response to changing hydrodynamic influences throughout growth and maturation.
In addition to adapting locomotor behavior, controlling buoyancy effects is critical for aquatic survival since aquatic ecosystems vary greatly by depth. Fish generally control their depth by regulating the amount of gas in specialized organs that are much like balloons. By changing the amount of gas in these swim bladders, fish actively control their density. If they increase the amount of air in their swim bladder, their overall density will become less than the surrounding water, and increased upward buoyancy pressures will cause the fish to rise until they reach a depth at which they are again at equilibrium with the surrounding water.
The transition of predominantly swimming locomotion directly to flight has evolved in a single family of marine fish, the Exocoetidae. Flying fish are not true fliers in the sense that they do not execute powered flight. Instead, these species glide directly over the surface of the ocean water without ever flapping their "wings." Flying fish have evolved abnormally large pectoral fins that act as airfoils and provide lift when the fish launches itself out of the water. Additional forward thrust and steering forces are created by dipping the hypocaudal (i.e. bottom) lobe of their caudal fin into the water and vibrating it very quickly, in contrast to diving birds in which these forces are produced by the same locomotor module used for propulsion. Of the 64 extant species of flying fish, only two distinct body plans exist, each of which optimizes two different behaviors.
While most fish have caudal fins with evenly sized lobes (i.e. homocaudal), flying fish have an enlarged ventral lobe (i.e. hypocaudal) which facilitates dipping only a portion of the tail back onto the water for additional thrust production and steering.
Because flying fish are primarily aquatic animals, their body density must be close to that of water for buoyancy stability. This primary requirement for swimming, however, means that flying fish are heavier (have a larger mass) than other habitual fliers, resulting in higher wing loading and lift to drag ratios for flying fish compared to a comparably sized bird. Differences in wing area, wing span, wing loading, and aspect ratio have been used to classify flying fish into two distinct classifications based on these different aerodynamic designs.
In the biplane or Cypselurus body plan, both the pectoral and pelvic fins are enlarged to provide lift during flight. These fish also tend to have "flatter" bodies which increase the total lift producing area thus allowing them to "hang" in the air better than more streamlined shapes. As a result of this high lift production, these fish are excellent gliders and are well adapted for maximizing flight distance and duration.
Comparatively, Cypselurus flying fish have lower wing loading and smaller aspect ratios (i.e. broader wings) than their Exocoetus monoplane counterparts, which contributes to their ability to fly for longer distances than fish with this alternative body plan. Flying fish with the biplane design take advantage of their high lift production abilities when launching from the water by utilizing a "taxiing glide" in which the hypocaudal lobe remains in the water to generate thrust even after the trunk clears the water's surface and the wings are opened with a small angle of attack for lift generation.
In the Exocoetus or monoplane body plan, only the pectoral fins are enlarged to provide lift. Fish with this body plan tend to have a more streamlined body, higher aspect ratios (long, narrow wings), and higher wing loading than fish with the biplane body plan, making these fish well adapted for higher flying speeds. Flying fish with a monoplane body plan demonstrate different launching behaviors from their biplane counterparts. Instead of extending their duration of thrust production, monoplane fish launch from the water at high speeds at a large angle of attack (sometimes up to 45 degrees). In this way, monoplane fish are taking advantage of their adaptation for high flight speed, while fish with biplane designs exploit their lift production abilities during takeoff.
A "walking fish" is a fish that is able to travel over land for extended periods of time. Some other cases of nonstandard fish locomotion include fish "walking" along the sea floor, such as the handfish or frogfish.
Most commonly, walking fish are amphibious fish. Able to spend longer times out of water, these fish may use a number of means of locomotion, including springing, snake-like lateral undulation, and tripod-like walking. The mudskippers are probably the best land-adapted of contemporary fish and are able to spend days moving about out of water and can even climb mangroves, although to only modest heights. The Climbing gourami is often specifically referred to as a "walking fish", although it does not actually "walk", but rather moves in a jerky way by supporting itself on the extended edges of its gill plates and pushing itself by its fins and tail. Some reports indicate that it can also climb trees.
There are a number of fish that are less adept at actual walking, such as the walking catfish. Despite being known for "walking on land", this fish usually wriggles and may use its pectoral fins to aid in its movement. Walking Catfish have a respiratory system that allows them to live out of water for several days. Some are invasive species. A notorious case in the United States is the Northern snakehead. Polypterids have rudimentary lungs and can also move about on land, though rather clumsily. The Mangrove rivulus can survive for months out of water and can move to places like hollow logs.
There are some species of fish that can "walk" along the sea floor but not on land; one such animal is the flying gurnard (it does not actually fly, and should not be confused with flying fish). The batfishes of the Ogcocephalidae family (not to be confused with Batfish of Ephippidae) are also capable of walking along the sea floor. Bathypterois grallator, also known as a "tripodfish", stands on its three fins on the bottom of the ocean and hunts for food. The African lungfish (P. annectens) can use its fins to "walk" along the bottom of its tank in a manner similar to the way amphibians and land vertebrates use their limbs on land. 
Many fishes, particularly eel-shaped fishes such as true eels, moray eels, and spiny eels, are capable of burrowing through sand or mud. Ophichthids, the snake eels, are capable of burrowing either forwards or backwards.
many have a bony, sharp tail and are equally adept at burrowing forward or backward.