Why does this piece of code fail in Scilab?
N=1000;
U=rand(N, 1);
X=(9*U - 1)^(1/3);
histplot(200, X);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most likely the code fails because
Xis not real. This can happen ifUis smaller than1/9, which means that you take the third root of a negative number.You can find problematic values of
Uby checking for whether the values inXare real.