From ceb71b98f69b38d99c9f9e15c99e9eaf570677cf Mon Sep 17 00:00:00 2001 From: cmwslw Date: Tue, 20 Nov 2018 22:24:02 -0800 Subject: [PATCH] Improve simplification. --- expreduce/builtin_expression.go | 38 ++++++++++++ expreduce/resources.go | 4 +- expreduce/resources/manip.m | 1 + expreduce/resources/power.m | 4 +- expreduce/resources/simplify.m | 26 +++++++-- expreduce/resources/solve.m | 100 ++++++++++++++++---------------- expreduce/resources/tests.m | 16 ----- 7 files changed, 116 insertions(+), 73 deletions(-) diff --git a/expreduce/builtin_expression.go b/expreduce/builtin_expression.go index 5d9147e..9677a18 100644 --- a/expreduce/builtin_expression.go +++ b/expreduce/builtin_expression.go @@ -45,6 +45,35 @@ func leafCount(e expreduceapi.Ex) int64 { return 1 } +func leafCountSimplify(e expreduceapi.Ex) int64 { + if asExpr, isExpr := e.(expreduceapi.ExpressionInterface); isExpr { + res := int64(0) + for _, part := range asExpr.GetParts() { + res += leafCountSimplify(part) + } + return res + } + if asInt, isInt := e.(*atoms.Integer); isInt { + if asInt.Val.Sign() == -1 { + return 2 + } + } + if asCmplx, isCmplx := e.(*atoms.Complex); isCmplx { + return leafCountSimplify(asCmplx.Im) + leafCountSimplify(asCmplx.Re) + 1 + } + if asRat, isRat := e.(*atoms.Rational); isRat { + val := int64(3) + if asRat.Num.Sign() == -1 { + val++ + } + if asRat.Den.Sign() == -1 { + val++ + } + return val + } + return 1 +} + func getExpressionDefinitions() (defs []Definition) { defs = append(defs, Definition{ Name: "Head", @@ -160,6 +189,15 @@ func getExpressionDefinitions() (defs []Definition) { return atoms.NewInt(leafCount(this.GetParts()[1])) }, }) + defs = append(defs, Definition{ + Name: "ExpreduceLeafCountSimplify", + legacyEvalFn: func(this expreduceapi.ExpressionInterface, es expreduceapi.EvalStateInterface) expreduceapi.Ex { + if len(this.GetParts()) != 2 { + return this + } + return atoms.NewInt(leafCountSimplify(this.GetParts()[1])) + }, + }) defs = append(defs, Definition{ Name: "Flat", OmitDocumentation: true, diff --git a/expreduce/resources.go b/expreduce/resources.go index f26984b..b08cd39 100644 --- a/expreduce/resources.go +++ b/expreduce/resources.go @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7beaa854524369b9e04b6b8443679d28c9d4aad7c15d299ae713082334edc697 -size 1340494 +oid sha256:3916d384fed3f084e23c0984d17c4cc22547dc7a10b4ca6f70a3866fcf5beca7 +size 1339970 diff --git a/expreduce/resources/manip.m b/expreduce/resources/manip.m index 58b0b5a..57519d5 100644 --- a/expreduce/resources/manip.m +++ b/expreduce/resources/manip.m @@ -61,6 +61,7 @@ ESameTest[(a+b+c+d)/((a+b) (c+d)), (1+a/(c+d)+b/(c+d))/(a+b)//Together], ESameTest[(a+b+a b c+a b d)/(a b), 1/a+1/b+c+d//Together], ESameTest[2(a+b), 2a+2b//Together], + ], EKnownFailures[ ESameTest[(I (a-b))/(2 Subscript[\[Omega], 0]), (I a)/(2 Subscript[\[Omega], 0])-(I b)/(2 Subscript[\[Omega], 0])//Together], ] }; diff --git a/expreduce/resources/power.m b/expreduce/resources/power.m index 5eb4697..09485b6 100644 --- a/expreduce/resources/power.m +++ b/expreduce/resources/power.m @@ -68,7 +68,9 @@ 1, I, 2, -1, 3, -I]; -Complex[re_,im_]^n_Integer := Module[{theta = ArcTan[re,im]}, Sqrt[re^2+im^2]^n*Complex[Cos[n*theta],Sin[n*theta]]]; +Complex[re_,im_]^n_Integer := If[n===-1, + Complex[re/(re^2+im^2), -(im/(re^2+im^2))], + Module[{theta = ArcTan[re,im]}, Sqrt[re^2+im^2]^n*Complex[Cos[n*theta],Sin[n*theta]]]]; Complex[re_,im_]^n_Real := Module[{theta = ArcTan[re,im]}, Sqrt[re^2+im^2]^n*Complex[Cos[n*theta],Sin[n*theta]]]; Power[ComplexInfinity+_, -1] := 0; _^ComplexInfinity := Indeterminate; diff --git a/expreduce/resources/simplify.m b/expreduce/resources/simplify.m index 877ae22..f8368a0 100644 --- a/expreduce/resources/simplify.m +++ b/expreduce/resources/simplify.m @@ -35,25 +35,43 @@ And[x1___, a_, x2___, Or[x3___, !a_, x4___], x5___] :> And[a, x1, x2, Or[x3, x4], x5], And[x1___, Or[x2___, !a_, x3___], x4___, a_, x5___] :> And[a, x1, Or[x2, x3], x4, x5] }; +trigSimplify[exp_] := exp //. { + (Rational[1,2]*c_.*(a_ + b_*Cos[inner_]) /; a == -b) :> c*a*Sin[inner/2]^2 +}; +tryFactoringOutTerm[e_] := e; +tryFactoringOutTerm[p_Plus] := Module[{cterms, simplest, i, tryVal}, + simplest = p; + cterms = ((ExpreduceConstantTerm /@ (List @@ p)) // Transpose)[[1]]; + For[i = 1, i <= Length[cterms], i++, + tryVal = cterms[[i]] (p/cterms[[i]] // Distribute); + If[ExpreduceLeafCountSimplify[tryVal] < ExpreduceLeafCountSimplify[simplest], + simplest = tryVal]; + ]; + simplest + ]; simplifyInner[exp_] := Module[{e = exp, tryVal}, e = booleanSimplify[e]; + e = trigSimplify[e]; inferredPower = 1; If[MatchQ[e, s_Plus^n_Integer], inferredPower := Replace[e, s_Plus^n_Integer -> n]]; If[inferredPower < 5, (*Similar to Expand, but not using ReplaceAll*) tryVal = FixedPoint[Replace[#, expandRules]&, e]; - If[LeafCount[tryVal] < LeafCount[e], e = tryVal]; + If[ExpreduceLeafCountSimplify[tryVal] < ExpreduceLeafCountSimplify[e], e = tryVal]; ]; (*Avoid expressions containing expensive expressions to expand.*) If[FreeQ[e, a_Plus^(b_Integer?((# >= 5) &))], tryVal = ComplexExpand[e]; - If[LeafCount[tryVal] < LeafCount[e], e = tryVal]; + If[ExpreduceLeafCountSimplify[tryVal] < ExpreduceLeafCountSimplify[e], e = tryVal]; ]; tryVal = Together[e]; - If[LeafCount[tryVal] < LeafCount[e], e = tryVal]; + If[ExpreduceLeafCountSimplify[tryVal] < ExpreduceLeafCountSimplify[e], e = tryVal]; tryVal = Private`myFactorCommonTerms[e]; - If[LeafCount[tryVal] < LeafCount[e], e = tryVal]; + If[ExpreduceLeafCountSimplify[tryVal] < ExpreduceLeafCountSimplify[e], e = tryVal]; + tryVal = Private`tryFactoringOutTerm[e]; + If[ExpreduceLeafCountSimplify[tryVal] < ExpreduceLeafCountSimplify[e], e = tryVal]; + e = trigSimplify[e]; (* also need to try complexexpand to simplify cases like (-1)^(1/3) (1 + I Sqrt[3]) *) e = Replace[e, Sqrt[inner_] :> Sqrt[FactorTerms[inner]]]; e diff --git a/expreduce/resources/solve.m b/expreduce/resources/solve.m index f909e7d..acf61d9 100644 --- a/expreduce/resources/solve.m +++ b/expreduce/resources/solve.m @@ -1,14 +1,14 @@ Solve::usage = "`Solve[eqn, var]` solves `eqn` for `var`."; -countVar[expr_, var_Symbol] := +countVar[expr_, var_Symbol] := If[expr === var, 1, Count[expr, var, -1]]; -containsOneOccurrence[eqn_Equal, var_Symbol] := +containsOneOccurrence[eqn_Equal, var_Symbol] := Count[eqn, var, -1] == 1; -containsZeroOccurrences[eqn_Equal, var_Symbol] := +containsZeroOccurrences[eqn_Equal, var_Symbol] := Count[eqn, var, -1] == 0; -checkedConditionalExpression[e_, c_] := +checkedConditionalExpression[e_, c_] := Module[{nextC = 1, res, reps, newC = -1}, While[True, If[Count[e, C[nextC], -1] > 0, nextC++, Break[]]]; res = ConditionalExpression[e, c]; @@ -58,7 +58,7 @@ }, E, If[MatchQ[rhs, _Real], {pow -> Log[rhs]}, - {pow -> ConditionalExpression[2 I Pi C[1] + Log[rhs], + {pow -> ConditionalExpression[2 I Pi C[1] + Log[rhs], C[1] \[Element] Integers]}, ], _, Message[Solve::ifun, Solve];{pow -> Log[rhs]/Log[base]} @@ -76,38 +76,38 @@ {lhs->checkedConditionalExpression[-ArcCos[rhs]+2 Pi C[-1],C[-1]\[Element]Integers], lhs->checkedConditionalExpression[ArcCos[rhs]+2 Pi C[-1],C[-1]\[Element]Integers]}; applyInverse[Tan[lhs_] -> rhs_, var_Symbol] := - {lhs -> ConditionalExpression[ArcTan[rhs] + Pi C[1], + {lhs -> ConditionalExpression[ArcTan[rhs] + Pi C[1], C[1] \[Element] Integers]}; applyInverse[Cot[lhs_] -> rhs_, var_Symbol] := - {lhs -> ConditionalExpression[ArcCot[rhs] + Pi C[1], + {lhs -> ConditionalExpression[ArcCot[rhs] + Pi C[1], C[1] \[Element] Integers]}; applyInverse[Sec[lhs_] -> rhs_, var_Symbol] := - {lhs -> ConditionalExpression[-ArcCos[1/rhs] + 2 Pi C[1], - C[1] \[Element] Integers], lhs -> - ConditionalExpression[ArcCos[1/rhs] + 2 Pi C[1], + {lhs -> ConditionalExpression[-ArcCos[1/rhs] + 2 Pi C[1], + C[1] \[Element] Integers], lhs -> + ConditionalExpression[ArcCos[1/rhs] + 2 Pi C[1], C[1] \[Element] Integers]}; applyInverse[Csc[lhs_] -> rhs_, var_Symbol] := - {lhs -> ConditionalExpression[Pi - ArcSin[1/rhs] + 2 Pi C[1], - C[1] \[Element] Integers], lhs -> - ConditionalExpression[ArcSin[1/rhs] + 2 Pi C[1], + {lhs -> ConditionalExpression[Pi - ArcSin[1/rhs] + 2 Pi C[1], + C[1] \[Element] Integers], lhs -> + ConditionalExpression[ArcSin[1/rhs] + 2 Pi C[1], C[1] \[Element] Integers]}; (* Inverses for inverse trig functions *) applyInverse[ArcSin[lhs_] -> rhs_, var_Symbol] := {lhs -> ConditionalExpression[ - Sin[rhs], (Re[rhs] == -(Pi/2) && Im[rhs] >= 0) || -(Pi/2) < + Sin[rhs], (Re[rhs] == -(Pi/2) && Im[rhs] >= 0) || -(Pi/2) < Re[rhs] < Pi/2 || (Re[rhs] == Pi/2 && Im[rhs] <= 0)]}; applyInverse[ArcCos[lhs_] -> rhs_, var_Symbol] := {lhs -> ConditionalExpression[ - Cos[rhs], (Re[rhs] == 0 && Im[rhs] >= 0) || + Cos[rhs], (Re[rhs] == 0 && Im[rhs] >= 0) || 0 < Re[rhs] < Pi || (Re[rhs] == Pi && Im[rhs] <= 0)]}; applyInverse[ArcTan[lhs_] -> rhs_, var_Symbol] := {lhs -> ConditionalExpression[ - Tan[rhs], (Re[rhs] == -(Pi/2) && Im[rhs] < 0) || -(Pi/2) < + Tan[rhs], (Re[rhs] == -(Pi/2) && Im[rhs] < 0) || -(Pi/2) < Re[rhs] < Pi/2 || (Re[rhs] == Pi/2 && Im[rhs] > 0)]}; applyInverse[Cosh[lhs_] -> rhs_, var_Symbol] := - {lhs -> ConditionalExpression[-ArcCosh[rhs] + 2 I \[Pi] C[1], - C[1] \[Element] Integers], lhs -> - ConditionalExpression[ArcCosh[rhs] + 2 I \[Pi] C[1], + {lhs -> ConditionalExpression[-ArcCosh[rhs] + 2 I \[Pi] C[1], + C[1] \[Element] Integers], lhs -> + ConditionalExpression[ArcCosh[rhs] + 2 I \[Pi] C[1], C[1] \[Element] Integers]} (* Base case: *) @@ -116,7 +116,7 @@ isolate[lhs_ -> rhs_, var_Symbol] := Module[{inverseApplied}, (* Switch sides if needed to get var on LHS: *) - If[(countVar[rhs, var] === 1) && (countVar[lhs, var] === 0), + If[(countVar[rhs, var] === 1) && (countVar[lhs, var] === 0), Return[isolate[rhs -> lhs, var]]]; (* Assert var occurs only once in the LHS: *) @@ -125,8 +125,8 @@ Return[$Failed]]; inverseApplied = applyInverse[lhs -> rhs, var]; - If[Head[inverseApplied] =!= List, - Print["Solve error: Finding inverse failed for ", lhs -> rhs, + If[Head[inverseApplied] =!= List, + Print["Solve error: Finding inverse failed for ", lhs -> rhs, ", var: ", var]; Return[SolveFailed]]; allIsolated = isolate[#, var]& /@ inverseApplied; @@ -187,67 +187,67 @@ {{x->0},{x->0},{x->0},{x->-(d/e)}}/;FreeQ[{d,e},x]; (* Solve using u-substitution for polynomial-like forms.*) -uSubstitute::usage = +uSubstitute::usage = "uSubstitute[eqn, var] takes a non-polynomial `eqn` and attempts a \ u-substitution such that `eqn` takes a polynomial form. If the \ substitution succeeds, the function returns `{transformed, uValue}`. \ The `transformed` equation will include the `uPlaceholder` symbol as \ the u symbol. The function returns an error symbol if the \ substitution fails to produce a polynomial form."; -uSubstitute[theEqn_, theVar_Symbol] := - Module[{eqn = theEqn, var = theVar, expGcd, uValue, transformed, +uSubstitute[theEqn_, theVar_Symbol] := + Module[{eqn = theEqn, var = theVar, expGcd, uValue, transformed, exponents}, - (* Attempt to extract exponents of polynomial-like equations. + (* Attempt to extract exponents of polynomial-like equations. We wish to ignore any zero-valued exponents. *) - + exponents = DeleteCases[Exponent[eqn, var, List], 0]; If[Length[exponents] === 0, Return[$Failed]]; - (* Find the signed GCD of the exponents. - This seems to work for many of the problem cases, + (* Find the signed GCD of the exponents. + This seems to work for many of the problem cases, but may not yield a useful polynomial form for all equations. *) - + expGcd = GCD @@ exponents*Sign[exponents[[1]]]; uValue = var^expGcd; (* Rewrite the variable with our u-value. *) - - transformed = + + transformed = eqn /. var -> uPlaceholder^(1/expGcd) // PowerExpand; (* If our transformed equation is polynomial, we have succeeded. *) If[PolynomialQ[transformed, var], {transformed, uValue}, $Failed] ]; -uSubstitutionSolve::usage = +uSubstitutionSolve::usage = "uSubstitutionSolve[eqn, var] takes a non-polynomial `eqn` and \ attempts a u-substitution such that `eqn` takes a polynomial form in \ order to solve the equation. The function returns the solve result or \ `$Failed` in case of an issue."; -uSubstitutionSolve[theEqn_, theVar_Symbol] := +uSubstitutionSolve[theEqn_, theVar_Symbol] := Module[{eqn = theEqn, var = theVar, transformed, uSolved, solved}, transformed = uSubstitute[eqn, var]; (* If the u- substitution fails to produce a polynomial form and instead \ returns an error symbol, fail this solution attempt. *) - + If[Head[transformed] =!= List, Return[$Failed]]; (* Find the roots of the equation that was transformed into a \ polynomial form. *) - + uSolved = Solve[transformed[[1]] == 0, uPlaceholder]; (* For each of the roots, solve for the original variable. *) If[Head[uSolved] =!= List, Return[$Failed]]; - - solved = + + solved = Map[Solve[transformed[[2]] == #[[1, 2]], var] &, uSolved]; (* There may be some roots that have no solution for the original \ variable. Throw these out. *) - + solved = Select[solved, (Length[#] >= 1) &]; (* No way to handle multiple solutions yet. *) - + If[AnyTrue[solved, (Length[#] != 1) &], Return[$Failed]]; (* Collect the unique solutions of eqn and return. *) - + Map[First, solved] // DeleteDuplicates // Sort ]; @@ -285,7 +285,7 @@ Print["Solve found no solutions for ", eqn, " for ", var]; SolveFailed ]; -solveMultOrdered[eqns_List, vars_List] := +solveMultOrdered[eqns_List, vars_List] := Module[{firstSol, secondSol, toSolve}, If[Length[eqns] =!= 2 || Length[vars] =!= 2, Return[SolveFailed]]; firstSol = Solve[eqns[[1]], vars[[1]]]; @@ -318,9 +318,9 @@ Solve[{a_.*x_Symbol+b_.*y_Symbol==c_,d_.*x_Symbol==f_},{x_Symbol,y_Symbol}] := {{x->f/d,y->-((-c d+a f)/(b d))}}/;FreeQ[{a,b,c,d,f},x]&&FreeQ[{a,b,c,d,f},y] Attributes[Solve] = {Protected}; -normSol[s_List] := - Sort[(# /. - ConditionalExpression[e_, a_And] :> +normSol[s_List] := + Sort[(# /. + ConditionalExpression[e_, a_And] :> ConditionalExpression[e, a // Sort]) & /@ s]; Tests`Solve = { ESimpleExamples[ @@ -360,8 +360,8 @@ ESameTest[{}, Solve[E^x==0,x]], ESameTest[{{x->ConditionalExpression[2 I Pi C[1],C[1]\[Element]Integers]}}, Solve[E^x==1,x]], (*ESameTest[{{x->2.4663 Log[y]}}, Solve[1.5^x==y,x]],*) - ESameTest[{{x->ConditionalExpression[(2 I Pi C[1])/Log[3]+Log[y]/Log[3],C[1]\[Element]Integers]}}, Solve[3^x == y, x]], - ESameTest[{{x->ConditionalExpression[(2 I Pi C[1])/Log[2]+Log[y]/Log[2],C[1]\[Element]Integers]}}, Solve[2^x == y, x]], + ESameTest[{{x->ConditionalExpression[(2 I Pi C[1])/Log[3]+Log[y]/Log[3],C[1]\[Element]Integers]}}//Simplify, Solve[3^x == y, x]], + ESameTest[{{x->ConditionalExpression[(2 I Pi C[1])/Log[2]+Log[y]/Log[2],C[1]\[Element]Integers]}}//Simplify, Solve[2^x == y, x]], ESameTest[{{x->ConditionalExpression[(2 I Pi C[1]+Log[y])/(I Pi+Log[2]),C[1]\[Element]Integers]}}, Solve[(-2)^x == y, x]], ESameTest[{{x->ConditionalExpression[(2 I Pi C[1]+Log[y])/(I Pi+Log[3]),C[1]\[Element]Integers]}}, Solve[(-3)^x == y, x]], (* Inverse of log *) @@ -430,11 +430,11 @@ ESameTest[{{x -> 0}, {x -> 1}}, Solve[4*x*(1 + -x^(1/2)) == 0, x]], ESameTest[{{x -> (a^(-1)*y)^(b^(-1))}}, Solve[a*x^b + -y == 0, x]], ESameTest[{{x -> 0}, {x -> a^(-2)}}, Solve[4*x*(1 + -a*x^(1/2)) == 0, x]], - ESameTest[{{x -> ConditionalExpression[(0 + 1*I)*Pi + (0 + 2*I)*Pi*C[1], Element[C[1], Integers]]}}, Solve[1 + E^x == 0, x]], + ESameTest[{{x -> ConditionalExpression[(0 + 1*I)*Pi + (0 + 2*I)*Pi*C[1], Element[C[1], Integers]]}}//Simplify, Solve[1 + E^x == 0, x]], ESameTest[{{x -> y^3}}, Solve[y^(-2)*(1 + -y^2)^(-1/2)*(x + -y^3) == 0, x]], ESameTest[{{x -> y^3}}, Solve[y^(-2)*(1 + -y^2)^(-1/2)*(x + -y^3) == 0, x]], - ESameTest[{{x -> ConditionalExpression[(0 + 2*I)*Pi*C[1]*Log[3]^(-1) + Log[3]^(-1)*Log[10], Element[C[1], Integers]]}}, Solve[-10 + 3^x == 0, x]], - ESameTest[{{x -> ConditionalExpression[(0 + 2*I)*Pi*C[1]*Log[3]^(-1) + Log[3]^(-1)*Log[10], Element[C[1], Integers]]}}, Solve[10 + -3^x == 0, x]], + ESameTest[{{x -> ConditionalExpression[(0 + 2*I)*Pi*C[1]*Log[3]^(-1) + Log[3]^(-1)*Log[10], Element[C[1], Integers]]}}//Simplify, Solve[-10 + 3^x == 0, x]], + ESameTest[{{x -> ConditionalExpression[(0 + 2*I)*Pi*C[1]*Log[3]^(-1) + Log[3]^(-1)*Log[10], Element[C[1], Integers]]}}//Simplify, Solve[10 + -3^x == 0, x]], ESameTest[{{y -> x^(1/3)}, {y -> -(-1)^(1/3)*x^(1/3)}, {y -> (-1)^(2/3)*x^(1/3)}}, Solve[x + -y^3 == 0, y]], ESameTest[{{x -> ConditionalExpression[-ArcCos[(1/2)*y] + 2*Pi*C[1], Element[C[1], Integers]]}, {x -> ConditionalExpression[ArcCos[(1/2)*y] + 2*Pi*C[1], Element[C[1], Integers]]}}, Solve[-y + 2*Cos[x] == 0, x]], ESameTest[{{x -> -(1 + -a^(1/2))^(1/2)}, {x -> (1 + -a^(1/2))^(1/2)}, {x -> -(1 + a^(1/2))^(1/2)}, {x -> (1 + a^(1/2))^(1/2)}}, Solve[-a + (-1 + x^2)^2 == 0, x]], diff --git a/expreduce/resources/tests.m b/expreduce/resources/tests.m index 610cb8d..e145c6f 100644 --- a/expreduce/resources/tests.m +++ b/expreduce/resources/tests.m @@ -47,24 +47,8 @@ ESameTest[1/2-1/4 E^(-2 I t)-1/4 E^(2 I t), TrigToExp[Sin[t]^2]], ESameTest[-(I/2), 1/(2\[ImaginaryJ])//FullSimplify], ESameTest[I/2, -1/(2\[ImaginaryJ])//FullSimplify], - ESameTest[1/2 (-1)^(1/4), (1/2)E^((I Pi)/4)//FullSimplify], - ESameTest[-((I A (1-E^(-(1/2) I k Subscript[T, 0] Subscript[\[Omega], 0])))/(k Subscript[T, 0] Subscript[\[Omega], 0])), 1/Subscript[T, 0]*Integrate[A*E^(-I*k*Subscript[\[Omega], 0]t),{t,0,Subscript[T, 0]/2}]], ESameTest[A/2, 1/Subscript[T, 0]*Integrate[A*E^(-I*k*Subscript[\[Omega], 0]t)/.k->0,{t,0,Subscript[T, 0]/2}]], - ESameTest[-((I A (-1+E^(I Subscript[T, 0] Subscript[\[Omega], 0])))/(2 Subscript[T, 0] Subscript[\[Omega], 0])), 1/Subscript[T, 0]*Integrate[A*E^(-I*k*Subscript[\[Omega], 0]t)/.k->-2,{t,0,Subscript[T, 0]/2}]], - ESameTest[-((I A (1-E^(-(1/2) I k Subscript[T, 0] Subscript[\[Omega], 0])))/(k Subscript[T, 0] Subscript[\[Omega], 0])), 1/Subscript[T, 0]*A*Integrate[E^(-I*k*Subscript[\[Omega], 0]t),{t,0,Subscript[T, 0]/2}]], - ESameTest[-((I (1-E^(-(1/2) I k Subscript[T, 0] Subscript[\[Omega], 0])))/(k Subscript[\[Omega], 0])), Integrate[E^(-I*k*Subscript[\[Omega], 0]t),{t,0,Subscript[T, 0]/2}]], - ESameTest[(I (-1+Cos[k Pi])+Sin[k Pi])/(k Subscript[\[Omega], 0]), -((I (1-E^(-(1/2) I k *2Pi)))/(k Subscript[\[Omega], 0]))//FullSimplify], - ESameTest[A/2-(I A E^(I t Subscript[\[Omega], 0]) (1-E^(-(1/2) I Subscript[T, 0] Subscript[\[Omega], 0])))/(Subscript[T, 0] Subscript[\[Omega], 0])-(I A E^(-I t Subscript[\[Omega], 0]) (-1+E^(1/2 I Subscript[T, 0] Subscript[\[Omega], 0])))/(Subscript[T, 0] Subscript[\[Omega], 0]), Sum[1/Subscript[T, 0]*Integrate[A*E^(-I*k*Subscript[\[Omega], 0]t)/.k->thek,{t,0,Subscript[T, 0]/2}]*E^(I*thek*Subscript[\[Omega], 0]t),{thek,-1,1}]], - ESameTest[Cos[(2 k Pi t)/Subscript[T, 0]]-I Sin[(2 k Pi t)/Subscript[T, 0]], ExpToTrig[E^(-I*k*((2Pi)/Subscript[T, 0])*t)]], ESameTest[(Sin[k Pi] Subscript[T, 0])/(2 k Pi), Integrate[Cos[(2Pi*k*t)/Subscript[T, 0]],{t,0,Subscript[T, 0]/2}]], ESameTest[(I Sin[(k Pi)/2]^2 Subscript[T, 0])/(k Pi), Integrate[I*Sin[(2Pi*k*t)/Subscript[T, 0]],{t,0,Subscript[T, 0]/2}]], - ESameTest[(I (-A+A Cos[k Pi]-I A Sin[k Pi]))/(2 k Pi), A/Subscript[T, 0]*((Sin[k Pi] Subscript[T, 0])/(2 k Pi)-(I Sin[(k Pi)/2]^2 Subscript[T, 0])/(k Pi))//FullSimplify//TrigReduce], - ESameTest[Cos[k t Subscript[\[Omega], 0]]+I Sin[k t Subscript[\[Omega], 0]], ExpToTrig[E^(I*k*Subscript[\[Omega], 0]*t)]], - ESameTest[(I (Cos[(k Pi)/3]-Cos[(2 k Pi)/3]))/(k Pi), ak=1/6*(Integrate[E^(-I*k*(2Pi)/6 t),{t,-2,-1}]+Integrate[-1*E^(-I*k*(2Pi)/6 t),{t,1,2}])//FullSimplify], - ESameTest[0, a0=1/6*(Integrate[1,{t,-2,-1}]+Integrate[-1,{t,1,2}])//FullSimplify], - ESameTest[E^(-I k Pi t) x[t], 1/2 Integrate[x[t]*E^(-I*k*Pi*t),{x,-3/2,1/2}]], - ESameTest[-((I A E^(-I k Pi+(2 I k Pi t)/Subscript[T, 0]) (-1+E^(I k Pi)))/(2 k Pi)), 1/Subscript[T, 0]*Integrate[A*E^(-I*k*((2Pi)/Subscript[T, 0])*t),{t,0,Subscript[T, 0]/2}]*E^(I*k*((2Pi)/Subscript[T, 0])t)], - ESameTest[1/2, 1/10*Integrate[1*E^(-I*0*((2Pi)/10)*t),{t,0,10/2}]*E^(I*0*((2Pi)/10)t)], - ESameTest[Null, ClearAll[ak, a0]], ] };