# why get different values when matlab also use maple for calculation?. Maple vs Matlab??

8 ビュー (過去 30 日間)
gourav pandey 2021 年 12 月 24 日

Hi, I have this problem where the maple show very small result but matlab show very large value. I have written the code in Maple and Matlab. I'm working on this from last 4 days and didn't find any result, why this is happening.
Thank you in advance and please share if you know the reason behind this difference.
n,m,omega1 are real numbers n>m, n and m are integer, omega>0, n=m+2, and m is any odd no.s greater then 2.
%%%%%% MATLAB CODE
clc; clear; close;
n=5;m=3;omega1=500;
fun_matlab=(omega1*gamma(n/2)*gamma(m/2 + 1)*hypergeom(m/2 + 1, [3/2, 1 - n/2], omega1^2/4))/(2*gamma(m/2 + n/2 + 1)) + (omega1*omega1^n*pi^(1/2)*gamma(-n/2)*hypergeom(m/2 + n/2 + 1, [n/2 + 1, n/2 + 3/2], omega1^2/4))/(4*2^n*gamma(n/2 + 3/2));
fun_matlab = 6.575169876935467e+209
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% MAPLE CODE
restart; Digits:=500: n:=5: m:=3: omega1:=500:
Fun_maple:=evalf((omega1*GAMMA(n/2)*GAMMA(m/2 + 1)*hypergeom([m/2 + 1], [3/2, 1 - n/2], omega1^2/4))/(2*GAMMA(m/2 + n/2 + 1)) + (omega1*omega1^n*Pi^(1/2)*GAMMA(-n/2)*hypergeom([m/2 + n/2 + 1], [n/2 + 1, n/2 + 3/2], omega1^2/4))/(4*2^n*GAMMA(n/2 + 3/2)));
Fun_maple := -1.81414220781335980673653067232748014592172464361706594606931258364*10^(-209)
##### 2 件のコメント表示非表示 1 件の古いコメント
gourav pandey 2021 年 12 月 24 日
thank you for correcting me. but Will you please suggest any idea/reason behind this

サインインしてコメントする。

### 回答 (1 件)

