To send us your changes, the best way is to use git. See
[https://github.com/sympy/sympy/wiki/Getting-the-bleeding-edge] for a
start.
> I'm working on the vectorization of subs.
>
> Will make it possible that one can give a list of substitutions for a
> variable.
> for example,
>
> x=Symbol('x')
> e=x**2
> a=[1,2,3]
> b=e.subs(x,a)
> print(b)
>
> will give
>
> [1,4,9]
>
> But this is very easy. What more features are required ?
>
Well, I don't think this change is a good thing, cf.
[http://code.google.com/p/sympy/issues/detail?id=1743] and I think that
the issue should just be closed. Sorry about that.
If this was a valid issue, nothing more would be required. That's what
"EasyToFix" means. You are just supposed to add test(s) for the new
feature and run all tests to check that nothing breaks.
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>
For issue 2200, we didn't decide if limit(sin(x), x, oo) should raise an error or should return nan (or something else).
Aaron Meurer
On Mar 17, 2011, at 1:25 PM, Chris Smith wrote:
> SherjilOzair wrote:
>> Mr. Ronan,
>> You've been a great help. Please help me start up my suggesting me a
>> small project or patch.
>> I would be very grateful.
>>
> Issue 2180, 2198 or 2200.
>
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
It is sin(x), not sin(x)/x that has the problem. This continues to oscillate between `+/-1` regardless of how large x becomes.
Hello Hector,limit(sin(x),x,oo) means sin(x) evaluated, as x approaches to infinity from default positive side.
It is an oscillatory limit, equal to k and not k/oo, where k can be anything in [-1,1].The answer should be Nan, and not an error, as then, sympy would be more robust, and users will be able to use the math.isnan() function to check if a limit is defined or undefined.
Regards,Sherjil
> Now mathematically, limit x tending to 0, abs(x)/x should not exist.
Why not? (tendind from the right.)
Consider definition of limit:
"the limit of f as x approaches 0 is L if and only if for every real ε >
0 there exists a real δ > 0 such that 0 < x < δ implies | f(x) − L | < ε"
Yes, abs(x)/x at point 0 is not well defined, but the limit with this
definition still exists.
The same with sin(x)/x (but in this case there is question whether this
function analytical or not, abs(x)/x is not).
--
Alexey U.
According strict mathematical definition of limits at infinity limit in
this case is not exists.
But, the nature aim of "limit" is the answer what is the behavior of
function in infinity.
So the question is only to determine the way how to tell to the user
that sin(x) has arbitary value in range [-1, 1].
I offer split into steps of realization:
1. If limit is not exist then return Non or something else
It is requirement.
2. If it is possible to known range ([-1, 1]) as in the sin(x) at oo
example, then return it.
But it is enchantment.
--
Alexey U.
Actually, SymPy computes limits from a single direction (from the right by default). I think there was an issue once to implement limit from both directions (it would basically check '+' and '-' and return the result only if they matched), but I can't find it now.
Aaron Meurer
18.03.2011 12:49, Hector пишет:Why not? (tendind from the right.)
Now mathematically, limit x tending to 0, abs(x)/x should not exist.
Consider definition of limit:
"the limit of f as x approaches 0 is L if and only if for every real ε > 0 there exists a real δ > 0 such that 0 < x < δ implies | f(x) − L | < ε"
Yes, abs(x)/x at point 0 is not well defined, but the limit with this definition still exists.
The same with sin(x)/x (but in this case there is question whether this function analytical or not, abs(x)/x is not).
--
Alexey U.
--You received this message because you are subscribed to the Google Groups "sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
As I understand smichr/2084 is merged with master already?
So in master branch it is ok now:
In [2]: limit(abs(x)/x, x, 0, dir="+")
Out[2]: 1
In [3]: limit(abs(x)/x, x, 0, dir="-")
Out[3]: -1
--
Alexey U.
Hi,
> When we say - "the limit of f as x *approaches* 0 ", we are allowing x to
> approach 0 from any side. ( Here are only two ways of approaching to 0 viz
> '+ve' and '-ve' but its not true always. For function f(x,y) there are
> infinitely many ways of approaching to (0,0)).
Yes, it is a complexity (which involve "Directional derivative", or
"Directional limit") in case of many variable.
Now in sympy only right and left limits as you cited:
"""For dir="+" (default) it calculates the limit from the right"""
> So when x approaches from +ve side the value of function will approach to +1
> and when it approaches from -ve side the value of function approaches to -1
> and you will never be able to find L in your definition.
> Hope the attachment will make my point clear.
Now implemented dir="+" as default (in master branch of git repository):
In [2]: limit(abs(x)/x, x, 0)
Out[2]: 1
In [3]: limit(abs(x)/x, x, 0, dir="-")
Out[3]: -1
From your remarks I see that you want to define dir="unknown" or
dir="both" as default. And in this case of 'dir' limit should return
"None" for "abs(x)/x" (when result differ between dir="-" and dir="+").
Right?
>
>
>
--
Alexey U.
Sorry, I have not understand instantly what you mean.
But in the message to Hecter it seems that I understand what you mean
indeed:
--
Alexey U.
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>> From your remarks I see that you want to define dir="unknown" or dir="both"
>> as default. And in this case of 'dir' limit should return "None" for
>> "abs(x)/x" (when result differ between dir="-" and dir="+"). Right?
>>
>>
>>
> Yes, exactly.
> It seems more consistent that way. Has this issue already been discussed? If
> not, do we need to report this?
> Since I am looking forward to apply for GSoC, and would love to work with
> SymPy, this would be good start for me.
>
> If core developers/contributors agree, I would like to work on this
> regardless GSoC. Because with thing implemented, we can never go for limit
> of multi-variable functions.
>
I don't know now the situation with organization of limit's branches
exactly (on some of them the job can be proceeding now).
Chris Smith or others can up to date about it.
And, as I understand, the algorithm of this behavior implementation
seems to be easy in real axes - it differ dir="+" and dir="-".
And, we must determine a little things, which variant is more convenient:
dir="unknown" | "both" | "any"
I tend to "unknown", "any" (keeping in mind multi variable case), though
one can imagine further the distinguish between "any" and "unknown":
>>> limit(abs(x)/x, x, 0, dir="+")
1
>>> limit(abs(x)/x, x, 0, dir="unknown")
None
>>> limit(abs(x)/x, x, 0, dir="any")
[{-1: dir="-"}, {1: dir="+"] # something like cases as Piecewise
(But towards to the future for multi variable cases, and *even for
complex variable* the algorithm it seems should be more intelligent)
That is all what I can write about this theme.
I think in a few hours, after others will add some remarks, issues will
be ready.
--
Alexey U.
You have a better memory for these things than me, but I wonder if you would have seen an implementation of the checking of roots for equations that I did where I used this sort of approach (as I recall).
/c
I agree that returning nan is better than raising an error. As to returning the range, I think it requires some more thought. If limit() return a Set object instead of an expression, then that might break a lot of things that expect an expression. Also, there are some other questions:
- How exactly are we defining the set returned. Is it a tight bound set as the function goes to infinity, or is it just the closed set [lim inf f(x), lim sup f(x)]? The two are the same if the function is continuous, but for a counterexample, consider a combination of two of the functions discussed in this thread, abs(sin(x))/sin(x). This function takes on values of 1 and −1 forever to infinity. Would limit(abs(sin(x))/sin(x)) return [-1, 1] or set([-1, 1])?
- Are there any algorithms to compute these things?
- What does the interface look like?
Aaron Meurer
Search the issues, and if you can't find it, go ahead and open a new one. I remember suggesting this before in the issues, but it might have just been in a comment.
By the way, we look forward to seeing you apply for GSoC!
Aaron Meurer
> Yes, exactly.
> It seems more consistent that way. Has this issue already been
> discussed? If not, do we need to report this?
> Since I am looking forward to apply for GSoC, and would love to work
> with SymPy, this would be good start for me.
>
> If core developers/contributors agree, I would like to work on this
> regardless GSoC. Because with thing implemented, we can never go for
> limit of multi-variable functions.
I thought about this before, but I didn't reach the point where I could
suggest a design.
I think there needs to be an object describing the "destination" of a
limit (i.e. "0", "0+", "0-", "+oo", ...), so the syntax for limit would
be limit(f(x), x, <something that means "0+">) instead of limit(f(x), x,
0, dir="+"). These destination objects would also be used by series()
and the like and would be passed around in the internal code.
The proper mathematical notion corresponding to this is a filter[*]. It
applies also in the multivariate case and allows to describe limits when
|(x,y)| -> 0, or when (x,y) -> (0,0) along a particular ray or some more
complicated curve, etc.
[*]: See http://fr.wikipedia.org/wiki/Filtre_%28math%C3%A9matiques%29
(in French) - I couldn't find a good description in English. The
en.Wikipedia article in particular is so full of category-theoretic
abstract nonsense as to be useless.
Isn't a filter some kind of set of subsets that satisfies some properties? One of my professors introduced these to me when describing the hyperreal system. But I don't understand how that lets you define a "limit path" like you want.
And I really don't understand how that could help with an implementation. I remember that when using filters to describe the hyperreal system, you have to use the axiom of choice to get what you want, i.e., it is only useful as a theoretical tool.
Aaron Meurer
Yes, it's a set F of subsets with the properties "Union(A, B) is in F
for any A, B in F" and "if A is in F and B contains A, then B is in F",
but you don't need the axiom of choice to define or use them.
Basically, the limit of f along a filter F is y0 iff y0 is in the
adherence of f(A) for every A in F (and is the only such point).
For instance, the filter that defines the limit of a function in 0+ is
the set of parts of R that contain an interval ]0, r[, with r>0.
But the actual definition of filters isn't terribly important for us -
besides the fact that it exists and is consistent. What matters is that
it captures well the notion of limit and that it's possible to do some
arithmetic with them (1/0+ = +oo, 0- * 0- = 0+, ...)
> Aaron Meurer
>
What is the adherence of f(A)?
By the way, I think the axiom of choice is needed to choose a filter on R to use for a set of equivalence classes for the hyperreals (something like that).
>
> But the actual definition of filters isn't terribly important for us -
> besides the fact that it exists and is consistent. What matters is that
> it captures well the notion of limit and that it's possible to do some
> arithmetic with them (1/0+ = +oo, 0- * 0- = 0+, …)
Yes, I think this is similar to the hyperreals. It seems to me like your 0+ is like an infinitesimal.
Aaron Meurer
>
>
>
>> Aaron Meurer
>>
Yes.
> Also, there are some other questions:
>
> - How exactly are we defining the set returned. Is it a tight bound
> set as the function goes to infinity, or is it just the closed set
> [lim inf f(x), lim sup f(x)]? The two are the same if the function
> is continuous, but for a counterexample, consider a combination of
> two of the functions discussed in this thread, abs(sin(x))/sin(x).
> This function takes on values of 1 and −1 forever to infinity. Would
> limit(abs(sin(x))/sin(x)) return [-1, 1] or set([-1, 1])?
>
> - Are there any algorithms to compute these things?
>
> - What does the interface look like?
>
> Aaron Meurer
>
Now in sympy:
In [1]: limit(sin(1/x), x, 0)
Out[1]: sin(oo)
In [2]: limit(sin(x), x, oo)
Out[2]: sin(oo)
Though it is incorrect (strictly saying limit is not exists
mathematically), but I see that some embryo intelligence present now too.
I think that when CAS (Matlab as I remember you said) return only
segment [-1, 1] it is more advertising of intelligence possibility than
pure mathematic.
I check Wolfram Alfa [1]: its result is more accurate. It returns that
limit is undefined, and it is essential singularity ([2], [3]) and
describe interval too.
I think that analytic about singularity will be useful in sympy too.
But I a still tend to destinguish it from pure mathematical limit()
procedure.
So I see a few similar variants:
# variant 1
>>> limit(sin(x), x, oo)
None
but there is method about singularity analysis (with classification of
it) in sympy, f.e.
>>> singularity(sin(x), x, oo)
Singularity(type="essential", interval=[-1, 1])
# variant 2
if limit is not exists then it return Singularity expression right
immediately
In both variant encapsulation of singularity analysis to singularity()
and Singularity class is used. So issue for singularity can be separeted
from limit (especially first).
About algorithms, first of all I think that Chris is more specialist
about it, I supposed that algorithm is combination of series's analysis and
some recurrent for interval (f.e. (sin(oo))**2 consecutively yield [0,
1]) involved.
[1] http://www.wolframalpha.com/input/?i=limit%28sin%28x%29%2C+x%2C+oo%29
[2] http://en.wikipedia.org/wiki/Classification_of_discontinuities
[3] http://en.wikipedia.org/wiki/Mathematical_singularity
--
Alexey U.