Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5800

Re: strange error

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: strange error
Date 2011-10-23 10:25 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j80q21$aac$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 10/22/11 at 6:09 AM, klemen_dovrtel@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]]

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: strange error Bill Rowe <readnews@sbcglobal.net> - 2011-10-23 10:25 +0000

csiph-web