Question: How make a table for numerical results between exact & approximation solution also error ?

If we calculating it take to much time but if we make a procedure it will be more effectable for such example, i want the exact and approximat and error

restart

with(PDEtools)

with(LinearAlgebra)

NULL

with(inttrans)

with(SolveTools)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(1)

NULL

eq := diff(y(x, t), `$`(t, 2))+(1+x)*(diff(y(x, t), x))-y(x, t) = 2*y(x, t)^3

diff(diff(y(x, t), t), t)+(1+x)*(diff(y(x, t), x))-y(x, t) = 2*y(x, t)^3

(2)

eq1 := laplace(eq, t, s)

s^2*laplace(y(x, t), t, s)-s*y(x, 0)+laplace(diff(y(x, t), x), t, s)*x-laplace(y(x, t), t, s)-(D[2](y))(x, 0)+laplace(diff(y(x, t), x), t, s) = 2*laplace(y(x, t)^3, t, s)

(3)

eq2 := subs({y(x, 0) = 1, (D[2](y))(x, 0) = 1}, eq1)

s^2*laplace(y(x, t), t, s)-s+laplace(diff(y(x, t), x), t, s)*x-laplace(y(x, t), t, s)-1+laplace(diff(y(x, t), x), t, s) = 2*laplace(y(x, t)^3, t, s)

(4)

eq3 := s^2*laplace(y(x, t), t, s) = s-laplace(diff(y(x, t), x), t, s)*x+1+laplace(diff(y(x, t), x), t, s)+2*laplace(y(x, t)^3, t, s)+laplace(y(x, t), t, s)

s^2*laplace(y(x, t), t, s) = s-laplace(diff(y(x, t), x), t, s)*x+1+laplace(diff(y(x, t), x), t, s)+2*laplace(y(x, t)^3, t, s)+laplace(y(x, t), t, s)

(5)

eq4 := expand(eq3/s^2)

laplace(y(x, t), t, s) = 1/s-laplace(diff(y(x, t), x), t, s)*x/s^2+1/s^2+laplace(diff(y(x, t), x), t, s)/s^2+2*laplace(y(x, t)^3, t, s)/s^2+laplace(y(x, t), t, s)/s^2

(6)

NULL

"u[0](x):=invlaplace(1/s+1/(s^2),s,x)"

proc (x) options operator, arrow, function_assign; invlaplace(1/s+1/s^2, s, x) end proc

(7)

u[0](x)

1+x

(8)

n := N

N

(9)

k := K

K

(10)

f := proc (u) options operator, arrow; u^3 end proc

proc (u) options operator, arrow; u^3 end proc

(11)

for j from 0 to 3 do A[j] := subs(lambda = 0, (diff(f(seq(sum(lambda^i*u[i](x), i = 0 .. 20), m = 1 .. 2)), [`$`(lambda, j)]))/factorial(j)) end do

(1+x)^3

 

3*(1+x)^2*u[1](x)

 

3*(1+x)*u[1](x)^2+3*(1+x)^2*u[2](x)

 

u[1](x)^3+6*(1+x)*u[1](x)*u[2](x)+3*(1+x)^2*u[3](x)

(12)

A[0]

(1+x)^3

(13)

y[0] := 1+x

1+x

(14)

y[1] := invlaplace(2*laplace(A[0], x, s)/s^2, s, x)-invlaplace(x*laplace(diff(y[0], x), x, s)/s^2, s, x)+invlaplace(laplace(y[0], x, s)/s^2, s, x)-invlaplace(laplace(diff(y[0], x), x, s)/s^2, s, x)

(1/10)*x^2*(x^3+5*x^2+10*x+10)-(1/2)*x^3+(1/6)*x^2*(x+3)-(1/2)*x^2

(15)

y[1] := expand((1/10)*x^2*(x^3+5*x^2+10*x+10)-(1/2)*x^3+(1/6)*x^2*(x+3)-(1/2)*x^2)

(1/10)*x^5+(1/2)*x^4+(2/3)*x^3+x^2

(16)

"u[1](x) :=y[1]  "

proc (x) options operator, arrow, function_assign; y[1] end proc

(17)

NULL

A[1]

3*(1+x)^2*((1/10)*x^5+(1/2)*x^4+(2/3)*x^3+x^2)

(18)

y[2] := invlaplace(2*laplace(A[1], x, s)/s^2, s, x)-invlaplace(x*laplace(diff(y[1], x), x, s)/s^2, s, x)+invlaplace(laplace(y[1], x, s)/s^2, s, x)-invlaplace(laplace(diff(y[1], x), x, s)/s^2, s, x)

(1/840)*x^4*(7*x^5+63*x^4+212*x^3+476*x^2+672*x+420)-(1/60)*x^4*(x^3+6*x^2+10*x+20)+(1/420)*x^4*(x^3+7*x^2+14*x+35)-(1/60)*x^3*(x^3+6*x^2+10*x+20)

(19)

y[2] := expand(%)

(1/120)*x^9+(3/40)*x^8+(5/21)*x^7+(7/15)*x^6+(17/30)*x^5+(1/12)*x^4-(1/3)*x^3

(20)

" u[2](x):=y[2]"

proc (x) options operator, arrow, function_assign; y[2] end proc

(21)

A[2]

3*(1+x)*((1/10)*x^5+(1/2)*x^4+(2/3)*x^3+x^2)^2+3*(1+x)^2*((1/120)*x^9+(3/40)*x^8+(5/21)*x^7+(7/15)*x^6+(17/30)*x^5+(1/12)*x^4-(1/3)*x^3)

(22)

y[3] := invlaplace(2*laplace(A[2], x, s)/s^2, s, x)-invlaplace(x*laplace(diff(y[2], x), x, s)/s^2, s, x)+invlaplace(laplace(y[2], x, s)/s^2, s, x)-invlaplace(laplace(diff(y[2], x), x, s)/s^2, s, x)

(1/10810800)*x^5*(7623*x^8+99099*x^7+518778*x^6+1634490*x^5+3647930*x^4+5167305*x^3+4221360*x^2+900900*x-1081080)-(1/25200)*x^5*(21*x^6+210*x^5+750*x^4+1680*x^3+2380*x^2+420*x-2100)+(1/831600)*x^5*(63*x^6+693*x^5+2750*x^4+6930*x^3+11220*x^2+2310*x-13860)-(1/25200)*x^4*(21*x^6+210*x^5+750*x^4+1680*x^3+2380*x^2+420*x-2100)

(23)

y[3] := expand(y[3])

(286/945)*x^9+(131/336)*x^8+(1/7)*x^10+(17/70)*x^7-(1/40)*x^6-(1/20)*x^5+(1/12)*x^4+(1091/23100)*x^11+(11/15600)*x^13+(11/1200)*x^12

(24)

NULL

addingterm := y[0]+y[1]+y[2]+y[3]

1+x+(37/60)*x^5+(2/3)*x^4+(1/3)*x^3+x^2+(2351/7560)*x^9+(781/1680)*x^8+(101/210)*x^7+(53/120)*x^6+(1/7)*x^10+(1091/23100)*x^11+(11/15600)*x^13+(11/1200)*x^12

(25)


 

Download aproximate_and_exact_solution.mw

a table like that

 

Please Wait...