Re: problems with FindRoot: what worked with 4.2 does not work with 5.0
- To: mathgroup at smc.vnet.net
- Subject: [mg47369] Re: problems with FindRoot: what worked with 4.2 does not work with 5.0
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 7 Apr 2004 03:16:27 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <c4u3gg$9l6$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, a) change test[] to test[x_?NumericQ] := Module[{y}, If[x > 0, y = x + 1]; If[x <= 0, y = x - 1]; Return[y] ] b) call FindRoot[test[x] == 5, {x, 8, 9}] Regards Jens Edgar Dachs wrote: > > I have written a Mathematica program called PET (Petrological elementary > tools) for Mathematica > (Dachs, 1998, Computers & Geosciences, 24/3: 219-235) und worked out a > new version that I tested with Mathematica version 4.2. With 5.0, I now > find problems that several of my functions do not work any more, > obviously do to changes that have been employed between 4.2 and 5.0 > concerning FindRoot. > Below is a little test-function that illustrates the problem: the > return-value of the function depends on the value of x, as in the much > more complex petrological functions that I have written, where > calculations depend e.g. on the value of the temperature. > > test[x_] := Module[{y}, > If[x > 0, y = x + 1]; > If[x <= 0, y = x - 1]; > Return[y] > ] > With 4.2 FindRoot (using two startin values for x) could have been used > to solve for a special value, e.g. > > FindRoot[test[x] == 5, {x, {8, 9}}] > > with the obvious result: {x -> 4.} > > With 5.0 the call > > FindRoot[test[x] == 5, {x, 9}] > > (only one starting value can be specified with 5.0) yields the error > message: FindRoot::nlnum "the function value {..} is not a list of > numbers with dimension {1} at {x} = {9} > > I would be grateful if someone could help me solving this problem, at > the moment I don't know what to do, but it looks like a compatibility > problem between Mathematica versions 4.2 and 5.0. > > Thanks in advance, > > Dr. Edgar Dachs > Department of Mineralogy > University Salzburg > Austria