Ask Your Question

sgia's profile - activity

2017-03-12 19:34:01 -0500 received badge  Notable Question (source)
2016-07-22 18:08:59 -0500 received badge  Famous Question (source)
2015-10-28 22:10:00 -0500 received badge  Notable Question (source)
2014-12-04 21:35:32 -0500 received badge  Popular Question (source)
2014-04-27 06:38:41 -0500 received badge  Popular Question (source)
2013-04-20 15:43:34 -0500 received badge  Nice Question (source)
2013-04-20 11:07:12 -0500 asked a question Sage cannot simplify arccos, but can simplify arcsin?

I am using Sage 5.7. It can simplify expressions involving arcsin, but not arccos, why?

Thanks

assume(x > 0)
assume(x < pi/2)
acos(cos(x)).simplify_full()

output: arccos(cos(x))

asin(sin(x)).simplify_full()

output: x
2013-04-07 02:31:12 -0500 received badge  Nice Answer (source)
2013-04-06 21:08:02 -0500 received badge  Self-Learner (source)
2013-04-06 21:08:02 -0500 received badge  Teacher (source)
2013-04-06 17:25:45 -0500 answered a question How to substitute a function within derivatives?

I figured this out. Sage's behavior is confusing to say the least. To make it work, I need the following:

gx=function('g', x)
dgx = gx.diff(x)
dgx

sage output: D[0](g)(x)

m(x)=h(x)*x
dgx.substitute_function(g, m)

sage output: x*D[0](h)(x) + h(x)

What's happening, as I understand, is:

  • function('g', x) has a side effect of creating a variable g with type : class 'sage.symbolic.function_factory.NewSymbolicFunction' which is important for my purpose, but the statement also returns an Express g(x). My original version assigned the returned Express to g, which overrided the NewSymbolicFunction that I need

  • I need to use .substitute_function() method instead of .subs(), and for that to work, I also need to first create another function m(x)

This seems unnecessarily complex and unintuitive. Is there a better way?

Thanks

2013-03-28 12:24:31 -0500 received badge  Student (source)
2013-03-21 18:03:00 -0500 answered a question How to substitute a function within derivatives?

The code does not show up correctly, trying again:

g=function('g', x)
h=function('h', x)
dg = g.diff(x)
dg
sage output: D[0](g)(x)

dg.subs(g==h*x)
sage output: D[0](g)(x)
2013-03-21 17:59:28 -0500 asked a question How to substitute a function within derivatives?

I want to simplify an ODE by making a substitution, say g(x) -> h(x)*x, but can't get it to work. I tried:

g=function('g', x)
h=function('h', x)
dg = g.diff(x)
dg

sage output: D[0](g)(x)

dg.subs(g==h*x)

sage output: D[0](g)(x)

The substitution is not done for the g function within derivatives. I tried dg.subs(g(x)==h(x)*x) too, got deprecation warnings and the same results. How can I make this work? This is a simplified example, in reality, instead of dg, I have the lhs of an ODE defined interms of g(x).

Thanks