Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11414
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: TimeValue around NDSolve |
| Date | 2012-08-19 00:36 +0000 |
| Message-ID | <k0pcer$e24$1@smc.vnet.net> (permalink) |
| References | <20120818074423.BC2F66845@smc.vnet.net> |
| Organization | Time-Warner Telecom |
age = 65;
eqn1 = y'[t] == 47/1000*y[t] - 5300;
sol1 = y[t] /. NDSolve[{eqn1, y[age] == 100000}, y[t], {t, age, 110}][[1]];
data = Table[{t, sol1}, {t, age, 85}];
Plot[sol1, {t, age, 85},
Epilog -> {Red, AbsolutePointSize[3], Point[data]}]
However, this can be soved exactly using DSolve.
sol2[t_] = Simplify[y[t] /. DSolve[{eqn1, y[age] == 100000}, y[t], t][[1]]]
100000/47 (53 - 6 E^((47 (-65 + t))/1000))
Plot[sol2[t], {t, age, 85},
Epilog -> {Red, AbsolutePointSize[3], Point[data]}]
In TimeValue you have fixed the time value at zero. Note that for
TimeValue[s, i, 0] this is independent of the intest rate and as you
observed there is no change.
TimeValue[s, i, t]
(1 + i)^t s
TimeValue[s, i, 0]
s
Presumably you want a time slider in addition to the interest rate slider.
Manipulate[sol3[t_] := TimeValue[sol2[t], discountRate/100, t2];
Column[{
Grid[
Partition[
Partition[
Table[{t, NumberForm[sol3[t] // N, {8, 2}]},
{t, age, 85}],
7] // Transpose // Flatten,
6],
Frame -> All],
Plot[sol3[t], {t, age, 85},
PlotRange -> {75000, 200000},
ImageSize -> 288]
}],
{t2, 0, 20, 1,
Appearance -> {"Labeled"}},
{{discountRate, 1.6, "Discount Rate"}, .8, 3, .1, Appearance -> {"Labeled"}}]
Bob Hanlon
On Sat, Aug 18, 2012 at 3:44 AM, Joe <design@rcn.com> wrote:
> (* #1 This expression works. I am trying to get the Present Value using a variable discountRate for each value in this table. *)
> age = 65;
> eqn1 = y'[t] == 4.7/100 *y[t] - 5300;
> sol1 = y[t] /. NDSolve[{eqn1, y[age] == 100000}, y[t], {t, age, 110}];
> Table[sol1, {t, age, 85}]
>
> (* #2 This attempt fails *)
> Manipulate[
> age = 65;
> eqn1 = y'[t] == 4.7/100 *y[t] - 5300;
> sol2 = TimeValue[y[t] /. { NDSolve[{eqn1, y[age] == 100000}, y[t], {t, age, 110}]}, discountRate/100, 0];
> Table[sol2, {t, age, 85}],
> {{discountRate, 1.6, "Discount Rate"}, .8, 3, .1,Appearance -> {"Labeled", Tiny}}
> ]
>
> (* #3 In the complete applet, this method calculates the PV correctly on opening but does not respond to the discountRate slider and eventually causes an error *)
> Manipulate[
> age = 65;
> eqn1 = y'[t] == 4.7/100 *y[t] - 5300;
> sol2 = y[t] /. NDSolve[{eqn1, y[age] == 100000}, y[t], {t, age, 110}];
> Table[TimeValue[sol2, discountRate/100, 0], {t, age, 85}],
> {{discountRate, 1.6, "Discount Rate"}, .8, 3, .1, Appearance -> {"Labeled", Tiny}}
> ]
>
> I hope this is a better description of the problem than I provided several days ago.
>
> Joe Rimback
> design@rcn.com
> Gaithersburg, MD
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: TimeValue around NDSolve Bob Hanlon <hanlonr357@gmail.com> - 2012-08-19 00:36 +0000
csiph-web