# Find square root using Monte carlo?

20 views (last 30 days)

Show older comments

derive numerical value of square root of 2 using MC

##### 2 Comments

John D'Errico
on 19 May 2015

Easy peasy. For example, to find the square root of 2...

X = 2;

Xroot = 1;

while Xroot.^2 ~= X

Xroot = X*rand;

end

When it converges, you are done. Of course, that may take some serious time. Just thinking, but I'm wondering just how many completely unworkable (but in theory, valid) answers I can think of for this problem? I'll bet I can think of at least a few more.

If you want a better answer, you will need to make more effort than simply posting your assignment.

### Answers (2)

Brandon
on 19 May 2015

This sounds like a homework assignment, so nobody here is going to answer it directly for you.

This website might give you some inspiration though: http://mathfaculty.fullerton.edu/mathews/n2003/montecarlopimod.html

In this problem, pi is the unknown value. Let's say you knew pi, would you be able to find another parameter? The answer is yes. Now how do you make that parameter equal to sqrt(2)...?

##### 0 Comments

Walter Roberson
on 19 May 2015

##### 1 Comment

Atishay Jain
on 21 Feb 2018

I can't figure out why it will approach sqrt(2)/2 ... It's not areas of square with side sqrt(2)/ area of square with side 2.

What is it?

Thank you!

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!