# Help with Symbolic Programming

**URL:** https://discourse.julialang.org/t/help-with-symbolic-programming/107842
**Category:** New to Julia
**Tags:** question, symbolics
**Created:** [December 20, 2023, 8:15am UTC](https://discourse.julialang.org/t/help-with-symbolic-programming/107842 "2023-12-20T08:15:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ContactPatch22](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@ContactPatch22](https://discourse.julialang.org/u/ContactPatch22)
#### Post date: [December 20, 2023, 8:15am UTC](https://discourse.julialang.org/t/help-with-symbolic-programming/107842/1 "2023-12-20T08:15:52Z")

</div>

Hi all, I am new to Julia (coming from Python).

I need some help with defining equations and extracting Mass, Stiffness and Damping Matrices. Does anyone have some advice to generate these matrices using the following equation, for example:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/d/ad46d968f19482006cd6c59c20d70ac28fd74e3e.png)  
Many thanks!

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [December 20, 2023, 8:44am UTC](https://discourse.julialang.org/t/help-with-symbolic-programming/107842/2 "2023-12-20T08:44:36Z")

</div>

Welcome to the community!

Some questions and remarks:

- I do not see any equation. This looks like a term, not like an equation.
- what is the definition of C\_{pi} and K\_{pi} and x and q and Z\_{si}? Are these variables scalars, vectors or matrices and if yes of which dimension?

---

<div class="post-metadata">

### Author: ![ContactPatch22](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@ContactPatch22](https://discourse.julialang.org/u/ContactPatch22)
#### Post date: [December 21, 2023, 9:37am UTC](https://discourse.julialang.org/t/help-with-symbolic-programming/107842/3 "2023-12-21T09:37:09Z")

</div>

Hi, and thank you!

That is correct, it is a term, the “right hand side” of the equation is the applied force. The term posted contains the description of a railway track and sub elements beneath it (such as sleepers ballasts and the sub-grade). It is in a 2 dimensional state at the moment, but I plan to extend to 3D soon.

Cpi and Kpi are constants that describe the rail pad stiffness and damping, whereas x is a float variable that describes location along the x-axis. q and Zsi are generalized coordinates and as such are in a single vector where the first K elements are q’s and next N elements are Zs.

Elements that have a coefficient that are a second derivative of the coordinate vector go to the mass matrix, elements that have a coefficient that are a first derivative of the coordinate vector go the damping matrix and elements that are a coefficient of the coordinate vector go to the stiffness matrix.

---

<div class="post-metadata">

### Author: ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)
#### Post date: [December 21, 2023, 10:06am UTC](https://discourse.julialang.org/t/help-with-symbolic-programming/107842/4 "2023-12-21T10:06:02Z")

</div>

You said you come from Python: Did you try to implement this in Python?

If you would post a code snippet, I guess much more people would be willing to help.  
Otherwise your question is still very unclear and it is unlikely that people can help.

---

<div class="post-metadata">

### Author: ![ContactPatch22](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@ContactPatch22](https://discourse.julialang.org/u/ContactPatch22)
#### Post date: [December 29, 2023, 7:38am UTC](https://discourse.julialang.org/t/help-with-symbolic-programming/107842/5 "2023-12-29T07:38:09Z")

</div>

Hi again,

I did implement in Python and have done so again in Julia by using for loops - not to worry, it produces the same result as the Python script. Will update when I find a quicker method.
