2
$\begingroup$

I have a function f1 with three inputs: x1,y1,z1. I have written this in standard form as

f1[x1, y1, z1] 

I wanted to convert to Infix form so I did

Infix[f1[x1, y1, z1]]

Now I wanted to convert it back to StandardForm so I did

StandardForm[Infix[f1[x1, y1, z1]]]

It is not returning back this

 f1[x1, y1, 1z] 

Instead, it is giving me this

   x1~f1~y1~f1~z1

I'm expecting StandarForm and Infix functions need to be kind of inverse of each other.

StandardForm[Infix[
   StandardForm[Infix[
     f1[x1, y1, z1]]]]]

I thought that the output of the above should be

 f1[x1, y1, z1] 

But it is not. Why? What concept I'm missing here?

$\endgroup$
2
  • $\begingroup$ Infix[f[x,y,z]]; StandardForm[%] works. $\endgroup$
    – Alx
    Commented Oct 11, 2019 at 14:57
  • $\begingroup$ It is not working in 11.0 version $\endgroup$ Commented Oct 13, 2019 at 4:49

1 Answer 1

2
$\begingroup$

First of all, Infix isn't a function: it just a formatting wrapper which affects printing, but not evaluation (like NumberForm, InputForm etc.):

Infix[f1[x1, y1, z1]]

x1 ~f1~ y1 ~f1~ z1

% // FullForm
Infix[f1[x1, y1, z1]]

Likewize StandardForm is also just a wrapper with the only difference that it is stripped off if the output is printed:

sf = StandardForm[f1[x1, y1, z1]]
f1[x1, y1, z1]
% // FullForm
sf // FullForm
f1[x1, y1, z1]
StandardForm[f1[x1, y1, z1]]

Secondly, the generated infix form is't equivalent to the original expression as one can easily see by copying it and evaluating:

x1 ~f1~ y1 ~f1~ z1
f1[f1[x1, y1], z1]

But since this infix form is just a display form and the Kernel still keeps the original expression simply wrapped with Infix, you can easily get it back in the StandardForm just by replacing the Head by StandardForm:

StandardForm @@ Infix[f1[x1, y1, z1]]
f1[x1, y1, z1]

... or just by removing the Infix Head:

Infix[f1[x1, y1, z1]]
% // First

x1 ~f1~ y1 ~f1~ z1

f1[x1, y1, z1]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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