# ModelingToolkit.jl -- intermediate symbolic variables calculated from solutions output in the state vector

**URL:** https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024
**Category:** General Usage
**Tags:** modelingtoolkit
**Created:** [January 27, 2021, 1:17am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024 "2021-01-27T01:17:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)
#### Post date: [January 27, 2021, 1:17am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024/1 "2021-01-27T01:17:22Z")

</div>

When getting a solution from ODEProblem which was created with ModelingToolkit.jl. Is there a way of evaluating symbolic variables/equations that are not in the state vector in plots, etc. Is there an easy way to maybe put the U vector from the solution and reference it back into the symbolic world so it can evaluate through all of the symbols to calculate these intermediate variables that aren’t captured by the solver states?

This is literally the first day I’ve used this toolbox and I’m wondering how to see the rest of the derived world that are not the state variables.

Partial example cut out from larger function:

```julia
@variables u(t), v(t), w(t) # Velocity in x,y, and z Axes
...
β = atan(v,u)
...
Cy = Cγβ*β + CγδR * δR
...
Fy = Cy * q̄ * S
...

D(v) ~ Fy / m + (p*w - u*r) + gy, # v is a state I can see in the solution output

```

So I have slapped together pieces for an example that probably would not work as is, but I get “v” out in the solution state vector. Fy is a symbolic variable created from “v” and other variables.  
After evaluating the solution, how can I put “v” back into this symbolic world and calculate all of my intermediate variables like Fy and Beta.

Noob question I’m sure.

Best Regards,  
Allan Baker

---

<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: [January 27, 2021, 1:27am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024/2 "2021-01-27T01:27:49Z")

</div>

Not a noob question because it’s just not complete. You’d make them states and then rely on `alias_elimination(sys)` to remove the explicit equations. We’re aiming to get a full examples on this in the first week of February so hold your 🐎 .

---

<div class="post-metadata">

### Author: ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)
#### Post date: [January 27, 2021, 2:44pm UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024/3 "2021-01-27T14:44:48Z")

</div>

I was wondering if there was an observation field where you could list variables that you would like to track at the output rate. The other thing I was thinking is that I could use some kind of wrapper function to take output state vector and remake the variables if I knew the syntax to evaluate the symbolic variables by substituting back in the calculated states.

---

<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: [January 27, 2021, 2:51pm UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024/4 "2021-01-27T14:51:00Z")

</div>

`observed`. But if you do alias elimination it handles all of that automatically. These next two weeks we’re working on the general interface around this.

---

<div class="post-metadata">

### Author: ![amytmoody](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@amytmoody](https://discourse.julialang.org/u/amytmoody)
#### Post date: [May 6, 2024, 9:27am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024/5 "2024-05-06T09:27:13Z")

</div>

Have you posted the full example and could you please provide the link?

---

<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: [May 6, 2024, 9:53am UTC](https://discourse.julialang.org/t/modelingtoolkit-jl-intermediate-symbolic-variables-calculated-from-solutions-output-in-the-state-vector/54024/6 "2024-05-06T09:53:23Z")

</div>

This is a question from 3 years ago. Everything is in ModelingToolkit now. Just see the documentation:

> **[Home · ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/stable/)**
>
> Documentation for ModelingToolkit.jl.
