MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: strange error


On 10/22/11 at 6:09 AM, klemen_dovrtel at yahoo.com (Klemen Dovrtel)
wrote:

>I defined a simple function that is composed of three functions,
>each for different range of argument/variable. The function was
>composed using If[] conditions. The problem is that i can't FindRoot
>of this composed function. I get an error "the function value is not
>a list of numbers with dimensions {1}", which is not true. Any idea
>how can i solve this?

Change your function to specify it takes numeric arguments. That
is instead of

test[m_] := Module[{ret},
   If[m < 100, ret = 2 m];
   If[100 <= m <= 200, ret = 200 + 1 (m - 100)];
   If[200 < m, ret = 300 + .5 (m - 200)];
   N[ret]]

Use

test[m_?NumericQ] := Module[{ret},
   If[m < 100, ret = 2 m];
   If[100 <= m <= 200, ret = 200 + 1 (m - 100)];
   If[200 < m, ret = 300 + .5 (m - 200)];
   N[ret]]




  • Prev by Date: a bug in Integrate (2nd message)
  • Next by Date: Integral points on elliptic curves
  • Previous by thread: Re: strange error
  • Next by thread: Re: strange error