Re: creating functions from the result of Solve[]
- To: mathgroup at smc.vnet.net
- Subject: [mg41926] Re: creating functions from the result of Solve[]
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 10 Jun 2003 04:46:56 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bbq83u$d4r$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
sol = y[n] /. First[Solve[3y[n - 2] + 6y[n - 1] - 2y[n] == 0, y[n]]]
y[n_Integer]/; n<0:=0
y[n_Integer?Positive]:=Evaluate[sol]
Regards
Jens
Okke wrote:
>
> hello,
>
> i have an equation and i want to make a function from the result of
> Solve[].
>
> for example:
>
> IN: Solve[3y[n - 2] + 6y[n - 1] - 2y[n] == 0, y[n]]
>
> OUT: {{y[n] -> (3*y[-2 + n] + 6*y[-1 + n])/2}}
>
> and now i'd like to have the function
> y[n_/;n>=0] := (3*y[-2 + n] + 6*y[-1 + n])/2
>
> y[n]/.Flatten[Solve[eqn==0,y[n]]] is possible, but
> y[n_]:=y[n]/.Flatten[Solve[eqn==0,y[n]]] isn't
>
> is there anybody who could help me get this to work?
>
> --
> Okke
> Experience is that marvelous thing that enables you to recognize a
> mistake when you make it again.
> -- F. P. Jones