Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10168 > unrolled thread
| Started by | djorser@comcast.net |
|---|---|
| First post | 2012-05-21 10:01 +0000 |
| Last post | 2012-05-21 10:01 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Amortization Schedule--Global Symbol Value Error djorser@comcast.net - 2012-05-21 10:01 +0000
| From | djorser@comcast.net |
|---|---|
| Date | 2012-05-21 10:01 +0000 |
| Subject | Re: Amortization Schedule--Global Symbol Value Error |
| Message-ID | <jpd3p5$edf$1@smc.vnet.net> |
Replace t=j/12; with t[j_]:=j/12; and replace references to t inside of Manipulate to t[j].
This will get you numeric values so you can correct your issue concerning incorrect
values.
Be sure to do Clear[t] if you have executed t=j/12;
Don Orser
----- Original Message -----
From: "waterhand" <sandwaterhand@gmail.com>
Sent: Sunday, May 20, 2012 2:36:13 AM
Subject: Amortization Schedule--Global Symbol Value Error
Let me begin by saying that I am very new to Mathematica, so any help is appreciated.
I am trying to make an amortization schedule in a table format. The code I have is below:
***
(* psv = Present Value, r = interest rate as a decimal, t = time in years, k = number of payments made *)
(* mortgage function calculates the monthly mortgage amount *)
mortgage[psv_, r_, t_] := N[psv*(r/12)/(1 - (1 + r/12)^(-12*t)), 2]
(* amountLeftOwed function calculates the amount left on the loan including interest *)
amountLeftOwed[psv_, r_, t_, k_] := N[psv*(1 + r/12)^k - mortgage[psv, r, t]*((1 + r/12)^k - 1)/(r/12), 2]
(* paidInInterest function calculates the amount of the mortgage payment that goes towards the interest *)
paidInInterest[psv_, r_, t_, k_] := N[amountLeftOwed[psv, r, t, k]*r/12, 2]
(* paidInPrincipal function calculates the amount of the mortgage payment that goes towards the principal *)
paidInPrincipal[psv_, r_, t_, k_] := N[mortgage[psv, r, t] - paidInInterest[psv, r, t, k], 2]
(* remainingBalance function gives the remaining balance after payment has been made *)
remainingBalance[psv_, r_, t_, k_] := N[amountLeftOwed[psv, r, t, k] - mortgage[psv, r, t], 2]
(* j is the number of months. this converts months to years *)
t = j/12;
Manipulate[
TableForm[
Prepend[
Table[{i, paidInInterest[psv, r, t, i], paidInPrincipal[psv, r, t, i], remainingBalance[psv, r, t, i]}, {i, 1, j}],
{"Month", "Interest", "Principal", "Balance"}]],
{{psv, 100000, "Loan Amount"}, 100, 200000, 100}, {{r, 0.05, "Interest Rate"}, 0.01, .1, 0.0005},
{{j, 120, "Number of Months"}, {120, 240, 360}}
]
***
Here's the issues I am having:
1) The variable j is coming up with the "Global symbols that have no assigned value" error despite it being assigned 120, 240, and 360 in the Manipulate[] function. When I add a line like "j = 120", the code "works". The reason for the quotations is explained in number 3 below.
2) Despite the N[*, 2] function, the numbers are coming out as scientific notation. Even with the line j = 120, the rounding is not to two places.
3) The table should end with the ending balance being zero. When I force the value of j (again, j = 120, 240, or 360), I am getting a negative value for the last two months. Is there a rounding issue related to #2?
Again, very new to Mathematica. I appreciate any help.
Thanks for reading,
Mike
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web