Struggling to apply chain rule on a recursive function

I have that $$h_{t}(w)=f(h_{t-1}(w),w)$$ and $$h_{1}(w)=f(w)$$ and I'm trying to find $$y = \frac{\partial h_{t}}{\partial w}$$

My attempt so far

$$\frac{\partial h_{t}}{\partial w} = \sum_{i=1}^{t} \frac{\partial h_{t}}{\partial h_{i}} * \frac{\partial h_{i}}{\partial w}$$

But it doesn't feel right. In particular, it's as if each second term in the sum will correspond to its own sum.

To reach what I did, I used the fact that $$h_t$$ is a function of all $$h_i$$ for $$1<=i<=t-1$$ with each (including $$h_{t}$$) being a function in $$w$$

• Let's be clear: do you mean $h_t(w)=f(h_{t-1}(w),w)$ ? Sep 13, 2022 at 17:15
• Yes, I thought that was implicitly implied. Will modify the question. Sep 13, 2022 at 17:31
• Well you haven't modified it: it is $h_t(w)$ and $h_1(w)$ on the LHS. It matters. Sep 13, 2022 at 17:34
• And now we have a second difficulty. You are using $f$ both as the name of a unary function when you write $h_1(w)=f(w)$ and then as the name of a binary function when you write $h_t(w)=f(h_{t-1}(w),w)$. These can't be the same function, so please re-edit to tell us what you mean. Sep 13, 2022 at 17:37
• Thank you a lot for the corrections. How should I express it in case it's true that $h_{1}(w)=f(h_{0},w)$ but $h_{0}$ is constant? Sep 13, 2022 at 17:43

From the comments I wonder if this is what you are asking.

Suppose we are given some $$c\in\mathbb{R}$$ and some function $$f:\mathbb{R}^2\to\mathbb{R}$$, all of whose derivatives exist. Then we can define recursively a sequence of functions (of a single variable) $$h_t:\mathbb{R}\to\mathbb{R}$$ by

$$h_t(w)= \begin{cases} c &\text{ when t=0;}\\ f(h_{t-1}(w),w) &\text{ when t\geqslant 1.} \end{cases}$$

Find an expression for $$h_t'(w)$$.

Notation: Let us write $$f_1(x,y)$$ for $$\frac{\partial f}{\partial x}(x,y)$$, and $$f_2(x,y)$$ for $$\frac{\partial f}{\partial y}(x,y)$$.

The derivatives of the first few $$h_t$$ are as follows.

$$\begin{eqnarray} h_0'(w) &=& 0;\\ h_1'(w) &=& f_2(h_0(w),w);\\ h_2'(w) &=& f_1(h_1(w),w)f_2(h_0(w),w)+f_2(h_1(w),w);\\ h_3'(w) &=& f_1(h_2(w),w)f_1(h_1(w),w)f_2(h_0(w),w)+f_1(h_2(w),w)f_2(h_1(w),w)+f_2(h_2(w),w). \end{eqnarray}$$

I think it's clear what the pattern is, and that it would be straightforward to prove by induction. But it would be a notational nightmare and perhaps not very illuminating.

If there is an easier answer to this question I hope someone will post it and then I can delete this very extended comment.