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

Support for sqrt-like nth-roots when rendering x**(1/p)? #184

Open
jonbarron opened this issue Oct 20, 2023 · 2 comments
Open

Support for sqrt-like nth-roots when rendering x**(1/p)? #184

jonbarron opened this issue Oct 20, 2023 · 2 comments
Assignees
Labels

Comments

@jonbarron
Copy link
Contributor

jonbarron commented Oct 20, 2023

Description

When I latexify something like x**(1/p), I get $x^{1/p}$, which makes complete sense, but isn't quite as nice looking as $\sqrt[p]{x}$.

Ideas of the solution

Is there a way to coax latexify to look for patterns like 1/expr in the exponent, and use sqrt[expr] in those cases?

Alternative ideas

having a flag for the latexify decorator that renders all powers p as sqrt[1/p] would probably still be useful if the fully automatic version isn't possible

Additional context

image
@odashi
Copy link
Collaborator

odashi commented Oct 23, 2023

Thanks for the suggestion. It is basically possible to implement the ideas above, but we also need to carefully choose the default behavior.

I think introducing some flags (such as ensure_root_op?) to choose the representation $\sqrt[p]{x}$ for x**(1/p) is better. Using $x^{\frac{1}{p}}$ by default (the current behavior) would be more consistent because users can easily guess that every case of x**(q/p) will be literally converted to $x^{\frac{q}{p}}$ if the users asked nothing.

@jonbarron
Copy link
Contributor Author

yeah I like that!

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

No branches or pull requests

2 participants