Here is my code. I have an equation that is given below. This code sorts through the terms and puts each term into a list and then each factor of the term into another list. I am able to call each factor in the equation.
eqn = Derivative[1][f1][y] . E^(I*x)*Derivative[1][f2][y] .
(2*I*E^(2*I*x)) + Derivative[1][f1][y] .
(I*E^(I*x))*Derivative[1][f2][y] . E^(2*I*x) +
Derivative[1][f3][y] . (3*I*E^(3*I*x)) +
Derivative[1][g3][y] . (I*E^(I*x)) +
(-f2[y]) . (2*I*E^(2*I*x))*Derivative[2][f1][y] .
E^(I*x) + (-f1[y]) . (I*E^(I*x))*
Derivative[2][f2][y] . E^(2*I*x) +
Derivative[1][f1][y] . (I*E^(I*x))*
Derivative[1][g2][y] + (-f1[y]) . (I*E^(I*x))*
Derivative[2][g2][y];
Newlist = List @@ eqn;
For[i = 1, i < Length[Newlist] + 1, i++,
Terms = List @@ Newlist[[i]];
Factor1 = Terms[[1]];
Factor2 = Terms[[2]];
Print[Factor1];
Print[Factor2];
]
Here is my output from running this code
$\text{f1}'(y).e^{i x}$
$\text{f2}'(y).\left(2 i e^{2 i x}\right)$
$\text{f1}'(y).\left(i e^{i x}\right)$
and so on.
Most factors have a "." between the $f$ function and the $e^{m i x}$. I want to get rid of the period. I cannot get rid of the periods in the "eqn" definition as they are there for a specific reason. Here is what I have tried so far.
StringReplace["Factor1", "." -> ""]
Which outputs "Factor1" however, when I do this
StringReplace["f1'[y].e^{i x}","."->""]
It returns
$\text{f1}'(y)e^{i x}$
without the period how I want it.
My question is: How can I call Factor1
in the StringReplace
without Mathematica thinking "Factor1" is the string and will replace it with the expression that it is equal to?
Thank you for any help
List @@@ List @@ eqn /. Dot -> Times
? $\endgroup$NewList =
and it sorted my terms and took out the periods giving the desired output. $\endgroup$