f[t_,x_]:=x+0.09(x^2)+Cos[10t];

rk2[x0in_]:=Module[{h,t0,x0,x1,x2,step},
h=0.025;
t0=0.0;
x0=x0in;
For[step=1,step≤40,step++,
x1=x0+0.5*h*f[t0,x0];
x2=x0+h*f[t0+0.5*h,x1];
t0=t0+h;
x0=x2;
];
Return[x2];
];

g[x0_]:=x0+rk2[x0]-3.0;

secant[s00_,s10_,tol_]:=Module[{s0,s1,s2,err},
err=(10^10);
s0=s00;
s1=s10;
While[err>tol,
s2=s1-g[s1]*(((s1-s0))/((g[s1]-g[s0])));
err=Abs[s2-s1];
s0=s1;
s1=s2;
];
Return[s2];
];

secant[0.7,1.0,(10^(-4))]

0.7378581237264985`

NDSolve[{x'[t]== x[t]+0.09*((x[t])^2)+Cos[10 t],x[0]+x[1]-3.0==0},x,{t,0,1}]

x[0]/.%

rk2[0.7378581237264985`]

2.2621419171052546+0.7378581237264985-3.0