for a formula eg y=a*x+b in book, we can use y=a*x+b and use y to quote the expression a*x+b for later using. but we also can define a function y[x_]:=a*x+b and use y[x] eg y[1] to quote the expression for later using.
i wonder whether a choice is better in some cases and another choice is better in some cases or equal essentially? or ask this way: in which cases you will create a function(i think in most simple cases, just using a symbol to receive the right is ok)
Asked
Active
Viewed 56 times
0
Aerterliusi
- 353
- 1
- 5
eqn1= (y==a*x+b)is an option too. – rhermans Feb 03 '23 at 08:26y=exprstores the expression: expr in y. On the other hand,f[x_]=expris a function with an parameter y to be replaced by an actual value. – Daniel Huber Feb 03 '23 at 14:22y[a_, b_, x_] := a*x+b(and with descriptive variable/parameter names). This makes the code clearer and easier to maintain. Abbreviated forms are principally for quick, limited use. – Bob Hanlon Feb 03 '23 at 16:49