For a finitely presented group, the word problem asks for an algorithm which declares whether or not words on the generators represent the identity. The Dehn function is a complexity measure of a direct attack on the word problem by applying the defining relations. Dison & Riley showed that a "hydra phenomenon" gives rise to novel groups with extremely fast growing (Ackermannian) Dehn functions. Here we show that nevertheless, there are efficient (polynomial time) solutions to the word problems of these groups. Our main innovation is a means of computing efficiently with enormous integers which are represented in compressed forms by strings of Ackermann functions.and so it is possible to check efficiently when a word on a ±1 and b ±1 represents the identity by multiplying out the corresponding string of matrices.A celebrated 1-relator group due to Baumslag [1] provides a more dramatic example:Platonov [29] proved its Dehn function grows like n → ⌊log 2 n⌋ exp 2 ( exp 2 · · · (exp 2 (1)) · · · ), where exp 2 (n) := 2 n . (Earlier results in this direction are in [2,14,15].) Nevertheless, Miasnikov, Ushakov & Won [27] solve its word problem in polynomial time. (In unpublished work I. Kapovich and Schupp showed it is solvable in exponential time [33].)another example. Diekert, Laun & Ushakov [11] recently gave a polynomial time algorithm for its word problem and, citing a 2010 lecture of Bridson, claim it too has Dehn function growing like a tower of exponentials. The groups we focus on in this article are yet more extreme 'natural examples'. They arose in the study of hydra groups by Dison & Riley [12] . Let θ : F(a 1 , . . . , a k ) → F(a 1 , . . . , a k )be the automorphism of the free group of rank k such that θ(a 1 ) = a 1 and θ(a i ) = a i a i−1 for i = 2, . . . , k. The family G k := a 1 , . . . , a k , t | t −1 a i t = θ(a i ) ∀i > 1 , are called hydra groups. Take HNN-extensions Γ k := a 1 , . . . , a k , t, p | t −1 a i t = θ(a i ), [p, a i t] = 1 ∀i > 1 TAMING THE HYDRA 5 of G k where the stable letter p commutes with all elements of the subgroup H k := a 1 t, . . . , a k t .It is shown in [12] that for k = 1, 2, . . ., the subgroup H k is free of rank k and Γ k has Dehn function growing like n → A k (n). Here we prove that nevertheless:Theorem 2. For all k, the word problem of Γ k is solvable in polynomial time.(In fact, our algorithm halts within time bounded above by a polynomial of degree 3k 2 + k + 2-see Section 5.)1.3. The membership problem and subgroup distortion. Distortion is the root cause of the Dehn function of Γ k growing like n → A k (n). The massive gap between Dehn function and the time-complexity of the word problem for Γ k is attributable to a similarly massive gap between a distortion function and the time-complexity of a membership problem. Here are more details.Suppose H is a subgroup of a group G and G and H have finite generating sets S and T , respectively. So G has a word metric d S (g, h), the length of a shortest word on S ±1 representing g −1 h, and H has a word metric d T s...