Crates.io | rustypi |
lib.rs | rustypi |
version | 0.1.0 |
source | src |
created_at | 2024-06-09 01:00:37.254044 |
updated_at | 2024-06-09 01:00:37.254044 |
description | A library for estimating π using Monte Carlo simulations |
homepage | |
repository | https://github.com/SyntaxSpirits/rustypi |
max_upload_size | |
id | 1266098 |
size | 7,989 |
RustyPi is a Rust library designed to estimate the value of π (pi) using Monte Carlo simulations. It provides a straightforward and efficient method for performing these simulations, making it an ideal choice for educational purposes, numerical methods demonstrations, and more.
Ensure you have Rust installed on your machine. If Rust is not already installed, you can install it by following the instructions on the official Rust website: https://www.rust-lang.org/tools/install.
To use RustyPi in your project, add the following to your Cargo.toml:
[dependencies]
rustypi = "0.1.0"
Then, run the following command to build your project and download the RustyPi crate:
cargo build
Here is a simple example of how to use RustyPi to estimate the value of π:
extern crate rustypi;
fn main() {
let simulator = rustypi::RustyPi::new(1_000,000);
let pi_estimate = simulator.estimate_pi();
println!("Estimated value of Pi: {}", pi_estimate);
}
To run this example, save it as main.rs, and run:
cargo run
To run the tests included with RustyPi, execute:
cargo test
This will run all the unit and integration tests defined in the library.
Contributions to RustyPi are welcome! Here are a few ways you can help:
This project is licensed under the MIT License - see the LICENSE file for details.