Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: [mg4149] Problem with condition in function definition !
Posted:
Jun 16, 1996 2:08 AM


a_kowald@chemie.fuberlin.de (Axel Kowald) [mg4149] Problem with condition in function definition ! Writes
>I'd like to define a function with condition in the following way: > >b=1 >bla[t_]/;(t<b) := {a,b,c} > >bla[0] gives {a,b,c}, fine. But now I want to clear b, Clear[b], and >still get the same result. So really I want to type 1 instead of b, >but for some reason can't do it.
Axel:
I'm not sure why you can't type 1 instead of b; it works for me.
Clear[bla] After entering b=1; bla[t_]/;(t<b) := {a,b,c} The infomation stored on bla and on b is ?bla Global`bla bla[t_] /; t < b := {a, b, c}
b is not evaluated because. ?b Global`b b = 1 When we evaluate bla[0] the condition t<b becomes first 0<b, then 0<1, then True; so we get {a,1,c} bla[0] {a, 1, c} The change of b to 1 was because of the information stored on b. Now clear b Clear[b] No rule is stored under b ?b Global`b So now, when bla[a] is evaluated the condition becomed 0<b and stays at this values  this is not True so the condition fails and no rule is applied bla[0] bla[0] You have the flexibility to define b to be whatever you want: b = 3; bla[2] {a, 3, c} If you don't want this flexiblity then you can use bla[t_]/;(t<1) := {a,b,c} or bla[t_]/;(t<1) := {a,1,c}
Allan Hayes hay@haystack.demon.co.uk



