stephenmor
(stephen Morris)
April 29, 2022, 10:18pm
1
I have tried the following and get an error I don’t understand. I am a bit of a newbie so I expect there is a simple explanation.
DSolve[{f'[t] == k f[t] - c, f[0] == D, f[T] == 0}, f[t], t]
I get
DSolve::bvnul: For some branches of the general solution, the given boundary conditions lead to an empty solution.
I don’t understand this! please help!
Many thanks,
Steve
hdolhaine
(Hans Dolhaine)
April 30, 2022, 12:07am
2
D is a Mathematica intrinsic symbol. You should avoid variable names with capital letters.
I think
hh[t_] := (a (-E^(k t) + E^(k T)))/(-1 + E^(k T))
With D interchanged with a is what you are looking for.
hh[0]
hh[T]
stephenmor
(stephen Morris)
April 30, 2022, 12:30am
4
I tried changing the variable names but that didn’t help.
DSolve[{f'[t] == k f[t] - c, f[0] == s, f[p] == 0}, f[t], t]
Maybe I didn’t understand your suggestion.
stephenmor
(stephen Morris)
April 30, 2022, 12:38am
5
Now I must also find out how to mark myself as retired! Because a I am also happily retired.
hdolhaine
(Hans Dolhaine)
April 30, 2022, 12:40am
6
Well, DSolve doesn’t work on my system either, but hh given above solves the ODE and the other conditions.
stephenmor
(stephen Morris)
April 30, 2022, 12:56am
7
Don’t the E^(k t) terms cancel?
stephenmor
(stephen Morris)
April 30, 2022, 1:19am
9
Your solution is missing the constant ‘c’
It does give the correct boundary values.
stephenmor
(stephen Morris)
April 30, 2022, 1:27am
10
In[32]:= hh[t_] := (a (-E^(k t) + E^(k T)))/(-1 + E^(k T))
In[33]:= hh[0]
Out[33]= a
In[34]:= hh[T]
Out[34]= 0
In[35]:= hh'[t] - k hh[t]
Out[35]= -((a E^(k t) k)/(-1 + E^(k T))) - (
a (-E^(k t) + E^(k T)) k)/(-1 + E^(k T))
hdolhaine
(Hans Dolhaine)
April 30, 2022, 12:18pm
11
Your In[35] is not the complete differential equation. And c is fixed by your conditions. Look at
hh'[t] - (k hh[t] - c) /. c -> (a E^(k T) k)/(-1 + E^(k T)) // FullSimplify
hdolhaine
(Hans Dolhaine)
April 30, 2022, 12:57pm
12
Here is the whole procedure
dgl = f'[t] == k f[t] - c
sol = f[t] /. DSolve[dgl, f[t], t][[1, 1]] /. C[1] -> u
ff[u_] := Evaluate[sol]
(*ff fulfills the diff equation*)
D[ff[u], t] - (k ff[u] - c) // Simplify
(*you have only one constant of integration, so c is not free but must be adapted*)
e1 = (ff[u] /. t -> 0) == d
e2 = (ff[u] /. t -> T) == 0
sol2 = Solve[{e1, e2}, {u, c}] // Flatten
gg = ff[u] /. sol2 // Simplify
gg /. t -> 0
gg /. t -> T
(* use the fixed c in the differential equation *)
D[gg, t] - (k gg - c) /. sol2 // Simplify