Re: creating functions from the result of Solve[]
- To: mathgroup at smc.vnet.net
- Subject: [mg41848] Re: [mg41826] creating functions from the result of Solve[]
- From: Bobby Treat <drmajorbob-MathGroup3528 at mailblocks.com>
- Date: Sat, 7 Jun 2003 00:08:38 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Use Set rather than SetDelayed. ClearAll[n, y] y[n_ /; n ? 0] = y[n] /. First@Solve[3y[n - 2] + 6y[n - 1] - 2y[n] == 0, y[n]] ?y It requires knowing that the First solution is the one you want (in case there are several). If you have already seen the solution, that's no problem. Bobby -----Original Message----- From: Okke <kroosu at tref.nl> To: mathgroup at smc.vnet.net Subject: [mg41848] [mg41826] creating functions from the result of Solve[] 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