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
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
(* 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. *)
(* 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.*)}
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