A general method for calculating the optimal leaf longevity from the viewpoint of carbon economy