Re: FindRoot question (number of variables)
- To: mathgroup at smc.vnet.net
- Subject: [mg15764] Re: [mg15743] FindRoot question (number of variables)
- From: Daniel Lichtblau <danl>
- Date: Sun, 7 Feb 1999 02:03:47 -0500 (EST)
- References: <199902050842.DAA10047@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Doug Webb wrote:
>
> Hello,
> This is a simplified example of I problem I have run into with
> FindRoot. Does anybody have any idea why it's doing what it is? And if
> so, how I can make it do what I want, or some other work around? Thanks
> for any info. Here's the example:
>
> define a function that takes one input, and outputs two results:
>
> r[x_] := {x, x^2}
>
> It does what's expected:
>
> r[4]
> {4,16}
>
> Now, find a solution using FindRoot:
>
> FindRoot[ r[x] == {5, 25}, {x, 2}]
>
> returns an error (rather than the obvious answer of x->5):
>
> FindRoot::"frnum":
> "Function {{-3., -21.}} is not a length 1 list of numbers at {x} =
> {2.}."
>
> It seems that FindRoot REQUIRES you to solve for as many variables as
> your function returns. Even though when entered seperatly, r[5] == {5,
> 25} returns "true". Why? Any ideas? Or any ideas how to get around this
> "feature" of FindRoot? Thanks for any input.
>
> Doug
> D_Webb at prodigy.net
> Douglas.S.Webb at maf.nasa.gov
I do not know offhand of a way to have FindRoot work around this
limitation that #variables must equal #equations (possibly another
reader will have ideas about this). But notice you can simply resort to
FindMinimum instead.
In[5]:= FindMinimum[Evaluate[Apply[Plus, Thread[r[x] - {5,25}]^2]],
{x,2}]
-28
Out[5]= {3.187 10 , {x -> 5.}}
Daniel Lichtblau
Wolfram Research
- References:
- FindRoot question (number of variables)
- From: "Doug Webb" <D_Webb@prodigy.net>
- FindRoot question (number of variables)