I have the following function:


f=-a n^2/v^2 +v/n

I want to Replace v/n by v_new

Attempt: [Failed]

f/. v/n -> v_new

Desired output:

-a/v_new +v_new

closed as off-topic by LLlAMnYP, dr.blochwave, Jason B., user9660, gpap Nov 17 '15 at 14:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – LLlAMnYP, dr.blochwave, Jason B., Community, gpap
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ One imediate issue that I can spot is use of underscore _ in the variable you are trying to use to replace 'v/n' $\endgroup$ – e.doroskevic Nov 17 '15 at 13:35
  • 1
    $\begingroup$ As a general rule, structure replacement rules with the LHS of the rule to be as simple as possible to avoid having to handle multiple cases separately. For example, as pointed out in answer by @JasonB, instead of v/n -> v2 use v -> n*v2 $\endgroup$ – Bob Hanlon Nov 17 '15 at 13:51
  • $\begingroup$ @ Bob Hanlon Thanks! This helps $\endgroup$ – jasmin Nov 17 '15 at 14:12

Just simplify your replacement rule so that you aren't replacing v/n->v2, but replacing v->n v2

f = -a n^2/v^2 + v/n
(* -((5 n^2)/v^2) + v/n *)

f /. v -> n v2
(* -(5/v2^2) + v2 *)


I do not know how to evaluate your eq. to the desired output. However if you use ReplaceAll in a following way you can replace 'v/n' term. Please see the implementation below. Also, please refer to this link for information on basic syntax issues.


-a*n^2/v^2 + v/n /. v/n -> v2

Where v2 is the variable which is going to be used for replacement and v/n is going to be the term to be replaced.


-((a n^2)/v^2) + v2


  • $\begingroup$ The main point here is that the replacement is not complete. When I replace v/n by v2 there shall be the output -((a/(v2)^2) + v2 . This is the expectation, but what really happening is that: -((a n^2)/v^2) + v2. This is not the output I want $\endgroup$ – jasmin Nov 17 '15 at 13:43
  • $\begingroup$ -a*n^2/v^2 + v/n /. {v/n -> v2, n^2/v^2 -> v2} - do you mean this? $\endgroup$ – e.doroskevic Nov 17 '15 at 13:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.