solving ordinary differential equations ensure that any list/tuple returned from f_ is wrapped as array f_ lambda utasarray( (ut) zeros((n_t+ len(u_ )) linspace( n_t*dtlen( ) [ u_ for in range(n_t) [ + [ndt*f_( [ ] [ ]return ut the line f_ lambda needs an explanation for userwho just needs to define the in the ode systemit is convenient to insert the various mathematical expressions on the right-hand sides in list and return that list obviouslywe could demand the user to convert the list to numpy arraybut it is so easy to do general such conversion in the ode_fe function as well to make sure that the result from is indeed an array that can be used for array computing in the formula [ndt* ( [ ] [ ])we introduce new function f_ that calls the user' and sends the results through the numpy function asarraywhich ensures that its argument is converted to numpy array (if it is not already an arraynote also the extra parenthesis required when calling zeros with two indices let us show how the previous sir model can be solved using the new general ode_fe that can solve any vector ode the user' (utfunction takes vector uwith three components corresponding to si and as argumentalong with the current time point [ ]and must return the values of the formulas of the right-hand sides in the vector ode an appropriate implementation is def (ut)sir return [-beta* *ibeta* * gamma*igamma*inote that the siand values correspond to and rn these values are then just inserted in the various formulas in the vector ode here we collect the values in list since the ode_fe function will anyway wrap this list in an array we couldof coursereturned an array insteaddef (ut)sir return array([-beta* *ibeta* * gamma*igamma* ]the list version looks bit nicerso that is why we prefer list and rather introduce f_ lambda utasarray( ( , )in the general ode_fe function we can now show function that runs the previous sir examplewhile using the generic ode_fe functiondef demo_sir()"""test case using sir model ""def (ut)sir return [-beta* *ibeta* * gamma*igamma*