Hello , by matlab , compute the product of :

4 views (last 30 days)
Abdulfattah lulu
Abdulfattah lulu on 2 May 2011
p1=sqrt(2)/2 , p2=sqrt(2+sqrt(2))/2 , p3=sqrt(2+sqrt(2+sqrt(2)))/2 ,
compute product by matlab, p1 * p2* p3 *........... * p20
  5 Comments

Sign in to comment.

Answers (3)

Walter Roberson
Walter Roberson on 2 May 2011
function t66 = prod_p1_p20
V = 2;
t1 = V ^ V;
t3 = t1 ^ V;
t4 = t3 ^ V;
t5 = t4 ^ V;
t6 = V^(-1);
t7 = V^t6;
t11 = (V + t7)^t6;
t14 = (V + t11)^t6;
t16 = (V + t14)^t6;
t19 = (V + t16)^t6;
t23 = (V + t19)^t6;
t25 = (V + t23)^t6;
t28 = (V + t25)^t6;
t30 = (V + t28)^t6;
t33 = (V + t30)^t6;
t38 = (V + t33)^t6;
t40 = (V + t38)^t6;
t43 = (V + t40)^t6;
t45 = (V + t43)^t6;
t48 = (V + t45)^t6;
t52 = (V + t48)^t6;
t54 = (V + t52)^t6;
t57 = (V + t54)^t6;
t59 = (V + t57)^t6;
t62 = (V + t59)^t6;
t66 = t62 * t59 * t57 * t54 * t52 * t48 * t45 * t43 * t40 * t38 * t33 * t30 * t28 * t25 * t23 * t19 * t16 * t14 * t11 / t7 / t5 / t1 / V;
end
  9 Comments
Walter Roberson
Walter Roberson on 4 May 2011
Abdulfattah: how would you calculate any one p(n)? If you know p(n-1) how would you extend it to p(n) ?

Sign in to comment.


Matt Tearle
Matt Tearle on 4 May 2011
disp(1*0.6366)
  5 Comments
John D'Errico
John D'Errico on 4 May 2011
Well, arguably, multiplying by 1 makes it a computation.
Matt Tearle
Matt Tearle on 4 May 2011
Exactly, John. And there was no specification of accuracy. So I claim that my answer computes the product requested (just to 4 dp, that's all).

Sign in to comment.


John D'Errico
John D'Errico on 4 May 2011
Well, for complete overkill...
disp(0 + 0.63661977236781944823166583843277598162106456255690961760282370334657710024147820303991996854856502247043508070567897809925678676832984935864030869184975575167078632289509242155624801993112605554672293135860993145476492852903886184623882769012238145575770975998129003396352798880718475639573387445219320317598093723758568037151319811216067649754946716309234535128512187466093946760854635939038744626459238525652130733923947876362385118364006093735040924909121572691582778720782038355177247697778990109)
Walter - this IS a computation, as I added 0 to the result.
  6 Comments
John D'Errico
John D'Errico on 4 May 2011
Walter - I tried to verify that. Using a good approximation of pi that is sufficiently accurate for many school boards...
pi = 3;
2/pi
ans =
0.6666666666666667
Can you help me here? It seems to give the wrong answer.
Sean de Wolski
Sean de Wolski on 4 May 2011
Absolutely! Couldn't you just add 'ths to the end of each of the suffix and reverse the order? I.e. tenths hundredths thousandths etc...

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!