Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

How can I print my expression with my function's arguments hidden?

For example:

exp=A[r,z]+B[s]^2;

HideArgs[exp]

Output:

A+B^2

The expression that could be tested is this one:

r^3*(Br[r, z]^2+Bz[r, z]^2)==E^(6\[Psi][r, z])*(r*D[\[Psi][r, z], z, z]+r*D[\[Psi][r, z],r,r])

Where the unknown functions are:

Br[r,z],Bz[r,z],\[Psi][r, z]
share|improve this question

marked as duplicate by Mr.Wizard Jan 13 at 9:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
What do you want as output of exp=Sin[A[r,z]+B[s]^2]? –  belisarius Jan 13 at 1:28
    
Just for my unknow functions, so I want it as: exp=Sin[A+B^2] –  Giovanni Jan 13 at 1:39

2 Answers 2

Here is another crude way but it seems flexible.

funcs = {Plus, Times, Power, Sin, Equal};
SetAttributes[HideArgs, HoldAll];
HideArgs[expr_] :=  expr /. {x_[__] /; And @@ (UnsameQ[x, #] & /@ funcs) :> x}

You can continue to add functions to funcs that shouldn't have their arguments hidden. For your example:

HideArgs[A[r, z] + B[s]^2]

Gives:

A + B^2

Also:

HideArgs[A[r, z]]

Gives:

A

Finally:

HideArgs[Sin[A[r, z] + B[s]^2]]

Gives:

Sin[A + B^2]

To test your real equation, I've added Equal to funcs:

HideArgs[r^3*(Br[r, z]^2 + Bz[r, z]^2) == E^(6 \[Psi][r, z])*(r*D[\[Psi][r, z], z, z] +
r*D[\[Psi][r, z], r, r])]

Gives:

(Br^2 + Bz^2)*r^3 == E^(6*\[Psi])*(r*Derivative[0, 2][\[Psi]] + r*Derivative[2, 0][\[Psi]])
share|improve this answer
    
Is there a function that returns a list of all known functions in MMA? –  s0rce Jan 13 at 2:04
    
@s0rce, I guess Names["System`*"] –  RunnyKine Jan 13 at 2:06
    
Hrmm, why doesn't replacing funcs with Names["System`*"] work? –  s0rce Jan 13 at 2:12
1  
@s0rce, I think that expression not only includes the MMA functions but the ones you've defined so it's probably not a good idea to use. –  RunnyKine Jan 13 at 2:14

This should work for polynomials but is a bit messy:

HideArgs[exp_] := With[{exp2 = exp + 0[_]}, Replace[exp2, #[__] -> # & /@ Variables[exp2][[All, 0]], \[Infinity]]]

HideArgs[A[r,z]+B[s]^2]

A + B^2

HideArgs[A[r, z]]

A

There might be a cleaner way.

share|improve this answer
    
Thanks sOrce, it's this what I want, but it fails to work for example on HideArgs[A[r,z]] –  Giovanni Jan 13 at 1:42
    
Fixed but pretty crude, must be a better way. –  s0rce Jan 13 at 1:47

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