# Creating a function in which certain conditions exist

I am trying to create a function for which it is known that certain conditions exist on the argument. I want this to be a simplified version of the function. For example, if I wanted to create a function to find $$\sqrt{x^2}$$, and I know that $$x>0$$, then the function should be $$x$$. I have tried this

f[x_] = Sqrt[x^2] && x > 0


However, when I look at f[x], it shows up as Sqrt[x^2] && x > 0, not x. How can I do this?

• Something like f[x_] = Simplify[Sqrt[x^2], x>0]? – Carl Woll Jun 17 '19 at 23:26
• Wow, I did not know that would work. Thanks for the help – automaticallyGenerated Jun 17 '19 at 23:29