Question for the math lovers!  Using while loop and exponents

Hi there Java geniuses! ; ) A little question here that has been perplexing me for the past few days. I'm trying to create a class that contains a single static method as follows:
public static double exp(double a)
It's supposed to work to calculate an "exp" value much like the Math.exp method of the Math class. Essentially, I need to keep calculating approximations of "exp" until a certain condition is met. This condition is specified in a while loop. Following is what I've written so far. But I can't seem to get the thing to work properly. Any suggestions/ advice would be greatly appreciated! Thanks.
A class that computes the "exp" for a user-defined
value.
public class MyMath
public static double exp(double x)
double dbloldGuess;
double dblnewGuess = 1 + x; // First value for newGuess
double dblcounter = 1;
do
dblcounter++; // increments counter
dbloldGuess = dblnewGuess;
dblnewGuess = dbloldGuess + ((x ** dblcounter) / counter);
while (Math.abs((newGuess - oldGuess) / newGuess) > 1e-15);
return x;
}

** wasn't an operator in C when I last checked...
Anyway here's my lousy attempt:public static double exp(double a) {
        double guess = 1;
        int N = 18;
        while (N --> 1) guess = 1 + a/N * guess;
        return guess;
}When called with 1.0 as argument gives the value equal to the constant Math.E, so is "probably" ok for arguments 0.0 -- 1.0. I wont guarantee anything else because this method is pretty pathological when it comes to loss of precision due to rounding, even if you increase N.

