Comments (7)
Although, minimum(f, itr)
"returns the smallest result of calling function f on each element of itr". So it is actually true. But minimum(p)
"returns the smallest element in a collection", i.e., the coefficient, is a little bit unmatched. I guess this is because we treat a polynomial as an iterable.
from polynomials.jl.
Yes, with the newer PR we would have:
cps = Polynomials.critical_points(p) # over the domain of p, includes endpoints
minimum(p, cps) == first(findmin(p, cps))
argmin(p, cps) == cps[last(findmin(p, cps))]
minimum(p) == minimum(coeffs(p))
from polynomials.jl.
I have thought about the API, I will list the one that looks idiomatic to me:
minimum(p, list_of_points)
maximum(p, list_of_points)
returns the smallest/largest result of calling polynomial p
on each element of list_of_points
, which is the current implementation, good!
The only one thing I am not sure is that
minimum(p)
maximum(p)
returns the minimum coefficients and maximum coefficients of p
. It does coincide with the definition in Base
where minimum/maximum
return the smallest/largest element in the collection p
. To me, it is a little bit counterintuitive, so we probably need to warn the users in doc.
findmin(p, domain) -> (p(x), x)
findmax(p, domain) -> (p(x), x)
returns a pair of a value in the codomain (outputs of p
) and the x
in the domain (inputs to p
) such that p(x)
is minimised. If there are multiple minimal points, then the first one will be returned.
That is, findmin
returns the minimum on the domain
. The difference between this and minimum
is that in minimum
, we compute p
on a finite number of points and find their minimum, this minimum may or may not be the local minimum on the range between two endpoints of the range. However, findmin
only takes the maximum and minimum of the domain
, regardless of the type of the domain
. That is, once a domain
is given, findmin
will always return the local minima in the whole range.
argmin(p, domain)
argmax(p, domain)
Similar to findmin/findmax
, return a value x
in the domain of p
for which p(x)
is minimised.
extrema(p, list_of_points)
returns the results of (minimum(p, list_of_points), maximum(p, list_of_points))
. extrema
should be defined regardless of the findmin
and findmax
.
from polynomials.jl.
The current PR has the following docstring:
"""
critical_points(p::AbstractPolynomial{<:Real}, I=domain(p); endpoints::Bool=true)
Return the critical points of p
(real zeros of the derivative) within I
in sorted order.
-
p
: a polynomial -
I
: a specification of a closed or infinite domain, defaulting toPolynomials.domain(p)
. When specified, the values ofextrema(I)
are used with closed endpoints when finite. -
endpoints::Bool
: iftrue
, return the endpoints ofI
along with the critical points
Can be used in conjuction with findmax
, findmin
, argmax
, argmin
, extrema
, etc.
Example
x = variable()
p = x^2 - 2
cps = Polynomials.critical_points(p)
findmin(p, cps) # (-2.0, 2.0)
argmin(p, cps) # 0.0
extrema(p, cps) # (-2.0, Inf)
cps = Polynomials.critical_points(p, (0, 2))
extrema(p, cps) # (-2.0, 2.0)
"""
If you want to suggest edits that would be great. It might be worth commenting how maximum(p) and maximum(p, critical_points(p)) will return different things, the latter in agreement with findmax(p, critical_points(p)) and the former in agreement with maximum(coeffs(p))
from polynomials.jl.
I feel like someone calling minimum(p)
will very rarely, if ever, be looking for the smallest coefficient. It's much more likely they'll be looking for the global minimum, and may think that's what they're getting.
from polynomials.jl.
It's much more likely they'll be looking for the global minimum, and may think that's what they're getting.
Agree. That is what I was thinking.
from polynomials.jl.
A math person might, but a julia person would expect, I believe, that minimum(p)
treats p
like a vector, unlike minimum(f, itr)
which has a function in that first position. Since Polynomial
(and other types) are basically just wrappers around a vector, the view that minimum(p)
treats p
like a vector seems appropriate. We may need some documentation here...
from polynomials.jl.
Related Issues (20)
- docs: advertise composition of polynomials HOT 1
- `ImmutablePolynomial` constructors seem to prevent good type inference HOT 4
- improved implementations of composition of polynomials HOT 4
- bad type inference for composition of `ImmutablePolynomial`s HOT 2
- Should `AbstractPolynomial` subtype `Function`? HOT 2
- Question: is multipliciation of polynomials implemented with FFT HOT 6
- type stability: `(::Polynomial)(::ImmutablePolynomial)` composition yields `ImmutablePolynomial` HOT 2
- polynomials should have `big` methods? HOT 2
- Should `coeffs(::ImmutablePolynomial)` be type-stable? HOT 1
- Feature request: decompose a polynomial HOT 1
- Polynomials.fit fails with InexactError for Rational HOT 2
- Question about using HOT 2
- Warnings and Test failure with Julia 1.10 HOT 2
- Polynomial/Polynomial = Rational or? HOT 1
- (Low priority) Axis offset warning when using OffsetArrays HOT 3
- Conversions to and from RationalFunction broken HOT 3
- MakieCore doesn't need to be in `deps` HOT 12
- Issues with differentiating with respect to polynomial coefficients
- Polynomials.fit changes behavior somewhere between (inclusive) Julia 1.7.3 and Julia 1.10.4, the latter being self-inconsistent (problematic)
- Polynomials requiring MakieCore HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polynomials.jl.