michelgordilloa
(Michel Alberto Gordillo Andrade)
1
How to evaluate an expression with a list of numbers:
Base4={x^2 Cos[x], Cos[x] Sin[x]}
(I want to know if the base is equal to 0 at points x=0 and x=Pi. So I do as following)
x=0;
Base4
x=Pi;
Base4
Clear[x]
(is there any way to do this in a single line?)
Two ways to do it “with one line” (there are more ways btw)
In[901]:= Map[{#^2 Cos[#], Cos[#] Sin[#]} &, {1, 2}]
Out[901]= {{Cos[1], Cos[1] Sin[1]}, {4 Cos[2], Cos[2] Sin[2]}}
In[893]:= f[x_] := {x^2 Cos[x], Cos[x] Sin[x]};
In[894]:= SetOptions[f[x], Listable]
Out[894]= SetOptions[{x^2 Cos[x], Cos[x] Sin[x]}, Listable]
In[896]:= f[{1, 2}]
Out[896]= {{Cos[1], 4 Cos[2]}, {Cos[1] Sin[1], Cos[2] Sin[2]}}