Functions order truncation (linearization)

I want from from expression like

$$e = (1 + h + \frac{\partial h}{\partial x}) (1 + h + \frac{\partial h}{\partial y})$$

arrive to

$$e \approx 1 + 2h + \frac{\partial h}{\partial x} + \frac{\partial h}{\partial y} + O(\dots)$$

by assumptions $h \ll 1; \frac{\partial h}{\partial x} \ll 1; \frac{\partial h}{\partial y} \ll 1$

Is there instrument for such transformations in sagemath? The problem I'm running into is $h$ being function of some vairables, while every occurance of big O notation in documentation operates on some ring variable.

edit retag close merge delete

Sort by ยป oldest newest most voted

In such a case, I would introduce a "small" parameter, t say, substitute t*h for h, perform the expansion in term of t, and set t=1 in the final result. Here is the corresponding code:

sage: x, y = var('x y')
sage: h = function('h')
sage: H = h(x, y)
sage: e = (1 + H + diff(H, x)) * (1 + H + diff(H, y))
sage: e
(h(x, y) + diff(h(x, y), x) + 1)*(h(x, y) + diff(h(x, y), y) + 1)
sage: t = var('t')
sage: th(x, y) = t*H
sage: et = e.substitute_function(h, th)
sage: et
(t*h(x, y) + t*diff(h(x, y), x) + 1)*(t*h(x, y) + t*diff(h(x, y), y) + 1)
sage: taylor(et, t, 0, 1).subs({t: 1})
2*h(x, y) + diff(h(x, y), x) + diff(h(x, y), y) + 1

more

Please start posting anonymously - your entry will be published after you log in or create a new account.