Results 1 to 5 of 5
  1. #1
    ellipse is offline Member
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default not getting precision as expected

    Per Ellipse Cirumference-High Accuracy from Polynomial

    <script LANGUAGE="JavaScript">
    function ec(form) {
    X1=eval(form.A.value)
    X2=eval(form.B.value)
    HT1 = X2-X1;
    HB1 = X2+X1;
    H1 = (Math.pow(HT1,2))/(Math.pow(HB1,2));
    H2 = 4-3*H1;
    C1 = Math.PI*HB1*(1+(3*H1)/(10+Math.pow(H2,0.5))+(5.1227200788995887836041683 376024e-4)*Math.pow(H1,(0.3629877*Math.pow(H1,1024)-0.80311737+Math.pow(H1,512)+1.7512218474*Math.pow( H1,256)-1.734067037*Math.pow(H1,128)+2.957992923*Math.pow( H1,64)-1.545484804*Math.pow(H1,32)+2.7559284083*Math.pow( H1,16)+0.176369301*Math.pow(H1,8)+2.95202242*Math. pow(H1,4)-0.600612825*Math.pow(H1,2)+4.2106880013*H1+5.89029 54352)));
    P = 9;
    C1 = C1.toPrecision(P);
    form.C.value = C1}
    </SCRIPT>
    <form>

    When inputting numbers X1=1, X2=0.5 I am getting 4.84422412 when it should be 4.84422411. I did the calculations on a spreadsheet and verified 4.84422411 should be the correct answer. I changed the value of (44-14*pi)/(11*pi) to the 5.122...e-4 and even added more decimal places to the coefficients (that the truncated coefficients as listed on my web page were derived from) and still it does not help (this should not matter anyway but thought I would try).

    I tried putting double declarations above and then deleted them when I was getting no response (perhaps I don't know how to properly do it).

    Would someone copy the above into a program to troubleshoot the above and if somehow adding the double precision syntax or some other fashion to fix this, please show me how I should include into my program above.

    Thanks!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: not getting precision as expected

    What does this have to do with coding in the Java programming language?

  3. #3
    ellipse is offline Member
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default Re: not getting precision as expected

    Note, there are no gaps in the numbers even though it is showing in the above window as such.

  4. #4
    ellipse is offline Member
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default Re: not getting precision as expected

    Hmm, perhaps this part: "<script LANGUAGE="JavaScript">"

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: not getting precision as expected

    Quote Originally Posted by ellipse View Post
    Note, there are no gaps in the numbers even though it is showing in the above window as such.
    Again, what does this have to do with coding in Java? Your post looks like nothing but Javascript, and surely you're smart enough to know the difference before posting here, right?

Similar Threads

  1. Possible Loss of Precision?
    By jwb4291 in forum New To Java
    Replies: 6
    Last Post: 12-02-2010, 04:28 AM
  2. Possible loss of precision
    By jankidudel in forum New To Java
    Replies: 2
    Last Post: 08-07-2010, 10:15 AM
  3. possible loss of precision?
    By gandalf5166 in forum New To Java
    Replies: 6
    Last Post: 04-13-2010, 08:21 PM
  4. Precision
    By c_walker in forum New To Java
    Replies: 1
    Last Post: 10-18-2009, 11:36 AM
  5. Wrong precision
    By lclclc in forum New To Java
    Replies: 0
    Last Post: 09-28-2009, 09:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •