Hot answers tagged

5

expr = (-1 + (E^(w[1, 0] - 1.55432 w[1, 1]) - E^(-w[1, 0] + 1.55432 w[1, 1]))^2 / (E^(w[1, 0] - 1.55432 w[1, 1]) + E^(-w[1, 0] + 1.55432 w[1, 1]))^2) expr /. Power[E, Plus[x_, y__]] :> Inactive[Times][Power[E, x], Power[E, y]]/. {Power[E, Times[c_, w[i_, j_], ___]] :> Power[T[i, j], Sign[c]], Power[E, w[i_, j_]] ...


3

Instead of SelectionMove and NotebookSelection one can use NotebookRead[PreviousCell[]] and then cleanup the text returned by the ExportPacket. Thread @ MakeExpression[ "{" <> StringReplace[ First[FrontEndExecute[FrontEnd`ExportPacket[NotebookRead[PreviousCell[]], "InputText"]]], {"\r\n " -> "", "\r\n" -> ","}] <> "}", ...


2

These are two test lists with exponents: test1 = 1/16 E^(2 I t1) a[ 1] - (E^(-I (-2 + Sqrt[2]) t1) a[ 2])/(16 (-2 + Sqrt[2])) + (E^(I (2 + Sqrt[2]) t1) a[ 3])/(16 (2 + Sqrt[2])) - (E^(2 I t1 - I Sqrt[2] t1) a[ 4])/(16 Sqrt[2]) + (E^(-I Sqrt[2] t1 + 2 I (1 + Sqrt[2]) t1) a[ 5])/(16 Sqrt[2]); test2 = c1*E^a + c2*E^(a + b); ...


2

My solution does not use Coefficient(List) because I couldn't get Mathematica to avoid interpreting c1*E^a + c2*E^(a+b) as E^a (c1 + c2*E^b ) when finding the coefficient of E^a. It is probably possible, and would probably look prettier than what I'm about to present. Let me first address test1 and test2. I will assume that t1 ONLY appears in ...


2

Here is a slight modification of Karsten's answer. Previously I felt it was too similar, but I suppose it cannot hurt to post it. The main difference is that I avoid MakeExpression. I also like the alternative in your question, which is to use StringToStream. read[cObj_] := DeleteCases[#, HoldComplete[Null]] &@( ToExpression[#, InputForm, ...



Only top voted, non community-wiki answers of a minimum length are eligible