Skip to content

Commit

Permalink
Added monte carlo simulation example
Browse files Browse the repository at this point in the history
  • Loading branch information
ceticamarco committed Mar 15, 2024
1 parent d0156fa commit b247dad
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ lB -1 * lD + lA # POSITIVE DELTA
0 lL x
```

17. Estimate $\pi$ using Monte Carlo simulation
```
10 k
[ 0 1 @ sX 0 1 @ sY ] sR
[ lX 2 ^ sX lY 2 ^ sY ] sQ
[ 0 ;A 1 + 0 :A ] sI
[ 1 lX lY + <=I ] sC
[ lR x lQ x lC x 1 + d lN >=L ] sL
0 0 :A
0 6500 sN
lL x 0 ;A lN /
4 * p
```

## License

[GPLv3](https://choosealicense.com/licenses/gpl-3.0/)
16 changes: 15 additions & 1 deletion man.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: dc
section: 1
header: General Commands Manual
footer: Marco Cetica
date: March 14, 2024
date: March 15, 2024
---


Expand Down Expand Up @@ -503,6 +503,20 @@ c 1 lL x # Clear the stack, add lower bound, load and execute macro
0 lL x
```

13. Estimate *pi* using Monte Carlo simulation
```
10 k
[ 0 1 @ sX 0 1 @ sY ] sR
[ lX 2 ^ sX lY 2 ^ sY ] sQ
[ 0 ;A 1 + 0 :A ] sI
[ 1 lX lY + <=I ] sC
[ lR x lQ x lC x 1 + d lN >=L ] sL
0 0 :A
0 6500 sN
lL x 0 ;A lN /
4 * p
```

# AUTHORS
The original version of the **dc** command was written by Robert Morris and Lorinda Cherry.
This version of **dc** is developed by Marco Cetica.
Expand Down

0 comments on commit b247dad

Please sign in to comment.