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


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

Re: FindRoot and replacement rule

From Helen Read <readhpr@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: FindRoot and replacement rule
Date 2011-12-30 12:17 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jdka5f$8f4$1@smc.vnet.net> (permalink)
References <jdh68h$kjj$1@smc.vnet.net>

Show all headers | View raw


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
>



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


Thread

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

csiph-web