Due to the complex mechanism and fabrication process of flexible materials, it remains extremely challenging for a flexible robotic fish to achieve fast and efficient locomotion. In this article, taking advantage of the passive bending and energy storage properties of flexible materials, we propose an untethered robotic fish with multiple flexible joints to achieve high performance and low Cost of Transport (COT). First, combining rigid links and flexible materials, a compact flexible tail with a simple and efficient structure is proposed. Next, the pseudo-rigid body theory is applied to analyze the deformation of passive joints, and a full-state dynamic model is established. More importantly, an optimization method by adjusting the phase differences of the passive joints is used to obtain high aquatic performance. Finally, extensive simulations and experiments validate the effectiveness of the proposed method, and the robotic fish can achieve a maximum speed of 1.63 body length (BL) per second and a minimum COT of 4.8 J/m (2.87 J/m <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$\cdot$</tex-math> </inline-formula> kg). Compared with the multi-joint robotic fish with a similar design, the COT is reduced by up to 81.05% with the basically same aquatic ability. Excitingly, the flexible robotic fish can achieve a COT of 7.36 J/m at 1.23 BL/s, which is 15.72%-36.34% lower than that of the bluefin tuna and is within the range of yellowfin tuna, offering valuable insight into high speed and long endurance applications for underwater robots. <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">Note to Practitioners</i> –This paper is motivated by the design and optimization of an efficient bionic flexible underwater robot with high aquatic abilities, which is conducive to aquatic tasks that require long-time and long-distance sailing, such as underwater topographic exploration, submarine archaeology, and underwater search and rescue. Existing studies of free-swimming bionic underwater robots usually focus on the improvement of swimming speed and rarely consider achieving both high swimming performance and low energy cost. Thus, this paper proposes a bionic underwater robot design with two joints made of flexible materials on the tail to address the problem. Based on detailed analyses of the hydrodynamic force and flexible joint deformation, we propose an effective optimization method for swimming performance. A series of simulations and experiments suggest that the mechatronic design and optimization method are practical and valid. Hopefully, our design and method can provide theoretical guidance for engineers to design and optimize robots with flexible joints.