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


Groups > comp.soft-sys.math.mathematica > #7454 > unrolled thread

FindRoot and replacement rule

Started bySamTakoy <pavelgrinfeld@gmail.com>
First post2011-12-29 07:52 +0000
Last post2011-12-30 12:19 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  FindRoot and replacement rule SamTakoy <pavelgrinfeld@gmail.com> - 2011-12-29 07:52 +0000
    Re: FindRoot and replacement rule Helen Read <readhpr@gmail.com> - 2011-12-30 12:17 +0000
    Re: FindRoot and replacement rule Szabolcs Horvát <szhorvat@gmail.com> - 2011-12-30 12:19 +0000

#7454 — FindRoot and replacement rule

FromSamTakoy <pavelgrinfeld@gmail.com>
Date2011-12-29 07:52 +0000
SubjectFindRoot and replacement rule
Message-ID<jdh68h$kjj$1@smc.vnet.net>
Hi,

Just wondering why FindRoot and other solvers return substitution
rules rather than simply a list of solutions. What's the advantage?

Thanks!

Sam

[toc] | [next] | [standalone]


#7488

FromHelen Read <readhpr@gmail.com>
Date2011-12-30 12:17 +0000
Message-ID<jdka5f$8f4$1@smc.vnet.net>
In reply to#7454
It's useful if you want to substitute the solutions into a function.

For example, suppose you want to find point(s) of intersection.

f[x_] := 8 x^2 - 12 x + 5

g[x_]:=26 - 10 x

{x, f[x]} /. Solve[f[x] == g[x], x]


Here's another way that I use it all the time, when I'm rigging up 
functions for my calculus students (for example when we are doing area 
or volume problems etc.).

Make up a function that looks nice:

f[x_] := x^4 - 2 x^3 + 5

Say I want a parabola that will intersect f[x] at let's say x=-3/2 and 
x=2. I'll need another point to determine the parabola, so plot f[x] and 
pick something that will make it look nice. Let's say I want the 
parabola to go through (1,15).

Now I start with a generic parabola, here called gg[x]. My final 
parabola will be g[x], which I get by solving for the values of a, b, 
and c in gg[x] and then evaluating gg[x] using the substitution rules 
from Solve.

gg[x_] := a x^2 + b x + c

g[x_] = gg[x] /.
   Solve[{gg[-3/2] == f[-3/2], gg[2] == f[2], gg[1] == 15}, {a, b,
      c}][[1]]

The [[1]] is picking out the first solution (there is in fact only one, 
but Solve returns a list of solutions).


Helen Read
University of Vermont



On 12/29/2011 2:52 AM, SamTakoy wrote:
> Hi,
>
> Just wondering why FindRoot and other solvers return substitution
> rules rather than simply a list of solutions. What's the advantage?
>
> Thanks!
>
> Sam
>



[toc] | [prev] | [next] | [standalone]


#7492

FromSzabolcs Horvát <szhorvat@gmail.com>
Date2011-12-30 12:19 +0000
Message-ID<jdka99$8gm$1@smc.vnet.net>
In reply to#7454
On 2011.12.29. 8:52, SamTakoy wrote:
> Hi,
>
> Just wondering why FindRoot and other solvers return substitution
> rules rather than simply a list of solutions. What's the advantage?
>

If you have more than one variable, Mathematica needs a way to tell you 
which value belongs to which variable.

Consider the following from the docs:

sol = Solve[a x + y == 7 && b x - y == 1, {x, y}]

If it simply returned {{8/(a + b), -((a - 7 b)/(a + b))}}, (using the 
order of variables instead of explicit names), this would be a lot more 
work to substitute back to the original equation.

With the current method equation /. sol[[1]] will substitute back the 
first solution easily.

-- 
Szabolcs Horvát
Matheamtica QA site proposal: http://area51.stackexchange.com/proposals/37304

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web