Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5790 > unrolled thread
| Started by | Klemen Dovrtel <klemen_dovrtel@yahoo.com> |
|---|---|
| First post | 2011-10-22 10:16 +0000 |
| Last post | 2011-10-25 10:21 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
strange error Klemen Dovrtel <klemen_dovrtel@yahoo.com> - 2011-10-22 10:16 +0000
Re: strange error David Bailey <dave@removedbailey.co.uk> - 2011-10-25 10:21 +0000
| From | Klemen Dovrtel <klemen_dovrtel@yahoo.com> |
|---|---|
| Date | 2011-10-22 10:16 +0000 |
| Subject | strange error |
| Message-ID | <j7u562$t8q$1@smc.vnet.net> |
Hello everybody,
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?
Mathematica print screen:
http://www.shrani.si/f/t/vo/3jLzgMiy/prtscr.jpg
Best Regards
Klemen
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2011-10-25 10:21 +0000 |
| Message-ID | <j862jq$5ss$1@smc.vnet.net> |
| In reply to | #5790 |
On 22/10/2011 11:16, Klemen Dovrtel wrote:
> Hello everybody,
>
> 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?
>
>
> Mathematica print screen:
>
> http://www.shrani.si/f/t/vo/3jLzgMiy/prtscr.jpg
>
> Best Regards
> Klemen
The problem is that your function 'evaluates' even when its argument is
not a number (remember that Mathematica can do algebra as well as
numerics). The following version will fix this:
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 + 0.5 (m - 200)];
N[ret]
];
BTW, why not post a link to a notebook containing a problem, rather than
an image, which requires typing back into a notebook?
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web