# Revision history [back]

In your handwritten note, one sees that $u_0=1$ and that, for $n\geq 1$,

$$u_n(t)=\sum_{k=0}^{n-1} \frac{b_k}{k!} t^k + \chi_n u_{n-1}(t) -\chi_n \sum_{k=0}^{n-1} \frac{u_{n-1}^{(k)}(0)}{k!} t^k +\frac{h}{\Gamma(\eta-\alpha)} \int_0^t (t-\tau)^{n-\alpha-1} u_{n-1}(\tau) P(\tau) \,d\tau.$$

This expression can be rewritten as follows:

$$u_n(t)=\sum_{k=0}^{n-1} \frac{b_k}{k!} t^k + \chi_n \bigl(u_{n-1}(t) -q_{n-1}(t)\bigr) +\frac{h}{\Gamma(\eta-\alpha)} I_n(t),$$

where $q_{n-1}$ is the MacLaurin polinomial of $u_{n-1}$ of order $n-1$ and

$$I_n(t) = \int_0^t (t-\tau)^{n-\alpha-1} u_{n-1}(\tau) P(\tau) \,d\tau.$$

You have defined $\chi_n$ as $\chi_n=1$ for $n\geq 2$, as well as $\chi_1=0$ to avoid the term $u_0(t) -q_0(t)$ in the expression of $u_1$. However, since $u_0(t)=1$, it is obvious that $q_0(t)=1$. Hence $u_0(t) -q_0(t)=0$. This implies that, in fact, you do not need $\chi_n$.

Let us consider $I_n(t)$. I think that $n-\alpha-1$ should be greater than $-1$ for this integral to be convergent. Since $\alpha=1.2$, there is a problem in the case $n=1$.

Finally, what is the sense of $U(t)=t^3/3+1$? This function does not appear in the computation of any $u_n$.

Taking all the above facts into account, I have rewritten your code. I do not define $\chi_n$ (not needed), I ignore $U(t)$ and I take a value of $\alpha$ so that $n-\alpha-1>-1$ for any $n$, such as $\alpha=0.8$. It seems that SageMath does not like, at least in this case, float numbers as exponents, so I write $\alpha=8/10$ instead of $\alpha=0.8$. Here it is the code:

var("t,tau")
lamda = 1
P(t) = 2*t - lamda*(-t^4/24+t^5/15-t^7/126+t^8/72)
h = 1
eta = 1.3
alpha = 8/10
nmax = 4
b = nmax*[1]

forget()
assume(t>0)
u = [SR(1).function(t)]
for n in [1..nmax]:
un = sum(b[k]*t^k/factorial(k) for k in [0..n-1])
un += u[n-1](t) - taylor(u[n-1](t), t, 0, n-1)
un += (h/gamma(eta-alpha)) * integrate((t-tau)^(n-alpha-1)*u[n-1](tau)*P(tau),tau, 0, t)
#un = un.full_simplify()
u.append(un.function(t))

UU(t) = sum(u[k](t) for k in [1..nmax])
forget()


Observe that I introduce the variable nmax, for the case being you want to compute more functions $u_n$. Likewise, SageMath needs some help to integrate, so I added the assumption that $t>0$. The forget commands delete the effect of any assume command; thus, SageMath does not get confused by any previous assume you could been using before, and stops using the assumption $t>0$ once $UU$ is computed.

The main loop provides a list with the functions $u_0$, $u_1$,...,$u_{nmax}$. They are symbolic callable functions, so to evaluate, say, $u_3$ at $t=0.5$, you simply write u[3](0.5).

The code also defines $UU$. You can show it

sage: show(UU(t))
[Very large output]


evaluate it at, say, $t=0.9$

sage: UU(0.9).n()
19.7969629979363


or plot it

sage: plot(UU(t), (t,0,1))
[Long time]


In your handwritten note, one sees that $u_0=1$ and that, for $n\geq 1$,

$$u_n(t)=\sum_{k=0}^{n-1} \frac{b_k}{k!} t^k + \chi_n u_{n-1}(t) -\chi_n \sum_{k=0}^{n-1} \frac{u_{n-1}^{(k)}(0)}{k!} t^k +\frac{h}{\Gamma(\eta-\alpha)} \int_0^t (t-\tau)^{n-\alpha-1} u_{n-1}(\tau) P(\tau) \,d\tau.$$

This expression can be rewritten as follows:

$$u_n(t)=\sum_{k=0}^{n-1} \frac{b_k}{k!} t^k + \chi_n \bigl(u_{n-1}(t) -q_{n-1}(t)\bigr) +\frac{h}{\Gamma(\eta-\alpha)} I_n(t),$$

where $q_{n-1}$ is the MacLaurin polinomial of $u_{n-1}$ of order $n-1$ and

$$I_n(t) = \int_0^t (t-\tau)^{n-\alpha-1} u_{n-1}(\tau) P(\tau) \,d\tau.$$

You have defined $\chi_n$ as $\chi_n=1$ for $n\geq 2$, as well as $\chi_1=0$ to avoid the term $u_0(t) -q_0(t)$ in the expression of $u_1$. However, since $u_0(t)=1$, it is obvious that $q_0(t)=1$. Hence $u_0(t) -q_0(t)=0$. This implies that, in fact, you do not need $\chi_n$.

Let us consider $I_n(t)$. I think that $n-\alpha-1$ should be greater than $-1$ for this integral to be convergent. Since $\alpha=1.2$, there is a problem in the case $n=1$.

Finally, what is the sense of $U(t)=t^3/3+1$? This function does not appear in the computation of any $u_n$.

