(*******************************************************************
This file was generated automatically by the Mathematica front end.
It contains Initialization cells from a Notebook file, which
typically will have the same name as this file except ending in
".nb" instead of ".m".

This file is intended to be loaded into the Mathematica kernel using
the package loading commands Get or Needs.  Doing so is equivalent
to using the Evaluate Initialization Cells menu command in the front
end.

DO NOT EDIT THIS FILE.  This entire file is regenerated
automatically each time the parent Notebook file is saved in the
Mathematica front end.  Any changes you make to this file will be
overwritten.
***********************************************************************)

BeginPackage["SymbolicLinearization`"]





SymbolicLinearization::usage=
  "Computes an n-th order linearization by using the Taylor approximation around a prespecified expansion point in the prespecified variables. Input: function to be linearized, arguments of this function, coordinates of expansion point, order of expansion. Output: linearized function"

Begin["`Private`"]

\!\(SymbolicLinearization[functionexpand_, listofvariables_, expansioncoordinate_, expansionorder_:  1] := \((expansions = Table[FullSimplify[ReplaceAll[ReplaceAll[Normal[Series[ReplaceAll[functionexpand, Drop[Table[listofvariables[\([i]\)] -> expansioncoordinate[\([i]\)], {i, 1, Length[listofvariables]}], {j, j}]], {listofvariables[\([j]\)], expansioncoordinate[\([j]\)], expansionorder}]], \((listofvariables[\([j]\)] - expansioncoordinate[\([j]\)])\) -> expansioncoordinate[\([j]\)]*\(If[Length[Level[Head[listofvariables[\([j]\)]], 1]] > 0, \(ToExpression[ToString[\(Head[listofvariables[\([j]\)]]\)[\([1]\)]] <> "\<der\>"]\)\_\(\(Head[listofvariables[\([j]\)]]\)[\([2]\)]\), ToExpression[ToString[Head[listofvariables[\([j]\)]]] <> "\<der\>"]]\)[listofvariables[\([j, 1]\)]]], listofvariables[\([j]\)] \[Rule] expansioncoordinate[\([j]\)] + expansioncoordinate[\([j]\)]*\(If[Length[Level[Head[listofvariables[\([j]\)]], 1]] > 0, \(ToExpression[ToString[\(Head[listofvariables[\([j]\)]]\)[\([1]\)]] <> "\<der\>"]\)\_\(\(Head[listofvariables[\([j]\)]]\)[\([2]\)]\), ToExpression[ToString[Head[listofvariables[\([j]\)]]] <> "\<der\>"]]\)[listofvariables[\([j, 1]\)]]]] - ReplaceAll[functionexpand, Table[listofvariables[\([i]\)] -> expansioncoordinate[\([i]\)], {i, 1, Length[listofvariables]}]], {j, 1, Length[listofvariables]}]; Total[expansions])\)\[IndentingNewLine]
  End[]\[IndentingNewLine]
  EndPackage[]\)