Skip to content

Conversation

@Happypig375
Copy link
Member

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a separate LaTeX-specific priority system for calculus operators (derivative, integral, limit) to position them between addition/subtraction and multiplication/division in the operator precedence hierarchy, while maintaining their original priority for text formats. This improves LaTeX rendering by using parentheses more appropriately.

Changes:

  • Added LatexPriority virtual property to Entity and overridden it in CalculusOperator to return Priority.LatexCalculusOperation
  • Updated all LaTeX rendering code to use LatexPriority instead of Priority for parenthesization decisions
  • Updated test expectations to reflect the new parenthesization behavior (square brackets [] changed to parentheses () in most cases)

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Sources/AngouriMath/Core/Entity/Entity.Definition.cs Added new LatexCalculusOperation priority level (30) between Sum/Minus (20) and Mul/Div (40)
Sources/AngouriMath/Functions/Output/Latex.Definition.cs Added virtual LatexPriority property that defaults to Priority
Sources/AngouriMath/Core/Entity/Continuous/Entity.Continuous.Definition.cs Reorganized and added CalculusOperator abstract base class
Sources/AngouriMath/Core/Entity/Continuous/Entity.Continuous.Calculus.Classes.cs Changed Derivativef, Integralf, and Limitf to inherit from CalculusOperator
Sources/AngouriMath/Functions/Output/Latex/Latex.Calculus.Classes.cs Overrode LatexPriority in CalculusOperator and updated LaTeX rendering logic to use it
Sources/AngouriMath/Functions/Output/Latex/Latex.Arithmetics.Classes.cs Updated all LaTeX rendering to use LatexPriority instead of Priority
Sources/AngouriMath/Functions/Output/Latex/Latex.Discrete.Classes.cs Updated all LaTeX rendering to use LatexPriority instead of Priority
Sources/AngouriMath/Functions/Output/Latex/Latex.Omni.Classes.cs Updated all LaTeX rendering to use LatexPriority instead of Priority
Sources/Tests/UnitTests/Convenience/LatexTest.cs Updated test expectations to match new parenthesization behavior and added new test cases for nested calculus operators

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

(_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf })
or Powf(Number { LatexPriority: Priority.Leaf } or Factorialf(Number { LatexPriority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i"
(var left, var right) => left.LatexPriority >= right.LatexPriority &&
!(left.Priority == Priority.Div && right.LatexPriority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together.
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Inconsistent use of Priority and LatexPriority in the same condition. The left side uses Priority while the right side uses LatexPriority. For consistency with the rest of this PR, left.Priority should be changed to left.LatexPriority.

Suggested change
!(left.Priority == Priority.Div && right.LatexPriority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together.
!(left.LatexPriority == Priority.Div && right.LatexPriority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together.

Copilot uses AI. Check for mistakes.
or Factorialf(Number { Priority: Priority.Leaf } or Variable { IsLatexUprightFormatted: true }), _)) => false,
or Complex { ImaginaryPart.IsZero: false, LatexPriority: >= Priority.Mul } /* don't combine upright "i" with an upright variable*/,
Variable { IsLatexUprightFormatted: true } or Number { LatexPriority: >= Priority.Mul }
or Factorialf(Number { LatexPriority: Priority.Leaf } or Variable { IsLatexUprightFormatted: true })
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Condition always evaluates to 'false'.

Suggested change
or Factorialf(Number { LatexPriority: Priority.Leaf } or Variable { IsLatexUprightFormatted: true })
or Factorialf(Variable { IsLatexUprightFormatted: true })

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Why is this the case?

or Powf(Number { Priority: Priority.Leaf } or Factorialf(Number { Priority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i"
(var left, var right) => left.Priority >= right.Priority &&
!(left.Priority == Priority.Div && right.Priority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together.
(Number { LatexPriority: Priority.Leaf }, { LatexPriority: Priority.Div }) => false,
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Condition always evaluates to 'false'.

Copilot uses AI. Check for mistakes.
or Powf(Number { Priority: Priority.Leaf } or Factorialf(Number { Priority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i"
(var left, var right) => left.Priority >= right.Priority &&
!(left.Priority == Priority.Div && right.Priority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together.
(Number { LatexPriority: Priority.Leaf }, { LatexPriority: Priority.Div }) => false,
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Condition always evaluates to 'false'.

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +75
(_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf })
or Powf(Number { LatexPriority: Priority.Leaf } or Factorialf(Number { LatexPriority: Priority.Leaf }), _)) => false, // Keep the \cdot in "f(x) \cdot -2" "f(x) \cdot 2i" "f(x) \cdot -2i"
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Condition always evaluates to 'false'.

Copilot uses AI. Check for mistakes.
!(left.Priority == Priority.Div && right.Priority == Priority.Div) // Without \cdot, the fraction lines may appear too closely together.
(Number { LatexPriority: Priority.Leaf }, { LatexPriority: Priority.Div }) => false,
// 2 * 3 instead of 2 3 (= 23), 2 * 3^4 instead of 2 3^4 (= 23^4), but "(2+i) 2", "2 (2+i)" and "2 (2+i)^2" are fine with the parentheses - so we have the LatexPriority check.
(_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf })
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Condition always evaluates to 'false'.

Suggested change
(_, Number { LatexPriority: >= Priority.Mul } or Factorialf(Number { LatexPriority: Priority.Leaf })
(_, Number or Factorialf(Number { LatexPriority: Priority.Leaf })

Copilot uses AI. Check for mistakes.
@Happypig375 Happypig375 merged commit b44972d into master Jan 16, 2026
24 checks passed
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.

2 participants