MathGroup Archive 1999

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

Search the Archive

Re: FindRoot question (number of variables)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15761] Re: [mg15743] FindRoot question (number of variables)
  • From: BobHanlon at aol.com
  • Date: Sun, 7 Feb 1999 02:03:45 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 2/5/99 5:40:57 AM, D_Webb at prodigy.net writes:

>  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,

r[x_] := {x, x^2};

FindRoot[r[x][[1]] == 5, {x,2}]

{x\[Rule]5.}

FindRoot[r[x][[2]] == 25, {x,2}]

{x\[Rule]5.}

s[x_, y_] := {x+y, x*y};

FindRoot[{s[x,y][[1]] == 11, s[x,y][[2]] == 30}, {x, 2}, {y,3}]

{x\[Rule]5.,y\[Rule]6.}

FindRoot[Evaluate[Thread[
			s[x,y] == {11,30}]], {x,2},{y,3}]

{x\[Rule]5.,y\[Rule]6.}

Solve[r[x][[1]] == 5, x]

{{x\[Rule]5}}

Solve[r[x][[2]] == 25, x]

{{x\[Rule]-5},{x\[Rule]5}}

Solve[{s[x,y][[1]] == 11, s[x,y][[2]] == 30}, 
	{x, y}]

{{x\[Rule]5,y\[Rule]6},{x\[Rule]6,y\[Rule]5}}

Solve[Evaluate[Thread[
			s[x,y] == {11,30}]], {x,y}]

{{x\[Rule]5,y\[Rule]6},{x\[Rule]6,y\[Rule]5}}


Bob Hanlon


  • Prev by Date: Re: Integration of very simple partwise definded functions fails
  • Next by Date: Re: Surfacecoloring of a sphere
  • Previous by thread: Re: FindRoot question (number of variables)
  • Next by thread: Q: how to list vertices of the Geodesate[] of a polyhedron?