Skip to content

Fixed function exponentiation not being parsed correctly - #266

Merged
m-messer merged 1 commit into
lambda-feedback:mainfrom
MadScientistBR:fix/func_exp
Jul 27, 2026
Merged

Fixed function exponentiation not being parsed correctly#266
m-messer merged 1 commit into
lambda-feedback:mainfrom
MadScientistBR:fix/func_exp

Conversation

@MadScientistBR

Copy link
Copy Markdown
Contributor

Problem

sec2(x)** and sec^2(x) were treated as invalid. Therefore, the users had to manually write sec(x)^2 to get sec^2(x).

Turns out this was a SymPy parser configuration issue: the function_exponentiation transformation, which rewrites f**n(x) as f(x)**n, isn't enabled by default and has to be explicitly included.

Changes

  • app/utility/expression_utilities.py: We explicitly pass the function_exponentitation transformation to the SymPy parser in function parse_expression (line 813 and 815).
  • app/tests/symbolic_evaluation_test.py: added test cases covering all supported trig/hyperbolic functions.

Closes issue #257.

@m-messer

Copy link
Copy Markdown
Member

Thanks, @MadScientistBR, for the contribution. I ran the change against our dataset (https://github.com/lambda-feedback/compareExpressions/actions/runs/30247364907). The 50 network errors are from AWS blocking parallelised requests, and the remaining 36 errors are unrelated to this change.

@peterbjohnson, I have reviewed the change, and it is well implemented. I have also tested it on the platform, and the elementary functions when squared, such as sec^2(x) and sin^2(x), all preview and evaluate correctly.

@peterbjohnson peterbjohnson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work, thank you for the contribution!

@m-messer
m-messer merged commit bf0dc00 into lambda-feedback:main Jul 27, 2026
10 of 11 checks passed
@m-messer m-messer mentioned this pull request Jul 27, 2026
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

Successfully merging this pull request may close these issues.

3 participants