A spring of force constant 500 NM-1 is compressed such that its length shortens by…