Assignment week 2 - issue

¡Hi everyone!
Today, I solved the assignment for week 2.
I have a trouble in excersice 6. I am sure that code is good, but the result is bad.
W1 is different compared with real value. I don’t understand what is wrong.
Anyone can help me?
I submited the exam.

{moderator edit - solution code removed}

Welcome to DLS Course 2. Note that you filed this question under “General Discussion”. You’ll have better luck getting timely responses if you file things under the appropriate categories. Forunately I recognized the code as being from DLS Course 2. I moved it for you by using the little “edit pencil” on the title.

The most common mistake here is getting the “order of operations” wrong in some places. We can’t see all of your code at the bottom, but have a careful look at the right hand side of those last two assignment statements. Compare what you wrote to the mathematical formula and note that the \epsilon value there is a) in the denominator, but b) not under the square root, right? From what can see of your code, I’ll bet you put it under the square root. That results in a very small difference, but it’s a bug if that’s the way it’s written.

Also note as a general matter that we’re not supposed to publicly share code, so you shouldn’t just post your code and say “I can’t find the problem”. Just show us the error output that you are getting and if we can’t figure it out from that, we’ll ask to privately see your code through a DM.