Given,
dxdy+x2y=ex
I.F.=e∫x2dx=e2lnx=x2
∴ General solution: y(x2)=∫ex(x2)dx
We know that
∫exf(x)dx==ex[f(x)−f′(x)+f′′(x)−f′′′(x)+⋯+(−1)nfn(x))]+C
So, y(x2)=ex[x2−2x+2]+C...(i)
Given y(1)=0⇒(0)(1)=e1[1−2(1)+2]+C
⇒C=−e
∴y=x2ex[x2−2x+2]−e (from eq (i))
Hence, z(x)=x2(x2ex)[x2−2x+2]−e−ex
=ex[x2−2x+2]−e−ex
z(x)=ex[x2−2x+1]−e
z′(x)=ex(2x−2)+(x2−2x+1)ex
z′(x)=ex[x2−1]
To find local maxima, put z′(x)=0
⇒ex(x2−1)=0 ⇒(x−1)(x+1)=0 (∵ex>0,∀x∈R)
⇒x=1,−1

It is clear from the sign scheme method, z(x) has local maximum value at x=−1 and has local minimum value at x=1.
∴ The local maximum value is
z(−1)=e−1[(−1)2−2(−1)+1]−e
=e1[1+2+1]−e =e4−e