Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Basic plotting of an evaluated function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86906] Re: Basic plotting of an evaluated function
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Wed, 26 Mar 2008 04:48:36 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fsa5cd$ab2$1@smc.vnet.net>

lederer at ssb.rochester.edu wrote:

> I have some function in two varaibles
> 
> f[x_,y_]= some arbitrary polynomial
> 
> Now I want to minimize the function with respect to y over some
> compact interval with fixed x
> 
> NMinimize[{f[x,y],y=995,y=989},y]


There are two syntax errors in the above line:

First, the expression y = 995 _assigns_ the integer value 995 to the 
symbol y. What you had in mind was the comparison operator for equality, 
which is written as a double equal sign == in Mathematica. (See Set, =, 
and Equal, ==, and also SameQ, ===, in the online documentation.)

Second, NMinimize accepts constraints expressed in the form of 
inequalities and domain specification. Therefore, your expression should 
read,

     Minimize[{f[x, y], 989 <= y <= 995}, y]


> I want to plot the y's versus the x's.
> 
> I have tried many things like defining
> 
> s[x_]=Part[NMinimize[{f[x,y],y=995,y=989},y],2]


Using SetDelayed, :=, and the replacement operator /. should work here.

     s[x_] := y /. Last@NMinimize[{f[x, y], 989 <= y <= 995}, y]


> Plot[s[x],{x,-14, 46}]

<snip>

The following expressions are a working example of what you are looking for.

f[x_, y_] := x^2 - 3 y^2 + x y + 10
s[x_] := y /. Last@NMinimize[{f[x, y], 989 <= y <= 995}, y]
Plot[s[x], {x, -14, 46}]


Hope this helps,
-- 
Jean-Marc


  • Prev by Date: Re: Match Pairs of Numbers
  • Next by Date: Re: Match Pairs of Numbers
  • Previous by thread: Basic plotting of an evaluated function
  • Next by thread: Re: Basic plotting of an evaluated function