My question is straightforward: How do I convert a continuous function into a discrete-valued function?
The function I want to convert is the JacobiAmplitude function:
ϕ[t_] = With[{k = 1.01}, JacobiAmplitude[k t, k^-3]];
Plot[ϕ[t], {t, 0, 50}]
I am using RSolve
to solve a second-order difference equation and want to add a discrete-time version of the JacobiAmplitude
function to the model as a forcing term.
I'd like to put a discrete-time JacobiAmplitude
function, ϕ[n], into the following difference equation:
RSolve[
{y[n + 2] - y[n + 1] + 0.99*y[n] == ϕ[n], {y[0] == 0, y[1] == 1, ϕ[0] == 0}},
y[n], n
];
ListPlot[
Transpose@Table[{y[n]} /. First[%],
{n, 0, 350}],
Joined -> True, PlotRange -> All
]
I'd immensely appreciate any assistance.
RSolve
here, just doy[n_]:= y[n-1] - 0.99*y[n-2] +ϕ[n-2]
. No need for phi to be discrete. $\endgroup$y[n_] := y[n] = y[n - 1] - 0.99*y[n - 2] + ϕ[n - 2]
(Similar to @george2079 's solution, but with an extray[n] =
; this will prevent redundant evaluations). $\endgroup$