# Transform ODE Solution

**URL:** https://discourse.julialang.org/t/transform-ode-solution/132262
**Category:** Numerics
**Tags:** diffeq
**Created:** [September 10, 2025, 4:35pm UTC](https://discourse.julialang.org/t/transform-ode-solution/132262 "2025-09-10T16:35:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![homocarbonis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/homocarbonis/32/223614_2.png) [@homocarbonis](https://discourse.julialang.org/u/homocarbonis)
#### Post date: [September 10, 2025, 4:35pm UTC](https://discourse.julialang.org/t/transform-ode-solution/132262/1 "2025-09-10T16:35:01Z")

</div>

Hi,  
I’m trying to solve some PDEs using a pseudo-spectral method with SplitODEProblem, which gives me a solution in the wavenumber domain. Is there a good way to take the inverse DCT of the solution, or am I going about this in completely the wrong way?

At the moment I am just taking the IDCT of solution.u which is fine but doesn’t work with code that needs continuous output.

---

<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: [September 10, 2025, 8:20pm UTC](https://discourse.julialang.org/t/transform-ode-solution/132262/2 "2025-09-10T20:20:42Z")

</div>

> [@homocarbonis](#):
>
> At the moment I am just taking the IDCT of solution.u which is fine but doesn’t work with code that needs continuous output.

It’s not a _discrete_ cosine transform (DCT) if you want continuous output. What actual mathematical transformation do you need?

---

<div class="post-metadata">

### Author: ![homocarbonis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/homocarbonis/32/223614_2.png) [@homocarbonis](https://discourse.julialang.org/u/homocarbonis)
#### Post date: [September 10, 2025, 9:43pm UTC](https://discourse.julialang.org/t/transform-ode-solution/132262/3 "2025-09-10T21:43:47Z")

</div>

It’s a discrete transform in space, which leads to a system of ODEs with one equation with respect to time for each point in the wavenumber domain. After solving (with dense=true), the resulting ODESolution (with can then be called as solution(t) to give the value in the wavenumber domain at time t. What I would like to do is perform an inverse transform to get back to a solution in the spatial domain.

---

<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: [September 10, 2025, 9:50pm UTC](https://discourse.julialang.org/t/transform-ode-solution/132262/4 "2025-09-10T21:50:48Z")

</div>

> [@homocarbonis](#):
>
> After solving (with dense=true), the resulting ODESolution (with can then be called as solution(t) to give the value in the wavenumber domain at time t. What I would like to do is perform an inverse transform to get back to a solution in the spatial domain.

You can call `solution(t)`, then call the IDCT on that, but this could be expensive if you want to do it at a large number of times `t`.

In principle, internal to `solution(t)` is probably a piecewise polynomial in time, and since polynomial evaluation is linear in the coefficients, you could call the IDCT on the coefficients to get a callable object `spatialsolution(t)` that gives you the spatial solution at any desired `t` (by evaluating the transformed coefficients). I’m not sure if DifferentialEquations.jl gives you enough access to the solution internals to do this, though?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [September 11, 2025, 7:39am UTC](https://discourse.julialang.org/t/transform-ode-solution/132262/5 "2025-09-11T07:39:41Z")

</div>

sol.k[i] gives the coefficients of the ith polynomial. They are defined per method though so it can be a bit difficult to parse what that polynomial is if you need to find how exactly it is defined

---

<div class="post-metadata">

### Author: ![homocarbonis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/homocarbonis/32/223614_2.png) [@homocarbonis](https://discourse.julialang.org/u/homocarbonis)
#### Post date: [September 11, 2025, 8:37am UTC](https://discourse.julialang.org/t/transform-ode-solution/132262/6 "2025-09-11T08:37:16Z")

</div>

I think that should work, thank you. The method doesn’t change so I should be able to write a dct method that operates on sol.k.
