# How to avoid precision loss when handling very long integer constant involved multiple precision computation?

I have a numerical computation problem which requires solving nonlinear equations (with long integers) in multiple precision.

I tried an MPFR C++ wrapper from this link by Pavel: mpfr C++ wrapper by Pavel The wrapper can be downloaded here: mpfrc++-3.5.6.zip

However, there is precision loss in the solution when handling very long integers (equations with small integers worked well).

I tried three options as in the sample code below:

1. to use the code immediately does not work with "constant integer too long" error.
2. below the two options "worked" with precision loss

How can I handle such equations in multiple precision without precision loss?

Below is a sample of my nonlinear equations with the long integers:

#include "mpreal.h"

VectorXmp testfun126(VectorXmp x0)
{
VectorXmp value(3);
mpreal x,y,z;
x=x0(0);
y=x0(1);
z=x0(2);

// Working option 1: write all the long integers into "double" ( but there are precision loss )
value(0)=(256.*((256.*(-24610976415716501050652227.*x+256.*(-10153609683556422184100.+374519398571124540883.*y-4145573659500944095488.*z))*(29427736469514379027531261659072347.+58899562724319710108573382000184640.*y-1732944474195510410991057714955859184.*z))/pow(5042560366642267.*x-256.*(2446745837411900.+4901398098088043.*y-144207654645973248.*z),3)-(256.*(-308518681989548429992935348850261.+41445095210006425938788783390458.*y-1638970396838251453451269879637336.*z)*(-801790542801929135637671.-732048260009923946735424.*x+56975701334774517040256.*y-187552638032246240630656.*z))/pow(-3075770275504817.+198931044892562752.*x+14199788245258112.*y-1122852841901814912.*z,3)+(5*(-89303793175477833893354121208000.+6533090911353242906294143748495.*y-32276910383172707359896832089932.*z)*(-61468981380127448102256.-5328427636421850183140.*x+4647710007810227520885.*y-13344414478836548348450.*z))/pow(-46366672189358032.-18896234711237580.*x+3927118781169095.*y+14705346416259850.*z,3)-(3*(9101665097092871812176.+3063507166600182944940.*x+6945927557350563805665.*y+1052001549322007294950.*z)*(19493858980629008651267653094056.+93282964805436900100617577630195.*y+42271355681070699741325611572830.*z))/pow(46366672189358032.+18896234711237580.*x-3927118781169095.*y-14705346416259850.*z,3)-(4*(39553725461800043367392.+17203831108841472538824.*x+45483386678520344593037.*y+2703260049547565568088.*z)*(52830583937680669669892057655944.+303023948138837354463602341532495.*y+134962043561465977901954677856080.*z))/pow(92856945980914656.+51329763147513032.*x-8586501277743859.*y-56199770659759016.*z,3)-((22670037111266004087968.+12461845278544574559640.*x+39219302812923818032157.*y-46563087562792926056.*z)*(95973949246309465842551069546976.+723429769797021053206211106031819.*y+317530466286898645427564085427048.*z))/pow(50159316775994592.+36243094308305160.*x-4827156544231217.*y-52318895858217464.*z,3)-(80.*(4157117722725769078952.+4534359335248895646832.*x+26193979470458655189977.*y-2382852476120229696128.*z)*(205429639975670471114284923188348.+2095815907391732802212116237430935.*y+883539023887333564964405237094400.*z))/pow(45070329471431608.+130124049256651728.*x-5583613021604317.*y-387630670566282112.*z,3)-(16.*(9439334964924689507817.+17499514376929345709248.*x+187907876794815451253888.*y-21704870055089718153088.*z)*(943164674716649969807523653958385.+18130967224506023673179633045358720.*y+7486136216172114262568716503454336.*z))/pow(-3075770275504817.+198931044892562752.*x+14199788245258112.*y-1122852841901814912.*z,3)+(80.*(2304705299858575630109.*x-256.*(204828849006588248100.+19508530860149228990861.*y-2445924471668591306496.*z))*(-179928369646271075844345534739549.+3401432279430696137250330740801392.*y+12500875943051297916024009205116096.*z))/pow(5042560366642267.*x-256.*(2446745837411900.+4901398098088043.*y-144207654645973248.*z),3)+(80.*(-805507884940017483975376678503744.+52529278437993151034132605337909.*y-620040027953848498781390188900552.*z)*(-716026618045942942760.*x+243780804476456624597.*y-8*(408351630952413337484.+89777022692195474597.*z)))/pow(-50159316775994592.-36243094308305160.*x+4827156544231217.*y+52318895858217464.*z,3)+(768.*(61889933231497708820968.+30294916915069669525488.*x-4484037822343607626207.*y+13934625423713945278848.*z)*(16858970779944867265671037333379.*y-176.*(1546216290476124632111328928258.+3134171189636832381705249359145.*z)))/pow(45070329471431608.+130124049256651728.*x-5583613021604317.*y-387630670566282112.*z,3)-(40.*(1717566388539311579248.*x+7025931019459451548321.*y+48.*(46537098413809906919.-8301700878138964680.*z))*(3434616943638241443585000648954199.*y+320.*(1107265969195848092307625165761.+4643932844541992753284837619195.*z)))/pow(85141430232132048.+97951351741329392.*x-8855616621991191.*y-199920422688690560.*z,3)+(12.*(88457226224862447127008.+13504083955712971035976.*x-6622138801690554356387.*y+19322683651036147287512.*z)*(36451820000039413375829754767131.*y-8*(66864837166560711793644210325852.+35619205657210451197984743698883.*z)))/pow(92856945980914656.+51329763147513032.*x-8586501277743859.*y-56199770659759016.*z,3)+(512.*(45619694076424722199344.+14936846773318822792976.*x-3365788117861218576473.*y+10130491989577935272320.*z)*(12048859085295019197936041733505.*y-6*(32519187452933223586671104614156.+40471151781636260063426632487709.*z)))/pow(85141430232132048.+97951351741329392.*x-8855616621991191.*y-199920422688690560.*z,3)))/125.;
value(1)=(128.*((32768.*(24610976415716501050652227.*x-256.*(-10153609683556422184100.+374519398571124540883.*y-4145573659500944095488.*z))*(98990697209366584150952278657452.+920305667567495470446459093752885.*x-65799721166407263195366683527104.*z))/pow(5042560366642267.*x-256.*(2446745837411900.+4901398098088043.*y-144207654645973248.*z),3)+(1024.*(-10864227594859409007678067839115.+566592725765813239786863532667460.*x-3214793226869529893757297514562848.*z)*(9439334964924689507817.+17499514376929345709248.*x+187907876794815451253888.*y-21704870055089718153088.*z))/pow(-3075770275504817.+198931044892562752.*x+14199788245258112.*y-1122852841901814912.*z,3)+(40.*(2938923392457131154149055759247753.+8383263629566931208848464949723740.*x-24821520393182477390523323699174560.*z)*(4157117722725769078952.+4534359335248895646832.*x+26193979470458655189977.*y-2382852476120229696128.*z))/pow(45070329471431608.+130124049256651728.*x-5583613021604317.*y-387630670566282112.*z,3)+(80.*(1717566388539311579248.*x+7025931019459451548321.*y+48.*(46537098413809906919.-8301700878138964680.*z))*(3017477155357435955713408172820441.+3434616943638241443585000648954199.*x-6875761229715351344214913955270620.*z))/pow(85141430232132048.+97951351741329392.*x-8855616621991191.*y-199920422688690560.*z,3)+(2*(1013986939222028224203834326214704.+723429769797021053206211106031819.*x-1002019231842824621894736024449560.*z)*(22670037111266004087968.+12461845278544574559640.*x+39219302812923818032157.*y-46563087562792926056.*z))/pow(50159316775994592.+36243094308305160.*x-4827156544231217.*y-52318895858217464.*z,3)+(2*(698833722744934775627393528218146.+279848894416310700301852732890585.*x-191427609122898840477329914007915.*z)*(9101665097092871812176.+3063507166600182944940.*x+6945927557350563805665.*y+1052001549322007294950.*z))/pow(46366672189358032.+18896234711237580.*x-3927118781169095.*y-14705346416259850.*z,3)+(8*(557016173590538671691101855964863.+303023948138837354463602341532495.*x-309197308873592242001670976702725.*z)*(39553725461800043367392.+17203831108841472538824.*x+45483386678520344593037.*y+2703260049547565568088.*z))/pow(92856945980914656.+51329763147513032.*x-8586501277743859.*y-56199770659759016.*z,3)-(128.*(-57335208466953058729715954197164.+96390872682360153583488333868040.*x-372364031472286149332017066304111.*z)*(45619694076424722199344.+14936846773318822792976.*x-3365788117861218576473.*y+10130491989577935272320.*z))/pow(85141430232132048.+97951351741329392.*x-8855616621991191.*y-199920422688690560.*z,3)-(5*(-5058036108182894712997605343704.+13066181822706485812588287496990.*x-23584235630998237996607750176151.*z)*(61468981380127448102256.+5328427636421850183140.*x-4647710007810227520885.*y+13344414478836548348450.*z))/pow(46366672189358032.+18896234711237580.*x-3927118781169095.*y-14705346416259850.*z,3)-(256.*(-35027435322808897803896166913833.+101153824679669203594026224000274.*x-443348667941077090029000877418626.*z)*(61889933231497708820968.+30294916915069669525488.*x-4484037822343607626207.*y+13934625423713945278848.*z))/pow(45070329471431608.+130124049256651728.*x-5583613021604317.*y-387630670566282112.*z,3)-(24.*(-23539469566855513950637813409344.+36451820000039413375829754767131.*x-87577625291530403453057402554096.*z)*(88457226224862447127008.+13504083955712971035976.*x-6622138801690554356387.*y+19322683651036147287512.*z))/pow(92856945980914656.+51329763147513032.*x-8586501277743859.*y-56199770659759016.*z,3)-(112.*(97743545586690977941666831119873.+189463292388600804291605866927808.*x-534599264249120709692835475330432.*z)*(801790542801929135637671.+732048260009923946735424.*x-56975701334774517040256.*y+187552638032246240630656.*z))/pow(-3075770275504817.+198931044892562752.*x+14199788245258112.*y-1122852841901814912.*z,3)-(2560.*(2304705299858575630109.*x-256.*(204828849006588248100.+19508530860149228990861.*y-2445924471668591306496.*z))*(-29205293090710790323990469408790736.+212589517464418508578145671300087.*x+1750806894610755007047140949242022912.*z))/pow(5042560366642267.*x-256.*(2446745837411900.+4901398098088043.*y-144207654645973248.*z),3)-(160.*(3266813047619306699872.+716026618045942942760.*x-243780804476456624597.*y+718216181537563796776.*z)*(52529278437993151034132605337909.*x-4*(8646336391489439377118003754263.+39602745269819371968458588313429.*z)))/pow(50159316775994592.+36243094308305160.*x-4827156544231217.*y-52318895858217464.*z,3)))/125.;
value(2)=(128.*((-24576.*(3839508863935892182987929073642496.+36103009879073133562313702394913733.*x-87732961555209684260488911369472.*y)*(24610976415716501050652227.*x-256.*(-10153609683556422184100.+374519398571124540883.*y-4145573659500944095488.*z)))/pow(5042560366642267.*x-256.*(2446745837411900.+4901398098088043.*y-144207654645973248.*z),3)-(30720.*(65108728870058843312625047943313.*x-256.*(4791937744017588738333042319232.+569924119339438478856491194414721.*y))*(2304705299858575630109.*x-256.*(204828849006588248100.+19508530860149228990861.*y-2445924471668591306496.*z)))/pow(5042560366642267.*x-256.*(2446745837411900.+4901398098088043.*y-144207654645973248.*z),3)+(256.*(650985307933227267490679218098413.+935767027021514282821089562931792.*x+12859172907478119575029190058251392.*y)*(9439334964924689507817.+17499514376929345709248.*x+187907876794815451253888.*y-21704870055089718153088.*z))/pow(-3075770275504817.+198931044892562752.*x+14199788245258112.*y-1122852841901814912.*z,3)+(1280.*(114748411888321695540849692963124.+110442377985916695620550654636800.*x+775672512286952418453853865599205.*y)*(4157117722725769078952.+4534359335248895646832.*x+26193979470458655189977.*y-2382852476120229696128.*z))/pow(45070329471431608.+130124049256651728.*x-5583613021604317.*y-387630670566282112.*z,3)+(1600.*(100744894915663705876272277122960.+74302925512671884052557401907120.*x+343788061485767567210745697763531.*y)*(1717566388539311579248.*x+7025931019459451548321.*y+48.*(46537098413809906919.-8301700878138964680.*z)))/pow(85141430232132048.+97951351741329392.*x-8855616621991191.*y-199920422688690560.*z,3)+(16.*(72249495731635781189477972681776.+39691308285862330678445510678381.*x+125252403980353077736842003056195.*y)*(22670037111266004087968.+12461845278544574559640.*x+39219302812923818032157.*y-46563087562792926056.*z))/pow(50159316775994592.+36243094308305160.*x-4827156544231217.*y-52318895858217464.*z,3)+(640.*(505227745581172894057712966825000.+155010006988462124695347547225138.*x-39602745269819371968458588313429.*y)*(3266813047619306699872.+716026618045942942760.*x-243780804476456624597.*y+718216181537563796776.*z))/pow(50159316775994592.+36243094308305160.*x-4827156544231217.*y-52318895858217464.*z,3)+(2*(356681541401645116923690413208956.+126814067043212099223976834718490.*x+191427609122898840477329914007915.*y)*(9101665097092871812176.+3063507166600182944940.*x+6945927557350563805665.*y+1052001549322007294950.*z))/pow(46366672189358032.+18896234711237580.*x-3927118781169095.*y-14705346416259850.*z,3)+(8*(301993014170585471859024964195112.+134962043561465977901954677856080.*x+309197308873592242001670976702725.*y)*(39553725461800043367392.+17203831108841472538824.*x+45483386678520344593037.*y+2703260049547565568088.*z))/pow(92856945980914656.+51329763147513032.*x-8586501277743859.*y-56199770659759016.*z,3)+(128.*(4874430224431350455160317539284048.+1942615285518540483044478359410032.*x-372364031472286149332017066304111.*y)*(45619694076424722199344.+14936846773318822792976.*x-3365788117861218576473.*y+10130491989577935272320.*z))/pow(85141430232132048.+97951351741329392.*x-8855616621991191.*y-199920422688690560.*z,3)+((1486971442137244004077030949061728.+322769103831727073598968320899320.*x-117921178154991189983038750880755.*y)*(61468981380127448102256.+5328427636421850183140.*x-4647710007810227520885.*y+13344414478836548348450.*z))/pow(46366672189358032.+18896234711237580.*x-3927118781169095.*y-14705346416259850.*z,3)+(512.*(3005184872892536482128059816733656.+1654842388128247497540371661628560.*x-221674333970538545014500438709313.*y)*(61889933231497708820968.+30294916915069669525488.*x-4484037822343607626207.*y+13934625423713945278848.*z))/pow(45070329471431608.+130124049256651728.*x-5583613021604317.*y-387630670566282112.*z,3)+(192.*(137644881571986015841084811827840.+35619205657210451197984743698883.*x-10947203161441300431632175319262.*y)*(88457226224862447127008.+13504083955712971035976.*x-6622138801690554356387.*y+19322683651036147287512.*z))/pow(92856945980914656.+51329763147513032.*x-8586501277743859.*y-56199770659759016.*z,3)+(64.*(13728575451141247570683309821008705.+13111763174706011627610159037098688.*x-935548712435961241962462081828256.*y)*(801790542801929135637671.+732048260009923946735424.*x-56975701334774517040256.*y+187552638032246240630656.*z))/pow(-3075770275504817.+198931044892562752.*x+14199788245258112.*y-1122852841901814912.*z,3)))/125.;

// This will work: all long interger being written into a string ( but there are precisiion loss)
//value(0)=(256*((256*("-24610976415716501050652227"*x+256*("-10153609683556422184100"+"374519398571124540883"*y-"4145573659500944095488"*z))*("29427736469514379027531261659072347"+"58899562724319710108573382000184640"*y-"1732944474195510410991057714955859184"*z))/pow("5042560366642267"*x-256*("2446745837411900"+"4901398098088043"*y-"144207654645973248"*z),3)-(256*("-308518681989548429992935348850261"+"41445095210006425938788783390458"*y-"1638970396838251453451269879637336"*z)*("-801790542801929135637671"-"732048260009923946735424"*x+"56975701334774517040256"*y-"187552638032246240630656"*z))/pow("-3075770275504817"+"198931044892562752"*x+"14199788245258112"*y-"1122852841901814912"*z,3)+(5*("-89303793175477833893354121208000"+"6533090911353242906294143748495"*y-"32276910383172707359896832089932"*z)*("-61468981380127448102256"-"5328427636421850183140"*x+"4647710007810227520885"*y-"13344414478836548348450"*z))/pow("-46366672189358032"-"18896234711237580"*x+"3927118781169095"*y+"14705346416259850"*z,3)-(3*("9101665097092871812176"+"3063507166600182944940"*x+"6945927557350563805665"*y+"1052001549322007294950"*z)*("19493858980629008651267653094056"+"93282964805436900100617577630195"*y+"42271355681070699741325611572830"*z))/pow("46366672189358032"+"18896234711237580"*x-"3927118781169095"*y-"14705346416259850"*z,3)-(4*("39553725461800043367392"+"17203831108841472538824"*x+"45483386678520344593037"*y+"2703260049547565568088"*z)*("52830583937680669669892057655944"+"303023948138837354463602341532495"*y+"134962043561465977901954677856080"*z))/pow("92856945980914656"+"51329763147513032"*x-"8586501277743859"*y-"56199770659759016"*z,3)-(("22670037111266004087968"+"12461845278544574559640"*x+"39219302812923818032157"*y-"46563087562792926056"*z)*("95973949246309465842551069546976"+"723429769797021053206211106031819"*y+"317530466286898645427564085427048"*z))/pow("50159316775994592"+"36243094308305160"*x-"4827156544231217"*y-"52318895858217464"*z,3)-(80*("4157117722725769078952"+"4534359335248895646832"*x+"26193979470458655189977"*y-"2382852476120229696128"*z)*("205429639975670471114284923188348"+"2095815907391732802212116237430935"*y+"883539023887333564964405237094400"*z))/pow("45070329471431608"+"130124049256651728"*x-"5583613021604317"*y-"387630670566282112"*z,3)-(16*("9439334964924689507817"+"17499514376929345709248"*x+"187907876794815451253888"*y-"21704870055089718153088"*z)*("943164674716649969807523653958385"+"18130967224506023673179633045358720"*y+"7486136216172114262568716503454336"*z))/pow("-3075770275504817"+"198931044892562752"*x+"14199788245258112"*y-"1122852841901814912"*z,3)+(80*("2304705299858575630109"*x-256*("204828849006588248100"+"19508530860149228990861"*y-"2445924471668591306496"*z))*("-179928369646271075844345534739549"+"3401432279430696137250330740801392"*y+"12500875943051297916024009205116096"*z))/pow("5042560366642267"*x-256*("2446745837411900"+"4901398098088043"*y-"144207654645973248"*z),3)+(80*("-805507884940017483975376678503744"+"52529278437993151034132605337909"*y-"620040027953848498781390188900552"*z)*("-716026618045942942760"*x+"243780804476456624597"*y-8*("408351630952413337484"+"89777022692195474597"*z)))/pow("-50159316775994592"-"36243094308305160"*x+"4827156544231217"*y+"52318895858217464"*z,3)+(768*("61889933231497708820968"+"30294916915069669525488"*x-"4484037822343607626207"*y+"13934625423713945278848"*z)*("16858970779944867265671037333379"*y-176*("1546216290476124632111328928258"+"3134171189636832381705249359145"*z)))/pow("45070329471431608"+"130124049256651728"*x-"5583613021604317"*y-"387630670566282112"*z,3)-(40*("1717566388539311579248"*x+"7025931019459451548321"*y+48*("46537098413809906919"-"8301700878138964680"*z))*("3434616943638241443585000648954199"*y+320*("1107265969195848092307625165761"+"4643932844541992753284837619195"*z)))/pow("85141430232132048"+"97951351741329392"*x-"8855616621991191"*y-"199920422688690560"*z,3)+(12*("88457226224862447127008"+"13504083955712971035976"*x-"6622138801690554356387"*y+"19322683651036147287512"*z)*("36451820000039413375829754767131"*y-8*("66864837166560711793644210325852"+"35619205657210451197984743698883"*z)))/pow("92856945980914656"+"51329763147513032"*x-"8586501277743859"*y-"56199770659759016"*z,3)+(512*("45619694076424722199344"+"14936846773318822792976"*x-"3365788117861218576473"*y+"10130491989577935272320"*z)*("12048859085295019197936041733505"*y-6*("32519187452933223586671104614156"+"40471151781636260063426632487709"*z)))/pow("85141430232132048"+"97951351741329392"*x-"8855616621991191"*y-"199920422688690560"*z,3)))/125;
//value(1)=(128*((32768*("24610976415716501050652227"*x-256*("-10153609683556422184100"+"374519398571124540883"*y-"4145573659500944095488"*z))*("98990697209366584150952278657452"+"920305667567495470446459093752885"*x-"65799721166407263195366683527104"*z))/pow("5042560366642267"*x-256*("2446745837411900"+"4901398098088043"*y-"144207654645973248"*z),3)+(1024*("-10864227594859409007678067839115"+"566592725765813239786863532667460"*x-"3214793226869529893757297514562848"*z)*("9439334964924689507817"+"17499514376929345709248"*x+"187907876794815451253888"*y-"21704870055089718153088"*z))/pow("-3075770275504817"+"198931044892562752"*x+"14199788245258112"*y-"1122852841901814912"*z,3)+(40*("2938923392457131154149055759247753"+"8383263629566931208848464949723740"*x-"24821520393182477390523323699174560"*z)*("4157117722725769078952"+"4534359335248895646832"*x+"26193979470458655189977"*y-"2382852476120229696128"*z))/pow("45070329471431608"+"130124049256651728"*x-"5583613021604317"*y-"387630670566282112"*z,3)+(80*("1717566388539311579248"*x+"7025931019459451548321"*y+48*("46537098413809906919"-"8301700878138964680"*z))*("3017477155357435955713408172820441"+"3434616943638241443585000648954199"*x-"6875761229715351344214913955270620"*z))/pow("85141430232132048"+"97951351741329392"*x-"8855616621991191"*y-"199920422688690560"*z,3)+(2*("1013986939222028224203834326214704"+"723429769797021053206211106031819"*x-"1002019231842824621894736024449560"*z)*("22670037111266004087968"+"12461845278544574559640"*x+"39219302812923818032157"*y-"46563087562792926056"*z))/pow("50159316775994592+36243094308305160"*x-"4827156544231217"*y-"52318895858217464"*z,3)+(2*("698833722744934775627393528218146"+"279848894416310700301852732890585"*x-"191427609122898840477329914007915"*z)*("9101665097092871812176"+"3063507166600182944940"*x+"6945927557350563805665"*y+"1052001549322007294950"*z))/pow("46366672189358032"+"18896234711237580"*x-"3927118781169095"*y-"14705346416259850"*z,3)+(8*("557016173590538671691101855964863"+"303023948138837354463602341532495"*x-"309197308873592242001670976702725"*z)*("39553725461800043367392"+"17203831108841472538824"*x+"45483386678520344593037"*y+"2703260049547565568088"*z))/pow("92856945980914656"+"51329763147513032"*x-"8586501277743859"*y-"56199770659759016"*z,3)-(128*("-57335208466953058729715954197164"+"96390872682360153583488333868040"*x-"372364031472286149332017066304111"*z)*("45619694076424722199344"+"14936846773318822792976"*x-"3365788117861218576473"*y+"10130491989577935272320"*z))/pow("85141430232132048"+"97951351741329392"*x-"8855616621991191"*y-"199920422688690560"*z,3)-(5*("-5058036108182894712997605343704"+"13066181822706485812588287496990"*x-"23584235630998237996607750176151"*z)*("61468981380127448102256"+"5328427636421850183140"*x-"4647710007810227520885"*y+"13344414478836548348450"*z))/pow("46366672189358032"+"18896234711237580"*x-"3927118781169095"*y-"14705346416259850"*z,3)-(256*("-35027435322808897803896166913833"+"101153824679669203594026224000274"*x-"443348667941077090029000877418626"*z)*("61889933231497708820968"+"30294916915069669525488"*x-"4484037822343607626207"*y+"13934625423713945278848"*z))/pow("45070329471431608"+"130124049256651728"*x-"5583613021604317"*y-"387630670566282112"*z,3)-(24*("-23539469566855513950637813409344"+"36451820000039413375829754767131"*x-"87577625291530403453057402554096"*z)*("88457226224862447127008"+"13504083955712971035976"*x-"6622138801690554356387"*y+"19322683651036147287512"*z))/pow("92856945980914656"+"51329763147513032"*x-"8586501277743859"*y-"56199770659759016"*z,3)-(112*("97743545586690977941666831119873"+"189463292388600804291605866927808"*x-"534599264249120709692835475330432"*z)*("801790542801929135637671"+"732048260009923946735424"*x-"56975701334774517040256"*y+"187552638032246240630656"*z))/pow("-3075770275504817"+"198931044892562752"*x+"14199788245258112"*y-"1122852841901814912"*z,3)-(2560*("2304705299858575630109"*x-256*("204828849006588248100"+"19508530860149228990861"*y-"2445924471668591306496"*z))*("-29205293090710790323990469408790736"+"212589517464418508578145671300087"*x+"1750806894610755007047140949242022912"*z))/pow("5042560366642267"*x-256*("2446745837411900"+"4901398098088043"*y-"144207654645973248"*z),3)-(160*("3266813047619306699872"+"716026618045942942760"*x-"243780804476456624597"*y+"718216181537563796776"*z)*("52529278437993151034132605337909"*x-4*("8646336391489439377118003754263"+"39602745269819371968458588313429"*z)))/pow(50159316775994592+"36243094308305160"*x-"4827156544231217"*y-"52318895858217464"*z,3)))/125;
//value(2)=(128*((-24576*("3839508863935892182987929073642496"+"36103009879073133562313702394913733"*x-"87732961555209684260488911369472"*y)*("24610976415716501050652227"*x-256*("-10153609683556422184100"+"374519398571124540883"*y-"4145573659500944095488"*z)))/pow("5042560366642267"*x-256*("2446745837411900"+"4901398098088043"*y-"144207654645973248"*z),3)-(30720*("65108728870058843312625047943313"*x-256*("4791937744017588738333042319232"+"569924119339438478856491194414721"*y))*("2304705299858575630109"*x-256*("204828849006588248100"+"19508530860149228990861"*y-"2445924471668591306496"*z)))/pow("5042560366642267"*x-256*("2446745837411900"+"4901398098088043"*y-"144207654645973248"*z),3)+(256*("650985307933227267490679218098413"+"935767027021514282821089562931792"*x+"12859172907478119575029190058251392"*y)*("9439334964924689507817"+"17499514376929345709248"*x+"187907876794815451253888"*y-"21704870055089718153088"*z))/pow("-3075770275504817"+"198931044892562752"*x+"14199788245258112"*y-"1122852841901814912"*z,3)+(1280*("114748411888321695540849692963124"+"110442377985916695620550654636800"*x+"775672512286952418453853865599205"*y)*("4157117722725769078952"+"4534359335248895646832"*x+"26193979470458655189977"*y-"2382852476120229696128"*z))/pow(45070329471431608+"130124049256651728"*x-"5583613021604317"*y-"387630670566282112"*z,3)+(1600*("100744894915663705876272277122960"+"74302925512671884052557401907120"*x+"343788061485767567210745697763531"*y)*("1717566388539311579248"*x+"7025931019459451548321"*y+48*("46537098413809906919"-"8301700878138964680"*z)))/pow("85141430232132048"+"97951351741329392"*x-"8855616621991191"*y-"199920422688690560"*z,3)+(16*("72249495731635781189477972681776"+"39691308285862330678445510678381"*x+"125252403980353077736842003056195"*y)*("22670037111266004087968"+"12461845278544574559640"*x+"39219302812923818032157"*y-"46563087562792926056"*z))/pow("50159316775994592"+"36243094308305160"*x-"4827156544231217"*y-"52318895858217464"*z,3)+(640*("505227745581172894057712966825000"+"155010006988462124695347547225138"*x-"39602745269819371968458588313429"*y)*("3266813047619306699872"+"716026618045942942760"*x-"243780804476456624597"*y+"718216181537563796776"*z))/pow("50159316775994592"+"36243094308305160"*x-"4827156544231217"*y-"52318895858217464"*z,3)+(2*("356681541401645116923690413208956"+"126814067043212099223976834718490"*x+"191427609122898840477329914007915"*y)*("9101665097092871812176"+"3063507166600182944940"*x+"6945927557350563805665"*y+"1052001549322007294950"*z))/pow("46366672189358032"+"18896234711237580"*x-"3927118781169095"*y-"14705346416259850"*z,3)+(8*("301993014170585471859024964195112"+"134962043561465977901954677856080"*x+"309197308873592242001670976702725"*y)*("39553725461800043367392"+"17203831108841472538824"*x+"45483386678520344593037"*y+"2703260049547565568088"*z))/pow("92856945980914656"+"51329763147513032"*x-"8586501277743859"*y-"56199770659759016"*z,3)+(128*("4874430224431350455160317539284048"+"1942615285518540483044478359410032"*x-"372364031472286149332017066304111"*y)*("45619694076424722199344"+"14936846773318822792976"*x-"3365788117861218576473"*y+"10130491989577935272320"*z))/pow("85141430232132048"+"97951351741329392"*x-"8855616621991191"*y-"199920422688690560"*z,3)+(("1486971442137244004077030949061728"+"322769103831727073598968320899320"*x-"117921178154991189983038750880755"*y)*("61468981380127448102256"+"5328427636421850183140"*x-"4647710007810227520885"*y+"13344414478836548348450"*z))/pow("46366672189358032"+"18896234711237580"*x-"3927118781169095"*y-"14705346416259850"*z,3)+(512*("3005184872892536482128059816733656"+"1654842388128247497540371661628560"*x-"221674333970538545014500438709313"*y)*("61889933231497708820968"+"30294916915069669525488"*x-"4484037822343607626207"*y+"13934625423713945278848"*z))/pow("45070329471431608"+"130124049256651728"*x-"5583613021604317"*y-"387630670566282112"*z,3)+(192*("137644881571986015841084811827840"+"35619205657210451197984743698883"*x-"10947203161441300431632175319262"*y)*("88457226224862447127008"+"13504083955712971035976"*x-"6622138801690554356387"*y+"19322683651036147287512"*z))/pow("92856945980914656"+"51329763147513032"*x-"8586501277743859"*y-"56199770659759016"*z,3)+(64*("13728575451141247570683309821008705"+"13111763174706011627610159037098688"*x-"935548712435961241962462081828256"*y)*("801790542801929135637671"+"732048260009923946735424"*x-"56975701334774517040256"*y+"187552638032246240630656"*z))/pow("-3075770275504817"+"198931044892562752"*x+"14199788245258112"*y-"1122852841901814912"*z,3)))/125;

return value;

}

