# Question:solving ODE with analytical solution

## Question:solving ODE with analytical solution

Maple 18

Dear maple users,
Greetings.
Now I'm working on a project "solving ODE with an analytical solution".

So, I need how to find a residual error.

Here I used the Homotopy Analysis Method(HAM) to solve the ode problem.

A similar HAM problem has solved using the Mathematica BVP2.H package.

Here I have encoded a maple code for my working problem. HAM.mw

CODE:Note(N is order of ittrration)

restart; with(plots)

pr := .5; ec := .5; N := 7; re := 2; ta := .5; H := 1:

dsolve(diff(f(x), `\$`(x, 4)))

Rf := x^3*(diff(f[m-1](x), x, x, x, x))-2*x^2*(diff(f[m-1](x), x, x, x))+3*x*(diff(f[m-1](x), x, x))-3*(diff(f[m-1](x), x))-re*x^2*R*(sum((diff(f[m-1-n](x), x, x, x))*(diff(f[n](x), x)), n = 0 .. m-1))-re*x*R*(sum((diff(f[m-1-n](x), x))*(diff(f[n](x), x)), n = 0 .. m-1))+re*x^2*R*(sum((diff(f[m-1-n](x), x, x, x))*f[n](x), n = 0 .. m-1))-3*re*x*R*(sum((diff(f[m-1-n](x), x, x))*f[n](x), n = 0 .. m-1))+3*re*R*(sum((diff(f[m-1-n](x), x))*f[n](x), n = 0 .. m-1))+ta*x^3*(diff(f[m-1](x), x, x))-ta*x^2*(diff(f[m-1](x), x)):

dsolve(diff(f[m](x), x, x, x, x)-CHI[m]*(diff(f[m-1](x), x, x, x, x)) = h*H*Rf, f[m](x)):

f[0](x):=3 *x^(2)-2* x^(3);

for m from 1 by 1 to N do  CHI[m]:=`if`(m>1,1,0);  f[m](x):=int(int(int(int(CHI[m]*(x^(3)* diff(f[m-1](x),x,x,x,x))+h*H*(x^(3)* diff(f[m-1](x),x,x,x,x))-2*h*H*x^(2)*diff(f[m-1](x),x,x,x)+3*h*H*x*diff(f[m-1](x),x,x)-3*h*H*diff(f[m-1](x),x)-re*h*H*x^(2)*sum(diff(f[m-1-n](x),x,x,x)*diff(f[n](x),x),n=0..m-1)-re*h*H*x*sum(diff(f[m-1-n](x),x)*diff(f[n](x),x),n=0..m-1)+re*h*H*x^(2)*sum(diff(f[m-1-n](x),x,x,x)*(f[n](x)),n=0..m-1)-3*re*x*h*H*sum(diff(f[m-1-n](x),x,x)*(f[n](x)),n=0..m-1)+3* re*h*H*sum(diff(f[m-1-n](x),x)*(f[n](x)),n=0..m-1)+ta*x^(3)*h*H*diff(f[m-1](x),x,x)-ta*x^(2)*h*H*diff(f[m-1](x),x),x),x)+_C1*x,x)+_C2*x,x)+_C3*x+_C4;  s1:=evalf(subs(x=0,f[m](x)))=0;  s2:=evalf(subs(x=0,diff(f[m](x),x)))=0;  s3:=evalf(subs(x=1,f[m](x)))=0;  s4:=evalf(subs(x=1,diff(f[m](x),x)))=0;   s:={s1,s2,s3,s4}:  f[m](x):=simplify(subs(solve(s,{_C1,_C2,_C3,_C4}),f[m](x)));  end do:

f(x):=sum(f[l](x),l=0..N):  hh:=evalf(subs(x=1,diff(f(x),x)));

plot(hh, h = -5 .. 5);

For Mathematica, code already exist to find a residual error for another problem(Not this)

which is,

eq:

Bc:

Mathematica code:

waiting for users' responses.

Have a good day

﻿