Re: Problem with user defined functions
- To: mathgroup at smc.vnet.net
- Subject: [mg37379] Re: [mg37340] Problem with user defined functions
- From: Tomas Garza <tgarza01 at prodigy.net.mx>
- Date: Fri, 25 Oct 2002 02:48:42 -0400 (EDT)
- References: <200210240655.CAA05087@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I would use Solve instead of FindRoot, and Part[[1,1,2]] instead of Part[[1]]. Try this: In[1]:= test[x_] := Solve[Sin[p] == x, p] In[2]:= data[x_] := D[test[x][[1,1,2]], x] In[3]:= Plot[Evaluate[data[x]], {x, 0, 1}]; Tomas Garza Mexico City ----- Original Message ----- From: "Farhat Habib" <farhat at pacific.mps.ohio-state.edu> To: mathgroup at smc.vnet.net Subject: [mg37379] [mg37340] Problem with user defined functions > Hello all, > > I am trying to evalute a function which looks like this. This is an > analogous problem not the actual problem. > > test[x_] := p /. FindRoot[Sin[p] == x, {p, 1}][[1]] > data[x_] := D[test[x], x] > Plot[data[x], {x, 0, 1}] > > Now, when trying to evaluate the derivative mathematica replaces both the > x's with the number at which it is trying to calculate the datapoint. This > gives an error of 'xxxx is not a valid variable'. Replacing D[test[x]] > with test'[x] doesn't help either though it results in a different set of > errors. Is there any of way of getting around this problem? > > Thanks in advance, > > Farhat > > >
- References:
- Problem with user defined functions
- From: Farhat Habib <farhat@pacific.mps.ohio-state.edu>
- Problem with user defined functions