Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit multiplication #1408

Closed
yolhan83 opened this issue Jan 16, 2025 · 5 comments
Closed

Add explicit multiplication #1408

yolhan83 opened this issue Jan 16, 2025 · 5 comments

Comments

@yolhan83
Copy link

This is a feature request.
Hello, I would need a way to have explicit multiplication with "*" inside the string after some symbolic computation for the result to be compatible with other API (paraview calculator in my case).
Is it possible to add that or is there an easy way to get it ?
Thank you.

@ChrisRackauckas
Copy link
Member

I'm not entirely sure what you're asking for. Can you give an example?

@yolhan83
Copy link
Author

yolhan83 commented Jan 16, 2025

I would like to have an easy way from

using Symbolics
@variables x
expr = 2*cos(3*x) + 2
string(expr)

which return "2 + 2cos(3x)" to instead use explicit multiplication meaning return "2 + 2 * cos(3*x)". Or is there a way to cheat , I tried

string(Meta.parse(string(expr)))

and it's nearly working

"2 + 2 * cos(3x)"

@ChrisRackauckas
Copy link
Member

Ahh I see. 3x is a valid Julia expression though? That might be the issue here?

julia> x = 2
2

julia> 3x
6

It might be something special cased in one of the Julia dispatches and not a Symbolics one because of this.

@yolhan83
Copy link
Author

Yes true I mean in a perfect world every symbolic parser should allow implicit multiplication so it's mostly shame on them 😅

@yolhan83
Copy link
Author

Thank you I will find another way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants