I have looked here which describes how to define operators. I was wondering whether there was a way to assign thes operators to special characters? eg Let $\odot:=(a+b)(ab),$ so 4\[CircleDot]3 would yield 84? It is really a stylistic / display issue - of course the same could be achieved with cd[a_,b_]:=(a+b) a b, implemented with cd[a,b].
Asked
Active
Viewed 226 times
1
-
1Take a look at this question, see if my answer there might help you along: How to assign symbols to functions – MarcoB Jun 19 '15 at 12:32
-
@MarcoB I have taken a look at the link, but usure on syntax when it comes to applying it to the example above – martin Jun 19 '15 at 12:38
-
1I think Karsten took care of that below :-) – MarcoB Jun 19 '15 at 12:46
1 Answers
4
CircleDot[a_, b_] := (a + b) a b
Now
4⊙3
84
Karsten7
- 27,448
- 5
- 73
- 134
-
ha! I didn't think it would be that simple - I thought the operator would have to preceed the arguments - thank you! :) – martin Jun 19 '15 at 12:47
-
3@martin
4⊙3//FullFormmay shed some light on your confusion. Some operators are infix, meaning⊙is the same as~CircleDot~and we know, thata~CircleDot~bis the same asCircleDot[a,b]. But in fact, you could just as easily set like so:a_⊙b_:=(a + b) a b, MMA would interpret this just like the full form that Karsten showed in this answer. – LLlAMnYP Jun 19 '15 at 13:06 -
-
1