0
$\begingroup$

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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.