-2

i have this exp function in matlab

a1=(exp(-beta0*abs(z-zaks)));
b1=(ohmi*exp(-2*beta0*H)*exp(-beta0*(z+zaks)))
c1=(ohmu*exp(beta0*(z+zaks)))
f1=(ohmu*ohmi*exp(-2*beta0*H)*exp(beta0*abs(z-zaks)))
g1=2*beta0*(1-(ohmu*ohmi*exp(-2*beta0*H)))
h1=(a1+b1+exp(c1)+f1)
j1=exp(h1)
gpm=j1/g1

with

beta0=1.411608078945960e+20 + 8.949434210398852e-26i
betai=[1.411608078945960e+20 + 8.949434210398852e-26i 1.411608078945960e+20 +   1.398349095374821e-26i 1.411608078945960e+20 + 1.398349095374821e-27i 1.411608078945960e+20 + 1.398349095374821e-26i]

ohmi=[9.803212783111246e-92 + 2.674639380309578e-46i 2.428723887707741e-93 + 4.457732300515962e-47i -2.428723887707741e-93 - 4.457732300515962e-47i;1.411608078945960e+20 + 1.398349095374821e-26i]

ohmu=1.004853842833425e-91 + 3.169942969255795e-46i
z=zaks=4950
H=5000

and it return to be inf even if i had using vpa or sym in it what should go wrong with this?

1 Answers1

0

It also depends on whether you used vpa correctly:

>> vpa(1e400)

ans =

Inf

>> vpa('1e400')

ans =

1.0e400

So you always have to prevent matlab from evaluating something large/small before using vpa. Now, this doesn't solve your problem, since

>> vpa(exp(1.3975e+024 +8.8599e-022*i))

ans =

Inf + Inf*i

>> vpa('exp(1.3975e+024 +8.8599e-022*i)')

ans =

Inf + Inf*i

>> exp(vpa('1.3975e+024 +8.8599e-022*i'))

ans =

RD_INF + RD_INF*i

so regardless of the approach you use, you will get infinity for all intents and purposes.


Why is that, you might ask? Consider that

exp(710)

ans =

   Inf

Now, your number is roughly equal to

exp(1397500000000000000000000)

or

10^606926538459794441764864

or

1e606926538459794441764864

Of course I ignored a teeny-tiny imaginary part, but that doesn't change much. You do realise that it's a very big number, right?

So, as @BillBokeey has already commented: what do you plan to do with this number? Your best options are probably doing anything you want on paper first, and reach a result that can be handled by a computer.

Community
  • 1
  • 1
  • my apologize for suddenly just post a line from my work, i was trying to implement a formula from a paper, and those formulas lead me into this problem, so i just curious why it happen, because on the paper its possible to do it right, and yes i think i should do it on the paper first rather than all of sudden jump onto matlab but is there's any way that i could compute it Mr Andras? – ariel rahardi Oct 27 '15 at 10:47
  • @arielrahardi as you see, even your best chances (i.e. symbolic math toolbox) give inf, since your number is just so mind-bogglingly large. Looking at your updated question: are you sure those numbers are correct? You seem to have some physical motivation behind your work, but it's very rare to have quantities with such different magnitudes (1e24 and 1e-24) next to each other. Are you sure that both the formulae and the parameters are correct? – Andras Deak -- Слава Україні Oct 27 '15 at 11:15
  • yes, i am very sure with it, because i have another work with those order of magnitudes. and i have found no problem. This time i just want to try this new formula, and it turned to be like this – ariel rahardi Oct 28 '15 at 03:01