ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 17 Nov 2010 14:37:03 +0100Any way to define variables as constant?https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/I want to come up with a function that will return true when I compare $(x-1)^2+C$ and $x^2-2x+C$
where $C$ is an arbitrary constant. Any way that you know can do this ?
Wed, 17 Nov 2010 12:39:32 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/Answer by Shu for <p>I want to come up with a function that will return true when I compare $(x-1)^2+C$ and $x^2-2x+C$
where $C$ is an arbitrary constant. Any way that you know can do this ?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?answer=11788#post-id-11788I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"
$(x-1)^2+C_1$ and $x^2-2x+C_2$
For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?Wed, 17 Nov 2010 13:18:06 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?answer=11788#post-id-11788Comment by Evgeny for <p>I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"</p>
<p>$(x-1)^2+C_1$ and $x^2-2x+C_2$</p>
<p>For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22486#post-id-22486you can edit your previous posts too :)Wed, 17 Nov 2010 13:30:12 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22486#post-id-22486Comment by Shu for <p>I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"</p>
<p>$(x-1)^2+C_1$ and $x^2-2x+C_2$</p>
<p>For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22487#post-id-22487will do next time. thanks for letting me know.Wed, 17 Nov 2010 13:26:36 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22487#post-id-22487Comment by Shu for <p>I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"</p>
<p>$(x-1)^2+C_1$ and $x^2-2x+C_2$</p>
<p>For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22485#post-id-22485I was able to edit the answer, but do not see any edit button for comments.Wed, 17 Nov 2010 13:41:33 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22485#post-id-22485Comment by John Palmieri for <p>I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"</p>
<p>$(x-1)^2+C_1$ and $x^2-2x+C_2$</p>
<p>For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22484#post-id-22484Your "answer" should be a comment, I think, not an answer.Wed, 17 Nov 2010 14:04:38 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22484#post-id-22484Comment by Evgeny for <p>I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"</p>
<p>$(x-1)^2+C_1$ and $x^2-2x+C_2$</p>
<p>For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22488#post-id-22488hey you can put math between dollar signs and it'll typesetWed, 17 Nov 2010 13:22:49 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22488#post-id-22488Comment by Shu for <p>I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"</p>
<p>$(x-1)^2+C_1$ and $x^2-2x+C_2$</p>
<p>For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22489#post-id-22489one can find indefinite integral of sin(x)cos(x) as
(1/2)*(sin(x))^2+C_1
or
-(1/2)*(cos(x))^2+C_2
both are right. But can I make a function using sage methods that will consider both as same?
Wed, 17 Nov 2010 13:20:55 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22489#post-id-22489Comment by Evgeny for <p>I know there is none. But I want to make one if possible at all.
Probably you will like the expression with different "C"</p>
<p>$(x-1)^2+C_1$ and $x^2-2x+C_2$</p>
<p>For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal.
Anyone else have any idea?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22483#post-id-22483Yes, sorry, the comments are not editable yet, but this feature will be finished soon.Wed, 17 Nov 2010 14:37:03 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?comment=22483#post-id-22483Answer by John Palmieri for <p>I want to come up with a function that will return true when I compare $(x-1)^2+C$ and $x^2-2x+C$
where $C$ is an arbitrary constant. Any way that you know can do this ?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?answer=11789#post-id-11789So you want to know if a specific mathematical expression (like $(x-1)^2 - (x^2-2x))$ is a constant. Just check whether its derivative is zero:
sage: var('C, C2')
sage: diff(((x-1)^2+C) - (x^2-2*x+C2), x)
0
sage: bool(diff(((x-1)^2+C) - (x^2-2*x+C2), x) == 0)
True
Wed, 17 Nov 2010 14:04:42 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?answer=11789#post-id-11789Answer by John Palmieri for <p>I want to come up with a function that will return true when I compare $(x-1)^2+C$ and $x^2-2x+C$
where $C$ is an arbitrary constant. Any way that you know can do this ?</p>
https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?answer=11787#post-id-11787There is no such function, because they're not equal. Perhaps the second expression should be `x^2-2x+1+C`...
What have you tried? Here are two options:
sage: var('C')
sage: expand(((x-1)^2+C) - (x^2-2*x+1+C))
0
sage: bool(expand((x-1)^2+C) == expand(x^2-2*x+1+C))
True
Wed, 17 Nov 2010 13:00:13 +0100https://ask.sagemath.org/question/7768/any-way-to-define-variables-as-constant/?answer=11787#post-id-11787