Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: join/problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23069] Re: join/problem
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 15 Apr 2000 03:00:27 -0400 (EDT)
  • References: <8d3rmo$oiv@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

David:

xm = x -> g[y];

fy[y_] = f[x, y] /. xm;

Definition[fy]

fy[y_] = f[g[y], y]

We don't need to always use := . But beware that with = the right side is
evaluated before the definition is stored. Here is an example where := is
needed

With
tb[n_] = Expand[(a + b)^n];

we get

tb[2]

        (a + b)^2

Clear[tb];

But with

tb[n_] := Expand[(a + b)^n];

we get

tb[2]

a^2 + 2*a*b + b^2


Here is another way to get what I think you want.
Clear[fy]

Unevaluated[fy[y_] := f[x, y]] /. xm

Definition[fy]

fy[y_] := f[g[y], y]

The Unevaluated allows the definition to be evaluated only after the
replacement has been made.

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"David Braunholtz" <D.A.BRAUNHOLTZ at bham.ac.uk> wrote in message
news:8d3rmo$oiv at smc.vnet.net...
> I would like to join the mathgroup list, please. The list was kind
> enough to solve a problem I had recently.
>
> I also have another urgent, and probably trivial (once you know how)
> problem:
>
> I have an equation
>
> eq:=f[x,y]
>
> I find the solution xm=x->g[y] which maximises f[x,y] for any y
>
> I now want to define this 'maximised' function of y only fy[y]
>
> I've tried:
>
> fy[y_]:=f[x,y]/.xm
>
> but this doesn't seem to recognise that I want the y s from xm to
> 'match' the y_ on the LHS.
>
> I'm also unclear as to whether I want  :=  or  =  in the above line.
>
> Thanks in anticipation
>
>
> David Braunholtz
> Department of Public Health & Epidemiology
> Public Health Building
> University of Birmingham
> Birmingham B15 2TT
> E-Mail:  D.A.Braunholtz at bham.ac.uk
> Tel: 0121-414-7495
> FAX: 0121-414-7878
>




  • Prev by Date: RE: Chop? Programming Challenge!!
  • Next by Date: Re: Re: 3 credit online university course - Intro to Mathematica
  • Previous by thread: join/problem
  • Next by thread: Need help with ideas to make NIntegrate a little faster for multiple variables