rootsearch in a piecewise function
- To: mathgroup at smc.vnet.net
- Subject: [mg60247] rootsearch in a piecewise function
- From: juejung <juejung at indiana.edu>
- Date: Thu, 8 Sep 2005 04:53:39 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
hi group, why does the root search in the following piecewise function not work, when the plot function before evaluates just fine. if i use the /.para already at the point where i define f2 and f3 then the root command works. however, the actual functions f2 and f3 are much longer and i would like to replace parametervalues only at the point where i do in the example below. it seems that findroot is evaluated before the replacement takes place?? thanks juergen para = {a -> 3, b -> 4, c -> 20, d -> 1.5}; f2[x_] := 10 + a* x^(1/2) - x - b; f3[x_] := -6 + c/x + d^2; f1[x_] := Which[0 < x < b, f2[x], b <= x < 10, f3[x],10 <= x, x^(1/2)] /.para; df1[x_] = D[f1[x], x]; Plot[f1[x] /.para, {x, 0.1, 15}] Plot[df1[x] /.para, {x,0.1, 15}] FindRoot[{f1[x] == 0} /.para, {x, 2}] FindRoot[{df1[x] == 0} /.para, {x, 2}]