Is there anyway to increase the calculation speed of this sqrt integral2 without loosing accuracy?

2 views (last 30 days)
Any suggestion to increase the calculation speed of this integral2?
g = @(xx,yy)sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
integral2(g,-1,1,-1,1)
  8 Comments
Paul
Paul on 12 Dec 2023
I was wondering the same thing, i.e. split integral2 into real/imag, thanks for showing that. Any idea why doing so is so much more efficient?

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 12 Dec 2023
Let's look at what the surface you're trying to integrate looks like.
g = @(xx,yy)sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
figure
fsurf(@(xx,yy)real(g(xx,yy)), [-1,1,-1,1])
title("Real part of g")
Okay, not so bad.
figure
fsurf(@(xx,yy)imag(g(xx,yy)),[-1,1,-1,1])
title("Imaginary part of g")
I might consider integrating over each of those peaks separately to see if that helps. Rotating the plot of the real part it looks like the peaks are around x = 0.4 and x = 0.6. So let's integrate once for the flat part and once for each peak.
R = @(xx, yy) real(g(xx, yy));
tic
part1 = integral2(R, -1, 0.3, -1, 1);
toc
Elapsed time is 2.387720 seconds.
tic
part2 = integral2(R, 0.3, 0.5, -1, 1);
toc
Elapsed time is 0.229699 seconds.
tic
part3 = integral2(R, 0.5, 1, -1, 1);
toc
Elapsed time is 0.471389 seconds.
sol = part1+part2+part3
sol = 5.7963e-04
That agrees with Torsten's answer pretty closely.
Focusing even more closely at the "flat" part of the surface, it looks like there's another much smaller ridge at x = -0.4.
figure
fsurf(R, [-1, 0.3, -1, 1])
zlim([0, 1e-5])
title("Flat part of real(g)")
If we integrate that region in parts:
tic
part1a = integral2(R, -1, -0.5, -1, 1) + ...
integral2(R, -0.5, -0.3, -1, 1) + ...
integral2(R, -0.3, 0.3, -1, 1);
toc
Elapsed time is 0.486807 seconds.
part1-part1a
ans = 1.6351e-11
That matches the result of the integration from x = -1 to x = 0.3 pretty closely while taking less time than is required to compute the integration over the whole region.
  2 Comments
Paul
Paul on 13 Dec 2023
Edited: Paul on 13 Dec 2023
All kidding aside, shouldn't the adpative step size control of integral2 essentially find those regions? I wouldn't expect integral2 to do it as well as a person carefully inspecting the surface and then dividing and conquering, but I'm surprised that ~2.5 seconds by-hand is so much better than the 20-seconds time that @Torsten showed for integrating the real part.

Sign in to comment.

More Answers (2)

Torsten
Torsten on 13 Dec 2023
Edited: Torsten on 13 Dec 2023
The solution of the 2d-integral via an ode problem is adaptive and fast.
It's somehow like applying iterated "trapz", but adaptive.
tic
% Integrate the x-integrals in y-direction
yspan = [-1 1];
Gy0 = 0;
[~,G] = ode45(@fun,yspan,Gy0,odeset('RelTol',1e-10,'AbsTol',1e-10));
G(end)
ans = 5.7963e-04 + 9.5394e-04i
toc
Elapsed time is 1.574866 seconds.
function dGydy = fun(y,Gy)
% Compute the x-integrals at y = y
xspan = [-1 1];
Gx0 = 0;
[~,Gx] = ode45(@(x,~)g(x,y),xspan,Gx0,odeset('RelTol',1e-10,'AbsTol',1e-10));
dGydy = Gx(end);
end
function value = g(xx,yy)
value = sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
end
  4 Comments
