# Solving ODEs with Initial Values u(t0) = u0 for t0 ≠ 0

**URL:** https://discourse.julialang.org/t/solving-odes-with-initial-values-u-t0-u0-for-t0-0/80456
**Category:** New to Julia
**Tags:** question, ode, ordinarydiffeq
**Created:** [May 3, 2022, 11:04pm UTC](https://discourse.julialang.org/t/solving-odes-with-initial-values-u-t0-u0-for-t0-0/80456 "2022-05-03T23:04:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ethan\_wood](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@ethan\_wood](https://discourse.julialang.org/u/ethan_wood)
#### Post date: [May 3, 2022, 11:04pm UTC](https://discourse.julialang.org/t/solving-odes-with-initial-values-u-t0-u0-for-t0-0/80456/1 "2022-05-03T23:04:47Z")

</div>

Hello,

I’ve gotten into Julia to solve a number of ODEs (mostly for boundary value problems) and I’ve started to practice solving them in Julia. I’ve checked a lot of threads and the documentation for Differentialequations.jl but have now been able to find an answer to this problem. In all of the reading I have done, the initial values that we use when defining a problem are always some u(t0) = u0 for a t0 = 0. However, I am encountering a number of ODEs I must solve whose initial conditions are given by some u(t0) = u0 where t0 ≠ 0.

For instance, solving `du/dt + u*tan(t) = exp(2*t)*cos(t), u(0) = 2` looks like

```julia
using DifferentialEquations
f(u,p,t) = exp(2*t)*cos(t) - u*tan(t)
u0 = 2.
tspan = (0.,4.)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob)

```

However, I am clueless on how to set up `t*du/dt = u + t, u(2) = 8`

Thank you so much!

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [May 4, 2022, 12:37am UTC](https://discourse.julialang.org/t/solving-odes-with-initial-values-u-t0-u0-for-t0-0/80456/2 "2022-05-04T00:37:50Z")

</div>

> [@ethan\_wood](#):
>
> However, I am encountering a number of ODEs I must solve whose initial conditions are given by some u(t0) = u0 where t0 ≠ 0.

Just use a `tspan` that starts at `t0`.

---

<div class="post-metadata">

### Author: ![ethan\_wood](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@ethan\_wood](https://discourse.julialang.org/u/ethan_wood)
#### Post date: [May 4, 2022, 6:13pm UTC](https://discourse.julialang.org/t/solving-odes-with-initial-values-u-t0-u0-for-t0-0/80456/3 "2022-05-04T18:13:17Z")

</div>

That’ll do it, thank you.
