Search Results

Search found 1803 results on 73 pages for 'pi calculation'.

Page 6/73 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Code Golf: Leibniz formula for Pi

    - by Greg Beech
    I recently posted one of my favourite interview whiteboard coding questions in "What's your more controversial programming opinion", which is to write a function that computes Pi using the Leibniz formula. It can be approached in a number of different ways, and the exit condition takes a bit of thought, so I thought it might make an interesting code golf question. Shortest code wins! Given that Pi can be estimated using the function 4 * (1 - 1/3 + 1/5 - 1/7 + ...) with more terms giving greater accuracy, write a function that calculates Pi to within 0.00001. Edit: 3 Jan 2008 As suggested in the comments I changed the exit condition to be within 0.00001 as that's what I really meant (an accuracy 5 decimal places is much harder due to rounding and so I wouldn't want to ask that in an interview, whereas within 0.00001 is an easier to understand and implement exit condition). Also, to answer the comments, I guess my intention was that the solution should compute the number of iterations, or check when it had done enough, but there's nothing to prevent you from pre-computing the number of iterations and using that number. I really asked the question out of interest to see what people would come up with.

    Read the article

  • ARM TechCon 2013: Oracle, ARM expand collaboration on servers, Internet of Things

    - by terrencebarr
    Over the years, Oracle has been making big investments in Java for ARM-based devices. This week, Oracle and ARM announced further expanding their collaboration on a number of fronts, from additional hardware platforms, porting layers, and optimized communication protocols, to 64-bit ARMv8 support, and IoT architectures. Henrik Stahl, VP of Product Management in the Java Platform Group at Oracle, just posted an excellent summary: “ARM TechCon 2013: Oracle, ARM expand collaboration on servers, Internet of Things”. Highly recommended reading. Cheers, – TerrenceFiled under: Embedded Tagged: 6LoWPAN, ARM, CoAP, Freescale, Gemalto, iot, Java Embedded, Java ME Embedded, Java SE Embedded, Lego Mindstorms, OpenJDK, Qualcomm, Raspberry Pi, TechCon

    Read the article

  • Code Golf - PI day

    - by gnibbler
    The Challenge The shortest code by character count to display a representation of a circle of radius R using the *character. Followed by an approximation of pi Input is a single number, R Since most computers seem to have almost 2:1 ratio you should only output lines where y is odd. The approximation of pi is given by dividing the twice the number of * characters by R squared. The approximation should be correct to at least 6 significant digits. Leading or trailing zeros are permitted, so for example any of 3,3.000000,003 is accepted for the inputs of 2 and 4 Code count includes input/output (i.e full program). Test Cases Input 2 Output *** *** 3.0 Input 4 Output ***** ******* ******* ***** 3.0 Input 8 Output ******* ************* *************** *************** *************** *************** ************* ******* 3.125 Input 10 Output ********* *************** ***************** ******************* ******************* ******************* ******************* ***************** *************** ********* 3.16

    Read the article

  • [Java] Cannot draw pixels

    - by Wilhelm
    Hello everyone. I want to print each digit of pi number as a colored pixel, so, I get na input, with the pi number, then parse it into a list, each node containing a digit (I know, I'll use an array later), but I never get this painted to screen... Can someone help me to see where I'm wrong? package edu.pi.view; import java.awt.Graphics; import java.awt.Image; import java.awt.image.MemoryImageSource; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; public class Main extends JPanel { private static final long serialVersionUID = 6416932054834995251L; private static int pixels[]; private static List<Integer> pi; public static void readFile(String name) { File file = new File(name); BufferedReader reader = null; pi = new ArrayList<Integer>(); char[] digits; try { reader = new BufferedReader(new FileReader(file)); String text = null; while((text = reader.readLine()) != null) { digits = text.toCharArray(); for(char el : digits) if(el != ' ') pi.add(Character.getNumericValue(el)); } } catch (Exception e) { e.printStackTrace(); } } public void paint(Graphics gg) { readFile("c:\\pi.txt"); int h = 5; int w = 2; int color = 0xffffff; int digit; int i = 0; pixels = new int[w * h]; for (int y = 0; y < h; y++) { for (int x = 0; x < h; x++) { digit = pi.get(i); if(digit == 0) color = 0x000000; else if(digit == 1) color = 0x787878; else if(digit == 2) color = 0x008B00; else if(digit == 3) color = 0x00008B; else if(digit == 4) color = 0x008B8B; else if(digit == 5) color = 0x008B00; else if(digit == 6) color = 0xCDCD00; else if(digit == 7) color = 0xFF4500; else if(digit == 8) color = 0x8B0000; else if(digit == 9) color = 0xFF0000; pixels[i] = color; i++; } } Image art = createImage(new MemoryImageSource(w, h, pixels, 0, w)); gg.drawImage(art, 0, 0, this); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300,300); frame.setVisible(true); } }

    Read the article

  • Streaming audio to headless linux box

    - by Ralph
    I have a dual boot (Win 7 + Ubuntu) PC connected via wifi with my music collection on a local HDD. I usually use Rhythmbox on Ubuntu or Winamp on Windows to listen to my music but I'll change if I have to. I also have a Raspberry Pi (low power PC running Debian) in the living room that is usually headless and connected via ethernet. The Raspberry Pi is also connected to my living room speakers via an amp. I would like to be able to stream music from my PC over the network to the linux raspberry pi. What software can I use to do this? Some sort of audio client\server?

    Read the article

  • Redirect physical keyboard input to SSH

    - by Dimme
    I'm having a raspberry pi running debian linux and I have an RFID reader connected to it. The RFID reader behaves like a keyboard. Every time I scan a tag it types then number of the tag and then carriage return. My problem is that I want to redirect the output of the RFID reader to my SSH session. That means anything that is typed to the physical keyboard of the pi should be displayed in my SSH window. I have tried with: cat /dev/tty0 but it wont work because the user is not logged in. Is there a way to disable the login screen after the pi boots and then redirect all input through SSH?

    Read the article

  • Implicit casting Integer calculation to float in C++

    - by Ziddiri
    Is there any compiler that has a directive or a parameter to cast integer calculation to float implicitly. For example: float f = (1/3)*5; cout << f; the "f" is "0", because calculation's constants(1, 3, 10) are integer. I want to convert integer calculation with a compiler directive or parameter. I mean, I won't use explicit casting or ".f" prefix like that: float f = ((float)1/3)*5; or float f = (1.0f/3.0f)*5.0f; Do you know any c/c++ compiler which has any parameter to do this process without explicit casting or ".f" thing?

    Read the article

  • Will Multi threading increase the speed of the calculation on Single Processor

    - by Harsha
    On a single processor, Will multi-threading increse the speed of the calculation. As we all know that, multi-threading is used for Increasing the User responsiveness and achieved by sepating UI thread and calculation thread. But lets talk about only console application. Will multi-threading increases the speed of the calculation. Do we get culculation result faster when we calculate through multi-threading. what about on multi cores, will multi threading increse the speed or not. Please help me. If you have any material to learn more about threading. please post. Thanks in advance, Harsha

    Read the article

  • Happy Tau Day! (Or: How Some Mathematicians Think We Should Retire Pi) [Video]

    - by Jason Fitzpatrick
    When you were in school you learned all about Pi and its relationship to circles and turn-based geometry. Some mathematicians are rallying for a new lesson, on about Tau. Michael Hartl is a mathematician on a mission, a mission to get people away from using Pi and to start using Tau. His manifesto opens: Welcome to The Tau Manifesto. This manifesto is dedicated to one of the most important numbers in mathematics, perhaps the most important: the circle constant relating the circumference of a circle to its linear dimension. For millennia, the circle has been considered the most perfect of shapes, and the circle constant captures the geometry of the circle in a single number. Of course, the traditional choice of circle constant is p—but, as mathematician Bob Palais notes in his delightful article “p Is Wrong!”,1 p is wrong. It’s time to set things right. Why is Pi wrong? Among the arguments is that Tau is the ration of a circumference to the radius of a circle and defining circles by their radius is more natural and that Pi is a 2-factor number but with Tau everything is based of a single unit–three quarters of a turn around a Tau-defined circle is simply three quarters of a Tau radian. Watch the video above to see the Tau sequence (which begins 6.2831853071…) turned into a musical composition. For more information about Tau hit up the link below to read the manifesto. The Tau Manifesto [TauDay] HTG Explains: Photography with Film-Based CamerasHow to Clean Your Dirty Smartphone (Without Breaking Something)What is a Histogram, and How Can I Use it to Improve My Photos?

    Read the article

  • SharePoint 2010 and Excel Calculation Services

    - by Cj Anderson
    I'm curious what the requirements are for Excel Calculation Services in Sharepoint 2010. I found an architecture document but it doesn't list out the specific requirements. (architecture I understand that you can install all the services on one server but it isn't recommended. It then talks about how you can scale up the application servers, and web front ends. What should the hardware look like for both the application server and web front ends? Do I need to setup a standalone box for each application server?

    Read the article

  • Run Photoshop on VM (virtual machine) to increase calculation power, without violating the licence agreement (EULA)

    - by mecplusultra
    A question concerning the possibility to run Photoshop as VM without violating the licence agreement (EULA) : My Adobe Photoshop is bloody slow, nd sometimes I need to launch thousands of image calculations that have to use hundreds of PSD templates. I want to increase my Photoshop calculation power by creating non-persistent virtual machines on my hosted server. Each VMm would only alive for a few seconds, just enough time to deliver the calculated file. Is this a violation of the EULA? I must clarify that I'm the only one to access my non persistent VMs.

    Read the article

  • Optimizing division/exponential calculation

    - by Saltheart
    I've inherited a Visual Studio/VB.Net numerical simulation project that has a likely inefficient calculation. Profiling indicates that the function is called a lot (1 million times plus) and spends about 50% of the overall calculation within this function. Here is the problematic portion Result = (A * (E ^ C)) / (D ^ C * B) (where A-C are local double variables and D & E global double variables) Result is then compared to a threshold which might have additional improvements as well, but I'll leave them another day any thoughts or help would be appreciated Steve

    Read the article

  • Android: Communication with host computer

    - by dannyn382
    I am looking for ideas as to how all of you can think to solve this issue. I am going to be using an Android Tablet as basically a touch screen input for a project. I need to be able to control servos and solenoids and such, so I will be using a Raspberry Pi to do this. I am looking for ideas on how to get the tablet and the Raspberry Pi to talk. Here are a few that I have though of so far. Use Wifi (which I really do not want to, Ethernet would be okay) to ssh into the Raspberry Pi (with an external library) and run scripts that way from the Android app. Use a com port for Android (maybe Andropod if there hardware becomes available?) and run scripts on the Raspberry Pi. Those are probably two of the "best" ideas that I can think of for now. Can anyone think of any other "better" ideas? Thanks in advance for the help, Dan

    Read the article

  • Excel 2010 - more than 1 calculation within an IF() statement

    - by Da Bajan
    I have a situation where I need to calculate shipping values based on the length of the supply chain. Easy, however I need to have instances where an increased amount is required based on specific date criteria. My example is as follows: Shipvalue = 100 Date1 = 1/1/2013 (Jan) - ship 50% more than usual Date2 = 2/1/2013 (Feb) - ship 25% more than usual Date3 = 3/1/2013 (Mar) - ship 25% more than usual Supply chain length is: June - October 100 days November - March 140 days April - June 100 days The issue I have is that as there is an increase in the number of days, my formula: IF( Date1-(Supply chain length + any extra days)=today's date, shipvalue+(shipvalue X 50%), IF( Date2-(Supply chain length + any extra days)=today's date, shipvalue+(shipvalue x 50%) IF( Date2-(Supply chain length + any extra days)=today's date, shipvalue+(shipvalue x 50%), IF( preceding cell<>0,shipvalue, 0) ) ) ) Now the problem with this is that if the length of the supply chain increases then the formula misses all but the 1st increase. So, I thought of adding a variable that would be incremented and checked every time you made an increased shipping amount. So, how do I do both the calculation for the increased shipping value, and set the variable in one part of the IF statement?

    Read the article

  • How can find the USB wireless adapter into the dmesg log file?

    - by AndreaNobili
    I am pretty new in Linux (RaspBian for RaspBerry Pi but I think that there are not difference) and I have to install an USB wireless network adapter (the product is the TP-Link TL-WN725N, this one: http://www.tp-link.it/products/details/?model=TL-WN725N ) Now, I think that this is not automatically recognized by my system because if I execute ifconfig command I obtain the following output: pi@raspberrypi ~ $ ifconfig eth0 Link encap:Ethernet HWaddr b8:27:eb:2a:9f:b0 inet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:475 errors:0 dropped:0 overruns:0 frame:0 TX packets:424 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:34195 (33.3 KiB) TX bytes:89578 (87.4 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) So now it see only my ethernet network interface and not the wireless. So I was thinkig to try to see into the dmesg, but I don't know what have I to see and how to select it into the dmesg output. For example by the following command I can see the line of the dmesg log file relate to my ethernet port: pi@raspberrypi ~ $ cat /var/log/dmesg |grep -i eth [ 3.177620] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:2a:9f:b0 [ 18.030389] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup [ 19.642167] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1 But what can I try to search for the USB wireless adapter? Tnx

    Read the article

  • How can I find the USB wireless adapter into the dmesg log file?

    - by AndreaNobili
    I am pretty new in Linux (RaspBian for RaspBerry Pi but I think that there are not difference) and I have to install an USB wireless network adapter (the product is the TP-Link TL-WN725N, this one: http://www.tp-link.it/products/details/?model=TL-WN725N ) Now, I think that this is not automatically recognized by my system because if I execute ifconfig command I obtain the following output: pi@raspberrypi ~ $ ifconfig eth0 Link encap:Ethernet HWaddr b8:27:eb:2a:9f:b0 inet addr:192.168.1.8 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:475 errors:0 dropped:0 overruns:0 frame:0 TX packets:424 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:34195 (33.3 KiB) TX bytes:89578 (87.4 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) So now it see only my ethernet network interface and not the wireless. So I was thinkig to try to see into the dmesg, but I don't know what have I to see and how to select it into the dmesg output. For example by the following command I can see the line of the dmesg log file relate to my ethernet port: pi@raspberrypi ~ $ cat /var/log/dmesg |grep -i eth [ 3.177620] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:2a:9f:b0 [ 18.030389] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup [ 19.642167] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1 But what can I try to search for the USB wireless adapter? Tnx

    Read the article

  • Calculate pi to an accuracy of 5 decimal places?

    - by pgras
    In this message at point 18 I saw following programming question: Given that Pi can be estimated using the function 4 * (1 – 1/3 + 1/5 – 1/7 + …) with more terms giving greater accuracy, write a function that calculates Pi to an accuracy of 5 decimal places. So I know how to implement the given function and how to choose how "far" I should calculate, but how can I tell when I've reached the "accuracy of 5 decimal places" ?

    Read the article

  • Run a script after killing lxsession (xorg)

    - by user284194
    I am trying to run a program automatically within a bash script after killing the LXDE session. My script consists of: #!/bin/sh pkill lxsession; sh /home/pi/RetroPie/EmulationStation/emulationstation My aim is to log out of the LXDE session and run EmulationStation on my Raspberry Pi with a bash script. I'm using pkill lxsession; to bypass lxsession's logout confirmation dialog. As it stands, this script just gets me to the command line from a working LXDE desktop. Thanks for reading.

    Read the article

  • What can I do with enthusiast single board computers?

    - by ajax81
    I'm a career Windows developer and the only experience I have interfacing hardware is with printers, USB, and point-of-sale devices. However, after reading this article my interest in enthusiast programmable boards has been peaked. Unfortunately, I'm at a loss when it comes to exactly what I would do with one of these boards. Are activities limited to simple exercises akin to the projects in high school where we hooked LED's up to bread boards and made them blink? or are they capable of much, much more?

    Read the article

  • Timestamps and Intervals: NUMTOYMINTERVAL SYSTDATE CALCULATION SQL QUERY

    - by MeachamRob
    I am working on a homework problem, I'm close but need some help with a data conversion I think. Or sysdate - start_date calculation The question is: Using the EX schema, write a SELECT statement that retrieves the date_id and start_date from the Date_Sample table (format below), followed by a column named Years_and_Months_Since_Start that uses an interval function to retrieve the number of years and months that have elapsed between the start_date and the sysdate. (Your values will vary based on the date you do this lab.) Display only the records with start dates having the month and day equal to Feb 28 (of any year). DATE_ID START_DATE YEARS_AND_MONTHS_SINCE_START 2 Sunday , February 28, 1999 13-8 4 Monday , February 28, 2005 7-8 5 Tuesday , February 28, 2006 6-8 Our EX schema that refers to this question is simply a Date_Sample Table with two columns: DATE_ID NUMBER NOT Null START_DATE DATE I Have written this code: SELECT date_id, TO_CHAR(start_date, 'Day, MONTH DD, YYYY') AS start_date , NUMTOYMINTERVAL((SYSDATE - start_date), 'YEAR') AS years_and_months_since_start FROM date_sample WHERE TO_CHAR(start_date, 'MM/DD') = '02/28'; But my Years and months since start column is not working properly. It's getting very high numbers for years and months when the date calculated is from 1999-ish. ie, it should be 13-8 and I'm getting 5027-2 so I know it's not correct. I used NUMTOYMINTERVAL, which should be correct, but don't think the sysdate-start_date is working. Data Type for start_date is simply date. I tried ROUND but maybe need some help to get it right. Something is wrong with my calculation and trying to figure out how to get the correct interval there. Not sure if I have provided enough information to everyone but I will let you know if I figure it out before you do. It's a question from Murach's Oracle and SQL/PL book, chapter 17 if anyone else is trying to learn that chapter. Page 559.

    Read the article

  • Images to video - converting to IplImage makes video blue

    - by user891908
    I want to create a video from images using opencv. The strange problem is that if i will write image (bmp) to disk and then load (cv.LoadImage) it it renders fine, but when i try to load image from StringIO and convert it to IplImage, it turns video to blue. Heres the code: import StringIO output = StringIO.StringIO() FOREGROUND = (0, 0, 0) TEXT = 'MY TEXT' font_path = 'arial.ttf' font = ImageFont.truetype(font_path, 18, encoding='unic') text = TEXT.decode('utf-8') (width, height) = font.getsize(text) # Create with background with place for text w,h=(600,600) contentimage=Image.open('0.jpg') background=Image.open('background.bmp') x, y = contentimage.size # put content onto background background.paste(contentimage,(((w-x)/2),0)) draw = ImageDraw.Draw(background) draw.text((0,0), text, font=font, fill=FOREGROUND) pi = background pi.save(output, "bmp") #pi.show() #shows image in full color output.seek(0) pi= Image.open(output) print pi, pi.format, "%dx%d" % pi.size, pi.mode cv_im = cv.CreateImageHeader(pi.size, cv.IPL_DEPTH_8U, 3) cv.SetData(cv_im, pi.tostring()) print pi.size, cv.GetSize(cv_im) w = cv.CreateVideoWriter("2.avi", cv.CV_FOURCC('M','J','P','G'), 1,(cv.GetSize(cv_im)[0],cv.GetSize(cv_im)[1]), is_color=1) for i in range(1,5): cv.WriteFrame(w, cv_im) del w

    Read the article

  • Ninety-Fifth Percentile Calculation for Bandwidth

    - by Kyle Brandt
    I am trying to calculate the bandwidth of my current internet connection. I am pulling the current input and output transfer rate via snmp. If the argument to the following function is a sorted ascending list of the the some of each input and output sample, is this the right way to calculate 95th percentile? sub ninetyFifth { #Expects Sorted Data my $ninetyFifthLine = (@_ * .95) - 1; return $_[$ninetyFifthLine]; }

    Read the article

  • how to offer subdomain hosting with bandwidth calculation per user

    - by Ke
    Hi, Im a php developer and I would like to offer subdomain hosting,but need also to be able to calculate bandwidth for each subdomain. For the subdomains creation I will use catch-all and wildcards etc to easily set these up. The one thing im a bit stumped on is how to calculate bandwidth for each subdomain, is this possible within php? or are there better solutions for this perhaps using folders or something? Also a script will be loaded under the subdomain, this will vary per user. Is it worth giving each user a new folder and their own script, or more easy to manage one script for all users? Any considerations here? Cheers Ke

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >