Sorting a formula in Mathematica according to level of derivative or exponential

892 Views Asked by At

I have an impedance equation which I have transferred to Mathematica in hopes to simplify it. It is representative of a circuit schematic, and the circuit impedance (Z, from V = iZ) is a large fraction of several terms in the s-plane.

As an abbreviated example, it could look like:

 L0s + (R1/(1 + R1 C1 s) + R3b + L3s + V3/s)/(R2a L2a s/(R2a + L2a s))

I would like to rearrange the data as:

k1*s^-1 + k2*s^0 + k3*s^1 ...  

with all values of k representing the excess data (fractions of various R-, L-, and C-values).

What formula manipulation would be best used to craft these types of structures?
.
.
.
I believe that the Collect function is unable to handle separating things out according to exponentials of s, even if the equation is Simplified and then ExpandAll-ed due to the level of divisions between terms - there are several layers of unresolved fractions.

In wondering about this, I was also curious that if I transformed everything to the time domain, is it possible to sort by primes (number of times derivated/integrated)?

S c0 + c1 + d/dt*c2 + d^2/dt^2*c3 ...
2

There are 2 best solutions below

2
On

Your function is not a polynomial in s and s^(-1). The closest I could come to making sense of your question, would be to develop your expression into series around s==0 and then determine series coefficients. This can be done using SeriesCoefficient:

In[80]:= SeriesCoefficient[
 L0*s + (R1/(1 + R1*C1*s) + R3b + L3s + V3/s)/(R2a*
     L2a*(s/(R2a + L2a*s))), {s, 0, n}]

Out[80]= Piecewise[{
          {(R1*((-C1)*R1)^n*(L2a - C1*R1*R2a))/(L2a*R2a), n > 1}, 
          {L0 + (C1*R1^2*(-L2a + C1*R1*R2a))/(L2a*R2a), n == 1}, 
          {((-C1)*R1^2*R2a + L2a*(L3s + R1 + R3b))/(L2a*R2a), n == 0}, 
          {V3/L2a, n == -2}, 
          {(L3s*R2a + R1*R2a + R2a*R3b + L2a*V3)/(L2a*R2a), n == -1}
         }, 0]

I hope this is helpful.

0
On

I could not do anything with your original equation and to illustrate a possible useful approach I will use the following greatly simplified version. Possibly, this is not what you require at all.

myeqn = Expand[L0 s + (R3b + L3 s + V3/s)/(R2a L2a s/(R2a + L2a s))]

giving:

enter image description here

Select, FreeQ and MemberQ may now be used to define k0, k1 ... as follows:

k0 = Select[myeqn, FreeQ[#, s] &]

enter image description here

Similarly:

k1 = Expand[Select[myeqn, MemberQ[#, s] &] 1/s];

km1 = Expand[Select[myeqn, MemberQ[#, 1/s] &] s];

km2 = Expand[Select[myeqn, MemberQ[#, 1/s^2] &] s^2];

The following now evaluates to True (I am assuming that ultimately you require something like this)

Expand[k0 + k1 s + km1/s + km2/s^2] == myeqn

However, the approach given above by Sasha seems much better:

scoeff = SeriesCoefficient[myeqn, {s, 0, n}];

where, for example,

k0alt = First@scoeff[[1, 2]]