We report direct numerical simulations of the flow around a spanwise-flexible wing in forward flight. The simulations were performed at
$Re=1000$
for wings of aspect ratio 2 and 4 undergoing a heaving and pitching motion at Strouhal number
$St_c\approx 0.5$
. We have varied the effective stiffness of the wing
$\varPi _1$
while keeping the effective inertia constant,
$\varPi _0=0.1$
. It has been found that there is an optimal aerodynamic performance of the wing linked to a damped resonance phenomenon, that occurs when the imposed frequency of oscillation approaches the first natural frequency of the structure in the fluid,
$\omega _{n,f}/\omega \approx 1$
. In that situation, the time-averaged thrust is maximum, increasing by factor 2 with respect to the rigid case with an increase in propulsive efficiency of approximately 15 %. This enhanced aerodynamic performance results from the combination of larger effective angles of attack of the outboard wing sections and a delayed development of the leading edge vortex. With increasing flexibility beyond the resonant frequency, the aerodynamic performance drops significantly, in terms of both thrust production and propulsive efficiency. The cause of this drop lies in the increasing phase lag between the deflection of the wing and the heaving/pitching motion, which results in weaker leading edge vortices, negative effective angles of attack in the outboard sections of the wing, and drag generation in the first half of the stroke. Our results also show that flexible wings with the same
$\omega _{n,f}/\omega$
but different aspect ratio have the same aerodynamic performance, emphasizing the importance of the structural properties of the wing for its aerodynamic performance.