Re: Re: SetDelayed::write ... [x_] is protected
- To: mathgroup at smc.vnet.net
- Subject: [mg97938] Re: [mg97899] Re: [mg97863] SetDelayed::write ... [x_] is protected
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Thu, 26 Mar 2009 05:20:55 -0500 (EST)
- References: <16449487.41188.1237895183797.JavaMail.hanlonr@127.0.0.1>
- Reply-to: drmajorbob at bigfoot.com
> Thanks for the Flatten, now it seem that it works (without any error > messages), but in fact it doesn't work. No, it doesn't seem to work... since it doesn't work. But this does: Clear[x, myfun] sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] 11000/x + 2 (100 + x) myfun[1] 11202 or this: Clear[x, myfun] sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; myfun[x_] := Evaluate[50*i1 + 2*i2 /. Flatten[sol]] myfun[1] 11202 Bobby On Wed, 25 Mar 2009 05:42:59 -0500, Serych Jakub <Serych at panska.cz> wrote: > Thanks for the Flatten, now it seem that it works (without any error > messages), but in fact it doesn't work. > > sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; > myfun[x_] := 50*i1 + 2*i2 /. Flatten[sol] > (no errors here) but: > > In: myfun[1] > > Out: 11000/x + 2 (100 + x) > > and not 11202 which would be result for argument 1. > > So it cannot recognize (or connect together with the pattern x_) the = > variable > x in the result from sol. > > What to do with it? > > Thanks > > Jakub > > >> -----Original Message----- >> From: Bob Hanlon [mailto:hanlonr at cox.net] >> Sent: Tuesday, March 24, 2009 12:46 PM >> To: Serych Jakub >> Cc: mathgroup at smc.vnet.net >> Subject: RE: [mg97863] SetDelayed::write ... [x_] is protected >> >> sol = {{i1 -> 220/x}, {i2 -> 100 + x}}; >> >> myfun[x_] = 50*i1 + 2*i2 /. Flatten[sol] >> >> 2*(x + 100) + 11000/x >> >> >> >> Bob Hanlon >> >> >> On Tue, Mar 24, 2009 at 7:46 AM , Serych Jakub wrote: >> >> > Dear M users, >> > I have solution of equations which is dependend on one >> parameter lets >> > say: >> > sol={{i1->220/x}, {i2 -> 100+x}} and I need to define >> function based >> > on this solution with the x as argument lets say: >> myfun[x_]:=50*220/x >> > + 2 (100+x); >> > >> > I'm trying to do it like this: >> > >> > myfun[x_]:=50 * i1 + 2 * i2 /. sol >> > >> > But it prints the error message: "SetDelayed::write ... [x_] is >> > protected". >> > >> > Does anybody know what's the problem and how to define such >> function? >> > >> > Thanks in advance >> > >> > Jakub >> > -- DrMajorBob at bigfoot.com