Closed Thread
Results 1 to 9 of 9

Thread: Matlab

  1. #1
    strokebow is offline Newbie
    Join Date
    Feb 2007
    Posts
    5
    Rep Power
    0

    Cool Matlab

    Hi!

    I don't know if this is the correct forum to post this message in but Matlab programming ispretty similar to C.

    I'm trying to write a program that calculates the value of pi to 10 decimal places by using 'Archimedes Method'.
    Archimedes concluded that:
    n*sin(theta/2) < pi < n*tan(theta/2)
    (BTW, I can't use pi in my program - kinda defeats the object)

    Basically, I need some help. Anyone got any ideas or any code just to get me started. I'm clueless at the moment.

    Thanks in advance

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143
    1) I believe it's for a particular theta. I don't recall what it was, but that's going to be important.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    strokebow is offline Newbie
    Join Date
    Feb 2007
    Posts
    5
    Rep Power
    0
    Areyou taking the biscuit chap?
    I come on this forum to learn.

  5. #4
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143
    Archimedes used values of theta for which the sin and tan were known. Basicly, you're looking at starting with something like theta=pi/2, and then using half angle formulas to get successively finer values without actually using the sin/tan functions.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    strokebow is offline Newbie
    Join Date
    Feb 2007
    Posts
    5
    Rep Power
    0
    Thanks for your reply.

    But I cant use theta=pi/2 because that would mean using the value of pi to calculate pi which is off limits.

  7. #6
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143
    No, you store pi/2 as a logical value, or pi/4. The key is that you have the exact values of Sin and tan without going through the standard functions. Using pi/4, sin(pi/4) = sqrt(2)/2 and tan(pi/4)=1. Then use the half angle formulas.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  8. #7
    strokebow is offline Newbie
    Join Date
    Feb 2007
    Posts
    5
    Rep Power
    0
    How do you mean store them as logical values? How would I use these to get pi to the required accuracy of 10 dp

  9. #8
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143
    You need a function that will compute square roots to about 15 decimal places and you're set.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  10. #9
    strokebow is offline Newbie
    Join Date
    Feb 2007
    Posts
    5
    Rep Power
    0
    thank you very much for your reply and help

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I need some help with MATLAB..
    By Ravi Mudhoo in forum General Programming
    Replies: 12
    Last Post: 10-27-2011, 10:36 AM
  2. New in MATLAB (Help)
    By toto_7 in forum General Programming
    Replies: 1
    Last Post: 05-03-2011, 04:10 PM
  3. Matlab and C++
    By ahmed in forum C and C++
    Replies: 6
    Last Post: 06-08-2010, 11:11 PM
  4. MATLAB
    By priteshdesai in forum General Programming
    Replies: 0
    Last Post: 03-10-2010, 08:45 AM
  5. can someone help with this function in matlab?
    By Reza in forum General Programming
    Replies: 2
    Last Post: 02-18-2008, 02:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

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