       re: eval differential expressions

• To: mathgroup at yoda.physics.unc.edu
• Subject: re: eval differential expressions
• From: "Dr A. Hayes" <hay at leicester.ac.uk>
• Date: Mon, 20 Jun 1994 15:41:24 +0100 (BST)

```Geoff Latham <gal at melba.bby.com.au writes:

> Is there an easy way to evaluate differential expressions for various
> functions?
> For example, if I have D[f[x],x]^2+f[x] in Mma, I'd like to evaluate it for
> various functions f[x]. This can be done via naming the expression and
> then letting f[x_]=<desired fn of x> and typing the expressions name
> upon which its evaluated - but this seems awfully clumbsy!

> Any suggestions?

> Thanks.

Here are two ways:

In:= op[exp_,v_:x] := D[exp,v]^2+exp
(*The v_:x makes x the default independent variable.*)

In:= op[Sin[x]]
Out = Cos[x]^2 + Sin[x]

In:= op[Sin[t],t]
Out= Cos[t]^2 + Sin[t]

And a functional variant
In:= opf[f_] := (f'[#]^2 + f[#])&

In:= opf[Sin][x]
Out= Cos[x]^2 + Sin[x]

Allan Hayes,
hay at le.ac.uk

```

• Prev by Date: help
• Next by Date: Re: Mathematica licensing
• Previous by thread: eval differential expressions
• Next by thread: Re: eval differential expressions