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

Simplifying acos(0/1), asin(0,1) and anything + 0 #1264

Merged
merged 14 commits into from
Sep 14, 2024

Conversation

n0rbed
Copy link
Member

@n0rbed n0rbed commented Sep 6, 2024

as discussed here, acos(0) should be simplified.

@codecov-commenter
Copy link

codecov-commenter commented Sep 6, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 91.17647% with 3 lines in your changes missing coverage. Please review.

Project coverage is 80.46%. Comparing base (47cfd60) to head (eb664af).
Report is 115 commits behind head on master.

Files with missing lines Patch % Lines
src/solver/postprocess.jl 89.28% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1264       +/-   ##
===========================================
+ Coverage    8.30%   80.46%   +72.15%     
===========================================
  Files          46       47        +1     
  Lines        4549     4663      +114     
===========================================
+ Hits          378     3752     +3374     
+ Misses       4171      911     -3260     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 116 to 124
if any(isequal(oper, o) for o in opers) && isempty(Symbolics.get_variables(x))
val = eval(Symbolics.toexpr(x))
for i in eachindex(exacts)
exact_val = eval(Symbolics.toexpr(exacts[i]))
if isapprox(exact_val, val, atol=1e-6)
return exacts[i]
elseif isapprox(-exact_val, val, atol=1e-6)
return -exacts[i]
end
Copy link
Member Author

Choose a reason for hiding this comment

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

this is easier to extend id think, just add more exacts into exacts and the loop will check if the asin, acos, or atan evaluate into it

Copy link
Member

Choose a reason for hiding this comment

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

then make it a function

Copy link
Member Author

Choose a reason for hiding this comment

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

okok

Copy link
Member Author

Choose a reason for hiding this comment

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

done, and changed eval -> symbolic_to_float

@@ -122,3 +135,33 @@ function postprocess_root(x)
end
x # unreachable
end

function check_trig_consts(x)
Copy link
Member

Choose a reason for hiding this comment

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

Missing a docstring, and should add to the docs

Also, is the name correct? For example, why not add e to this?

Copy link
Member Author

Choose a reason for hiding this comment

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

wdym e?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also adding this to the docs is a bit weird. Used only once and the user wouldnt really care. Some other functions like filter_poly are much more interesting. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

A general function for taking floats to common symbolic constants has lots of other uses?

Copy link
Member Author

Choose a reason for hiding this comment

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

its the reverse but yes ok makes sense

Copy link
Member

Choose a reason for hiding this comment

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

This conversation was not resolved. Why was it merged?

Copy link
Member Author

Choose a reason for hiding this comment

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

check the latest couple of commits, added a small docstring and made the array a const

@n0rbed n0rbed merged commit 734dd60 into JuliaSymbolics:master Sep 14, 2024
11 checks passed
@n0rbed n0rbed deleted the trig_issue branch October 29, 2024 16:35
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