Re: [sympy] Names that aren't unique

2021-04-12 Thread 'Bruce Allen' via sympy
Hi Oscar, It wouldn't be hard to make any new definition of a Symbol with the same name as a previously created symbol raise an error but it would break the assumption that it is okay to define a symbol that is only used local to some context and that assumption is depended on by many users and

Re: [sympy] Names that aren't unique

2021-04-12 Thread 'Bruce Allen' via sympy
Hi David, However, my feeling is that some proportion of SymPy users will work interactively - in one scope - without defining any Python functions. So they might calculate a polynomial without regard to any assumptions, and then wish to apply an assumption for one specific calculation and

Re: [sympy] Names that aren't unique

2021-04-11 Thread 'Bruce Allen' via sympy
Hi David, Thanks for picking this up. I wanted to comment that in your example, the two symbols are defined differently: Symbol("x", positive=True) Symbol("x") that is to say, with different assumptions. For the issue that I was reporting, the two symbols that were defined with identical

[sympy] behavior of asec()

2021-04-08 Thread 'Bruce Allen' via sympy
Dear Sympy developers, This is not a serious issue, but I wanted to flag it. According to the documentation (and IMO correctly): acos(x) = asec(1/x) So I was surprised to see the contrast between: >>> acos(Rational(1,2)) pi/3 >>> asec(Rational(2,1)) asec(2) I would expect the previous

Re: [sympy] Why does subs() not work as expected - a related question ?

2021-04-07 Thread 'Bruce Allen' via sympy
15:55, Oscar Benjamin wrote: On Wed, 7 Apr 2021 at 14:43, 'Bruce Allen' via sympy wrote: David, Oscar, Thank you for your help. Oscar, the list 'u' was created in the course of a calculation, and saved as a .pkl file. I then reloaded it and want to manipulate the saved equations, of which u[7

Re: [sympy] Why does subs() not work as expected - a related question ?

2021-04-07 Thread 'Bruce Allen' via sympy
David, Oscar, Thank you for your help. Oscar, the list 'u' was created in the course of a calculation, and saved as a .pkl file. I then reloaded it and want to manipulate the saved equations, of which u[7] is an example. I found an even cleaner example, see below. I have the impression

[sympy] Why does subs() not work as expected ?

2021-04-07 Thread 'Bruce Allen' via sympy
I have a very basic sympy question, which has me stumped, and am hoping that someone here can set me straight. I have an expression for which subs() seems to have no effect: >>> a=Symbol('a', real=True, positive=True) >>> q=u[7] >>> q -a*(45*a**18 - 120*a**16 + 240*a**12 - 504*a**8 +

Re: [sympy] Re: Simplifying expressions involving the Abs function

2021-04-03 Thread 'Bruce Allen' via sympy
[NOTE: I mistakenly sent several replies to individuals rather than to the group. Several are moot, but I did not want to leave them off-list. So I am resending below. Sorry about that! Bruce] Dear Aaron, Thank you again for your help. I found the solution to my problem (which involves

Re: [sympy] Re: Simplifying expressions involving the Abs function

2021-04-03 Thread 'Bruce Allen' via sympy
[NOTE: I mistakenly sent several replies to individuals rather than to the group. Several are moot, but I did not want to leave them off-list. So I am resending below. Sorry about that! Bruce] Dear Chris, THANK YOU! That's an excellent solution for me. I did not know about it and

Re: [sympy] Re: Simplifying expressions involving the Abs function

2021-04-03 Thread 'Bruce Allen' via sympy
[NOTE: I mistakenly sent several replies to individuals rather than to the group. Several are moot, but I did not want to leave them off-list. So I am resending below. Sorry about that! Bruce] Hi Oscar, Thanks for the quick reply. The symbol 'a' is declared to be real and positive. But

Re: [sympy] Re: Simplifying expressions involving the Abs function

2021-04-03 Thread 'Bruce Allen' via sympy
[NOTE: I mistakenly sent several replies to individuals rather than to the group. Several are moot, but I did not want to leave them off-list. So I am resending below. Sorry about that! Bruce] Hi Oscar, Thanks for your comments. def MyAbs(x): x1=symbols('x1',real=True,positive=True)

Re: [sympy] Re: Simplifying expressions involving the Abs function

2021-03-31 Thread 'Bruce Allen' via sympy
Dear Chris, On 31.03.21 05:48, Chris Smith wrote: Oscar posted code at issue https://github.com/sympy/sympy/issues/19164 for a interva-based Newton solver. Thank you, that's very useful. I didn't know about interval arithmetic. I just implemented the following, which works very well and

Re: [sympy] Re: Simplifying expressions involving the Abs function

2021-03-30 Thread 'Bruce Allen' via sympy
Hi Aaron, This section of the tutorial may help to clear things up https://docs.sympy.org/latest/tutorial/gotchas.html. This blog post also goes into more detail about how variables work in Python https://nedbatchelder.com/text/names.html. Thanks for the pointers. I'll study them. What I

Re: [sympy] Re: Simplifying expressions involving the Abs function

2021-03-30 Thread 'Bruce Allen' via sympy
Hi Aaron, Thanks for your help! def MyAbs(x): x1=symbols('x1',real=True,positive=True) x1 = x.evalf(subs={a:0.573}) if x1 < 0.0: return S(-1)*x else: return x - Defining x1 as a symbol does nothing in this code, as you immediately overwrite it with