Re: rootsearch in a piecewise function
- To: mathgroup at smc.vnet.net
- Subject: [mg60254] Re: rootsearch in a piecewise function
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Thu, 8 Sep 2005 06:37:20 -0400 (EDT)
- Organization: Uni Leipzig
- References: <dfovrd$feo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, because you don't define a Picewise[] function 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_] := Piecewise[{{ f2[x], 0 < x < b}, { f3[x], b <= x < 10}, { x^(1/2), 10 <= x}}] /. para; df1[x_] = D[f1[x], x]; FindRoot[Evaluate[{f1[x] == 0} /. para], {x, 2}] FindRoot[Evaluate[{df1[x] == 0} /. para], {x, 2}] work as expected. Regards Jens "juejung" <juejung at indiana.edu> schrieb im Newsbeitrag news:dfovrd$feo$1 at smc.vnet.net... | 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}] |