After reading and re-reading thoroughly letter by letter textbooks of Sadiku and Hayt (thanks to @Deep), I have finally figured out the whole technology and all the math behind RLC-circuits.
Little nota bene: doesn't matter which textbook is used (among these both), the confusion will always come because of seemingly enormous avalanche of the information. Personally, I think that both authors make the same error, namely first proposing the solutions prêt-à-porter for parallel and series RLC circuits, and only then start to discuss how to solve differential equations for general cases. Pedagogically correct would be to start from teaching students how to derive differential equations from the scratch. Besides giving the better understanding of RLC-networks, the folks will refresh their brains with some pure math.
Procedure will be the same for all kind of circuits. 1) Find vC(0-) and iL(0-), id est before the step happened; 2) find vC(∞) and iL(∞), i.e. at stable DC conditions after the transient response is finished; 3) find derivatives vC(0+)/dt and iL(0+)/dt (this step requires that we take into consideration all the independent sources at t=0+); 4) derive differential equation and find out the form of the transient response (this step requires that we switch off all the independent sources). Here some basic math is required because sometimes we have to differentiate original parameters; 5) The next step is to find roots of quadratic equation, define the form of the transient responce, write the general equation for the current and find its coefficients. I skip this part because this is not relevant to topic question.
Reminder: vC(0-)=vC(0+) and iL(0-)=iL(0+). Once again: capacitor voltage cannot change quickly, all others voltages can. Inductor current cannot change quickly, all others can. Important detail: if inductor is in series with any other element, the current through the element at t=0+ will be the current through the inductor. I don't write "the same as through the inductor" because semantically this expression means the value of the current. It's the same current, basta. Event if there is a 1000-V generator in series.
Let's start to solve for the first circuit which was mentioned in the question.
1) vC(0-)=40 V, iL(0-)=1 A.
2) vC(∞)=40 V, iL(∞)=3 A.
3) find derivatives vC(0+)/dt and iL(0+)/dt. At this point we must remember following principle: at t=0+ only 3 values are known and stable - vC(0+), iL(0+) and independent source. Here we need to write all possible KCL and KVL equations and then try to figure out how to express derivatives through the known values. It is possible that the first written equation will suffice, however, it is not excluded that we have to abandon some equations and examine the others. Let's start from the node A. Please don't forget to take into consideration all the independent sources:
KCL: 2 = iL(0+) + i(40); where i(40) is a current through 40-Ohm resistance
We remember that iL(0+)=iL(0-)=1 A, thus i(40R)=1 A. If someone would like to argue that there is a current through 40-Ohm resistance which is caused by 50-V source, than I would like to repeat once again: at t=0+, only 3 values are known and stable - vC(0+), iL(0+) and independent source. Everything that is between can change.
Now let's write KVL equation for the central mesh. Once again, this sequence (KCL --> KVL --> etc) is not a generally prescribed procedure. We can blindly write all possible KCL and KVL equations and then figure out how to find the desired values.
KVL: vL(0+) = i(40)*R + vC(0+).
We still remember that vC(0+)=vC(0-)=40 V. The value i(40)=1 A. Then vL(0+)=80 V. Since
vL = L*di/dt
di(0+)/dt = vL(0+)/L = 80/0.5 = 160 A/s.
We have found current derivative. Basically it's enough and there is no need to calculate voltage derivative. The reason is that the general equation for the transient response will have the same form for voltage and current. And even if we will compose the differential equation for the voltage, the roots of the characteristic equation will be the same for voltage and current waveforms. The only thing which changes is the steady part of the general equation, namely vC(∞) and iL(∞).
As I have already mentioned, the step 4 requires that we switch off all the independent sources. Little detail: voltage source must be replaced by short circuit, current source - by open circuit.
We are free to write currents in any direction. However, here it would be rational to represent 40-Ohm resistor and inductor in series, it will reduce the number of currents to 3. Let's write KCL equation:
0 = iL + iC + i(10); where i(10) is the current through 10-Ohm resistance.
Now we have to find the way to express all the values through iL and vC:
0 = iL + C*dvC/dt + i(10).
Here we notice that the 10-Ohm resistance has the same voltage as the capacitor, thus
0 = iL + C*dvC/dt + vC/10.
Since there is only one possible KCL equation, then now we can write KVL equation. We have 2 meshes and we can write 2 equations. I arbitrarily decide to write it for the right mesh:
vC = 40*iL + L*diL/dt.
I can continue to write the equation for another mesh, however, I notice that I can substitute vC from KCL equation by the value form the KVL equation:
0 = iL + C*dvC/dt + vC/10;
0 = iL + C*dv(40*iL + L*diL/dt)/dt + 0.1(40*iL + L*diL/dt);
0 = iL + dv(40*iL + 0.5*diL/dt)/dt + 0.1(40*iL + 0.5*diL/dt);
0.5*d(di)/d(dt) + 40.05*di/dt + 5*i = 0;
d(di)/d(dt) + 80.1*di/dt + 10*i = 0;
s^2 + 80.1*s + 10 = 0; characteristic equation.
Here is another nota bene: all the parameters in the differential equations must be positive. If there is a "-" somewhere, please check once again KCL and KVL equations.
Also, we have derived a differential equation for current. Actually it will be the same equation for the voltage waveform too, however, we have already calcualted current derivative di(0+)/dt, so let's avoid any useless movements.
Let's carry out the same sequence for the second RLC-circuit.
1) iL(0-)=0 A; vC(0-)=-12 V;
2) iL(∞)=0 A; vC(∞)=50 V;
3) t=0+, current source is off, voltage source is on. This is a simple series circuit, so let's directly write KVL equation.
-50 + 6*iL(0+) + L*di(0+)/dt + vC(0+) = 0;
-50 + 6*0 + 1*di(0+)/dt - 12 = 0;
di(0+)/dt = 62 A/s;
4) Switch off voltage source and derive differential equation. Once again, let's write KVL:
6*iL + L*di/dt + vC = 0;
This is a series circuit and the current is the same through all the elements. It would be convenient to express capacitor voltage through the current:
6*iL + L*di/dt + 1/C*∫i(t)dt = 0;
We can differentiate this equation:
6*di/dt + 1*d(di)/d(dt) + i*1/0.04 = 0;
s^2 + 6*s + 25 = 0;