Can we have the taylor expansion module built for some given expressions of nonlinear equations? Up to 3rd order would be great. Thanks!
To be more specific, the expression to be expanded should be a symbolic expression, this is going to be used in funnel/region-of-attraction computation, where we need to approximate the system dynamics with polynomials.
I think its signature should be something like the following. Can any of you confirm? (or suggest a better one)
/// Returns the Taylor series expansion of `f` around `a` of order `order`.
Expression TaylorExpand(const Expression& f, const Environment& a, int order);
That looks pretty fine by me.
Thanks Soonho! That function signature looks great.
Do you think it makes sense to have Taylor expansion appear somewhere in either the function name or the documentation? Series is not very specific to me.
Also it would be good if we can have a function that we can pass in an Eigen::Vector of expressions, and also return the Eigen::Vector of expressions. This could be easily done by using unaryExpr, and would be a nice syntax sugar.
@hongkai-dai , just updated the signature above.
Also it would be good if we can have a function that we can pass in an Eigen::Vector of expressions, and also return the Eigen::Vector of expressions. This could be easily done by using unaryExpr, and would be a nice syntax sugar.
I agree. After finishing the scalar version, I'll add the vector version.
There is a function named DoFirstOrderTaylorApproximation in systems/primitives/linear_system that construct a pointer of type AffineSystem. It does quite different things than the Taylor expansion intended here - might be something worth considering when deciding on the function name.
@soonho-tri To follow up an earlier discussion, it would be highly desirable to go to the 3rd order. The reason is that we have to guarantee an odd order of the dynamics (f(x)) in order to multiply an odd order of Vdot. As a result, the product is of even order and it satisfies the definition of Sum-of-Squares.
@joycezyu , I've implemented it in my branch, https://github.com/soonho-tri/drake/tree/taylor-expand. Can you pick it up and test it with your application?