Re: Rule to Function, Frontend funnies

• To: mathgroup at smc.vnet.net
• Subject: [mg5320] Re: Rule to Function, Frontend funnies
• From: haberndt at dnai.com (Harald Berndt)
• Date: Wed, 27 Nov 1996 01:47:37 -0500
• Organization: DNAI ( Direct Network Access )
• Sender: owner-wri-mathgroup at wolfram.com

```In article <57645l\$28t at dragonfly.wolfram.com>, Wouter Meeussen
<meeussen.vdmcc at vandemoortele.be> wrote:

> how can I convert a rule to a function?
> if I get a result from
>
> rulesoln = DSolve[{y'[x]==y[x]/(c+1/x),y[0]==1},y[x],x]
>
> in the form :
>
>                                2
>            x/c - Log[1 + c x]/c
> {{y[x] -> E                     }}
>
> how do I get the definition :
>
> y[x_]:= E^(x/c - Log[1 + c x]/c^2)
>

Simply change the attribute of the output cell
from Formatted to Not Formatted. On the Mac that is <Command>+t, on
Windows it's something similar (<Alt>+t or <Ctrl>+t). Then copy and paste,
but even easier ...

> Flatten[rulesoln]/.y[x]->y[x_]/.Rule->SetDelayed
>
> {Null}

... simply write

In[5]:=
y[x_] := Evaluate[y[x]/.Flatten[rulesoln]]

That still leaves undefined parameter c, so you might consider

In[5]:=
y[x_][c_] := Evaluate[y[x]/.Flatten[rulesoln]]

Best,

--
Harald Berndt, Ph.D.                            Research Specialist,
Voice: 510-652-5974                                      Consultant
FAX:   510-215-4299

```

• Prev by Date: Re: Single Problem
• Next by Date: Re: Arnold's Cat Map
• Previous by thread: Re: Rule to Function, Frontend funnies
• Next by thread: Indexed object as a variable