JuliaSymbolics / Symbolics.jl

Symbolic programming for the next generation of numerical software
https://docs.sciml.ai/Symbolics/stable/
Other
1.37k stars 154 forks source link

Inconsistent display of equations with and without connectors #1311

Open hersle opened 1 month ago

hersle commented 1 month ago

Because systems of equations with and without connectors are displayed in different Latex environments, they are displayed without and with alignment, respectively. This makes the ModelingToolkit big RC circuit tutorial equations unreadable:

Bad (before structural_simplify())

image

Good (after structural_simplify())

image

ChrisRackauckas commented 1 month ago

oh that's not good 😅

ChrisRackauckas commented 1 month ago

why would connectors be in a different environment?

hersle commented 1 month ago

They are currently displayed in this "function form", which does not have an equality sign that makes sense to align with:

image

hersle commented 1 month ago

One way to fix it would be to show equations(expand_connections(sys)) instead of equations(sys). But that would have to be done in ModelingToolkit, since expand_connections() is only defined there. And that would not fix the general problem in Symbolics.

Are connections used at all in Symbolics? I can't find it in any example or test. Or is it some historic remnant from Symbolics including (parts of?) ModelingToolkit before?

ChrisRackauckas commented 1 month ago

Are connections used at all in Symbolics? I can't find it in any example or test. Or is it some historic remnant from Symbolics including (parts of?) ModelingToolkit before?

Connections don't make sense in the Symbolics world. They really require systems to make sense.

They are currently displayed in this "function form", which does not have an equality sign that makes sense to align with:

What about just displaying it as 0 = connect?

hersle commented 1 month ago

I suppose that would fix it, yes. That might require some some changes in MTK, since it affect more than just the Latex rendering to be consistent throughout MTK.

hersle commented 1 month ago

Connections don't make sense in the Symbolics world. They really require systems to make sense.

Then I also think this connector equation logic should be moved to MTK.

ChrisRackauckas commented 1 month ago

yes that would make sense.