Search code examples
functionwolfram-mathematicanotation

Mathematica: simplify function notation


I have some calculations with an arbitrary function. In the output, Mathematica always shows the function arguments. I would like to tidy the notation a bit, by hidding the arguments in the output. How can I do that? Or even better, is there a way to write the function arguments just once in the code? Remembering it's an arbitrary function.

For example, its something like this:

f[x,y] + (f[x,y])^2 = ...

And I prefer like this:

f + f^2 = ...

Thanks!


Solution

  • You mean just for display purposes? May be a simple /. ?

    Clear[x, y, f]
    expr = f[x, y] + (f[x, y])^2 == 34;
    expr /. f[__] -> f
    

    gives

    Out[29]= f + f^2 == 34
    

    You can even modify $PrePrint to do this automatically

    Clear[x,y,f]
    $PrePrint=#/.f[__]->f&;
    expr=f[x,y]+(f[x,y])^2==34
    
    Out[6]= f+f^2==34
    
    expr
    Out[7]= f+f^2==34
    

    To get it back, do

    $PrePrint=.
    expr
    
    Out[10]= f[x,y]+f[x,y]^2==34
    

    I am not brave enough to do this myself in actual programming, but it is there to try.