Taking all the above facts into account, I have rewritten your code. I do not define $\chi_n$ (not needed), I ignore $U(t)$ and I take a value of $\alpha$ so that $n-\alpha-1>-1$ for any $n$, such as $\alpha=0.8$. It seems that SageMath does not like, at least in this case, float numbers as exponents, so I write $\alpha=8/10$ instead of $\alpha=0.8$. Here it is the code:

var("t,tau")
lamda = 1
P(t) = 2*t - lamda*(-t^4/24+t^5/15-t^7/126+t^8/72)
h = 1
eta = 1.3
alpha = 8/10
nmax = 4
b = nmax*[1]

forget()
assume(t>0)
u = [SR(1).function(t)]
for n in [1..nmax]:
un = sum(b[k]*t^k/factorial(k) for k in [0..n-1])
un += u[n-1](t) - taylor(u[n-1](t), t, 0, n-1)
un += (h/gamma(eta-alpha)) * integrate((t-tau)^(n-alpha-1)*u[n-1](tau)*P(tau),tau, 0, t)
#un = un.full_simplify()
u.append(un.function(t))

UU(t) = sum(u[k](t) for k in [1..nmax])
forget()


Observe that I introduce the variable nmax, for the case being you want to compute more functions $u_n$. Likewise, SageMath needs some help to integrate, so I added the assumption that $t>0$. The forget commands delete the effect of any assume command; thus, SageMath does not get confused by any previous assume you could been using before, and stops using the assumption $t>0$ once $UU$ is computed.

The main loop provides a list with the functions $u_0$, $u_1$,...,$u_{nmax}$. They are symbolic callable functions, so to evaluate, say, $u_3$ at $t=0.5$, you simply write u[3](0.5).

The code also defines $UU$. You can show it

sage: show(UU(t))
[Very large output]


evaluate it at, say, $t=0.9$

sage: UU(0.9).n()
19.7969629979363


or plot it

sage: plot(UU(t), (t,0,1))
[Long time]


In your handwritten note, one sees that $u_0=1$ and that, for $n\geq 1$,

$$u_n(t)=\sum_{k=0}^{n-1} \frac{b_k}{k!} t^k + \chi_n u_{n-1}(t) -\chi_n \sum_{k=0}^{n-1} \frac{u_{n-1}^{(k)}(0)}{k!} t^k +\frac{h}{\Gamma(\eta-\alpha)} \int_0^t (t-\tau)^{n-\alpha-1} u_{n-1}(\tau) P(\tau) \,d\tau.$$

This expression can be rewritten as follows:

$$u_n(t)=\sum_{k=0}^{n-1} \frac{b_k}{k!} t^k + \chi_n \bigl(u_{n-1}(t) -q_{n-1}(t)\bigr) +\frac{h}{\Gamma(\eta-\alpha)} I_n(t),$$

where $q_{n-1}$ is the MacLaurin polinomial of $u_{n-1}$ of order $n-1$ and

$$I_n(t) = \int_0^t (t-\tau)^{n-\alpha-1} u_{n-1}(\tau) P(\tau) \,d\tau.$$

You have defined $\chi_n$ as $\chi_n=1$ for $n\geq 2$, as well as $\chi_1=0$ to avoid the term $u_0(t) -q_0(t)$ in the expression of $u_1$. However, since $u_0(t)=1$, it is obvious that $q_0(t)=1$. Hence $u_0(t) -q_0(t)=0$. This implies that, in fact, you do not need $\chi_n$.

Let us consider $I_n(t)$. I think that $n-\alpha-1$ should be greater than $-1$ for this integral to be convergent. Since $\alpha=1.2$, there is a problem in the case $n=1$.

Finally, what is the sense of $U(t)=t^3/3+1$? This function does not appear in the computation of any $u_n$.

Taking all the above facts into account, I have rewritten your code. I do not define $\chi_n$ (not needed), I ignore $U(t)$ and I take a value of $\alpha$ so that $n-\alpha-1>-1$ for any $n$, such as $\alpha=0.8$. It seems that SageMath does not like, at least in this case, float numbers as exponents, so I write $\alpha=8/10$ instead of $\alpha=0.8$. Here it is the code:

var("t,tau")
lamda = 1
P(t) = 2*t - lamda*(-t^4/24+t^5/15-t^7/126+t^8/72)
h = 1
eta = 1.3
alpha = 8/10
nmax = 4
b = nmax*[1]

forget()
assume(t>0)
u = [SR(1).function(t)]
for n in [1..nmax]:
un = sum(b[k]*t^k/factorial(k) for k in [0..n-1])
un += u[n-1](t) - taylor(u[n-1](t), t, 0, n-1)
un += (h/gamma(eta-alpha)) * integrate((t-tau)^(n-alpha-1)*u[n-1](tau)*P(tau),tau, 0, t)
(h/gamma(eta-alpha))*integrate((t-tau)^(n-alpha-1)*u[n-1](tau)*P(tau),tau,0,t)
u.append(un.function(t))

UU(t) = sum(u[k](t) for k in [1..nmax])
forget()


Observe that I introduce the variable nmax, for the case being you want to compute more functions $u_n$. Likewise, SageMath needs some help to integrate, so I added the assumption that $t>0$. The forget commands delete the effect of any assume command; thus, SageMath does not get confused by any previous assume you could been using before, and stops using the assumption $t>0$ once $UU$ is computed.

The main loop provides a list with the functions $u_0$, $u_1$,...,$u_{nmax}$. They are symbolic callable functions, so to evaluate, say, $u_3$ at $t=0.5$, you simply write u[3](0.5).

The code also defines $UU$. You can show it

sage: show(UU(t))
[Very large output]


evaluate it at, say, $t=0.9$

sage: UU(0.9).n()
19.7969629979363


or plot it

sage: plot(UU(t), (t,0,1))
[Long time]