Message Boards Message Boards

0
|
3835 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:
GROUPS:

Finding terms with derivatives

Hi I have a list of equations eqns={lhs1==rhs1,lhs2==rhs2,...} I want to find those equations containing terms using the derivative operator ('). Could this be done??

Thanks in advance. J. Rico

5 Replies
(* Mathematica 7 *)
(* Clear memory *)
Clear["Global`*"];
(* Define a list of equations. *)
eqns = {x == 2y, x'[t] == 2t, x''[t] == 4t +1, y'[s] == 2z, y == t, y[m] == 2m, g[t] == x'[t]}


(* To find all equations with any derivative. *)
anyD = Position[ eqns, Derivative] (* Find positions. *);
pos  = Take[#, 1][[1]]& /@ anyD    (* Isolate first "address" element. *);
disp = Take[ eqns, {#}]& /@ pos    (* Print out all eqns with any derivative. *)

(* To find equations with a specified derivative. *)
specificD = Position[ eqns,#]& /@ { _'''}      (* Find positions. *);
pos       = Take[#, 1][[1]]& /@ specificD[[1]] (* Isolate the "address" element. *);
disp      = Take[ eqns, {#}]& /@ pos           (* Print out the equations. *)
POSTED BY: Isaac Abraham
(* Mathematica 7, Compact code. *)
(* Substitute without quotes, "Derivative" for all derivatives, 
" _' " for first derivative, " _'' " for second derivative etc.*) 

Take[ eqns, {#}]& /@ (Flatten[ Take[#, 1]& /@ Position[ eqns, #]])& /@ 
{_''''(* <--- User substitutions here.*)}
POSTED BY: Isaac Abraham

Isaac Thanks for the several alternatives. They work very well! Jesus

Isaac, In your code for finding specific derivatives

specificD = Position[ eqns,#]& /@ { _'''}      (* Find positions. *);

the result is a list of positions. How can I use them to extract the actual derivative e.g. x'[t]. The positions are lists and when I give them as arguments of [[...]] the result is not the expected. This may be a silly question, sorry!

I have solved the problem with extractÂ… sorry for the silly question.

Thanks!

Jesus

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

Group Abstract Group Abstract