Skip to content

Modelica.Math.Special.{der(erf), der(erfc)} - #4753

Open
AHaumer wants to merge 6 commits into
modelica:masterfrom
AHaumer:erf
Open

AHaumer wants to merge 6 commits into
modelica:masterfrom
AHaumer:erf

Conversation

@AHaumer

@AHaumer AHaumer commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

I noticed that the derivatives of erf and erfc are missing but can be easily defined.
Important if using erf in model equations or for index reduction, since erf is non-trivial.
Although it's a bug if one needs the derivative this is an enhancement.

@AHaumer AHaumer added this to the maintenance milestone Feb 27, 2026
@AHaumer AHaumer added enhancement New feature or enhancement L: Math Issue addresses Modelica.Math labels Feb 27, 2026

@casella casella left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@AHaumer, in the testing, we need to prove that the derivatives provided by the derivative annotation are very precise. Reference signals are not good for that, because CSV-compare if rather tolerant.

I would suggest to remove the comparison signals entirely, and instead

  • select a much tighter tolerance, e.g 1e-9, for the simulation of TestErf
  • add two asserts in the equation section of the TestErf such as
assert(abs(y1i - y1) < 1e-7, "The derivative function for erf is not correct");
assert(abs(y2i - y2) < 1e-7, "The derivative function for erfc is not correct");

If the test model runs successfully, then by construction it means the derivative is computed with high accuracy.

@HansOlsson

Copy link
Copy Markdown
Contributor

And also add annotation(smoothOrder=100) or similarly for these derivative-functions.
That way all tools can differentiate them as much as needed.

@AHaumer
AHaumer requested a review from casella March 3, 2026 09:48
@AHaumer
AHaumer enabled auto-merge March 3, 2026 09:48
@AHaumer

AHaumer commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

@casella @HansOlsson I integrated your recommendations, but I kept 2 comparison signals.

This branch has not been deployed

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

Labels

enhancement New feature or enhancement L: Math Issue addresses Modelica.Math

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants