Gradient of an expression with respect to another expression?

I am trying to evaluate the gradient of an expression with respect to a vector, whose elements are expressions, not variables. Let’s say the expression looks something like this :

I want to take the Gradient of H as follows:

As you can see, Mathematica doesn’t evaluate the Gradient. Any suggestions? Thanks in advance!

You can replace either by inspection or solving for the new variables:

h = (t1 - t2)^2 + (t2 - t3)^2 + (t1 - t3)^2 + (m1*(ob1 - on))^2/
    m1 + (m2*(ob2 - on))^2/m2 + (m3*(ob3 - on))^2/m3;
Simplify[h /.
  Solve[{e1 == t1 - t2, e2 == t2 - t3,
     p1 == m1*(ob1 - on), p2 == m2*(ob2 - on), p3 == m3*(ob3 - on)},
    {t2, t3, ob1, ob2, ob3}][[1]]]
Grad[%, {e1, e2, p1, p2, p3}]

Your three components of eta are not independent.

Thanks a lot!
But the thing is, I would like to have in the output of the gradient in terms of {ob1,ob2, ob3}

For example, Grad[h,{p1,p2,p3}] should result in {2*(ob1-on),2*(ob2-on),2*(ob3-on)} and not in {2*p1/m1,2*p2/m2,2*p3/m3}
Any ideas?
Thanks again!

The clean way is to start with H in terms of eta and p from the beginning. However, you can replace back:

h = (t1 - t2)^2 + (t2 - t3)^2 + (t1 - t3)^2 + (m1*(ob1 - on))^2/
    m1 + (m2*(ob2 - on))^2/m2 + (m3*(ob3 - on))^2/m3;
Simplify[h /. 
  Solve[{e1 == t1 - t2, e2 == t2 - t3, p1 == m1*(ob1 - on), 
     p2 == m2*(ob2 - on), p3 == m3*(ob3 - on)}, {t2, t3, ob1, ob2, 
     ob3}][[1]]]
Grad[%, {e1, e2, p1, p2, p3}] /. {e1 -> t1 - t2, e2 -> t2 - t3,
  p1 -> m1*(ob1 - on), p2 -> m2*(ob2 - on), p3 -> m3*(ob3 - on)}

You have to make up your mind on the three components of eta.

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]