When Must I Use `lambda`?
I tried
ahat(atheta)=vector([cos(atheta),sin(atheta),0])
and got:
TypeError: unable to convert (cos(atheta), sin(atheta), 0) to a symbolic
expression
.
Then I tried ahat=lambda atheta: vector([cos(atheta),sin(atheta),0])
and got what I obviously wanted.
Ordinarily, there is no problem with the ordinary kind of function declaration. How am I to tell when I can and when I cannot use the ordinary kind of function declaration?
Perhaps this is just a bug as indicated by the traceback line:
File "/tmp/tmpi4HZNt/___code___.py", line 3, in <module>
exec compile(u'__tmp__=var("atheta"); ahat = symbolic_expression(vector([cos(atheta),sin(atheta),_sage_const_0 ])).function(atheta)
Shouldn't this be the same as that generated by the labmda declaration above?
/tmp/tmp4V6zSv/___code___.py:exec compile(u'ahat=lambda atheta:vector([cos(atheta),sin(atheta),_sage_const_0 ])' + '\n', '', 'single')
That is to say, why are function declarations not treated as syntactic sugars (algebraic identities) for labmda expressions? Is not sagemath a computer aided algebra system?