# Remove part within square brackets for function

So I've defined a variable as follows:

 q = {{x[t]}, {Φ[t]}}
V=0.5*x[t]^2*m^2+0.5*Φ[t]^2*I


I've had to differentiate with respect to time so:

 dq=D[q,t]


Giving something like:

  q'[t]={{x'[t]}, {Φ'[t]}}


I'd now like to use a Function and have found that the following doesn't work:

fv=Function[{x, Φ}, D[V, q]][1, pi/8]


It seems that x is different to x[t]. Which seems to some regard logical, however it is now impossible to work with the Function.

 Function[{x[t],Φ[t]}, D[V, q]][1, pi/8]


doesn't work either. Is there a way to delete the "[t]" part of each variable? Or is there a better way of going about this?

• What do you want to get in the end? – Alexei Boulbitch Apr 15 '16 at 11:37
• I'd like the jacobian to be evaluated and then the values x=1 and phi=pi/8 to be substituted in. So in the end a numerical value. – aenes1519 Apr 15 '16 at 12:07
• Can you write a formula that you want in the end? – Alexei Boulbitch Apr 15 '16 at 13:10
• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Apr 15 '16 at 19:03

With

q = {x, Φ}
V = (x^2*m^2 + Φ^2*I)/2

fv = Function[{x, Φ}, Evaluate[Total[Flatten[D[V, {q}]]]]][1, pi/8]
(* m^2 + (I pi)/8 *)


gives the desired result, if I understand the question correctly.

If, as suggested in a comment, it is necessary that x and Φ have explicit t dependence, the following can be used instead.

q = {x[t], Φ[t]}
V = (x[t]^2*m^2 + Φ[t]^2*I)/2
fv = Function[{x, Φ}, Evaluate[Total[Flatten[D[V, {q}]]] /. {x[t] -> x, Φ[t] -> Φ}]]
[1, pi/8]


yielding the same result as before.

• I haven't put the entire script in to the question so it may not make sense as to why I started with q = {x[t], [Phi][t]}. But in other parts of my script I need to differentiate with respect to t. For example with D[T,D[q,t]] where T is function dependent on on dq/dt. – aenes1519 Apr 15 '16 at 12:39
• @aenes1519 You can use % /. {x -> x[t], Φ ->Φ[t]} to add the t dependence to the final result. – bbgodfrey Apr 15 '16 at 12:46
• Can I also do it the other way around? %/. {x[t]->x, [Phi][t]->[Phi]} I just tried and it seems to stay the same – aenes1519 Apr 15 '16 at 12:52
• Ignore the last comment, I managed to get it to work by understanding what "%" does. Converting from Matlab to Mathematica for symbolic calculations is proving more difficult than hoped for... – aenes1519 Apr 15 '16 at 12:59