[Date Index]
[Thread Index]
[Author Index]
Why all the if's the answer (revised!!!)
*To*: mathgroup at smc.vnet.net
*Subject*: [mg70845] Why all the if's the answer (revised!!!)
*From*: "dimitris" <dimmechan at yahoo.com>
*Date*: Sat, 28 Oct 2006 23:39:24 -0400 (EDT)
Dear Aaron,
Finally I evaluate your integral in a quick but what it is important
in a more reliable (at least for me) way than just setting
GenerateConditions->False.
The idea is based, on a old post of Paul Abbott. Unfortunately, I can't
find the
post. If you want you can search his archives in this forum; I
personally gave up
searching.
The trick is to replace your alpha constant by a Mathematica constant,
say EulerGamma,
evaluate the integral, and then get back by replacing in the result the
EulerGamma constant by alpha constant.
One important thing to notice is EulerGamma satisfies the condition
0<EulerGamma<Pi/2
like your alpha constant.
You can also do by Refine, but I personally want to have more control
of the substitutions.
Anyway, Copy and Paste the following (after the dashed lines of
course!) in a notebook, select all the cells, and execute the commands.
--------------------------------------------------------------------------------------------------------------------------------
Print[StyleForm["Here is your function", FontColor -> Blue]]
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]
Print[StyleForm["f1=f[[1]]", FontColor -> Red]]
f1 = f[[1]]
Print[StyleForm["f2=f[[2]]", FontColor -> Red]]
f2 = f[[2]]
Print[StyleForm["Here is the integral of f1", FontColor -> Blue]]
Timing[g1 = Assuming[c > 0 && b > 0 && alpha > 0 && alpha < Pi/2,
Integrate[(y/c)*f[[1]], {y, 0, c}]]]
Print[StyleForm["Here we replace the constant alpha with the EulerGamma
constant", FontColor -> Blue]]
Print[StyleForm["f1=f[[1]]", FontColor -> Red]]
f1 = f1 /. alpha -> EulerGamma
Print[StyleForm["f1=f[[1]]", FontColor -> Red]]
f2 = f2 /. alpha -> EulerGamma
Print[StyleForm["Note that 0<EulerGamma<Pi/2", FontColor -> Red]]
0 < N[EulerGamma] < Pi/2
Print[StyleForm["Let's make a test", FontColor -> Blue]]
Print[
StyleForm["We will evaluate the integral of f1, we will replace in
the result\nEulerGamma with alpha, and the result must be \
equal to g1", FontColor -> Red]]
Assuming[c > 0 && b > 0, Integrate[(y/c)*f1, {y, 0, c}]]
% /. EulerGamma -> alpha
FullSimplify[g1 == %, {b > 0, c > 0, 0 < alpha < Pi/2}]
Print[StyleForm["Here is the integral of f2", FontColor -> Blue]]
Timing[g2 = Assuming[c > 0 && b > 0, Integrate[(y/c)*f2, {y, 0, c}]]]
Print[StyleForm["Here we return to the alpha constant", FontColor ->
Blue]]
g2 = g2 /. EulerGamma -> alpha
Print[StyleForm["Here is (at last!!!) your solution", FontColor ->
Blue]]
sol1 = FullSimplify[g1 + g2, {b > 0, c > 0, 0 < alpha < Pi/2}]
Print[StyleForm["Here is the result with the setting
GenerateConditions->False", FontColor -> Blue]]
Timing[Integrate[(y/c)*f, {y, 0, c}, GenerateConditions -> False]]
sol2 = FullSimplify[%[[2]], {b > 0, c > 0, 0 < alpha < Pi/2}]
Print[StyleForm["check", FontColor -> Blue]]
sol1 - sol2
Print[StyleForm["It happens in this case the two approaches to give the
same result.\nHowever this does not say anything for the
reliability of the\nsetting GenerateConditions->False", FontColor ->
Red]]
---------------------------------------------------------------------------------------------------------------------------------
Best Regards
Dimitris
P.S. In this post, I follow one of the invalueble suggestions of David
Park's in order
to present your Mathematica work to someone else; for more see e.g.
http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/e5699d8dca5e9c2e/517d64cadf68f2c8?lnk=st&q=&rnum=4#517d64cadf68f2c8
I agree with him that the Print statements (as well many other things
he suggest!)
are indeed very helpful if not necessary!
Prev by Date:
**Re: Re: GraphPlot**
Next by Date:
**Re: Re: GraphPlot**
Previous by thread:
** Labelled ticks at the origin**
Next by thread:
**Matching with a "Flat" function**
| |