Similar Messages

  • Hi, I bouhgt a used Apple Power Mac G5, I want to buy a blue tooth card for the same to use wireless keyboard and mouse, i am just curious that why do i need to provide the serial number of my computer, is there any compatibilty issue?

    Hi, I am new in Apple Computer, I bought a used Power Mac G5. I want to buy a blue tooth card for the same to use wireless keyboard and mouse. so why it is mandatory to provide the serial number of the machine?

    Hello, Serial# not needed...
    At the Apple Icon at top left>About this Mac.
    Then click on More Info>Hardware and report this upto *but not including the Serial#*...
    Hardware Overview:
    Machine Name: Power Mac G5 Quad
    Machine Model: PowerMac11,2
    CPU Type: PowerPC G5 (1.1)
    Number Of CPUs: 4
    CPU Speed: 2.5 GHz
    L2 Cache (per CPU): 1 MB
    Memory: 10 GB
    Bus Speed: 1.25 GHz
    Boot ROM Version: 5.2.7f1

  • How to call sub VI and close the main VI in while loop and sequence condition

    Hiya,
    I have a problem with the while loop and the sequential condition in placed together i.e while loop as Global and sequential condition as local (i.e inside the Global loop). For example,when calling the sub vi from the main vi (main vi as main menu and sub vi as sub menu.)My problem is I can't run my sub menu when the particular icon is pressed through the main menu and only the front panel appears. My concerned was if possible the sub menu is activated in few second then jump back to the main menu again (analyze through the diagram).So, I don't know what should I need to do. If possible, please advice me how to encountered that particular problem.
    Thanks!

    Go to your block diagram of your main menu, then click on the "Hightlight Execution" it is something like a bulb. then you execute your vi. then LV will show you all your data flow.
    When you feel sad, laugh

  • Sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loop

    sir i have given lot of effort but i am not able to solve my problem either with notifiers or with occurence fn,probably i do not know how to use these synchronisation tools.

    sir i am using datasocket read ,i am communicating with java but my problem is that bcz im using while loop to see if value has changed my labview consumes all the processors time ,sir i want a event like thing so that while loop is not in continuous loopHi Sam,
    I want to pass along a couple of tips that will get you more and better response on this list.
    1) There is an un-written rule that says more "stars" is better than just one star. Giving a one star rating will probably eliminate that responder from individuals that are willing to anser your question.
    2) If someone gives you an answer that meets your needs, reply to that answer and say that it worked.
    3) If someone suggests that you look at an example, DO IT! LV comes with a wonderful set of examples that demonstate almost all of the core functionality of LV. Familiarity with all of the LV examples will get you through about 80% of the Certified LabVIEW Developer exam.
    4) If you have a question first search the examples for something tha
    t may help you. If you can not find an example that is exactly what you want, find one that is close and post a question along the lines of "I want to do something similar to example X, how can I modify it to do Y".
    5) Some of the greatest LabVIEW minds offer there services and advice for free on this exchange. If you treat them good, they can get you through almost every challenge that can be encountered in LV.
    6) If English is not your native language, post your question in the language you favor. There is probably someone around that can help. "We're big, we're bad, we're international!"
    Trying to help,
    Welcome to the forum!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • I am using a timed while loop and am unable to get the loop to run at a speed of less than 1ms (I am currently using the Wait(ms) function). How can I get a faster response?

    I am trying to create a virtual engine within a timed while loop and am unable to get the loop to run at a speed of less than 1ms (I am currently using the Wait(ms) function). This does not however allow realistic engine speeds. How can I overcome this? I have access to a PCI-MIO-16E-4 board.

    andyt writes:
    > I am using a timed while loop and am unable to get the loop to run at
    > a speed of less than 1ms (I am currently using the Wait(ms) function).
    > How can I get a faster response?
    >
    > I am trying to create a virtual engine within a timed while loop and
    > am unable to get the loop to run at a speed of less than 1ms (I am
    > currently using the Wait(ms) function). This does not however allow
    > realistic engine speeds. How can I overcome this? I have access to
    > a PCI-MIO-16E-4 board.
    Andy,
    Unless you use a real time platform, getting extactly 1 ms loop rate
    (or even less) is impossible. It starts getting troublesome at about
    0.1 Hz for standard operating systems.
    I'd tackle your problem with "if i mod 10 == 0 then sleep 1 ms".
    Of
    course this is jerky by design.
    HTH,
    Johannes Nie?

  • Please read my question carefully, this is, I think, a question for the experts. It's not the usual name change question.   When I setup my new MacBook Pro, something slipped by me and my computer was named First-Lasts-MacBook-Pro (using my real first and

    Please read my question carefully, this is, I think, a question for the experts. It's not the usual name change question.
    When I setup my new MacBook Pro, something slipped by me and my computer was named First-Lasts-MacBook-Pro (using my real first and last name).
    I changed the computer name in Preferences/Sharing to a new name and Preferences/Accounts to just be Mike. I can right click on my account name, choose advanced, and see that everything looks right.
    However, If I do a scan of my network with my iPhone using the free version of IP Scanner, it lists my computer as First-Lasts-MacBook-Pro! And it lists the user as First-Last.
    So even though another Mac just sees my new computer name, and my home folder is Mike, somewhere in the system the original setup with my full name is still stored. And it's available on a network scan. So my full name might show up at a coffee shop.
    Can I fully change the name without doing a complete re-install of Lion and all my apps?

    One thought... you said the iPhone displayed your computer's old name? I think that you must have used the iPhone with this computer before you changed the name. So no one else's iPhone should display your full name unless that iPhone had previously connected to your Mac. For example, I did this exact same change, and I use the Keynote Remote app to connect with my MacBook Pro. It would no longer link with my MacBook Pro under the old name, and I found that I had to unlink and then create a new link under the new name. So the answer to your question is, there is nothing you need to do on the Mac, but rather the phone, and no other phone will display your full name.

  • I'm using a macbook pro, running snow leopard. Yesterday I got around to emptying my trash for the first time in quite awhile and was surprised by how much there seemed to be in there. Immediately after a question mark symbols appeared on all my hard disk

    I'm using a macbook pro, running snow leopard. Yesterday I got around to emptying my trash for the first time in quite awhile and was surprised by how much there seemed to be in there. Immediately after a question mark symbol appeared on all my hard disk folders. If I click on these question marks I get a message saying ' the item can't be found'.

    mpagan47 wrote: a question mark symbol appeared on all my hard disk folders.
    Not sure where these hard disk folders are located that you are referring to?  Finder, Finder tool bar, Finder side bar, Desktop, Dock? 
    More then likely they are  an alias that not longer point to the orginals,  thus the question mark.
    I would reboot.  Delete icons if an alias and just recreate by dragging from the source. Try right click (control) click to remove.

  • I have created a .png logo to use on my video. It has it's own storyline so the logo is shown overthe whole video. Do I need to composite the logo storyline to the main storyline before exporting? Same question for the audio storyline.

    Final Cut Pro 10.0.8
    I have created a .png logo to use on my video. It has it's own storyline so the logo is shown over the whole video. Do I need to composite the logo storyline to the main storyline before exporting? Same question for the audio storyline.

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable                     
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar
    The missing apps could have been done by setting the Restrictions that can hid those apps. If the backup was made with those retrictions set the the Restrictions are also restored.
    Thus, if you get it to work restore to factory settings/new iPod, not from backup                               
    You can redownload most iTunes purchases by:        
      Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Which Mac Pro? More cores=slower speeds? And most of us know the speed matters or FPU for music and I don't understand the faster is for the least amount of procs. And while I get the whole rendering thing and why it makes sense.

    Which Mac Pro? More cores=slower speeds? And most of us know the speed matters or FPU for music and I don't understand the faster is for the least amount of procs. And while I get the whole rendering thing and why it makes sense.
    The above is what the bar says. It's been a while and wondered, maybe Apple changed the format for forums. Then got this nice big blank canvas to air my concerns. Went to school for Computer Science, BSEE, even worked at Analog Devices in Newton Massachusetts, where they make something for apple. 
    The bottom line is fast CPU = more FPU = more headroom and still can't figure out why the more cores= the slower it gets unless it's to get us in to a 6 core then come out with faster cores down the road or a newer Mac that uses the GPU. Also. Few. I'm the guy who said a few years ago Mac has an FCP that looks like iMovie on Steroids. Having said that I called the campus one day to ask them something and while I used to work for Apple, I think she thought I still did as she asked me, "HOW ARE THE 32 CORES/1DYE COMING ALONG? Not wanting to embarrass her I said fine, fine and then hung up.  Makes the most sense as I never quite got the 2,6,12 cores when for years everything from memory to CPU's have been, in sets of 2 to the 2nd power.  2,4,8,16,32,64,120,256,512, 1024, 2048,4196,8192, 72,768.  Wow. W-O-W and will be using whatever I get with Apollo Quad. 
    Peace to all and hope someone can point us in THE RIGHT DIRECTION.  THANK YOU

    Thanks for your reply via email/msg. He wrote:
    If you are interested in the actual design data for the Xeon processor, go to the Intel site and the actual CPU part numbers are:
    Xeon 4 core - E5.1620v2
    Xeon 6 core - E5.1650v2
    Xeon 8 core - E5.1680v2
    Xeon 12 core - E5.2697v2
    I read that the CPU is easy to swap out but am sure something goes wrong at a certain point - even if solderedon they make material to absorb the solder, making your work area VERY clean.
    My Question now is this, get an 8 core, then replace with 2 3.7 QUAD CHIPS, what would happen?
    I also noticed that the 8 core Mac Pro is 3.0 when in fact they do have a 3.4 8 core chip, so 2 =16? Or if correct, wouldn't you be able to replace a QUAD CHIP WITH THAT?  I;M SURE THEY ARE UO TO SOMETHING AS 1) WE HAVE SEEN NO AUDIO FPU OR PERHAPS I SHOULD CHECK OUT PC MAKERS WINDOWS machines for Sisoft Sandra "B-E-N-C-H-M-A-R-K-S" -
    SOMETHINGS UP AND AM SURE WE'LL ALL BE PLEASED, AS the mac pro      was announced Last year, barely made the December mark, then pushed to January, then February and now April.
    Would rather wait and have it done correct than released to early only to have it benchmarked in audio and found to be slower in a few areas- - - the logical part of my brain is wondering what else I would have to swap out as I am sure it would run, and fine for a while, then, poof....
    PEACE===AM SURE APPLE WILL BLOW US AWAY - they have to figure out how to increase the power for 150 watts or make the GPU work which in regard to FPU, I thought was NVIDIA?

  • While loop and for loop condition terminal

    Hello friends,
    I am using labview 8.6. The condition terminal of the while loop and conditional for loop is behaving in just the opposite way.
    When i wire a true to the condition terminal of my loop, the while loop continues to run when I click on run. when I wire a FALSE, it stops.
    Is there any setting change that I have to make it to get it work properly.
    Please suggest on this.
    Thanks and regards,
    Herok

    Please do NOT attach .bmp images with the extension changed to .jpg to circumvent the forum filters!
    Herok wrote:
    I am sending you the VI. I am not sure if this would help you because only in 2 computers this behaviour is seen. In others, it works as it is supposed to work.
    Whatever you are seeing must be due to some corruption or folding error. It all works fine here.
    To make sure there are no hidden objects, simply press the cleanup button which would reveal any extra stuff (which is obviously not there). Does it fix itself if you click the termination terminal an even number of times? What if you remove the bad loop and create a new one?
    Could it be you have some problems with the graphics card and the icon of the conditional terminal does not update correctly?
    Whay happens if you connect a control instead of a diagram constant?
    What is different on the computers where it acts incorrectly (different CPU (brand, model), #of cores, etc.) 
    LabVIEW Champion . Do more with less code and in less time .

  • Question for the Adobe Illustrator team or anyone who might know

    Is Adobe Illustrator meant only to use Bezier curves? I know that they are very useful for a number of curves, but are they used to approximate circles? Granted, all screens require rasterized objects to the nearest pixels in order to display them, but when drawing a circle, information is lost because it is converted into 4 Bezier curves (cubic or quadratic, I'm not sure). However, when I export a circle from Adobe Illustrator CS5 to SVG it preserves the circle or ellipse's information with its proper tag.
    So, my question is, does the Adobe Illustrator Artboard file format have some internal representation of ellipses and circles such that it it not broken down into Bezier curves?

    function(){return A.apply(null,[this].concat($A(arguments)))}
    when I export a circle from Adobe Illustrator CS5 to SVG it preserves the circle or ellipse's information with its proper tag.
    So what? That means nothing. You're just talking about terms within a progamming language. One could program Illustrator to export a freakin' square as SVG's circle tag if one wanted to.
    As explained in your previous thread about the same worry-wart subject:
    There being a "circle element" in SVG programming, in itself, means nothing. I can write you a Javascript called "Illustrator's Circle Element" that will work in Illustrator, that will prompt you for center coordinates and a radius, that will appear in one of Illustrator's menus, and that will cause Illustrator to render that which for any practical purpose is a circle. The presence of such a command in no way signifies to you what kind of curve-rendering math is employed by that "element" to actually plot the curve!
    By the same token, SVG's providing something called a "circle element" in its API and asking you to specify it in terms of center and radius in no way tells you what kind of curve-rendering math is actually being employed to render the curve, nor does it ensure that its rendered result will be any more precisely mathematically circular than rendered by a cubic Bezier curve. If you don't know for a fact that SVG's rendering math does not employ Bezier curves, then your concern is moot.
    It's moot anyway, because it's ridiculous. Again: the "inaccuracy" is so tiny as to be completely pointless for any practical SVG purpose.
    Again: You are reading entirely too much into a mere popularly-cited curiosity about the cubic Bezier equation. You are being silly; you just don't realize it.
    Illustrator's (i.e; PostScript's) using Bezier math to plot curves does not make Illustrator (or any of the similar programs) in any way "sub standard" or "less accurate" or "less desirable" or more "dumbed down" than any other. In fact, here are some other related curiosities for you to loose sleep over:
    The math primarily used for plotting curves in most CAD programs is quite arguably "more crude" than Bezier curves.
    Illustrator uses cubic Beziers. TrueType uses quadratic Beziers. But there are Bezier equations of higher order than cubic.
    (If I remember right) Bezier himself discovered the formulae bearing his name in pursuit of more supple curves for the automotive industry.
    If you're still worried about this, you really need to go take a couple of math courses, so you can understand that this really is silly.
    JET

  • Can't we use while loop inside a fn

    i am using a while loop inside a fn
    it is showing error
    the code is
    while (a=1) loop
    some condition
    end loop;
    the error is
    PLS-00103: Encountered the symbol "WHILE" when expecting one of
    the following:
    * & = - + < / > at in is mod not rem then <an exponent (**)>
    <> or != or ~= >= <= <> and or like between overlaps || year
    DAY_
    The symbol "*" was substituted for "WHILE" to continue.
    PLS-00103: Encountered the symbol "LOOP" when expecting one of
    the following:
    . ( * % & = - + < / > at in is mod not rem then
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between ||
    what is the error

    It looks like the OP misskeyed the assignment operator and got compilations errors, and from that assumed that you can't use WHILE loops in functions on a Tuesday.
    Message was edited by:
    William Robertson
    I was thinking of his is it possible to increment a value in a function, though I suspect the problem is similar.

  • I have a new email address and my old email keeps coming up on icloud when trying to update apps and i don't know the password or security questions for the old email. I can sign in with my apple id which is tied to another email but not itunes how to fix

    I have an apple id and it has my current email attached to it. however when i go to update apps it's asking for the password for an old email. I no longer have the old email and can't use it. when I go to icloud on my ipad it asks for the password for old email. it doesn't allow me to change the old email to current. when i go to reset it i can't remember the password or security questions for the old email so it doesn't let me go any further. How do I fix this? Do i need to call apple support?

    I have the same problem - it is maddening. I rely on this iPad for work so this is not just an annoyance! The above solutions of changing the appleid on the device or on the website do not work.
    The old email address no longer exists - I haven't used it in a year probably and I no longer have the account.  I logged into the appleid website and there is no trace of the old email address so there is nothing that can be deleted or changed there.  On the iPad there is no trace of the old email address so nothing can be deleted there either. I have updated the iPad software and the same problem comes right back.  Every 2 seconds I am asked to log in using the old non-existent email.  The device is currently useless.
    The only recent change to anything was the addition of an Apple TV device, which was set up using the correct login and password.
    Does anyone have any ideas? The iPad has been backed up to the iCloud so presumably it now won't recognize the current iCloud account? So restoring may notbe an option?

  • How can someone use a stolen iphone? does erasing the phone (which I feel like I should do) make it easier for the thief to use the iphone?  If I don't erase it, it doesn't seem like anyone should be able to use the phone because of my password.

    how can someone use a stolen iphone? does erasing the phone (which I feel like I should do) make it easier for the thief to use the iphone?  If I don't erase it, it doesn't seem like anyone should be able to use the phone because of my password. Also, is it possible to retrieve anything that has been sent to the phone (i.e. text messages) since it was stolen through icloud? The "find my iphone" app says the device is offline but it rings when I call my number -- any idea how that would be the case? Thanks!!

    You have a password, so good move on your part.  Whether you erase it or the thief does, they still get to use the iPhone as theirs.  Which is more important (pick one), protecting your data or punishing the thief?
    Ringing occurs at the carrier.  Chances are you're going to voicemail after only two or three rings.  If you have an iCloud backup also a good move.  Re-read my question in the first paragraph.

  • I just purchased the Mac Mini Server with the intention of replacing Lion Server with Lion for the first hard drive while installing Windows 7 thru Bootcamp on the second hard drive. Is it possible for me to do this? Thanks.

    I just purchased the Mac Mini Server with the intention of replacing Lion Server with Lion for the first hard drive while installing Windows 7 thru Bootcamp on the second hard drive. Is it possible for me to do this? Thanks.

    I would use Parallels or VMWare and use the second drive to hold the virtual machine. That way the VM only uses the space that it needs and you can still use the remainder of the drive for other things, not to mention that you would not need to reboot to run windows.
    Also Time Machine does not back up a boot camp partition.

Maybe you are looking for

  • Since upgrade I can no longer see tray icons on bottom of screen - how do I uncover them?

    Since the latest upgrade, Firefox now covers my entire screen. I can get used to the disappearing tabs & such on the top, but for my job I need to switch back & forth between browser and email a lot, and need quick control of the volume bar. The enti

  • Selecting and Deselecting Images in Aperture

    Is there anyway to select images in Aperture and keep them selected until you deselect them? For example if I close Aperture I would like to be able to comeback and the images are still selected.

  • Reset password locked up on macbook pro

    forgot mu pw and hit command s instead of command r now I see a padlock on screen and I cant do anything

  • PSE 8 vs PSE7 slideshow creation

    I have successfully created slideshows in PS Elements 7.  After installing PS Elements 8, I no longer can produce a viewable slideshow.  Here is my procedure;  -- start the browser, -- select images to be included in the slideshow, -- , go to CREATE

  • Description Column of specific RFC Import Object empty

    Hi all, I wonder if there is a way to display the fields descriptions of specific RFC Import Object in SAP XI. When the RFC object is imported, even if in the source SAP system the fields descriptions are filled they are not displayed in SAP XI, at l