# Linearize a polynomial in several variables?

Posted 3 months ago
713 Views
|
7 Replies
|
2 Total Likes
|
 Hello everyone,I would like to linearization polynomial in several variables. For example, we can linearize 1 + x + y + z+ x y + x y z to 1 + x + y + z but how can we get like this result in Mathematica please?Regards, Omar Answer
7 Replies
Sort By:
Posted 3 months ago
 Seems to be a bit tricky. Here a suggestion which , I think, has to be tested with other examples.Say your function is f = gamma + 3 x + a y + z + x y + x y z; and you know the variables are var = {x, y, z}; Get the constant term, if any, by setting all variables to 0 In:= const = f /. (# -> 0 & /@ var) Out= gamma Make a new function f1 ( f without constant term ) In:= f1 = f - const Out= 3 x + a y + x y + z + x y z Now for each variable set the other ones to zero and expand the (new) function in a series up to order 1 h[x_] := Normal[Series[f1 /. ( #1 -> 0 &) /@ Complement[var, {x}], {x, 0, 1}]] Do this for every variable In:= h /@ var Out= {3 x, a y, z} and finally get your linearized function f1L In:= f1L = const + Plus @@ (h /@ var) Out= gamma + 3 x + a y + z Certainely you can combine all these steps in a single function linF[f_, var_] := Module[{}, con = f /. (# -> 0 & /@ var); f1 = f - con; con + Plus @@ (Function[x, Normal[Series[f1, {x, 0, 1}] /. (a_. #1 -> 0 &) /@ Complement[var, {x}]]] /@ var)] Then for example In:= linF[123 a + 4 x + beta y + 45 x z - 78 x y z^2, {z, y, x}] Out= 123 a + 4 x + beta y Answer
Posted 3 months ago
 Thanks so much, Hans. It is a great code.Best wishes Omar Answer
Posted 3 months ago
 This is a variant of finding a total-degree based power series. linearize[poly_] := Module[ {vars = Variables[poly], t}, Normal[Series[poly /. Thread[vars -> t*vars], {t, 0, 1}]] /. t -> 1 ] The example: poly = 1 + x + y + z + x y + x y z; linearize[poly] (* Out= 1 + x + y + z *) Answer
Posted 3 months ago
 In order to to a multi-variable Taylor series expansion, it's necessary to use the procedure Daniel describes, since Series does its expansion sequentially in the variables. Why Mathematica doesn't have a TaylorSeries function is something I've wondered about for years. Answer
Posted 3 months ago
 I will give a suggestion for a procedure which (attempts) to form a Taylor series for a function of several variables in another thread. Answer
Posted 3 months ago
 Thanks so much. As Hans said, the code needs to check.Regards, Omar Answer
Posted 3 months ago
 Hello Dan,cool. But In:= linearize[gamma + 3 x - beta z + 123 x y z] Out= gamma + 3 x instead of In:= linF[gamma + 3 x - beta z + 123 x y z, {z, x, y}] Out= gamma + 3 x - beta z Answer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.