Ask Your Question

bso's profile - activity

2020-08-15 14:51:01 -0600 commented answer Beginner question: How to get y value given x in an equation?

Thanks a million.

Only think I don't understand is how to use sympy: "sympy is able to find a solution".

How do I install sympy? I am on Sage 8.1 running Ubuntu (actually ElementaryOS)

See I'm getting this:

solve(g.subs(x==1/5),y, algorithm="sympy")
[sqrt(y^2 - 4*y + 101/25) == -3/4*sqrt(y^2 + 1/25) + 7/4]
2020-08-15 14:45:05 -0600 received badge  Commentator
2020-08-15 14:45:05 -0600 commented answer Beginner question: How to get y value given x in an equation?

Thank you thank you thank you. You not only solved it, but taught us the way to solve similar problems. Tremendously grateful...

I'll work each step out today.

2020-08-14 17:43:55 -0600 asked a question Beginner question: How to get y value given x in an equation?

Hi, I have an equation like so (I put in some simplifying values for the constants):

var('h1 h2 x y n')
n = 4/3
h1 = 1
h2 = 1
g = sqrt(x^2 + y^2) + n * sqrt(x^2 + (h1 + h2 - y)^2) - (h1 + n * h2) == 0

I am able to get a beautiful implicit plot:

graph = implicit_plot(g, (x, -0.5, 0.5), (y, 0, 2.5))
show(graph)

But how do I find out the numerical values at say x = 0.2? This doesn't give numerical values (and I don't really understand its result either):

solve(g(x=0.2), y)

It gives

[sqrt(y^2 - 4*y + 101/25) == -3/4*sqrt(y^2 + 1/25) + 7/4]

Thanks

2020-02-13 11:07:59 -0600 commented answer gen_lengendre_p bug

Like. Thanks.

2020-02-13 11:07:11 -0600 received badge  Supporter (source)
2020-02-12 19:38:42 -0600 answered a question gen_lengendre_p bug

Thanks, Eric_G. I am interested to help out. Is there a page with Sage volunteering process? I will sign up. I have computer science degrees but new to math (but seriously interested to learn).

Correct definition:

def legendre_function(l, m, f):
    return ((-1)^m * (1 - x^2)^(m/2) * diff(legendre_P(l, x), x, m)).subs(x = f)

sage: legendre_function(2, 2, x)
-3*x^2 + 3

sage: legendre_function(2, 2, cos(x))
-3*cos(x)^2 + 3
2020-02-12 11:40:28 -0600 asked a question gen_lengendre_p bug

Hi, wonder if someone here familiar with associated Legendre function can verify:

sage: gen_legendre_P(2, 2, x)
3*x^2 - 3

I think it should be

3 - 3*x^2

In Sage 8.9

Thanks

2020-01-09 14:39:08 -0600 commented answer How to print trailing spaces?

Thanks. Extremely useful for fine grain control.

2020-01-08 23:02:24 -0600 commented answer How to print trailing spaces?

Very interesting. Thanks.

2020-01-08 19:49:08 -0600 commented question Running Sage in Bash

Actually .py suffix should work too. I just notice this:

[bryanso@localhost ~]$ sage -help
SageMath version 8.8, Release Date: 2019-06-26

Optional arguments:
  file.[sage|py|spyx] -- run given .sage, .py or .spyx file
...
2020-01-08 19:45:35 -0600 commented question Running Sage in Bash

If you have a file with Sage commands, make sure you name the file with .sage suffix.

At least in Linux, I can do this:

[bryanso@localhost ~]$ cat test.sage
f = sin(x) / x
d = diff(f, x)
show(d)

[bryanso@localhost ~]$ sage test.sage
cos(x)/x - sin(x)/x^2
2020-01-08 12:33:35 -0600 commented answer How to print trailing spaces?

Nice. Thanks!

2020-01-08 11:54:20 -0600 received badge  Nice Question (source)
2020-01-08 11:19:15 -0600 received badge  Organizer (source)
2020-01-08 11:07:11 -0600 asked a question How to print trailing spaces?

