Re: Why all the if's the answer
- To: mathgroup at smc.vnet.net
- Subject: [mg70795] Re: Why all the if's the answer
- From: "dimitris" <dimmechan at yahoo.com>
- Date: Sat, 28 Oct 2006 05:21:26 -0400 (EDT)
- References: <ehs31u$oe4$1@smc.vnet.net>
First things first.
f = -Log[y*(1 + Cos[alpha])] + Log[(b*c - b*y + c*y*Cos[alpha] +
Sqrt[b^2*(c - y)^2 + c^2*y^2 + 2*b*c*(c - y)*y*Cos[alpha]])/c];
Relative innocent with Sqrt and Log and so many parameters?
For me it is already too much you got an anlytical solution!
Secondly you don't neeed y>0 in the assumptions since you integrate for
0<y<c (c>0).
Thirdly, the easy part.
f[[1]]
-Log[y*(1 + Cos[alpha])]
Assuming[c > 0 && b > 0 && alpha > 0 && alpha < Pi/2,
Integrate[(y/c)*f[[1]], {y, 0, c}]]
(-(1/4))*c*(-1 + 2*Log[c] + 2*Log[1 + Cos[alpha]])
And now the difficult part.
f[[2]]
Log[(b*c - b*y + c*y*Cos[alpha] + Sqrt[b^2*(c - y)^2 + c^2*y^2 +
2*b*c*(c - y)*y*Cos[alpha]])/c]
I don't see how you will get a simpler answer without many nested If's
(nevertheless I hope I am wrong!).
By the way the indefinite integral is very easy (but unfortunately you
want
the definite!).
Timing[Integrate[(y/c)*f[[2]], y]]
{2.859*Second, (1/(4*c))*(-y^2 + (2*b*c*Sqrt[b^2*(c - y)^2 + c^2*y^2 -
2*b*c*y*(-c + y)*Cos[alpha]])/
(b^2 + c^2 - 2*b*c*Cos[alpha]) +
2*y^2*Log[(b*c - b*y + c*y*Cos[alpha] + Sqrt[b^2*(c - y)^2 +
c^2*y^2 - 2*b*c*y*(-c + y)*Cos[alpha]])/c] +
(2*b^2*c^2*(b - c*Cos[alpha])*Log[2*(Sqrt[b^2*(c - y)^2 + c^2*y^2 -
2*b*c*y*(-c + y)*Cos[alpha]] +
(c^2*y + b^2*(-c + y) - b*c*(-c + 2*y)*Cos[alpha])/Sqrt[b^2 +
c^2 - 2*b*c*Cos[alpha]])])/
(b^2 + c^2 - 2*b*c*Cos[alpha])^(3/2))}
I suggest you to give stricter values for the parameters
I tried
Timing[Assuming[c == 2 && b == 1 && alpha == Pi/4,
Integrate[(y/c)*f[[2]], {y, 0, c}]]]
{21.281000000000002*Second, (Sqrt[5 - 2*Sqrt[2]]*(4539291753586583 -
12193860859319106*Log[2 + Sqrt[2]]) +
8*Sqrt[10 - 4*Sqrt[2]]*(-401220497585102 + 1077795212604845*Log[2 +
Sqrt[2]]) +
2*(-1880236207775049 + 1329527772905767*Sqrt[2])*Log[2/(16 -
9*Sqrt[2] + 3*Sqrt[10 - 4*Sqrt[2]] - 6*Sqrt[5 - 2*Sqrt[2]])])/
(2*(7053121 - 4986960*Sqrt[2])^2*Sqrt[5 - 2*Sqrt[2]]*(-33 +
20*Sqrt[2]))}
N[%[[2]]]
1.0492574322774637
lims = {{y, 0, c}} /. c -> 2;
NIntegrate[(y/c)*f[[2]] /. {c -> 2, b -> 1, alpha -> Pi/4},
Evaluate[Sequence @@ lims]]
1.0492573918492765
Regards
Dimitris