MathGroup Archive 1999

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

Search the Archive

Re: RE: "f[x_]:= 2 x" vs. "f = 2 #&"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16522] Re: [mg16467] RE: [mg16365] "f[x_]:= 2 x" vs. "f = 2 #&"
  • From: Jurgen Tischer <jtischer at col2.telecom.com.co>
  • Date: Tue, 16 Mar 1999 04:00:02 -0500
  • Organization: Universidad del Valle
  • References: <199903130722.CAA24540@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

Ted,
how about the following?

PrecisionPlot[f_,{x_,xmin_,xmax_}]:=Module[{g,h},
		g[y_]:=(f/.x->y);
		h[y_]:=g[SetPrecision[y,100]];
		Plot[h[x],{x,xmin,xmax}]]

Jurgen

"Ersek, Ted R" wrote:
> 
................
> -------------------------------
> Suppose you are writing a program with the form
>   func[x_]:= (*****algorithm*****)
> and (algorithm) has to make a function that will be used at later stages of
> (algorithm).
> 
> It's illegal to use patterns on the right side of a definition.
> So (algorithm) can't make the function with the approach
>   f[x_]:= 2 x
> It also can't make the function with the approach
>   f[x_]= 2 x
> Instead (algorithm) must make the function with one of the following
>   f=2#&
>   f=Function[2#]
>   f=Function[x,2x]
> 
> So when would you need to do this?
> One such case is the function below.  This function will plot a function
> using arbitrary precision arithmetic to sample the function.  This is useful
> in special cases when a function must be sampled using arbitrary precision
> arithmetic.
> 
> (***********)
> PrecisionPlot[f_,{x_,xmin_,xmax_},opts___?OptionQ]:=
>  Module[{g,h},
>   (g=Function[f/.x->#];
>      h=(g[SetPrecision[#,17]]&);
>      Plot[h[x],{x,xmin,xmax},opts]
>    )
>  ]
> (***********)
> 
> As far as I can tell there was no way to get PrecisionPlot working without
> using a pure function as I do with   g=Function[f/.x->#]
> 
..................


  • Prev by Date: RE: Programmed PageBreaks
  • Next by Date: Footers
  • Previous by thread: RE: "f[x_]:= 2 x" vs. "f = 2 #&"
  • Next by thread: RE: RE: "f[x_]:= 2 x" vs. "f = 2 #&"