• Programming questions are off-topic here but can be asked on Stack Overflow. Since your question is about numerical methods, I think it would fit better on Computational Science, so I'm migrating it there. Note that computer science and scientific computing are not the same thing at all despite their confusingly similar names. Nov 28 '13 at 0:37
• thank you; what is the difference between stack overflow and stackexchange? I registered originally as StackOverFlow, but at the same time I have stackexchange acounts Nov 28 '13 at 4:43
• You should format your code so that it does not have lines so long. Nov 28 '13 at 8:45
• Thank you. It is easier to copy and paste this way, and simpler to understand the structure of the code. Do you agree? Nov 28 '13 at 8:47
• @LCFactorization Stack Exchange is a network of question-and-answer sites, each about a particular field. Stack Overflow is about programming, Computer Science is about computer science, Computational Science is about scientific computing, etc. Nov 28 '13 at 11:15

Libraries like MPFR & GMP [ http://gmplib.org/ ] are designed exactly for this requirement. Native datatypes for C and C++ have defined, fixed limits, GMP, MPFR,and other bignum libraries have extensible limits on precision. Each handled in its own way.

MPFR is also such a library, like GMP, it requires that it be installed. It is designed to have a fixed precision (declared at the beginningand the limits are smaller than GMP), GMP limits can be changed during runtime. MPFR has native (that is built-in) support for transcendental functions. Which can be a win if you need them.

However you choose to go, read the documentation, do not simply copy somebody else's code and expect good results.

Without knowing the magnitude of components x0 = (x,y,z), it's not possible to bound the size of results given by the three expressions value(0),value(1),value(2). As @jimmcnamara explains, knowing the necessary limits of precision in advance is critical to using libraries like MPFR.

You may have gotten a sufficient approximation, by either of your two techniques, to be able to bound the limits on magnitude, despite any "loss of precision". It depends partly on whether intermediate results are significantly larger than your final results.

In any case having an exact arithmetic environment will be useful, if only for the sake of validating a wide range of results obtained with C and MPFR. I'll throw out some ideas on how to compute integer expressions exactly.

An interpreted tool that will do this is IBM's Rexx, available on many platforms.

Most CAS (computer algebra system) packages support arbitrary precision integers, e.g. Maxima and Sage. Sympy has a more modest set of features but incorporates arbitrary precision arithmetic through mpmath, a Python library.

A useful case study for implementing algorithms with long integers is Victor Shoup's NTL (a library for doing number theory) which for portability is written in C++. By default it uses its own customized version of LIP, but can also be configured to use GMP either as a supplemental or a complete replacement for exact integers.

If I wanted to do something quick and easy but allowing for version control/regression testing with programming tools already on my desktop, I'd likely turn to Amzi Prolog which supports arbitrary precision integers as part of an "infinite precision real" data type. Also SWI-Prolog supports unbounded integers (and rational arithmetic on top of that) if it is built with GMP.