Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This question looks like homework, so it could be nice to tell us where is the point you are stuck. Here are some hints: if you want to pick a number between 0 and 1 uniformly at random, just type:

sage: random()
0.49232726718735065

Now, what you have to do is to compare this value to f(x). For this, you have to know that Sage uses the Python programming language, so you can look for tutorials about "if statement" in Python.

Please tell us if you encounter difficulties (and do not hesitate to post your code and where it does not work).

click to hide/show revision 2
No.2 Revision

This question looks like homework, so it could be nice to tell us where is the point you are stuck. Here are some hints: if you want to pick a number between 0 and 1 uniformly at random, just type:

sage: random()
0.49232726718735065

Now, what you have to do is to compare this value to f(x). For this, you have to know that Sage uses the Python programming language, so you can look for tutorials about "if statement" in Python.

Please tell us if you encounter difficulties (and do not hesitate to post your code and where it does not work).work), so that we can help further.

click to hide/show revision 3
No.3 Revision

This question looks like homework, so it could be nice to tell us where is the point you are stuck. Here are some hints: if you want to pick a number between 0 and 1 uniformly at random, just type:use the random() function:

sage: random()
0.49232726718735065

Now, what you have to do is to compare this value to f(x). For this, you have to know that Sage uses the Python programming language, so you can look for tutorials about "if statement" in Python.

Please tell us if you encounter difficulties (and do not hesitate to post your code and where it does not work), so that we can help further.