I want to do following:

ArcTan[1/Sqrt[-1 + (4 Sqrt[2] x^2)/(5 xc^2)]] /.4 Sqrt[2]/5->a^2

I expect to have

ArcTan[1/Sqrt[-1 + x^2/(a^2 xc^2)]]

Mathematica cannot recognize 4 Sqrt[2]/5 in expression.

  • $\begingroup$ Please provide a short but complete example, not just a fragment. Also explain what output you're expecting and what you actually got. $\endgroup$
    – Szabolcs
    Feb 6, 2015 at 18:49
  • $\begingroup$ /.4 is ambiguous, add a space to get /. 4 $\endgroup$ Feb 6, 2015 at 19:10
  • 1
    $\begingroup$ I was going to say what @Manuel --Moe-- G noted. I'll add that I for one believe this was a deplorable lexing/parsing decision, made by the wrong person, and retained ever since I have no idea why. The rule everywhere else is that a lexeme is as long as it can be. I will add that this bites me particularly hard because I often need to replace zeros (why that happens I don't know, but it does happen frequently). $\endgroup$ Feb 7, 2015 at 22:37

1 Answer 1

Sqrt[5/3] + 1 /. Sqrt[5/3] -> a
(* 1 + a *)

Tanh[Sqrt[5/3] x] /. Sqrt[5/3] ->  a
(* Tanh[a x] *)

Try starting a new Mathematica session

  • $\begingroup$ sorry, I tried to keep it as simple as possible, but it does not cover my problem (see edit) $\endgroup$ Feb 6, 2015 at 18:57
  • $\begingroup$ @belarus28 Copy this as is and execute ArcTan[1/Sqrt[-1 + (4 Sqrt[2] x^2)/(5 xc^2)]] /. 4 Sqrt[2]/5 -> a^2 $\endgroup$ Feb 6, 2015 at 19:01
  • $\begingroup$ wow! it was not working, and now in the new session it works... magic. thanks. $\endgroup$ Feb 6, 2015 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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