ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 24 Oct 2019 22:30:04 +0200Functions order truncation (linearization)https://ask.sagemath.org/question/48465/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.Tue, 22 Oct 2019 14:25:00 +0200https://ask.sagemath.org/question/48465/functions-order-truncation-linearization/Answer by eric_g for <p>I want from from expression like</p>
<p>$$e = (1 + h + \frac{\partial h}{\partial x}) (1 + h + \frac{\partial h}{\partial y})$$</p>
<p>arrive to</p>
<p>$$e \approx 1 + 2h + \frac{\partial h}{\partial x} + \frac{\partial h}{\partial y} + O(\dots)$$</p>
<p>by assumptions $h \ll 1; \frac{\partial h}{\partial x} \ll 1; \frac{\partial h}{\partial y} \ll 1$</p>
<p>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.</p>
https://ask.sagemath.org/question/48465/functions-order-truncation-linearization/?answer=48491#post-id-48491In 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
Thu, 24 Oct 2019 22:30:04 +0200https://ask.sagemath.org/question/48465/functions-order-truncation-linearization/?answer=48491#post-id-48491