# Solving boundary-value problems within a specified region

Is it possible to use DSolve with non-initial boundary conditions? For example,

eqn = a == b x'[z] + c x[z]


over the region 0 to L, something like

DSolve[{eqn, x[0] == x0, x[L] == xL}, x[z], z]


I wonder if maybe my approach is wrong.

This gives the error For some branches of the general solution, the given boundary conditions lead to an empty solution. I guess it needs to know more about L but I'm not sure how to proceed.

Thank you.

You should start with only one boundary condition, solve the equation and then impose the second boundary condition.

This then leads to a restriction of the parameters of the ODE, similar to that known as eigenvalue.

Here we go:

eqn = a == b x'[z] + c x[z];


Repeating first the unsucsessful attempt

DSolve[{eqn, x[0] == x0, x[L] == xL}, x[z], z]


During evaluation of In[9]:= DSolve::bvnul: For some branches of the general solution, the given boundary conditions lead to an empty solution. >>

(* Out[9]= {} *)


During evaluation of In[9]:= DSolve::bvnul: For some branches of the general solution, the given boundary conditions lead to an empty solution. >>

Out[9]= {}


Now the solution with just one boundary condition is

xx[z_] = x[z] /. DSolve[{eqn, x[0] == x0}, x[z], z][[1]]

(* Out[6]= (E^(-((c z)/b)) (-a + a E^((c z)/b) + c x0))/c *)


Imposng the second boundary condition and solving e.g. for the parameter "a":

sol = Solve[xx[L] == xL, a]

(* Out[12]= {{a -> -((c (x0 - E^((c L)/b) xL))/(-1 + E^((c L)/b)))}} *)


The solution is then

xxL[z_] = xx[z] /. sol[[1]] // FullSimplify

(* Out[21]= (-x0 + E^((c (L - z))/b) (x0 - xL) + E^((c L)/b) xL)/(-1 + E^((c L)/b)) *)


In Latex:

$$\frac{(\text{x0}-\text{xL}) e^{\frac{c (L-z)}{b}}+\text{xL} e^{\frac{c L}{b}}-\text{x0}}{e^{\frac{c L}{b}}-1}$$

Solving for the other two parameters would give

Solve[xx[L] == xL, b]

(* Out[10]= {{b -> ConditionalExpression[(c L)/(
2 I \[Pi] C[1] + Log[(a - c x0)/(a - c xL)]), C[1] \[Element] Integers]}} *)

Solve[xx[L] == xL, c]


During evaluation of In[11]:= Solve::nsmet: This system cannot be solved with the methods available to Solve. >>

(* Out[11]= Solve[(E^(-((c L)/b)) (-a + a E^((c L)/b) + c x0))/c == xL, c] *)