Pretty_Print / show seems to delete trailing spaces:

reset()
var('x t')
Psi = function('Psi')(x, t)
V = function('V')(x)
show('Plug ', Psi, ', ', diff(Psi, t), ', ', diff(Psi, x, x), ' into ', V)

See after "Plug" and after "into" (screenshot taken from CoCalc Jupyter Sage 8.9 Kernel): image description

2020-01-07 09:13:12 -0600 commented answer Simple Integration Problem

Thanks a lot.

2020-01-06 23:56:49 -0600 commented question Simple Integration Problem

Hi desjas, all of your test cases return the same way in Sage 8.0 My problem does not happen in 8.0. I actually tried a few versions up to 8.8. All good. It started in 8.9. So logically I tend to think your test cases may not help pinpoint the error I observed.

The follow also errors out. This test does not have conjugate.

var('x t')
f = function('f')(x, t)
g = function('g')(x, t)
integrate(g * diff(f, x), x)
2020-01-06 13:42:02 -0600 commented question Simple Integration Problem

That clearly looks like a bug.

But I am not sure if it is directly related to my problem, which has the same variable x for diff and integrate.

But thanks for pointing out this new situation.

2020-01-06 08:07:47 -0600 received badge  Good Question (source)
2020-01-06 04:33:50 -0600 received badge  Nice Question (source)
2020-01-05 18:01:26 -0600 asked a question Simple Integration Problem

Hi, these simple steps used to work in Sage 8.0. They now give an error in 8.9. I tried in CoCalc, same problem. Do I need to change anything? If this is a Sage regression, how can I work around it? Thanks.

Sage 8.0 behavior:

sage: var('x t')
(x, t)

sage: psi = function('psi')(x, t)

sage: integrate(conjugate(psi) * diff(psi, x), x)
integrate(conjugate(psi(x, t))*diff(psi(x, t), x), x)

In 8.9 it gives:

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.9, Release Date: 2019-09-29                     │
│ Using Python 2.7.15. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x t')
(x, t)
sage: psi = function('psi')(x, t)
sage: integrate(conjugate(psi) * diff(psi, x), x)
---------------------------------------------------------------------------
...
ValueError: No differentiation variable specified.

Posting the complete trace below:

sage: var('x t')
(x, t)
sage: psi = function('psi')(x, t)
sage: integrate(conjugate(psi) * diff(psi, x), x)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-13afb3c477cd> in <module>()
----> 1 integrate(conjugate(psi) * diff(psi, x), x)

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/misc/functional.pyc in integral
(x, *args, **kwds)
    751     """
    752     if hasattr(x, 'integral'):
--> 753         return x.integral(*args, **kwds)
    754     else:
    755         from sage.symbolic.ring import SR

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage
.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:64036
)()
  12360                     R = ring.SR
  12361             return R(integral(f, v, a, b, **kwds))
> 12362         return integral(self, *args, **kwds)
  12363
  12364     integrate = integral

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.p
yc in integrate(expression, v, a, b, algorithm, hold)
    912         return integrator(expression, v, a, b)
    913     if a is None:
--> 914         return indefinite_integral(expression, v, hold=hold)
    915     else:
    916         return definite_integral(expression, v, a, b, hold=hold)

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/function.pyx in sage.s
ymbolic.function.BuiltinFunction.__call__ (build/cythonized/sage/symbolic/function.cpp:11847)
()
    996             res = self._evalf_try_(*args)
    997             if res is None:
--> 998                 res = super(BuiltinFunction, self).__call__(
    999                         *args, coerce=coerce, hold=hold)
   1000

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/function.pyx in sage.s
ymbolic.function.Function.__call__ (build/cythonized/sage/symbolic/function.cpp:6927)()
    490                     (<Expression>args[0])._gobj, hold)
    491         elif self._nargs == 2:
--> 492             res = g_function_eval2(self._serial, (<Expression>args[0])._gobj,
    493                     (<Expression>args[1])._gobj, hold)
    494         elif self._nargs == 3:

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.p
yc in _eval_(self, f, x)
     92         for integrator in self.integrators:
     93             try:
---> 94                 A = integrator(f, x)
     95             except (NotImplementedError, TypeError):
     96                 pass

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/integration/external.p
yc in sympy_integrator(expression, v, a, b)
     66     else:
     67         result = sympy.integrate(ex, (v, a._sympy_(), b._sympy_()))
---> 68     return result._sage_()
     69
     70 def mma_free_integrator(expression, v, a=None, b=None):

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/interfaces/sympy.pyc in _sympys
age_integral(self)
    307     """
    308     from sage.misc.functional import integral
