Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.postgresql > #882

Re: calculating pi [Re: php and big data and predictive modelling...]

X-Received by 2002:ac8:742:: with SMTP id k2mr16502678qth.302.1577537703066; Sat, 28 Dec 2019 04:55:03 -0800 (PST)
X-Received by 2002:a0d:e195:: with SMTP id k143mr42453800ywe.211.1577537702806; Sat, 28 Dec 2019 04:55:02 -0800 (PST)
Path csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!g89no3694634qtd.0!news-out.google.com!w29ni369qtc.0!nntp.google.com!g89no3694617qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups comp.databases.postgresql
Date Sat, 28 Dec 2019 04:55:02 -0800 (PST)
In-Reply-To <5e073d4a$0$10273$e4fe514c@news.xs4all.nl>
Complaints-To groups-abuse@google.com
Injection-Info google-groups.googlegroups.com; posting-host=82.131.38.7; posting-account=gA_LzgoAAADDaXkDiFTMJbfzPcksMvwq
NNTP-Posting-Host 82.131.38.7
References <320cd439-2d99-40ea-be16-795ab84fb719@googlegroups.com> <f1f8c4f8-f99f-4158-aee7-2b172352dc71@googlegroups.com> <7e06ded4-4848-4811-85ec-23dfea85e89d@googlegroups.com> <5e0717d0$0$10269$e4fe514c@news.xs4all.nl> <f8d31fcf-af88-457c-8b78-a456b3f19654@googlegroups.com> <5e073d4a$0$10273$e4fe514c@news.xs4all.nl>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <6b2f2a6b-bddf-4398-8ba8-4aa5b4ea6e46@googlegroups.com> (permalink)
Subject Re: calculating pi [Re: php and big data and predictive modelling...]
From robamman2019@gmail.com
Injection-Date Sat, 28 Dec 2019 12:55:03 +0000
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
Lines 113
Xref csiph.com comp.databases.postgresql:882

Show key headers only | View raw


On Saturday, December 28, 2019 at 1:32:27 PM UTC+2, Luuk wrote:
> On 28-12-2019 11:22, robamman2019@gmail.com wrote:
> > On Saturday, December 28, 2019 at 10:52:33 AM UTC+2, Luuk wrote:
> >> On 26-12-2019 23:18, Azathoth Hastur wrote:
> >>> On Sunday, December 22, 2019 at 5:43:09 AM UTC-5, robamm...@gmail.com wrote:
> >>>> pühapäev, 29. september 2019 18:41.47 UTC+3 kirjutas azathot....@gmail.com:
> >>>>> Anyone doing php psotgresql for this?
> >>>>>
> >>>>> The java framework craziness I see at work must have better alternatives!
> >>>>
> >>>> I have used postgresql and php. And doing some statistical calculations in php. For example I have tried to calculate Pi. I used the so called "bombing"(method with random numbers). But the result came out so that the first 4 numbers of the number were only correct. 3.141 . I ran the code about 50 times, and there were no differences in the about 3-4 first numbers. Maybe the "bombing" method is not very good for this. I got the idea of it from schools programming lesson. I'm sure other mathematical methods would be better, but it was intresting for me to program and test it.
> >>>>
> >>>> Basically I think, if you can program, then there is no difference in which language you program.
> >>>>
> >>>> With the best wishes,
> >>>> Kristjan Robam
> >>>
> >>> Why not use the postgresql to calculate and sort, and php to just get in put and output?
> >>>
> >>
> >> Ok, its not postgresql, i tried to do 'calculate pi' in MSSQL 2017:
> >>
> >> WITH pi (x, f, a, kwartpi) as
> >>     (SELECT 1,1.0,1,
> >>         CONVERT(float(53), 0.0)
> >>     UNION ALL
> >>     SELECT x+2,-f,x,
> >>         CONVERT(float(53),kwartpi+(f/x)) from pi where x<20000 and x>=a
> >>     )
> >>
> >> SELECT top 10
> >>     x, 4*kwartpi
> >> FROM pi
> >> order by x desc
> >> OPTION(MAXRECURSION 10000)
> >>
> >>
> >> Output:
> >> x
> >> ----------- ----------------------
> >> 20001       3,14149265341197
> >> 19999       3,14169266341197
> >> 19997       3,14149263340797
> >> 19995       3,14169268341997
> >> 19993       3,14149261339597
> >> 19991       3,14169270343597
> >> 19989       3,14149259337597
> >> 19987       3,14169272345997
> >> 19985       3,14149257334797
> >> 19983       3,14169274349197
> >>
> >> (10 rows affected)
> >>
> >>
> >> Completion time: 2019-12-28T09:49:58.2239611+01:00
> >>
> >> *Will postgresql be better in doing this job?*
> >>
> >>
> >> Follow-up set to comp.databases.postgresql
> >> -- 
> >> Luuk
> > 
> > What is the idea of this ?
> > I used a circle inside a square and Pi=(Circle area)*4/(Square area)
> > And by the way the First numbers of pi area 3.14159.
> > My algorithm: https://groups.google.com/forum/#!topic/eesti-programmeerijad/qieWYzn8RxI
> > 
> > 
> > With the best wishes,
> > Kristjan Robam
> > 
> 
> Ah, this method
Ok. Proof.
d = 2r
Pi = C / 2r
Here we need a picture. Please look at : 
https://www.basic-mathematics.com/proof-of-the-area-of-a-circle.html 
Area of a circle = (1/2)r*2Pi*r
Area of a Circle=r*r*Pi
Area of a Square=(2r)*(2r)=4r*r

r*r*Pi     Points in Circle
------- =~ -----------------
4r*r       Points in Square

So Pi =~ 4*(Points in Circle)/(Points in Square)
The bigger the Square, the more precise Pi we have.

> it looks better than trying to calculate 4*arctan(1), which can be 
> written as the sum of 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 ......
> 
> But https://en.wikipedia.org/wiki/Squaring_the_circle pages says:
> "In 1882, the task was proven to be impossible,"
> 
> 
> -- 
> Luuk

Back to comp.databases.postgresql | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: calculating pi [Re: php and big data and predictive modelling...] robamman2019@gmail.com - 2019-12-28 02:22 -0800
  Re: calculating pi [Re: php and big data and predictive modelling...] robamman2019@gmail.com - 2019-12-28 04:55 -0800
    Re: calculating pi [Re: php and big data and predictive modelling...] robamman2019@gmail.com - 2019-12-28 08:30 -0800
    Re: calculating pi [Re: php and big data and predictive modelling...] robamman2019@gmail.com - 2019-12-28 09:40 -0800
      Re: calculating pi [Re: php and big data and predictive modelling...] robamman2019@gmail.com - 2019-12-29 04:15 -0800

csiph-web