Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Solve equation(s) with a List as Variable' topicStudent Support Forum > General > Archives > "Solve equation(s) with a List as Variable"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
01/20/13 9:30pm

In Response To 'Re: Re: Re: Re: Solve equation(s) with a List a...'
---------
Carefully use exact rational numbers to maintain precision for this example.

In[1]:= mag=49/30*10^-14;
w=5/1000;
d:=148*10^(-9);
mu0:=4*Pi*10^(-7);
B:=5/10000;
Table[{x,N[(w*d*B+mu0*mag)/(2*w*B)-x*Tanh[d/(2*x)],30]},{x,1,20}]

Out[6]= {
{1, 4.105014535765329831590891486602017102673418`30.*^-15},
{2, 4.105014434459329831591168862430017102027881`30.*^-15},
{3, 4.105014415698959461220813331095712575269563`30.*^-15},
{4, 4.105014409132829831591186198419267102017795`30.*^-15},
{5, 4.105014406093649831591186880763803982017677`30.*^-15},
{6, 4.105014404442737238998594533266428624651394`30.*^-15},
{7, 4.105014403447289015264656618680184532255041`30.*^-15},
{8, 4.105014402801204831591187281918595227017637`30.*^-15},
{9, 4.105014402358251642290775786423252482803085`30.*^-15},
{10, 4.105014402041409831591187324565128782017635`30.*^-15},
{11, 4.105014401806982724153170805018112177490622`30.*^-15},
{12, 4.105014401628681683443039191735431711071133`30.*^-15},
{13, 4.105014401489921547567518704739483997434462`30.*^-15},
{14, 4.105014401379819627509554693388984199060534`30.*^-15},
{15, 4.105014401290995016776372533492771672552614`30.*^-15},
{16, 4.105014401218298581591187349637303234830135`30.*^-15},
{17, 4.105014401158049554774578354069658341945318`30.*^-15},
{18, 4.105014401107560284266084470675017152822898`30.*^-15},
{19, 4.105014401064831216632738598418981551338926`30.*^-15},
{20, 4.105014401028349831591187352302711582017635`30.*^-15}}

You can see how slowly this is going to converge on zero as x increases.

If you introduce a decimal point ANYWHERE in this you should see the results are immediately compromised by $MachinePrecision approximate calculations. Try it and see. Spot the single difference in the code.

In[7]:=
mag=49/30*10^-14;
w=5/1000;
d:=148*10^(-9);
mu0:=4*Pi*10^(-7);
B:=5/10000.;
Table[{x,N[(w*d*B+mu0*mag)/(2*w*B)-x*Tanh[d/(2*x)],30]},{x,1,20}]

Out[12]= {
{1, 4.105014524035853`*^-15},
{2, 4.105014431391624`*^-15},
{3, 4.105014418156734`*^-15},
{4, 4.1050144049218444`*^-15},
{5, 4.1050144049218444`*^-15},
{6, 4.105014391686955`*^-15},
{7, 4.105014391686955`*^-15},
{8, 4.105014391686955`*^-15},
{9, 4.105014391686955`*^-15},
{10, 4.105014391686955`*^-15},
{11, 4.105014391686955`*^-15},
{12, 4.105014391686955`*^-15},
{13, 4.105014391686955`*^-15},
{14, 4.105014391686955`*^-15},
{15, 4.105014391686955`*^-15},
{16, 4.105014391686955`*^-15},
{17, 4.105014391686955`*^-15},
{18, 4.105014391686955`*^-15},
{19, 4.105014391686955`*^-15},
{20, 4.105014391686955`*^-15}}

Mathematica floating point calculations are not FORTRAN floating point calculations.



URL: ,

Subject (listing for 'Solve equation(s) with a List as Variable')
Author Date Posted
Solve equation(s) with a List as Variable Markus 01/17/13 12:15pm
Re: Solve equation(s) with a List as Variable Bill Simpson 01/17/13 10:19pm
Re: Re: Solve equation(s) with a List as Variable Markus 01/18/13 09:22am
Re: Re: Re: Solve equation(s) with a List as Va... Bill Simpson 01/18/13 2:05pm
Re: Re: Re: Re: Solve equation(s) with a List a... Markus 01/19/13 06:08am
Re: Re: Re: Re: Re: Solve equation(s) with a Li... Bill Simpson 01/20/13 9:02pm
Re: Re: Re: Re: Re: Solve equation(s) with a Li... Bill Simpson 01/20/13 9:30pm
Re: Re: Re: Re: Re: Re: Solve equation(s) with ... Markus 01/21/13 12:25pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic