# Formatted/modified Mathematica command

I know there is a way of making your own commands that outputs your desired information but I'm not sure how to do this. How do you format/modify/make your own command that outputs what you want.

E.g. How do you make a code that whenever you put in a function, it gives you information such as its domain, range, turning points, intercepts and so on...

This provides a couple of examples of information types, you can add other information as required.

Clear["Global*"]

funcInfo[func_, var_Symbol] := Module[
{dom, critPts, roots},
dom = FunctionDomain[func, var] /. True -> {-Infinity, Infinity};
roots = Solve[func == 0, var, Method -> Reduce];
critPts = Solve[
D[func, var] == 0, var, Reals, Method -> Reduce];
{"Domain", dom},
{"Roots", roots},
{"Critical Points", critPts}}]

funcInfo[x^2 + 2 x - 3, x] // Grid[#, Frame -> All] &


funcInfo[x^3 - 6 x^2 + 13 x - 10, x] // Grid[#, Frame -> All] &


funcInfo[x*E^-x, x] // Grid[#, Frame -> All] &
`

• Wow this is great. Thank you so much, really appreciate it. So I assume we can use this as a building block to make self made commands? – Krishiv SURESH Jul 7 at 3:36