import these from numpy rather than mathsince the functions in math work only with single numbers the following example illustrates how it worksfrom numpy import sinexplinspace def ( )return ** + * - def ( )return sin( )*exp(- *xx (xfloat object is float linspace( intervals in [ , (xy is array (xz is array we see thatexcept for the initial import from numpythe two functions look exactly the same as if they were written to work on single number the result of the two function calls will be two arrays , of length with each element being the function value computed for the corresponding value of if we try to send an array of length to function imported from mathwe will obtain an error messageimport mathnumpy numpy linspace( array([ ]math cos( [ ] math cos(xtraceback (most recent call last)file ""line in typeerroronly size- arrays can be converted to python scalars numpy cos(xarray([ ]on the other handusing numpy functions on single numbers will work just fine natural question to askthenis why do we ever need to import from math at allwhy not use numpy functions all the timesince they do the job for both arrays and numbersthe answer is that we can certainly do thisand in most cases it will work finebut the functions in math are more optimized for single numbers (scalarsand are therefore faster one will rarely notice the differencebut there can be applications where the extra efficiency matters there are also functions in math ( factorialthat do not have corresponding version in numpy we started this by computing points along curve using lists and for loops now that we have introduced numpywe can solve this task much