Walter Roberson 2021 年 12 月 24 日
fun_matlab=(omega1*gamma(n/2)*gamma(m/2 + 1)*hypergeom(m/2 + 1, [3/2, 1 - n/2], omega1^2/4))/(2*gamma(m/2 + n/2 + 1)) + (omega1*omega1^n*pi^(1/2)*gamma(-n/2)*hypergeom(m/2 + n/2 + 1, [n/2 + 1, n/2 + 3/2], omega1^2/4))/(4*2^n*gamma(n/2 + 3/2));
n and m are double precision. omega is double precision. The gamma() calls are being evaluated at double precision, and your hypergeom() calls are being evaluated at double precision. Double precision is not accurate enough for your purposes.
##### 3 件のコメント表示非表示 2 件の古いコメント
John D'Errico 2021 年 12 月 24 日
Even if you use the symbolic toolbox, with everything in sym form, a large value is still produced, not the infinitessimally small one apparently produced from Maple.
n=sym(5);m=sym(3);omega1=sym(500);
digits 5000
fun_matlab=(omega1*gamma(n/2)*gamma(m/2 + 1)*hypergeom(m/2 + 1, [3/2, 1 - n/2], omega1^2/4))/(2*gamma(m/2 + n/2 + 1)) + (omega1*omega1^n*pi^(1/2)*gamma(-n/2)*hypergeom(m/2 + n/2 + 1, [n/2 + 1, n/2 + 3/2], omega1^2/4))/(4*2^n*gamma(n/2 + 3/2));
vpa(fun_matlab)
ans =
147748731616237577931448363241910368283180484634000496100665387387718411349283956852373300175539197760922694640142292157562340440898059897980298202574649566231171561333775852154622445545528768308520930015426487.0863498830823765232823480627139222936503715438799464412851830768478983831036296973344755151435098437067437752391294062011452385312004303314656598808096311285145864980219749132556964600592390223455372953776512924490749958419751683873694385571230866979076302422525604930389533068747876362921891153760519734949338592654764531423925140806092090149888536227492888000923032296131366435507730103786420120218859203547085762997974107915729496756974053271088704728638187898053487675232852417616027618083087504497866163187415356170127322059067782083699563325588706621591438750039928022806285962578490840905063417687646547749245326945723557137978260046735238027396283720984590429674805556644098317669576443124441670981410255367029949936182153808843774660839144590472058384441299247528947675139797955621415394375443849053717899771742184755822787852276136646671933818125855174241072254334632780328000036308553314885060950269856196498793393606666552973537267376390169904344484764843074139018715753581572343010303661897945659915499169913394200232588627633151116060080364895158479676748781610745396475483288454825580865090714158662308657557433605382767136806246862020578700099946196284159964726339698164147107673911838790682145013229594511047285781270968596256827862215822470685106782190984432702702292103678892731665019125506501067388591399205113889796260660103182613672477681436818186904010621555251288714279518544719787238937443236444105316445645580057487554891642882034380970041760733794513864168932707249169175791210195487602121674578387737364790653948362659062583097934072705877077753099910766064973233982921766408718971002389585572756382046531800026450420915996862092472014366665093128625844683884456327441995359995094755671454333741849675350716427590968111383719035406523526415695911834748274184820516867436953945826232909105715965078570915320502259126290512818913313877420704218572682678098013431891997814279297049106299858615695633000718423647223430191779836456826387399561401197603771489170131208829096174783189739125052199788092496926022160823952450783800167193276370726798734156072774937990743894401684344358349257183707299693962663094234407332871408932652239299831546036033569381647972573178943603603285044062345759733792302999355908523925112609920030222973338108400713851144586222851232544397308448104164094072898506510345180658593016074656825742076505200914491294932930515431757156180763724847372060149750838118403882740191715431899502315068505631366944030641643501690121612806246148737459079019011461697588684682304825024137240423228904568075148244863590488435547668930028683371712401215740667223044574375329086967484218365017648256496067858651787089022986708050914547128166673766890605616055113216980565492628120034707174699532421909430708906231270732558284176077211389470684737860304877621036480815416371821478981860388735867663688907482445886586092645434987955091586685479870079176675897949627074893006506049330923746770069948742165934949685361114106958051913446978613546980111760801166847989843696233620120806975788957685588627466301934429219151026838394165412383233195831897070116715071389233427085379364706867446529026010399745019822441891854161740931421751154201056135119466746664416844750071721139563638949860033018976611483134988781174161132655870332572971927942261442618504455856570424862372485153118612960613012160427992763177647028380651116798426446740489748995135739230578478850241074209199523193415574664534042638953307613218296751960291588989029302363830433384692526139047220174111234476563765807338907716224456931764504072247961906469436135647032620539821264393670688905897395214825872724945098035540504290787265393716141527743157416854665405241789282709262811613272563251545741502230733996411735405260618237971351153845760880686980364183509484338435610898547857679708341225081738202345854205843954850929323088578413558590272973311256739597131596535276489770634966198619636676421873016780309617942694385009052020922459238733120162841517521185131785617099175720739231119080001279130653248127283004524937165292086986161642139457748796826109422507865015341473582193312793687111771056851880485571822320134311356877918646112101585224167647956238830825405527821711038516391336115291663519502823405367600864820713030936994800507233538386118970758530570795772045625738917259556602078618155992916892902400874609976240131803835137431103875794095842773993781554114441585881767950113635740851107802556554132571379276185542922733305923364985915364089205031022265184845783271795869425922452632788370799186733586905958028872319984373021210084090813772664930277280795406721885484043943658932898059132166540358379662834952435864982834842361303218289109922349437428413854927786478680351267442158088638852896814753016845716837821160566014644165069585212571556756518111206068557838534894630596
double(fun_matlab)
ans = 1.4775e+209
It is different from that which MATLAB produced without the aid of syms though.

サインインしてコメントする。

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by