--> 309     f, limits = self.function._sage_(), list(self.limits)
    310     for limit in limits:
    311         if len(limit) == 1:

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/interfaces/sympy.pyc in _sympys
age_mul(self)
    204     s = 1
    205     for x in self.args:
--> 206         s *= x._sage_()
    207     return s
    208

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/interfaces/sympy.pyc in _sympys
age_derivative(self)
    333     f = self.args[0]._sage_()
    334     args = [[a._sage_() for a in arg] if isinstance(arg,tuple) else arg._sage_() for
arg in self.args[2:]]
--> 335     return derivative(f, *args)
    336
    337 def _sympysage_order(self):

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/calculus/functional.pyc in deri
vative(f, *args, **kwds)
    129     """
    130     try:
--> 131         return f.derivative(*args, **kwds)
    132     except AttributeError:
    133         pass

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage
.symbolic.expression.Expression.derivative (build/cythonized/sage/symbolic/expression.cpp:255
45)()
   4172             ValueError: No differentiation variable specified.
   4173         """
-> 4174         return multi_derivative(self, args)
   4175
   4176     diff = differentiate = derivative

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/misc/derivative.pyx in sage.mis
c.derivative.multi_derivative (build/cythonized/sage/misc/derivative.c:3016)()
    217     if not args:
    218         # fast version where no arguments supplied
--> 219         return F._derivative()
    220
    221     for arg in derivative_parse(args):

/home/bryanso/sage-8.9/local/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage
.symbolic.expression.Expression._derivative (build/cythonized/sage/symbolic/expression.cpp:25
887)()
   4234                 return self.gradient()
   4235             else:
-> 4236                 raise ValueError("No differentiation variable specified.")
   4237         if not isinstance(deg, (int, long, sage.rings.integer.Integer)) \
   4238                 or deg < 1:

ValueError: No differentiation variable specified.
2019-12-26 23:40:50 -0600 received badge  Famous Question (source)
2019-12-26 23:40:50 -0600 received badge  Notable Question (source)
2018-11-25 14:25:39 -0600 received badge  Popular Question (source)
2017-11-21 13:24:17 -0600 received badge  Nice Answer (source)
2017-11-13 03:33:31 -0600 received badge  Self-Learner (source)
2017-11-13 03:33:31 -0600 received badge  Teacher (source)
2017-11-13 03:33:29 -0600 received badge  Nice Question (source)
2017-11-13 00:24:07 -0600 answered a question How To Accept Remote Network Connection

I found the answer myself... writing it up here in case other Mac users have the same question:

Edit the file /Applications/SageMath-8.0.app/Contents/Resources/sage/local/etc/jupyter/jupyter_notebook_config.py so that it has the following line somewhere:

c.NotebookApp.ip = '*'

Restart Sage App afterwards.

2017-11-09 14:11:46 -0600 received badge  Student (source)
2017-11-09 14:10:53 -0600 asked a question How To Accept Remote Network Connection

Hi, I use Mac OS's native Sage App. I can access Sage's Jupyter notebook from that Mac using localhost:8888. I researched a bit and find out if another computer needs to browse the same Jupyter notebook, one needs to start juypter by passing --ip '*' (otherwise it only accepts localhost traffic and will give a Connection Refused error).

But since I am clicking a Mac OS Sage icon to start the server... I am not sure how I can specify the command line option. Please give me some hints.

Thanks