Ask Your Question

Revision history [back]

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).

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.

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.