Torsten
Torsten on 14 Dec 2023
Edited: Torsten on 14 Dec 2023
If your g is symbolic, use "matlabFunction" first to turn it into a numeric function.
Note that the code below can be used for any function g(x,y) and any rectangular x-y-region to be integrated over.
tic
g =@(xx,yy) sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
% Integrate the x-integrals in y-direction
xspan = [-1 1];
yspan = [-1 1];
Gy0 = 0;
[~,G] = ode45(@(y,Gy)fun(y,Gy,g,xspan),yspan,Gy0,odeset('RelTol',1e-10,'AbsTol',1e-10));
G(end)
ans = 5.7963e-04 + 9.5394e-04i
toc
Elapsed time is 1.421408 seconds.
function dGydy = fun(y,Gy,g,xspan)
% Compute the x-integrals at y = y
Gx0 = 0;
[~,Gx] = ode45(@(x,~)g(x,y),xspan,Gx0,odeset('RelTol',1e-10,'AbsTol',1e-10));
dGydy = Gx(end);
end

Sign in to comment.


Paul
Paul on 14 Dec 2023
The iterated method works much faster as compared to auto (which I assume goes to tiled). Unclear why iterated integral2 is slower than @Torsten's ode45 approach.
g = @(xx,yy)sqrt((xx.*1.103872343207215e+1-yy.*3.605544873768034e-1+xx.^2.*yy.^2.*2.981255793882863e+2-xx.^2.*yy.^3.*7.145239549149272e-1+xx.^3.*yy.^2.*3.193184083673463e+2-xx.^2.*yy.^4.*1.40779965937169e+2-xx.^3.*yy.^3.*1.013059778118534e+1-xx.^4.*yy.^2.*9.292071372439611e+2+xx.^2.*yy.^5.*2.992332140731769e-1-xx.^3.*yy.^4.*1.369974107594584e+2-xx.^4.*yy.^3.*1.294220577933953-xx.^5.*yy.^2.*6.874377148048132e+2+xx.^2.*yy.^6.*6.543517412058207+xx.^3.*yy.^5.*9.4787478195207+xx.^4.*yy.^4.*4.219568904511715e+2+xx.^5.*yy.^3.*1.604618144716224e+1+xx.^6.*yy.^2.*1.052720200159863e+3+xx.^2.*yy.^7.*3.440257778168581e-1+xx.^3.*yy.^6.*3.97973617078252+xx.^4.*yy.^5.*8.158402880998847e-1+xx.^5.*yy.^4.*2.976761849175189e+2+xx.^6.*yy.^3.*1.431304162141321+xx.^7.*yy.^2.*4.87380378442101e+2-xx.^2.*yy.^8.*9.031661549154107-xx.^3.*yy.^7.*5.380951726564079-xx.^4.*yy.^6.*1.613413488924491e+1-xx.^5.*yy.^5.*2.095373277916843e+1-xx.^6.*yy.^4.*4.672406815181154e+2-xx.^7.*yy.^3.*1.396213341785615e+1-xx.^8.*yy.^2.*3.994601481287452e+2-xx.^2.*yy.^9.*2.294996536301288e-1-xx.^3.*yy.^8.*1.429845294263658e+1-xx.^4.*yy.^7.*9.050942192417836e-1-xx.^5.*yy.^6.*1.728805725264949e+1-xx.^6.*yy.^5.*1.34544008057555e-1-xx.^7.*yy.^4.*1.978746300893805e+2-xx.^8.*yy.^3.*2.258089732983687e-1-xx.^9.*yy.^2.*1.016436433222759e+2+xx.^3.*yy.^9.*1.828012711482035+xx.^4.*yy.^8.*3.336707091297534e+1+xx.^5.*yy.^7.*1.59217667567015e+1+xx.^6.*yy.^6.*1.57263834379615e+1+xx.^7.*yy.^5.*2.306992085826472e+1+xx.^8.*yy.^4.*1.745855936499575e+2+xx.^9.*yy.^3.*5.058823046755644+xx.^4.*yy.^9.*5.981939447987676e-1+xx.^5.*yy.^8.*3.596210086309369e+1+xx.^6.*yy.^7.*1.112016367919001e-1+xx.^7.*yy.^6.*1.495088302611445e+1-xx.^8.*yy.^5.*4.545223953790024e-1+xx.^9.*yy.^4.*3.373349362223411e+1-xx.^5.*yy.^9.*5.481785841428752-xx.^6.*yy.^8.*4.129058490033813e+1-xx.^7.*yy.^7.*1.994978298913851e+1-xx.^8.*yy.^6.*5.268976105202482-xx.^9.*yy.^5.*9.463935378555124-xx.^6.*yy.^9.*3.818431611067075e-1-xx.^7.*yy.^8.*3.411790228342504e+1+xx.^8.*yy.^7.*3.655275161975917e-1-xx.^9.*yy.^6.*3.422670732987394+xx.^7.*yy.^9.*6.935438665851035+xx.^8.*yy.^8.*1.650057442285759e+1+xx.^9.*yy.^7.*8.679731905869081+xx.^8.*yy.^9.*1.417469705276344e-2+xx.^9.*yy.^8.*1.111802135132597e+1-xx.^9.*yy.^9.*3.053749060430634-xx.*yy.*1.358041539872225-xx.*yy.^2.*1.761743113711948e+1+xx.^2.*yy.*3.007646166548722e-1+xx.*yy.^3.*2.987672996272836+xx.^3.*yy.*4.204788976746628+xx.*yy.^4.*3.4624013480431+xx.^4.*yy.*7.852805642778767e-1-xx.*yy.^5.*2.130815820353545-xx.^5.*yy.*5.532429583266559+xx.*yy.^6.*1.780044557350331-xx.^6.*yy.*1.026118629770241+xx.*yy.^7.*7.290080029920991e-1+xx.^7.*yy.*3.906556882879037+xx.*yy.^8.*1.336261799653921+xx.^8.*yy.*3.006291554277033e-1-xx.*yy.^9.*2.278236390391508e-1-xx.^9.*yy.*1.220870513639053-xx.^2.*1.548574693140216e+2-xx.^3.*1.720022808360341e+2+xx.^4.*4.900173107690596e+2+xx.^5.*3.710874862768505e+2-xx.^6.*5.599153171793714e+2-xx.^7.*2.703387290954101e+2+xx.^8.*2.136429561611328e+2+xx.^9.*6.021479908170309e+1-yy.^2.*2.217850749090318e+1+yy.^3.*8.032281878547765e-1+yy.^4.*1.147823900997428e+1-yy.^5.*5.259371043980779e-1-yy.^6.*8.669015228839822e-1+yy.^7.*8.425893861929189e-2+yy.^8.*4.546501004086849e-1-yy.^9.*9.955346991849411e-4+1.11125199034042e+1).*(xx.*8.917450828091442e-1-yy.*1.832764070999146e-3-xx.^2.*yy.^2.*3.149250096599649+xx.^2.*yy.^3.*3.432275747499679e-1+xx.^3.*yy.^2.*7.108205033182954e+1+xx.^2.*yy.^4.*3.910407900960859-xx.^3.*yy.^3.*1.007615333683764+xx.^4.*yy.^2.*7.301846550389142e+1-xx.^2.*yy.^5.*5.774881479713465e-1-xx.^3.*yy.^4.*1.040150888639639e+2-xx.^4.*yy.^3.*4.127436011116915-xx.^5.*yy.^2.*5.064993011991733e+2-xx.^2.*yy.^6.*1.840393391604457+xx.^3.*yy.^5.*1.597111669874699-xx.^4.*yy.^4.*9.955144214033603e+1+xx.^5.*yy.^3.*2.138303646817599-xx.^6.*yy.^2.*4.921591873960447e+2+xx.^2.*yy.^7.*5.225563086072636e-1+xx.^3.*yy.^6.*6.988888963931489e+1+xx.^4.*yy.^5.*7.079509787256945+xx.^5.*yy.^4.*7.302234063822373e+2+xx.^6.*yy.^3.*1.863040142690569e+1+xx.^7.*yy.^2.*1.76818389645896e+3+xx.^2.*yy.^8.*2.453279080016533e-1-xx.^3.*yy.^7.*1.163087952436314+xx.^4.*yy.^6.*5.915918234243827e+1-xx.^5.*yy.^5.*3.35018410738197+xx.^6.*yy.^4.*6.841086500842017e+2+xx.^7.*yy.^3.*1.252957342057255+xx.^8.*yy.^2.*1.480467010634292e+3-xx.^2.*yy.^9.*3.032655221718485e-1-xx.^3.*yy.^8.*2.278036773045523e+1-xx.^4.*yy.^7.*6.723071064431262-xx.^5.*yy.^6.*4.795297487798922e+2-xx.^6.*yy.^5.*3.326364713317154e+1-xx.^7.*yy.^4.*2.521032212095309e+3-xx.^8.*yy.^3.*4.653269694282666e+1-xx.^9.*yy.^2.*3.447954066931935e+3-xx.^2.*yy.^10.*1.673760709754303e-1+xx.^3.*yy.^9.*3.536004285541229e-1-xx.^4.*yy.^8.*1.647455285154051e+1+xx.^5.*yy.^7.*1.959490888593118-xx.^6.*yy.^6.*4.244258590721315e+2-xx.^7.*yy.^5.*1.851249760126308-xx.^8.*yy.^4.*2.060464579497394e+3-xx.^9.*yy.^3.*1.15097316035386e+1-xx.^10.*yy.^2.*2.38844937500287e+3+xx.^2.*yy.^11.*1.285283229959356e-1+xx.^3.*yy.^10.*5.985563635425356+xx.^4.*yy.^9.*4.224198125183847+xx.^5.*yy.^8.*1.530130293824737e+2+xx.^6.*yy.^7.*3.420937255464183e+1+xx.^7.*yy.^6.*1.628542058641167e+3+xx.^8.*yy.^5.*8.744487892771101e+1+xx.^9.*yy.^4.*4.871207293139532e+3+xx.^10.*yy.^3.*7.1312618419082e+1+xx.^11.*yy.^2.*3.949541181898515e+3+xx.^2.*yy.^12.*1.088122026806739e-1-xx.^3.*yy.^11.*2.535201427281161e-2+xx.^4.*yy.^10.*5.9004576328881+xx.^5.*yy.^9.*2.41233360867424e-1+xx.^6.*yy.^8.*1.299219303681419e+2+xx.^7.*yy.^7.*3.651593703534549+xx.^8.*yy.^6.*1.289366818512573e+3+xx.^9.*yy.^5.*1.728631843992101e+1+xx.^10.*yy.^4.*3.302797117233668e+3+xx.^11.*yy.^3.*1.883167226905925e+1+xx.^12.*yy.^2.*2.213047026124823e+3-xx.^2.*yy.^13.*3.515509262970026e-2-xx.^3.*yy.^12.*1.990127958180967-xx.^4.*yy.^11.*1.899800493738188-xx.^5.*yy.^10.*4.316621149718254e+1-xx.^6.*yy.^9.*2.381209633537286e+1-xx.^7.*yy.^8.*5.144972151621673e+2-xx.^8.*yy.^7.*9.767466929700799e+1-xx.^9.*yy.^6.*3.106243948572863e+3-xx.^10.*yy.^5.*1.41702297922157e+2-xx.^11.*yy.^4.*5.533605835398259e+3-xx.^12.*yy.^3.*6.786183956102263e+1-xx.^13.*yy.^2.*2.639229675258195e+3+xx.^2.*yy.^14.*7.731813451389398e-4+xx.^3.*yy.^13.*4.865422726462125e-3-xx.^4.*yy.^12.*2.445679991191839-xx.^5.*yy.^11.*6.715940725269066e-1-xx.^6.*yy.^10.*4.507673288076278e+1-xx.^7.*yy.^9.*5.603093601746989-xx.^8.*yy.^8.*4.109282146089062e+2-xx.^9.*yy.^7.*1.753996470905003e+1-xx.^10.*yy.^6.*2.05796865030684e+3-xx.^11.*yy.^5.*2.793033132389915e+1-xx.^12.*yy.^4.*3.023652971671623e+3-xx.^13.*yy.^3.*1.446278259530199e+1-xx.^14.*yy.^2.*1.175938086326686e+3+xx.^2.*yy.^15.*5.01490593227162e-3+xx.^3.*yy.^14.*1.226130225377401e-1+xx.^4.*yy.^13.*5.205137916111856e-1+xx.^5.*yy.^12.*1.508082715349343e+1+xx.^6.*yy.^11.*1.135783574844549e+1+xx.^7.*yy.^10.*1.550603977802377e+2+xx.^8.*yy.^9.*7.38498642874362e+1+xx.^9.*yy.^8.*9.780906748278276e+2+xx.^10.*yy.^7.*1.703675468456969e+2+xx.^11.*yy.^6.*3.48881762178512e+3+xx.^12.*yy.^5.*1.428822558885717e+2+xx.^13.*yy.^4.*3.667162483559571e+3+xx.^14.*yy.^3.*3.837413530633986e+1+xx.^15.*yy.^2.*9.503660390569385e+2+xx.^2.*yy.^16.*5.861221821537304e-3-xx.^3.*yy.^15.*2.037315527441673e-4+xx.^4.*yy.^14.*7.64869899364752e-2+xx.^5.*yy.^13.*1.907444769558822e-1+xx.^6.*yy.^12.*1.708589308022411e+1+xx.^7.*yy.^11.*4.065934064451773+xx.^8.*yy.^10.*1.491040426535532e+2+xx.^9.*yy.^9.*1.595803178073279e+1+xx.^10.*yy.^8.*6.744049813455803e+2+xx.^11.*yy.^7.*2.607330069477239e+1+xx.^12.*yy.^6.*1.859959336144574e+3+xx.^13.*yy.^5.*2.106027647564672e+1+xx.^14.*yy.^4.*1.578290455337145e+3+xx.^15.*yy.^3.*5.404759849680721+xx.^16.*yy.^2.*3.312168568189724e+2-xx.^2.*yy.^17.*1.209189583631184e-3-xx.^3.*yy.^16.*5.542030145778944e-2-xx.^4.*yy.^15.*7.890299096297505e-2-xx.^5.*yy.^14.*8.483322346337942e-1-xx.^6.*yy.^13.*3.107942149637959-xx.^7.*yy.^12.*5.564407009824581e+1-xx.^8.*yy.^11.*3.650661663212293e+1-xx.^9.*yy.^10.*3.135855585359998e+2-xx.^10.*yy.^9.*1.365638754511626e+2-xx.^11.*yy.^8.*1.099176627885069e+3-xx.^12.*yy.^7.*1.829398379551916e+2-xx.^13.*yy.^6.*2.286445876513336e+3-xx.^14.*yy.^5.*8.599320413293898e+1-xx.^15.*yy.^4.*1.308610165671812e+3-xx.^16.*yy.^3.*1.145401808951412e+1-xx.^17.*yy.^2.*1.419636251155902e+2+xx.^2.*yy.^18.*8.813655028507696e-7-xx.^3.*yy.^17.*1.594025887336131e-3-xx.^4.*yy.^16.*1.074352580846769e-1-xx.^5.*yy.^15.*3.328937208257363e-2-xx.^6.*yy.^14.*7.772215192279019e-1-xx.^7.*yy.^13.*1.176397856728984-xx.^8.*yy.^12.*5.503214239313669e+1-xx.^9.*yy.^11.*1.006936419795361e+1-xx.^10.*yy.^10.*2.635384382933626e+2-xx.^11.*yy.^9.*2.135812279225621e+1-xx.^12.*yy.^8.*6.248915151960172e+2-xx.^13.*yy.^7.*1.892072024283776e+1-xx.^14.*yy.^6.*9.501742999811358e+2-xx.^15.*yy.^5.*7.651190531025566-xx.^16.*yy.^4.*4.335602806008366e+2-xx.^17.*yy.^3.*7.754902865214392e-1-xx.^18.*yy.^2.*3.805352147351891e+1+xx.^3.*yy.^18.*1.055806479643397e-4+xx.^4.*yy.^17.*2.113472311575987e-2+xx.^5.*yy.^16.*4.859441895485767e-1+xx.^6.*yy.^15.*5.04519123868697e-1+xx.^7.*yy.^14.*2.975139612246843+xx.^8.*yy.^13.*9.972525025258876+xx.^9.*yy.^12.*1.14241908354265e+2+xx.^10.*yy.^11.*6.878430806750447e+1+xx.^11.*yy.^10.*3.740510789006829e+2+xx.^12.*yy.^9.*1.526436852440644e+2+xx.^13.*yy.^8.*7.22397895624235e+2+xx.^14.*yy.^7.*1.164418673445259e+2+xx.^15.*yy.^6.*8.059991480707276e+2+xx.^16.*yy.^5.*2.767809505586303e+1+xx.^17.*yy.^4.*1.933951468944043e+2+xx.^18.*yy.^3.*1.308041198296645+xx.^4.*yy.^18.*1.053414956120493e-4+xx.^5.*yy.^17.*2.064844552181837e-2+xx.^6.*yy.^16.*7.311122078559425e-1+xx.^7.*yy.^15.*2.068006677205367e-1+xx.^8.*yy.^14.*2.929492444862385+xx.^9.*yy.^13.*2.988342727601186+xx.^10.*yy.^12.*9.644324674983939e+1+xx.^11.*yy.^11.*1.305508809759776e+1+xx.^12.*yy.^10.*2.681367496312035e+2+xx.^13.*yy.^9.*1.503082047430628e+1+xx.^14.*yy.^8.*3.278088783118031e+2+xx.^15.*yy.^7.*6.634680801390892+xx.^16.*yy.^6.*2.526711036194698e+2+xx.^17.*yy.^5.*1.045007940823613+xx.^18.*yy.^4.*4.812290504794675e+1-xx.^5.*yy.^18.*1.50178494658072e-3-xx.^6.*yy.^17.*1.444998993096548e-1-xx.^7.*yy.^16.*2.012430010644059-xx.^8.*yy.^15.*1.736908330974427-xx.^9.*yy.^14.*5.995675469831725-xx.^10.*yy.^13.*1.880438280990048e+1-xx.^11.*yy.^12.*1.374982347789386e+2-xx.^12.*yy.^11.*7.754411397871978e+1-xx.^13.*yy.^10.*2.610329616357622e+2-xx.^14.*yy.^9.*9.995500470504359e+1-xx.^15.*yy.^8.*2.556878311939802e+2-xx.^16.*yy.^7.*3.961883526311578e+1-xx.^17.*yy.^6.*1.173608324930028e+2-xx.^18.*yy.^5.*3.536053671430259-xx.^6.*yy.^18.*9.220149238483281e-4-xx.^7.*yy.^17.*1.014690476686303e-1-xx.^8.*yy.^16.*2.473189356253753-xx.^9.*yy.^15.*5.594697728012737e-1-xx.^10.*yy.^14.*5.664508747841497-xx.^11.*yy.^13.*3.965075348636596-xx.^12.*yy.^12.*9.783286253951298e+1-xx.^13.*yy.^11.*9.179583293626597-xx.^14.*yy.^10.*1.573007989970698e+2-xx.^15.*yy.^9.*5.235877836375165-xx.^16.*yy.^8.*9.009099148888656e+1-xx.^17.*yy.^7.*8.544704478967668e-1-xx.^18.*yy.^6.*2.674768472208937e+1+xx.^7.*yy.^18.*8.789660503979215e-3+xx.^8.*yy.^17.*5.154726443207739e-1+xx.^9.*yy.^16.*4.575501924068617+xx.^10.*yy.^15.*3.519392032862595+xx.^11.*yy.^14.*7.244553726468354+xx.^12.*yy.^13.*2.129145940801576e+1+xx.^13.*yy.^12.*9.652573649437794e+1+xx.^14.*yy.^11.*5.089115632054402e+1+xx.^15.*yy.^10.*9.845644712361996e+1+xx.^16.*yy.^9.*3.474525767319002e+1+xx.^17.*yy.^8.*3.73992298363824e+1+xx.^18.*yy.^7.*5.405894441477231+xx.^8.*yy.^18.*2.917787272284469e-3+xx.^9.*yy.^17.*2.572393452106676e-1+xx.^10.*yy.^16.*4.733102430610986+xx.^11.*yy.^15.*8.181721343591682e-1+xx.^12.*yy.^14.*6.193203199800339+xx.^13.*yy.^13.*2.853719379455096+xx.^14.*yy.^12.*5.718940055267839e+1+xx.^15.*yy.^11.*3.241086639512342+xx.^16.*yy.^10.*4.931962357420912e+1+xx.^17.*yy.^9.*6.747402570722794e-1+xx.^18.*yy.^8.*1.000453477214209e+1-xx.^9.*yy.^18.*2.770194324088346e-2-xx.^10.*yy.^17.*1.060768626920755-xx.^11.*yy.^16.*6.063659935013136-xx.^12.*yy.^15.*4.298729062320957-xx.^13.*yy.^14.*5.188023946675464-xx.^14.*yy.^13.*1.408951687993052e+1-xx.^15.*yy.^12.*3.658477349173497e+1-xx.^16.*yy.^11.*1.763694828691533e+1-xx.^17.*yy.^10.*1.546810666592484e+1-xx.^18.*yy.^9.*4.825340323808244-xx.^10.*yy.^18.*4.375685387384132e-3-xx.^11.*yy.^17.*3.713267341545781e-1-xx.^12.*yy.^16.*5.390084222106306-xx.^13.*yy.^15.*6.738582988011823e-1-xx.^14.*yy.^14.*3.859376170867516-xx.^15.*yy.^13.*1.037177872154021-xx.^16.*yy.^12.*1.775828191771638e+1-xx.^17.*yy.^11.*4.29668961753619e-1-xx.^18.*yy.^10.*6.377690249692412+xx.^11.*yy.^18.*5.061696088482958e-2+xx.^12.*yy.^17.*1.300627194368403+xx.^13.*yy.^16.*4.682344463791613+xx.^14.*yy.^15.*3.094039065852764+xx.^15.*yy.^14.*2.03153119138446+xx.^16.*yy.^13.*4.946110325242825+xx.^17.*yy.^12.*5.777902331673031+xx.^18.*yy.^11.*2.424963328716446+xx.^12.*yy.^18.*3.183114231013491e-3+xx.^13.*yy.^17.*3.092145947884248e-1+xx.^14.*yy.^16.*3.629527888134607+xx.^15.*yy.^15.*2.949491814312678e-1+xx.^16.*yy.^14.*1.2714196413809+xx.^17.*yy.^13.*1.440966441698496e-1+xx.^18.*yy.^12.*2.241647785000835-xx.^13.*yy.^18.*5.349374321560299e-2-xx.^14.*yy.^17.*9.33783004746455e-1-xx.^15.*yy.^16.*1.957315224018444-xx.^16.*yy.^15.*1.199954149395863-xx.^17.*yy.^14.*3.355010021173755e-1-xx.^18.*yy.^13.*6.934728168026845e-1-xx.^14.*yy.^18.*9.373212372286827e-4-xx.^15.*yy.^17.*1.387400101197578e-1-xx.^16.*yy.^16.*1.336780615484007-xx.^17.*yy.^15.*5.351190538689366e-2-xx.^18.*yy.^14.*1.702723527279216e-1+xx.^15.*yy.^18.*3.026462613229377e-2+xx.^16.*yy.^17.*3.601327004082595e-1+xx.^17.*yy.^16.*3.430316844923598e-1+xx.^18.*yy.^15.*1.915157980525296e-1+xx.^16.*yy.^18.*2.672769955889301e-5+xx.^17.*yy.^17.*2.60341252165812e-2+xx.^18.*yy.^16.*2.078858690727986e-1-xx.^17.*yy.^18.*7.079740141201421e-3-xx.^18.*yy.^17.*5.710577672108429e-2+xx.^18.*yy.^18.*1.167810588291038e-6-xx.*yy.*3.075366976262442e-2-xx.*yy.^2.*3.526499241348434-xx.^2.*yy.*8.22091599289123e-2+xx.*yy.^3.*1.279267114308256e-1+xx.^3.*yy.*2.422755366776858e-1+xx.*yy.^4.*5.274972053599984+xx.^4.*yy.*9.838541330816038e-1-xx.*yy.^5.*2.057588038303203e-1-xx.^5.*yy.*4.953532667643909e-1-xx.*yy.^6.*3.667311777247011-xx.^6.*yy.*4.373943336369689+xx.*yy.^7.*1.591772639121506e-1-xx.^7.*yy.*4.450755114932008e-1+xx.*yy.^8.*1.241212300797983+xx.^8.*yy.*1.066815031820515e+1-xx.*yy.^9.*6.133207109844262e-2+xx.^9.*yy.*3.188597989877851-xx.*yy.^10.*3.006491051813672e-1-xx.^10.*yy.*1.585254055500515e+1+xx.*yy.^11.*1.34537384760043e-2-xx.^11.*yy.*5.153376996842015+xx.*yy.^12.*9.083199337053412e-2+xx.^12.*yy.*1.452649282223464e+1-xx.*yy.^13.*3.117573298460605e-3+xx.^13.*yy.*3.98291350637101-xx.*yy.^14.*6.304899409665063e-3-xx.^14.*yy.*7.82968931460302+xx.*yy.^15.*4.110970690634906e-4-xx.^15.*yy.*1.512490222340712+xx.*yy.^16.*2.003209230634498e-3+xx.^16.*yy.*2.180160034236967-xx.*yy.^17.*6.692898196101731e-6+xx.^17.*yy.*2.232626342763958e-1+xx.*yy.^18.*3.833781977872521e-7-xx.^18.*yy.*2.184421777805796e-1+xx.^2.*8.858362630041713e-1-xx.^3.*1.82382173556976e+1-xx.^4.*1.957558756949681e+1+xx.^5.*1.312418883880755e+2+xx.^6.*1.305923371426672e+2-xx.^7.*4.615843547867497e+2-xx.^8.*3.929721561768615e+2+xx.^9.*9.056915732081774e+2+xx.^10.*6.372469002766035e+2-xx.^11.*1.043360695274391e+3-xx.^12.*5.955720645853718e+2+xx.^13.*7.011815709552087e+2+xx.^14.*3.203552367072348e+2-xx.^15.*2.540433444872568e+2-xx.^16.*9.173269575880823e+1+xx.^17.*3.82198342698243e+1+xx.^18.*1.077219415605556e+1+yy.^2.*6.121374088507809e-5+yy.^3.*7.566679105625542e-3-yy.^4.*2.616937320847826e-4-yy.^5.*1.204865172584651e-2+yy.^6.*4.468547430148061e-4+yy.^7.*9.176084750846805e-3-yy.^8.*3.785602968701871e-4-yy.^9.*3.422992169154646e-3+yy.^10.*1.62999960348087e-4+yy.^11.*6.876030356471064e-4-yy.^12.*3.352881389468098e-5-yy.^13.*1.388009800634545e-4+yy.^14.*3.333314996184432e-6+yy.^15.*1.360695926359456e-5-yy.^16.*1.655644414705918e-7-yy.^17.*7.64905319289316e-7+yy.^18.*1.674878549087182e-9-4.550268315834584e-7).^2.*(-8.845979223770551e-5));
tic,integral2(g,-1,1,-1,1,'Method','iterated'),toc
ans = 5.7963e-04 + 9.5393e-04i
Elapsed time is 6.408831 seconds.

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!