# C2\_W2 UNQ\_C5 getting math domain error. please help

**URL:** <https://community.deeplearning.ai/t/c2-w2-unq-c5-getting-math-domain-error-please-help/422080>\
**Category:** NLP with Probabilistic Models\
**Tags:** week-module-2\
**Created:** [August 19, 2023, 12:03pm UTC](https://community.deeplearning.ai/t/c2-w2-unq-c5-getting-math-domain-error-please-help/422080 "2023-08-19T12:03:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arin\_Jain](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@Arin\_Jain](https://community.deeplearning.ai/u/Arin_Jain)\
**Post date:** [August 19, 2023, 12:03pm UTC](https://community.deeplearning.ai/t/c2-w2-unq-c5-getting-math-domain-error-please-help/422080/1 "2023-08-19T12:03:36Z")

</div>

for i in range(num\_tags): # Replace None in this line with the proper range.

```
    # Initialize best_probs at POS tag 'i', column 0
    # Check the formula in the instructions above
    best_probs[i,0] = best_probs[i,0] = math.log(A[s_idx,i]) + math.log(B[i,vocab[corpus[0]]] )

```

---

<div class="post-metadata">

**Author:** ![arvyzukai](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/arvyzukai/32/165165_2.png) [@arvyzukai](https://community.deeplearning.ai/u/arvyzukai)\
**Post date:** [August 22, 2023, 7:42am UTC](https://community.deeplearning.ai/t/c2-w2-unq-c5-getting-math-domain-error-please-help/422080/2 "2023-08-22T07:42:05Z")

</div>

Hi @Arin_Jain

The error tells that your code is probably taking a `log` of a number that is less than or equal to zero.

So make sure that the matrix `A` is greater than zero - make sure that the outputs after UNQ\_C3 matches the expected outputs:

```auto
Expected Output

A at row 0, col 0: 0.000007040
A at row 3, col 1: 0.1691
View a subset of transition matrix A
              RBS RP SYM TO UH
RBS 2.217069e-06 2.217069e-06 2.217069e-06 0.008870 2.217069e-06
RP 3.756509e-07 7.516775e-04 3.756509e-07 0.051089 3.756509e-07
SYM 1.722772e-05 1.722772e-05 1.722772e-05 0.000017 1.722772e-05
TO 4.477336e-05 4.472863e-08 4.472863e-08 0.000090 4.477336e-05
UH 1.030439e-05 1.030439e-05 1.030439e-05 0.061837 3.092348e-02

```

Cheers
