This looks like an equation for an APR. Try a simple iteration like this one instead:
#inputs
instalments=60
net=12800
monthly=387.63
interest=0.1890
#function
CalculateAPR <- function(InitialPayout, InterestRate, N, MonthlyRepayment) {
i <- InterestRate
repeat{
DF <- sapply(1:N, function(N) { MonthlyRepayment/((1+i)^(N/12)) } )
if(InitialPayout>=sum(DF)) break()
i <- i + 0.00001
}
return(i)
}
#output
ans=CalculateAPR(net, interest, instalments, monthly)
rm(list = c('instalments', 'interest', 'monthly', 'net'))
print(ans)
You might want to try a more efficient algorithm than this one, which simply adds 0,001% to each iteration.