Calculating algebra question

kmce

New member
Joined
Feb 13, 2017
Messages
31
Firstly sorry if this is in the wrong place, I was not sure.

Secondly, I am terrible at math but i am learning about time complexity for programming, and i have been trying to figure out how one of these answers comes about. The complexity is
[MATH]1 + (n * (1 + (4n + 1) + 2 )[/MATH]The book gives the answer to be 4n2 + 3n + 1 but I just cant see how this answer comes about. If possible could someone please give me to steps which would be involved in calculating this. ( I have also plugged this equation into one of the online calculator but the answer that gives is 4n2 + 4n + 1 so i am not sure if the book is wrong or i am plugging the equation wrong. Either way, I still cant figure out how these answers would come to be).

Thanks for any help provided.
 
… [MATH]1 + (n * (1 + (4n + 1) + 2 )[/MATH] …
Hi kmce. The expression has mismatched grouping symbols. If the book actually shows three open parentheses but only two closing parentheses, then there is a typographical error in the book.

Also, as posted, the grouping symbols enclosing 4n+1 are unnecessary.

If you've mistyped what's shown in your book, then please reply with the correct expression. Otherwise, ask your instructor for a corrected copy of the exercise.

?
 
Hi kmce. The expression has mismatched grouping symbols. If the book actually shows three open parentheses but only two closing parentheses, then there is a typographical error in the book.

Also, as posted, the grouping symbols enclosing 4n+1 are unnecessary.

If you've mistyped what's shown in your book, then please reply with the correct expression. Otherwise, ask your instructor for a corrected copy of the exercise.

?
Hey, I have double checked the book and what I had written is the same as what is in the book. Unfortunately, I am self learning, so do not have anyone I could ask.

If I was to guess I think the last closing parentheses would be right at the end, so [MATH] 1+(n∗(1+(4n+1)+2))[/MATH] I am not sure if that would make a difference though, I am just basing my guess on the way the code is written.
 
Hey, I have double checked the book and what I had written is the same as what is in the book. Unfortunately, I am self learning, so do not have anyone I could ask.

If I was to guess I think the last closing parentheses would be right at the end, so [MATH] 1+(n∗(1+(4n+1)+2))[/MATH] I am not sure if that would make a difference though, I am just basing my guess on the way the code is written.
1. Do you understand where this expression comes from?
2. Do you know how to simplify such expressions? E.g. n(n+2+4n) = 5n^2+2n
 
1. Do you understand where this expression comes from?
2. Do you know how to simplify such expressions? E.g. n(n+2+4n) = 5n^2+2n
I understand where the numbers in the expression comes from within the code. For the example you gave I can figure that one out quite easily, as its just n from outside the parenthesis multiplied by what is inside. But for my expression I do not understand how the answer is coming out to be 4n2 + 3n + 1
 
Hey, I have double checked the book and what I had written is the same as what is in the book. Unfortunately, I am self learning, so do not have anyone I could ask.

If I was to guess I think the last closing parentheses would be right at the end, so [MATH] 1+(n∗(1+(4n+1)+2))[/MATH] I am not sure if that would make a difference though, I am just basing my guess on the way the code is written.
I understand where the numbers in the expression comes from within the code. For the example you gave I can figure that one out quite easily, as its just n from outside the parenthesis multiplied by what is inside. But for my expression I do not understand how the answer is coming out to be 4n2 + 3n + 1

The answer is not correct for any (minor) correction I can think of.

Please show us an image of what the book says, so we can determine for certain that this can be ignored.
 
… I do not understand how the answer is coming out to be 4n^2 + 3n + 1
Hi kmce. There is no answer because the book has misprinted the question.

If I [were] to guess I think the last closing parentheses would be right at the end … I am not sure if that would make a difference …
Yes, it would make a difference. Adding a closing parenthesis will change the undefined expression into a defined expression. Adding it at the end results in:

1 + (n(1 + (4n + 1) + 2)) = 4n^2 + 4n + 1

?
 
The answer is not correct for any (minor) correction I can think of.

Please show us an image of what the book says, so we can determine for certain that this can be ignored.


The expression is in the second picture, but I added in a picture of the code too, as it might be a bit easier to understand when it is talking a out where a part of the expression is coming from.
IMG_20210708_231843.jpgIMG_20210708_231753.jpg
 
Firstly sorry if this is in the wrong place, I was not sure.

Secondly, I am terrible at math but i am learning about time complexity for programming, and i have been trying to figure out how one of these answers comes about. The complexity is
[MATH]1 + (n * (1 + (4n + 1) + 2 )[/MATH]The book gives the answer to be 4n2 + 3n + 1 but I just cant see how this answer comes about. If possible could someone please give me to steps which would be involved in calculating this. ( I have also plugged this equation into one of the online calculator but the answer that gives is 4n2 + 4n + 1 so i am not sure if the book is wrong or i am plugging the equation wrong. Either way, I still cant figure out how these answers would come to be).

Thanks for any help provided.
[MATH]1 + (n * (1 + (4n + 1) + 2 )[/MATH]
= 1 + n * (1 + 4*n + 1 + 2)

= 1 + n * (4*n + 4)

= 1 + 4 * n2 + 4 * n

So your book-answer is incorrect - assuming you posted the problem correctly and you are looking at the book-answer of the correct problem.
 
Top