Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Assign result of derivation to a new function?

Posted 9 years ago

Hi folks,

how i assign the result of the derivation as new function?

Clear[lx]

lx[x[t], phi[t], l, t] := x[t] + l*Sin[phi[t]]

D[lx[x[t], phi[t], l, t], t]

dlx[x[t], x´[t], phi[t], phi´[t], l, t] = %

many thanks john

3 Replies

Hi Johannes,

Mathematica has an excellent documentation:

ReplaceAll (Built-in Wolfram Language Symbol) expr /. rules applies a rule or list of rules in an attempt to transform each subpart of an expression expr. ReplaceAll[rules] represents an operator form of ReplaceAll that ...

The reason why I did it this way was that x' is not just a function, but a function acting on a function:

x' // FullForm
(*  Out:   Derivative[1][x]   *)

You can define those properties of x e.g. like so (i.e. using UpValues):

x /: Derivative[1][x] = Sin;

or

Derivative[1][x] ^= Sin;

but I can not see how to use this in this context.

Regards -- Henrik

POSTED BY: Henrik Schachner

many thanks Henrik,

working perfect! May, you could tell me what /. means? Or in other words why do I need to write this in that way? Why, I cannot just specifiy the variable in the function x'?

kind regrads Johannes

Hi Johannes,

how about this:

ClearAll["Global`*"]
lx[x_[t_], phi_[t_], l_] := x[t] + l*Sin[phi[t]]
dlx[dx_[t_], phi_[t_], dphi_[t_], l_] = (D[lx[x[t], phi[t], l], t] /. {x' -> dx, phi' -> dphi})

Regards -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard