Skip to content

Make expression comparison more thorough#3503

Open
benchristel wants to merge 3 commits intomainfrom
benc/expression-widget-scoring
Open

Make expression comparison more thorough#3503
benchristel wants to merge 3 commits intomainfrom
benc/expression-widget-scoring

Conversation

@benchristel
Copy link
Copy Markdown
Member

Summary:

Content creators reported a bug in an expression widget where the correct
answer was -x / sqrt(1-x^2). You could put anything in the numerator and your
answer would (usually) be marked correct.

The bug happened because of the nondeterministic (and not very thorough) way
that we compared expressions. Previously, we selected 12 random variable
bindings and checked that the two expressions evaluated the same for all of
them. Some effort was made to cover different orders of magnitude, but simple
values like -1, 0, and 1 were not always checked.

This meant that for expressions with a restricted domain, like -x / sqrt(1 - x^2) (which is only defined in the interval [-1, 1]), we might check only
variable bindings for which the expression was not defined.

Expressions are now compared more thoroughly. Now we always check that the
expressions evaluate the same with all variables bound to -1, 0, and 1. We also
check more randomly-chosen values: 28 instead of 12.

Summary:

Issue: LEMS-4042

Test plan:

The expression in this article should be scored correctly:
https://www.khanacademy.org/devadmin/content/articles/arc-length-of-function-graphs-examples/x615e6443

… compared more thoroughly. Now we always check that the expressions evaluate the same with all variables bound to -1, 0, and 1. We also check more randomly-chosen values: 28 instead of 12.
@benchristel benchristel self-assigned this Apr 16, 2026
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

Size Change: +100 B (+0.02%)

Total Size: 499 kB

📦 View Changed
Filename Size Change
packages/kas/dist/es/index.js 20.6 kB +100 B (+0.49%)
ℹ️ View Unchanged
Filename Size
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.36 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 11.9 kB
packages/perseus-core/dist/es/index.js 25.1 kB
packages/perseus-editor/dist/es/index.js 102 kB
packages/perseus-linter/dist/es/index.js 9.3 kB
packages/perseus-score/dist/es/index.js 9.7 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 196 kB
packages/perseus/dist/es/strings.js 8.27 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (821b13d) and published it to npm. You
can install it using the tag PR3503.

Example:

pnpm add @khanacademy/perseus@PR3503

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3503

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant