# Save only RHS of equation

If I have an equation in Mathematica, say

f=a*x+Exp[x]


is it possible to save only RHS of the equation into a text or mx file, so that later I can load it and assign it to some other variable? Save seems to save the whole thing. Thanks for any help in advance.

• Try Put and friends – Kuba Nov 24 '16 at 11:28
• That's not an equation, an equation is of the form f == a*x + Exp[x]. If you store this equation in g with g = f == a*x + Exp[x], running g[[2]] returns the RHS of the equation. – Feyre Nov 24 '16 at 12:09

f = a*x + Exp[x]


is an assignment to the variable f, not an equation. If you save f to a file, you will be saving its value, which is exactly what you want.

Suppose you want the save the file to your desktop, then you could write

f = a*x + Exp[x]


E^x+a x

path = FileNameJoin[{\$HomeDirectory, "Desktop", "f.m"}];
Put[f, path]


and retrieve it with

Get[path]


E^x+a x