Re: Re: Re: simplify a trig expression

*To*: mathgroup at smc.vnet.net*Subject*: [mg65470] Re: [mg65449] Re: [mg65436] Re: [mg65415] simplify a trig expression*From*: Murray Eisenberg <murray at math.umass.edu>*Date*: Mon, 3 Apr 2006 06:59:37 -0400 (EDT)*Organization*: Mathematics & Statistics, Univ. of Mass./Amherst*References*: <200603311109.GAA15029@smc.vnet.net> <200604011038.FAA07301@smc.vnet.net> <200604020900.FAA01612@smc.vnet.net> <11D40ADD-9EC9-4DCE-B685-1CA00605B9B2@mimuw.edu.pl>*Reply-to*: murray at math.umass.edu*Sender*: owner-wri-mathgroup at wolfram.com

Actually, what I was trying to do is this: To obtain in Mathematica, the answers to a ten-question integration exam that would be of the form students would obtain with standard paper-and-pencil techniques. And the purpose of that was to to provide to the graders, whom I supervise, answers that are unquestionably correct -- and, again, in that form. Andrzej Kozlowski wrote: > First, let me state a fundamental objection to the whole enterprise. I > am of the opinion that there is on the whole very little point in > putting a lot of effort into forcing computer algebra programs return > the answers you already know to be correct. The purpose of such programs > is to simplify expressions that are too complicated too analyse by hand > so as to make them simple enough to handle by hand. The "handling by > hand" part is precisely what computer programs are not very good at and > usually it takes longer to make them do so then just typing in the > answer. Of course once you already know the answer it is usually very > easy to verify that it equal the one given by Mathematica. For example, > in your situation the best approach, in my opinion would be simply this: > > > FullSimplify[D[Integrate[Sin[x]/(1 - Cos[x]), x] - > Log[1 - Cos[x]], x]] > > > 0 > > As far as I can see this is all you would even need to do in practice. > The rest is just playing with CAS. But if you like playing then by using > FullSimplify with suitable TransformationFunctions and > ComplexityFunction you can usually transform anything into anything > else. So in this case you can do, for example, > > > f[(n_)*Log[a_]] := Log[a^n]; > f[Cos[x_]^2] := (1/2)*(Cos[2*x] + 1); > f[Sin[2*(x_)]^2] := (1/2)*(1 - Cos[x]); > > > > FullSimplify[Integrate[Sin[x]/(1 - Cos[x]), x], > TransformationFunctions -> {Automatic, f}, > ComplexityFunction -> > (LeafCount[#1] + 50*Count[#1, x/2, {0, Infinity}] + > Count[#1, _Power, {0, Infinity}, Heads -> True] & )] > > > Log[(1/2)*(1 - Cos[x])] > > It is slightly amusing to analyse exactly why this works, but I > amusement is about all of value I can see in this aproach. > > Andrzej Kozlowski > > On 2 Apr 2006, at 11:00, Murray Eisenberg wrote: > >> OK, now how about the following--another case where Mathematica gives a >> more complicated looking answer than the typical paper-and-pencil direct >> substitution would provide? >> >> Mathematica gives: >> >> Integrate[Sin[x]/(1 - Cos[x]), x] >> 2*Log[Sin[x/2]] >> >> I'd like an answer in the form of Log[1-Cos[x]] (plus a constant, to >> actually equal the above). The best I've been able to do so far is: >> >> (Integrate[Sin[x]/(1 - Cos[x]), x] >> // Simplify[# /. a_*Log[b_]:>Log[b^a]] & >> //MapAt[TrigReduce, #, 1]&) /. (Log[c_ b_]->Log[b]+Log[c]) >> -Log[2] + Log[1 - Cos[x]] >> >> Is there some easier way? >> >> Andrzej Kozlowski wrote: >>> This is one of those cases where FullSimplify will not work because >>> it lacks a suitable transformation function. In this particular case >>> the transformation function is of the form: >>> >>> f[n_*Log[a_]] := Log[a^n] >>> >>> Of course this is only valid with various assumptions on n and a, but >>> I won't bother with this here. Anyway, observe that: >>> >>> >>> FullSimplify[Integrate[Cos[x]/(Sin[x] + 1), x], >>> TransformationFunctions -> {Automatic, f}] >>> >>> >>> Log[Sin[x] + 1] >>> >>> Note also that Simplify will not work even when you add f. >>> >>> I am not sure if there are good reasons for adding a version of f >>> (taking account of suitable assumptions) to the default >>> transformation functions of FullSimplify. It may however be a good >>> idea to have another possible value for the option >>> TransformationFunctions besides only Automatic and user defined ones. >>> In fact I have suggested in the past one or two other useful >>> TransformationFunctions; perhaps it might be a good idea to define >>> more and collect them into a single option value or maybe several. >>> >>> Andrzej Kozlowski >>> >>> >>> >>> >>> >>> >>> On 31 Mar 2006, at 13:09, Murray Eisenberg wrote: >>> >>>> A direct substitution (with paper and pencil) gives that the >>>> integral of >>>> Cos[x]/(Sin[x] + 1) is Log[Sin[x] + 1]. This is valid provided >>>> Sin[x] >>>> is not -1. >>>> >>>> Mathematica gives: >>>> >>>> Integrate[Cos[x]/(Sin[x] + 1), x] >>>> 2 Log[Cos[x/2] + Sin[x/2]] >>>> >>>> Is there some simple way to coerce the latter Mathematica-supplied >>>> result into the paper-and-pencil answer? >>>> >>>> The closest I could get is: >>>> >>>> Log[TrigExpand[Expand[(Cos[x/2] + Sin[x/2])^2]]] /. >>>> {Sin[x/2] -> Sqrt[(1 - Cos[x])/2], >>>> Cos[x/2] -> Sqrt[(1 + Cos[x])/2]} >>>> Log[1 + Sqrt[1 - Cos[x]]*Sqrt[1 + Cos[x]]] >>>> >>>> Am I not seeing some easier TrigExpand or TrigReduce method? >>>> >>>> --Murray Eisenberg murray at math.umass.edu >>>> Mathematics & Statistics Dept. >>>> Lederle Graduate Research Tower phone 413 549-1020 (H) >>>> University of Massachusetts 413 545-2859 (W) >>>> 710 North Pleasant Street fax 413 545-1801 >>>> Amherst, MA 01003-9305 >>>> >>> >>> >> >> --Murray Eisenberg murray at math.umass.edu >> Mathematics & Statistics Dept. >> Lederle Graduate Research Tower phone 413 549-1020 (H) >> University of Massachusetts 413 545-2859 (W) >> 710 North Pleasant Street fax 413 545-1801 >> Amherst, MA 01003-9305 >> > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305

**References**:**Re: simplify a trig expression***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>

**Re: Re: simplify a trig expression***From:*Murray Eisenberg <murray@math.umass.edu>

**Re: Re: Re: simplify a trig expression**

**HoldFirst confusion**

**Re: Re: Re: simplify a trig expression**

**Re: simplify a trig expression**