Skip to main content

Questions tagged [approximation]

For challenges relating to approximating a value, typically a constant or something related to the program's input

Filter by
Sorted by
Tagged with
22 votes
11 answers

How powerful must this e approximation be?

This challenge was inspired by this non-challenge about the natural logarithm base \$e\$ and the following pandigital approximation to \$e\$ appearing on a Math Magic page: $$\left|(1+9^{-4^{7×6}})^{3^...
Parcly Taxel's user avatar
  • 3,845
19 votes
17 answers

Approximate my atomic weight

Each element on the periodic table of the elements has an atomic weight. For example, boron (element 5) has an atomic weight of 10.81. Your challenge is to write a program which takes as input the ...
Ginger's user avatar
  • 5,701
29 votes
9 answers

Approximate when you are going to die

A mortality table or life table is an actuarial tool that gives the probability that a person aged \$A\$ years will die in the next year, and is used to help calculate the premiums for life insurance, ...
Giuseppe's user avatar
  • 28.7k
14 votes
13 answers

Diophantine Approximation: find lowest possible denominator to approximate within given precision

Challenge Given a number x and a precision e, find the lowest positive integer q such that <...
Stef's user avatar
  • 907
9 votes
5 answers

The first digit of a to the power of b (approximately)

Inspired by This answer to a Puzzling question Background - exponentiation by squaring If you don't want to read the background, or don't understand it, there's a worked example in Java, linked at ...
simonalexander2005's user avatar
49 votes
22 answers

"As we travel the universe..."

You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers. This is a code-challenge where your ...
Arnauld's user avatar
  • 194k
25 votes
6 answers

Two dozen kissing number approximations

Given a number from 1 to 24, output the kissing number to the best of current knowledge (some numbers will have more than one acceptable output). Knowledge of geometry is not essential as the outputs ...
trichoplax is on Codidact now's user avatar
4 votes
22 answers

Rounding Numbers

Task Given a number between 0 and 1 and another integer, print the approximated value of the first number rounded off to the specified number of digits given by the second integer. For example, if ...
Luc H's user avatar
  • 559
10 votes
19 answers

Approximate My Squares

Inspired by this video by tecmath. An approximation of the square root of any number x can be found by taking the integer square root ...
Stan Strum's user avatar
24 votes
24 answers

Approximate the Dottie number to arbitrary precision

The Dottie number is the fixed point of the cosine function, or the solution to the equation cos(x)=x.1 Your task will be to make code that approximates this constant. Your code should represent a ...
Wheat Wizard's user avatar
  • 98.9k
26 votes
19 answers

Approximate Brun's Constant

Brun's constant is the value to which the sum of the reciprocals of twin prime pairs (1/p and 1/(p+2) where ...
user avatar
12 votes
3 answers

Natural Pi #2 - River

Goal Given an string with a train of hashes, calculate its total length and divide by the distance from start to finish. Simulation What are we simulating? According to this paper, the ratio of the ...
NonlinearFruit's user avatar
10 votes
3 answers

Natural Pi #1 - Sand

Goal Generate (N) random line segments of uniform length (l), check if they cross the equidistant (...
NonlinearFruit's user avatar
38 votes
23 answers

Natural Pi #0 - Rock

Goal Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns <...
NonlinearFruit's user avatar
13 votes
16 answers

Compute the Fibonomial Coefficient

Background The Fibonacci sequence is defined as $$f(1) = 1 \\ f(2) = 1 \\ f(n) = f(n-1) + f(n-2)$$ The Fibonorial, similar to the factorial, is the product of the first \$n\$ Fibonacci numbers. $$g(n) ...
miles's user avatar
  • 16.9k
28 votes
55 answers

Approximation of e

We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion: $$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\...
Meow Mix's user avatar
  • 923
8 votes
1 answer

Approximate the Fransén-Robinson constant

Given an input n, output the value of the Fransén-Robinson constant with n digits after the decimal place, with rounding. Rules ...
Addison Crump's user avatar
27 votes
35 answers

Monte Carlo estimator of Pi

Happy Pi Day everyone! For no reason at all, I'm trying to construct a Monte Carlo estimator of Pi that is as short as possible. Can we construct one that can fit in a tweet? To clarify, what I have ...
keegan's user avatar
  • 397
22 votes
15 answers

Khinchin's constant to as many decimal places as possible in 64 bytes or less

Khinchin's constant is a curious mathematical constant that, according to Wolfram MathWold, is "notoriously difficult to calculate to high precision". Here it is to 100 digits: 2....
Calvin's Hobbies's user avatar
21 votes
18 answers

Let the trigonometry begin!

Introduction: The sine of \$x\$ is given by the formula: $$\sin(x) = x - \frac {x^3}{3!} + \frac {x^5}{5!} - \frac {x^7}{7!} + \frac {x^9}{9!} - \frac {x^{11}}{11!} + \cdots$$ The cosine of \$x\$ is ...
Gaurang Tandon's user avatar
2 votes
2 answers

Get as close to pi as you can [closed]

Your job is to write a program to find the closest number to PI. Let me clarify. You will first choose a number type. Let us say you choose ...
Christopher King's user avatar
17 votes
67 answers

Pi Calculation Code Golf [closed]

The Challenge You must calculate pi in the shortest length you can. Any language is welcome to join and you can use any formula to calculate pi. It must be able to calculate pi to at least 5 decimal ...
poseidon's user avatar
  • 367
24 votes
11 answers

Good rational approximations of pi

Write a program that prints out all the good rational approximations of pi with denominator < 1000000, in increasing denominator order. a/b is a "good rational ...
Keith Randall's user avatar