# Calculation cash flows for NPV = 0: numerical solutions

I have two time series of cashflows, one for renting a building and one for buying it. Normally I calculate the net present value for both cashflows and then calculate their difference. I do this for a period of 1,2,3, .. 50 years to check where the NPV difference is zero.

However now I want to calculate the series of cashflows given the net present value of the two series for both the property and the rental must be 0 after x number of years. The time series for the rental place is given/known (kind of ;) ).

So it's easy to calculate the total cashflow, the sum of the series? But I would like to add some additional rules to the series for buying the property, like e.g. 90% of investments are made in the first year, the next years every year 2% of total investment is used for renovation/maintenance, and the resell value at the last period is e.g. 95% of the initial investment. Given the interest rate is compounded, I guess an analytical solution does not exist? Would it be doable to calculate this numerically? If so, how would you approach the problem? So I want the dependent variable to be the series of cash flows for the property instead of the NPV, and, actually, specifically, I want to know the initial investment cost at year 1 I can make if the property is hold on to for x number of years. I guess this question must have been asked a million times already in the literature? But I couldn't find any available solution to it.

So somehow I think I should build in a simple division rule of the cashflows for each year into the numerical algorithm. If the discount factor was not compounded, it would probably be easy, but given compounding I'm not sure how to tackle this issue.

Thanks!

My current code in R calculates the reverse of what I want:

#common parameters
max_number_of_years_c = 50;
i_c = 0.03

# calculation
# declare variables
# npv_p <- rep("", times=max_number_of_years_c)
# npv_r =  rep("", times=max_number_of_years_c)

npv_p = c()
npv_r = c()
empty_vec = c()
loop_index_vec = 1:max_number_of_years_c

for (current_nr_of_years in loop_index_vec) {

print(current_nr_of_years)

# cashflow rental parameters
# cash flow at period 0
cf0_r = 0
# vector of cash flows
cf_r = rep(c(-100), times = current_nr_of_years)
# vector of the times for each cash flow
times_r = c(1:length(cf_r))

# cashflow  parameters property
# cash flow at period 0
cf0_p = 0
# vector of cash flows
cf_p = c(-1000, rep(c(-20), times = current_nr_of_years-1))
# vector of the times for each cash flow
times_p = c(1:length(cf_p))

# npv_p(current_nr_of_years) =
npv_p_temp = NPV(cf0_p,cf_p,times_p,i_c,plot=FALSE)
npv_r_temp = NPV(cf0_r,cf_r,times_r,i_c,plot=FALSE)

# saving values
npv_r = c(npv_r,npv_r_temp)
npv_p = c(npv_p,npv_p_temp)

}

NPV_difference = npv_p - npv_r  # when does NPV for property exceeds NPV for renting?
x_plot = 1:max_number_of_years_c;

# plot 1
# Warning, point of intersection is NOT point where both options are equal. To see that, you would need to integrate some surfaces on this plot
plot(x_plot,npv_p,main="NPV property vs. rental",ylab="NPV",xlab="years", lwd=2.5,mar=c(2,2,0,0),col="darkblue",bty='l',col.axis="black",ylim=range(c(npv_p,npv_r))) #
points(x_plot,npv_r,main="property",ylab="NPV",xlab="years",lwd=2.5,mar=c(2,2,0,0),col="cyan",bty='l',col.axis="black")

# plot 2

plot(x_plot,NPV_difference,main="NPV difference (property minus rental)",ylab="NPV",xlab="years",lwd=2.5,mar=c(2,2,0,0),col="green",bty='l',col.axis="black")