Ask Your Question
1

Difference Between Constants and Variables

asked 2013-10-08 12:33:02 +0100

Rafael Rojas gravatar image

Hello all. I'm working with variational calculus in sage and working with complicate expression F of a lot of variables declared with var. I used var to declare both variables and constants. My problem is that I have to know the exact number of variables which some generic expression depends. By this reason the member function variables of an expression does not work, i.e., it returs both variables and constants because them was declared with var function. I'm wondering if there is some type of variable in sage that can act as a variable to construct an expression and don't be returned by the variables member function.

edit retag flag offensive close merge delete

Comments

Could you please give an example of your expression, and tell us what you consider as variable and what you consider as constant in your example ?

tmonteil gravatar imagetmonteil ( 2013-10-08 13:17:18 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-09 10:14:34 +0100

Kamel gravatar image

I am not sur it answers the question :

def dependance(f):
    dep = []
    for var in variables:
        if diff(f, var) != 0:
            dep.append(var)
    return dep

variables = var('x y z')
constants = var('A B C')

f = A*x + z^2/B + C
print dependance(f)

It returns [x, z].

edit flag offensive delete link more

Comments

Hello thaks for your answer, but that is not that I'm looking for, because in your method you have to set a priori the set list variables that you are using.

Rafael Rojas gravatar imageRafael Rojas ( 2013-10-09 12:40:39 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-10-08 12:33:02 +0100

Seen: 562 times

Last updated: Oct 09 '13