# Course 5 Wk 2 A1 : Optional quick questions

Hi all,

I’ve got solutions for the two optional exercises, but am off by a factor of ~15% for both calculations

Is there an error in the following translation from calculation to code?

“”"
Ex3: Neutralize
redacted
“”"
I’m getting -3.8510^-17 instead of ~4.410^-17

“”"
Ex4:

redacted
“”"
I’m getting +~0.6 instead of ±0.77

For neutralize(), both your answers are essentially zero (there is a note in the instructions about this). The difference is likely because using norm() internally computes the square root, and then you have to square it again - that loses numerical precision.

Same explanation in Ex. 4 - squaring the norm is less accurate than computing the sum of the squares and not computing the square root.

Thanks tmosh

That’s right re: effectively zero answers. I figure that the percent-wise difference is due to a coding math error of sorts. For both exercises, I was previously using the square root of the sum of square,
(i.e.

sqrt(sum( x^2))
and
(sqrt(sum(x^2))^2)

) and receiving the same numerical result as I am currently.

Does that notation seem correct, or is there another function that isn’t np.linalg.norm? I noticed you explicitly stated not to compute the square root.

Code has been redacted, I just put it up briefly so a mentor could see it.

friendly bump if you know how to solve the problem

So, based on the justification provided, is it okay to assume the values -3.85 10^-17 (for Ex.3) and +~0.6 (for Ex.4) are acceptable ?
I just wanted to make sure as I have also got the same results and I have verified that I am using the right formulas as mentioned in the assignment.