Dynamic symmetry breaking and structure-preserving analysis on the longitudinal wave in an elastic rod with a variable cross-section