Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 5 years ago

Juanjo gravatar image

In your handwritten note, one sees that u0=1 and that, for n1,

un(t)=n1k=0bkk!tk+χnun1(t)χnn1k=0u(k)n1(0)k!tk+hΓ(ηα)t0(tτ)nα1un1(τ)P(τ)dτ.

This expression can be rewritten as follows:

un(t)=n1k=0bkk!tk+χn(un1(t)qn1(t))+hΓ(ηα)In(t),

where qn1 is the MacLaurin polinomial of un1 of order n1 and

In(t)=t0(tτ)nα1un1(τ)P(τ)dτ.

You have defined χn as χn=1 for n2, as well as χ1=0 to avoid the term u0(t)q0(t) in the expression of u1. However, since u0(t)=1, it is obvious that q0(t)=1. Hence u0(t)q0(t)=0. This implies that, in fact, you do not need χn.

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

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

Taking all the above facts into account, I have rewritten your code. I do not define χn (not needed), I ignore U(t) and I take a value of α so that nα1>1 for any n, such as α=0.8. It seems that SageMath does not like, at least in this case, float numbers as exponents, so I write α=8/10 instead of α=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 un. 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 u0, u1,...,unmax. They are symbolic callable functions, so to evaluate, say, u3 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]

image description

click to hide/show revision 2
No.2 Revision

In your handwritten note, one sees that u0=1 and that, for n1,

un(t)=n1k=0bkk!tk+χnun1(t)χnn1k=0u(k)n1(0)k!tk+hΓ(ηα)t0(tτ)nα1un1(τ)P(τ)dτ.

This expression can be rewritten as follows:

un(t)=n1k=0bkk!tk+χn(un1(t)qn1(t))+hΓ(ηα)In(t),

where qn1 is the MacLaurin polinomial of un1 of order n1 and

In(t)=t0(tτ)nα1un1(τ)P(τ)dτ.

You have defined χn as χn=1 for n2, as well as χ1=0 to avoid the term u0(t)q0(t) in the expression of u1. However, since u0(t)=1, it is obvious that q0(t)=1. Hence u0(t)q0(t)=0. This implies that, in fact, you do not need χn.

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

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

Taking all the above facts into account, I have rewritten your code. I do not define χn (not needed), I ignore U(t) and I take a value of α so that nα1>1 for any n, such as α=0.8. It seems that SageMath does not like, at least in this case, float numbers as exponents, so I write α=8/10 instead of α=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 un. 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 u0, u1,...,unmax. They are symbolic callable functions, so to evaluate, say, u3 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]

image description

click to hide/show revision 3
No.3 Revision

In your handwritten note, one sees that u0=1 and that, for n1,

un(t)=n1k=0bkk!tk+χnun1(t)χnn1k=0u(k)n1(0)k!tk+hΓ(ηα)t0(tτ)nα1un1(τ)P(τ)dτ.

This expression can be rewritten as follows:

un(t)=n1k=0bkk!tk+χn(un1(t)qn1(t))+hΓ(ηα)In(t),

where qn1 is the MacLaurin polinomial of un1 of order n1 and

In(t)=t0(tτ)nα1un1(τ)P(τ)dτ.

You have defined χn as χn=1 for n2, as well as χ1=0 to avoid the term u0(t)q0(t) in the expression of u1. However, since u0(t)=1, it is obvious that q0(t)=1. Hence u0(t)q0(t)=0. This implies that, in fact, you do not need χn.

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

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

Taking all the above facts into account, I have rewritten your code. I do not define χn (not needed), I ignore U(t) and I take a value of α so that nα1>1 for any n, such as α=0.8. It seems that SageMath does not like, at least in this case, float numbers as exponents, so I write α=8/10 instead of α=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 un. 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 u0, u1,...,unmax. They are symbolic callable functions, so to evaluate, say, u3 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]

image description