MATLAB: How to integrate a function from abs(x) to inf and then from -inf to inf

intvariable limt

I'm a beginner with Matlab, and I'm trying to solve the following problem
f(x) = \int_{abs(x)}^{\infty} 10^-15 *(u+x)^24 *(u-x)^19 *exp(-(u+x)/0.4 - (u-x)/0.2) du
h(x) = exp(-(x-3)^2)
g = int_{-\infty}^{\infty} abs(f(x)-h(x))*f(x) dx.
h = @(x) exp(-(x-3).^2)
ff =10.^(-15).*(u+x).^24.*(u-x).^19.*exp(-(u+x)./(0.4)-(u-x)./(0.2))
f = @(x) int(ff,[abs(x),Inf])
g= int(abs(hV(x) - hN(x)).*hV(x), -inf, inf)
I tried int() with symbolic but it takes too long. I waited for so long but I didn't get the answer.
Anyone please helps me? Any help is really appreciated.

Best Answer

If you have a new enough MATLAB version, I recommend using vpaintegral() for g. You will not be able to get a closed-form expression for the solution. The expression abs(f(x)-h(x))*f(x) can be resolved to a (moderately long) closed form, but not the integral of it:
Q = @sym;
vpaintegral((Q('39815708579071000576')/Q('12373575009405612945556640625'))*exp(-(Q(15)/2)*abs(x)+(Q(5)/2)*x)*abs((1/Q('75254345816500034516138839535415172576904296875'))*(Q('12460787176237432654850829097754574508051660800')*x+Q('364911707638202486530359951360000000000000000')*x^18+Q('10801782320033631899876327424000000000000000')*x^20+Q('242153548999443873792000000000000000000')*x^24+Q('7748913567982203961344000000000000000000')*x^23+Q('124757508444513483777638400000000000000000')*x^22+Q('1341836313047656136630599680000000000000000')*x^21+Q('1215982495947448897225498930434930848563200000000')*x^10+Q('69129780379957004576012579635200000000000000')*x^19+Q('2222566609516328614112172087206037052981248000000')*x^7+Q('2998303856195967613479585050257081014367027200000')*x^6+Q('1450119515412072306293791792163810046986158080000')*x^5+Q('1630847112211872638631845624348024902778880000000')*x^9+Q('1625430571490826341836884069580800000000000000')*x^17+Q('6228540677309384973761505342259200000000000000')*x^16+Q('20581138153841490558913456015147008000000000000')*x^15+Q('60217676965085082683869479532127846400000000000')*x^14+Q('150721651185694293397347184526386790400000000000')*x^13+Q('347514228856267477384178270354716753920000000000')*x^12+Q('651475079687021507321333823149029982208000000000')*x^11+Q('1770859125291983052314700035039995160759894016000')*x^4+Q('343539994884943156381558136710742406951075840000')*x^3+Q('2539907823085954755381175840790823472988160000000')*x^8+Q('397855133412723742622737186192592486078506598400')*x^2+Q('14288369295418922777562284032091912102565904384')+(Q('242153548999443873792000000000000000000')*x+Q('7748913567982203961344000000000000000000'))*abs(x)^23+(Q('124757508444513483777638400000000000000000')*x+Q('1341836313047656136630599680000000000000000'))*abs(x)^21+(Q('10801782320033631899876327424000000000000000')*x+Q('69133033316473483742404411392000000000000000'))*abs(x)^19+(Q('364808697981847312927951945728000000000000000')*x+Q('1627037522129967050034448957440000000000000000'))*abs(x)^17+(Q('6212149780790149750146343486095360000000000000')*x+Q('20703523514518446895239997874503680000000000000'))*abs(x)^15+(Q('59507841873158735933175536747859148800000000000')*x+Q('154034214948017244900585584186307379200000000000'))*abs(x)^13+(Q('334800293654208911138415650707592970240000000000')*x+Q('692159672333608919307774206019826089984000000000'))*abs(x)^11+(Q('1106586146831069411661959234271234647654400000000')*x+Q('1878812170208999472575868935652402958172160000000'))*abs(x)^9+(Q('2066519985091439890578949519209738094510080000000')*x+Q('2979987150307552397795734201735773658546176000000'))*abs(x)^7+(Q('1992294009709162690535776908394507779283353600000')*x+Q('2542358777312031936918497774757460987934146560000'))*abs(x)^5+(Q('824251764978684705773288183458831011938304000000')*x+Q('974611568427142054075832704431518506165469184000'))*abs(x)^3+(Q('93455903821780744911381218233159308810387456000')*x+Q('107162769715641920831717130240689340769244282880'))*abs(x))*exp(-(Q(15)/2)*abs(x)+(Q(5)/2)*x)-exp(-(x-3)^2))*((Q('4172821103674444526649344/81091461181640625'))*x+(Q('3051560512/2025'))*x^18+(Q('50183056')/1125)*x^20+x^24+32*x^23+(Q(2576)/5)*x^22+(Q(1246784)/225)*x^21+(Q('107247039185970331648/21357421875'))*x^10+(Q('4817460032/16875'))*x^19+(Q('4900639792485308039168/533935546875'))*x^7+(Q('297499440787296232669184/24027099609375'))*x^6+(Q('719422989798602637836288/120135498046875'))*x^5+(Q('239728675827463094272/35595703125'))*x^9+(Q('113271686528')/16875)*x^17+(Q('144683162624')/5625)*x^16+(Q('107568123959296')/1265625)*x^15+(Q('1573650225731584')/6328125)*x^14+(Q('3938763040436224')/6328125)*x^13+(Q('408666761175056384')/284765625)*x^12+(Q('3830579997805969408')/1423828125)*x^11+(Q('4392730229782723179839488')/Q('600677490234375'))*x^4+(Q('1533911590375100688367616')/Q('1081219482421875'))*x^3+(Q('124452446542008352768')/Q('11865234375'))*x^8+(Q('44410738889106588176482304/27030487060546875'))*x^2+(Q('4069799565323075584')/Q('1423828125')+(Q('393715538205237248')/284765625)*x)*abs(x)^11+(Q('2485607849368959451136')/Q('320361328125')+(Q('97598516629447049216')/Q('21357421875'))*x)*abs(x)^9+(Q('6570711333178065289216')/Q('533935546875')+(Q('911313076291480518656')/Q('106787109375'))*x)*abs(x)^7+(Q('1261296971232606490198016')/Q('120135498046875')+(Q('197680549470506049339392')/Q('24027099609375'))*x)*abs(x)^5+(Q('21758281469159603603243008')/Q('5406097412109375')+(Q('1817430794283294654464')/Q('533935546875'))*x)*abs(x)^3+(Q('179431307458001114645921792')/Q('405457305908203125')+(Q('2086410551837222263324672')/Q('5406097412109375'))*x)*abs(x)+(x+32)*abs(x)^23+(Q(1246784)/225+(Q(2576)/5)*x)*abs(x)^21+(Q('963537344')/3375+(Q('50183056')/1125)*x)*abs(x)^19+(Q('167975808')/25+(Q('1694832832')/1125)*x)*abs(x)^17+(Q('21641555167232')/253125+(Q('721512087296')/28125)*x)*abs(x)^15+(Q('1341776420368384')/2109375+(Q('1555100321302528')/6328125)*x)*abs(x)^13+Q('358862614916002229291843584')/Q('6081859588623046875')), x, -inf, inf)