How does this equation for the Fibonacci sequence work using powershell? - powershell-4.0

The original equation is below:
$($c=$p=1; while ($c -lt 100) {$c; $c,$p=($c+$p),$c})
The portion I do not understand, is below:
{$c; $c,$p=($c+$p),$c}
Would anyone be able to explain what is happening in layman's terms?
Thank you, it is much appreciated.

Related

Converting Logarithmic Bases and Approximating Exponents

I'm studying for an algorithms final. There are some sample questions that I'd like to know how to solve. No calculators are permitted, and the methods used are more relevant to computer science than algebra. I'll try to be as specific as possible, because researching this has only led me to change-of-base formulas that require a calculator.
What is (approximately) the Log base 2 of 130,000,000?
What is (approximately) the Log base 4 of 1,000,000?
I'd also appreciate it if someone would explain base conversions without a calculator to me. Thank you. If this post is inappropriate, I'll remove it without hesitation.
Edit: Answers delivered in log(x)/log(r) will not be considered correct. Thank you.
What you need to do is make your own table during the exam.
2, 4, 8, 32, 64, 128, 256,512, 1024, ....
Find the power of 2 that is closest to the value you looking for. If you are asked for Log2(1000), you'd see the closest is 1024 (2**10): Ans: 10.
log base r (x) may be evaluated as log(x)/log(r)

Algorithm design manual solution to 1-8

I'm currently reading through The Algorithm Design Manual by Steven S. Skiena. Some of the concepts in the book I haven't used in almost 7 years. Even while I was in college it was difficult for me to understand how some of my classmates came up with some of these proofs. Now, I'm completely stuck on one of the exercises. Please help.
Will you please answer this question and explain how you came up with what to use for your Base case and why each step proves why it is valid and correct. I know this might be asking a lot, but I really need help understanding how to do these.
Thank you in advance!
Proofs of Correctness
Question:
1-8. Proove the correctness of the following algorithm for evaluating a polynomial.
$$P(x) = a_nx_n+a_n−1x_n−1+⋯+a_1x+a_0$$
&function horner(A,x)
p=A_n
for i from n−1 to 0
p=p∗x+Ai
return p$
btw, off topic: Sorry guys, I'm not sure how to correctly add the mathematical formatting for the formula. I tried by addign '$' around each section. Not sure why that isn't working.
https://cs.stackexchange.com/ is probably better for this. Also I'm pretty sure that $$ formatting only works on some StackExchange sites. But anyways, think about what this algorithm is doing at each step.
We start with p = A_n.
Then we take p = p*x + A_{n-1}. So what is this doing? We now have p = x*A_n + A_{n-1}.
I'll try one more step. p = p*x + A_{n-2} so now p = (x^2)*A_n + x*A_{n-1} + A{n-2} (here x^2 means x to the power 2, of course).
You should be able to take it from here.

can you help me about big o?

I need help about big O.
I'm not sure.
while (i<n){
while(j=n){
j++;
}//this is I think n*(n+1)
i++;//(n+1)
}//n
I need to tell me someone how calculate this if I'm wrong.
Have you put the question correctly?
It looks like the program will newer enter the inner loop or just enter it once. If the code is correct I would say it is just O(n).

What are "d-smooth sequences?"

I have a homework problem that tells me this:
I can't seem to make sense of what d-smooth means. Can someone please help explain it in a more understandable way? Thanks!
A sequence is d-smooth if you can increment/decrement each number at most d times to obtain a (strictly) increasing sequence.

Mathematica. Two ArcCos functions which should give the same result are giving different results

I have written two lines of code in mathematica
Integrate[ArcCos[(1-(w/2t))],{w,0,F}]]
and
Integrate[ArcCos[-w/(2t)],{w,-2t,F-2t}]
where in both cases F < 2t.
I expect these two lines to give the same result but this is not the case. When I give try an equals it gives equals false.
Any help would be greatly appreciated.
Thank you very much for your help
James

Resources