Ask Your Question
0

how to define a constant in sage?

asked 2012-03-19 11:51:49 -0500

anonymous user

Anonymous

Hello, I just started using sage. I am having some difficulties in declaring constants. I am trying to calculate derivatives of functions but I don't want to put values for the constant but rather define constants in the function. Somehow I am not able to find any literature on that.

I would be really grateful if someone can help me with this issue.

Cheers,

Sanyog

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-03-19 15:35:55 -0500

The code

sage: var('x y z')
(x, y, z)
sage: f = 3*x*y + 2*z + 12
sage: f.diff(x)
3*y
sage: g(x,y,z) = 3*x*y + 2*z + 12
sage: g.diff(x)
(x, y, z) |--> 3*y

provides two slightly different ways of defining a function involving x, y, and z, then differentiating with respect to x, thus treating y and z as constants. Is this what you want?

edit flag offensive delete link more

Comments

1

To follow up, I think that John means just doing `var('a')` will make `a` a "symbolic constant" in the sense you desire.

kcrisman gravatar imagekcrisman ( 2012-03-19 17:27:41 -0500 )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: 2012-03-19 11:51:49 -0500

Seen: 2,906 times

Last updated: Mar 19 '12