Ask Your Question

zalba's profile - activity

2022-11-30 19:37:06 +0100 received badge  Popular Question (source)
2020-01-24 10:06:27 +0100 received badge  Famous Question (source)
2018-11-24 15:23:49 +0100 received badge  Notable Question (source)
2018-11-24 15:23:49 +0100 received badge  Popular Question (source)
2017-09-04 20:09:23 +0100 received badge  Notable Question (source)
2016-05-20 19:58:00 +0100 received badge  Popular Question (source)
2015-07-29 20:21:39 +0100 asked a question Substituting derivative in equation

There is likely a simple way to solve this, but I cannot seem to find a way. Let say I have two functions, f(x,y) and g(x,y)

var('x,y')

f=function('f',x,y)

g=function('g',x,y)

I want to be able to substitute a value for one of the derivatives. For example, if I have the equation x^2y+f.diff(x,1), I may want to substitute in the function g, so I have x^2y+g. I tried the following

(x^2y+f.diff(x,1)).subs(f.diff(x,1)=g)

And get an error that a keyword can't be an expression. Is there anyway to make this substitution?

2015-06-18 23:13:24 +0100 commented answer Taylor expansion assumptions

I have the same thing; however, I was considering the case where z>y+1, so the solution given isn't correct in that case. The solution I gave was the general analytic form, not the one Sage gave.

2015-06-18 20:43:17 +0100 asked a question Taylor expansion assumptions

This is a very simply question, but I can't seem to get an appropriate answer in Sage. Let's say I have the following function:f(x,y,z)=sqrt(x^2+(y+1-z)^2). The taylor expansion around x=0 is sqrt((y+1-z)^2)+x^2/(2*sqrt((y+1-z)^2)) (analytic form, not the value Sage gives). Is it possible for Sage to take assumptions into account when expanding? For example, if I have assume(y>0,z>0,z>y+1), then clearly, (y+1-z)<0, so when simplifying, sqrt((y+1-z)^2)=z-y-1. However, Sage simply gives me the same answer regardless of assumption. Is there a way to fix this?

2015-06-17 18:15:00 +0100 commented answer issue with variable assumptions

However, this does not really simplify. Is there something like canonicalize_radicals() that takes assumptions into account? For example, I have the following expression, that won't simplify further sqrt(((M - r)mu + M)^2 + (mu^2 - 1)(2Mr - r^2))), but in Mathematica correctly simplifies to sqrt((mu*M+M-r)^2). canonical_radical finds the solution, but does not get the correct assumptions

2015-06-17 17:13:36 +0100 received badge  Editor (source)
2015-06-17 16:45:56 +0100 commented answer issue with variable assumptions

Thank you! I was using canonicalize.radical(), which is what I assume was the issue.

2015-06-17 16:45:19 +0100 received badge  Scholar (source)
2015-06-16 23:08:55 +0100 asked a question using lists in multivariable functions

I wish to create a function that uses elements from a list and is used later on. For example, I have an array M=[m1,m2,...,mn], B=[b1,b2,...,bn] and wish to have a function R(r,u,b)=r+b+u (using the elements from the array B), which I then pass to another function Y(r,u,b,m)=R*b*m (using the result from the first function and the values from each array). In other words, if M=[m1,m2] and B=[b1,b2], I want to be able to have a function R(r,u,b)=[r+b1+u,r+b2+u] and then have that Y(r,u,b,m)=R*b*m=[(r+b1+u)*b1*m1,(r+b2+u)*b2*m2]. Basically, I wish to do what is mentioned in this post: http://ask.sagemath.org/question/8545..., but with more than one array. I tried the following

sage: m1,m2,b1,b2,u=var('m1','m2','b1','b2','u')

sage: M=[m1,m2], B=[b1,b2]

sage: R(r,b,u)=[r+b+u for b in B]

sage:R(r,b,u)

(r+b1+u,r+b2+u)

This is all what I want. I then want to take R(r,b,u) in another function: Y(r,b,u,m), so that it gets the result I have above. I can't seem to get a way to run through all the possibilities (I could use a loop, but that ends up getting a bit messy as I go deeper in)

Edit: The values for mi and bi will eventually have numerical values, but currently they are simply symbolic variables. I am currently using this to simplify some algebraic expressions.

2015-06-16 19:49:11 +0100 asked a question issue with variable assumptions

I am using sage to compute a variety of algebra, and often times, when calculating the squareroots of variables, sage gets the assumptions wrong. Here is a short example:

sage: r,M=var('r','M')

sage: assume(r>0,M>0,r>2*M)

sage: sqrt((2*M-r)^2)

2M-r

Clearly the last line is incorrect (should be r-2M), but I have no idea how to fix it. While this is a trivial example, I frequently work with equations that are many variables in length, where ensuring that the correct variables are positive is a requirement.

Edit: I found a partial solution, however it does not seem to work well with simplifying radicals. If there is an alternative to canonicalize_radical which takes assumptions into account, it would be helpful.