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, 19 Feb 2014 22:22:59 +0100Simplify produces an incorrect result.https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/I am using sagemath.com for this test on 19 Feb 2014. I applied Simplify to
C = ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)) *
((K - 1)^2*L*sin(-(K - 1)*t/K)/K + (K - 1)*sin(t))) -
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t)) *
(-(K - 1)^2*L*cos(-(K - 1)*t/K)/K + (K - 1)*cos(t)))
/ ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)*sin(t))^2 +
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t))^2)^(3/2))
The result returned is about 10 times too small and the peaks shift position as K is increased toward 1. K and L are parameters that should be within (0,1). Plot with K = 0.42 and L = 0.22 in Sagemath demonstrates the problem.
Cs = ((K - 1)*L*cos((K - 1)*t/K) - (K - 1)*cos(t)) *
((K - 1)^2*L*cos((K - 1)*t/K)/K - (K - 1)*cos(t)) +
((K - 1)*L*sin((K - 1)*t/K) - K + 1) *
((K - 1)^2*L*sin((K - 1)*t/K)/K - (K - 1)*sin(t))
As K approaches 0, the results more closely agree. Is this possibly a roundoff problem because of the numerator in C?
I verified the difference between the two using both Sagemath.com plot and Geogebra.
Wed, 19 Feb 2014 20:39:21 +0100https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/Comment by kcrisman for <p>I am using <a href="http://sagemath.com">sagemath.com</a> for this test on 19 Feb 2014. I applied Simplify to </p>
<pre><code>C = ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)) *
((K - 1)^2*L*sin(-(K - 1)*t/K)/K + (K - 1)*sin(t))) -
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t)) *
(-(K - 1)^2*L*cos(-(K - 1)*t/K)/K + (K - 1)*cos(t)))
/ ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)*sin(t))^2 +
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t))^2)^(3/2))
</code></pre>
<p>The result returned is about 10 times too small and the peaks shift position as K is increased toward 1. K and L are parameters that should be within (0,1). Plot with K = 0.42 and L = 0.22 in Sagemath demonstrates the problem.</p>
<pre><code>Cs = ((K - 1)*L*cos((K - 1)*t/K) - (K - 1)*cos(t)) *
((K - 1)^2*L*cos((K - 1)*t/K)/K - (K - 1)*cos(t)) +
((K - 1)*L*sin((K - 1)*t/K) - K + 1) *
((K - 1)^2*L*sin((K - 1)*t/K)/K - (K - 1)*sin(t))
</code></pre>
<p>As K approaches 0, the results more closely agree. Is this possibly a roundoff problem because of the numerator in C?</p>
<p>I verified the difference between the two using both <a href="http://Sagemath.com">Sagemath.com</a> plot and Geogebra.</p>
https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/?comment=16232#post-id-16232Can you put the entire session here? `C.simplify()` doesn't seem to really change things except rearrange terms. `C.simplify_full()` gives quite a different result. Is it possible that your `Cs` is only the numerator and this is why it's different from `C`?Wed, 19 Feb 2014 22:22:38 +0100https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/?comment=16232#post-id-16232Comment by kcrisman for <p>I am using <a href="http://sagemath.com">sagemath.com</a> for this test on 19 Feb 2014. I applied Simplify to </p>
<pre><code>C = ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)) *
((K - 1)^2*L*sin(-(K - 1)*t/K)/K + (K - 1)*sin(t))) -
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t)) *
(-(K - 1)^2*L*cos(-(K - 1)*t/K)/K + (K - 1)*cos(t)))
/ ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)*sin(t))^2 +
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t))^2)^(3/2))
</code></pre>
<p>The result returned is about 10 times too small and the peaks shift position as K is increased toward 1. K and L are parameters that should be within (0,1). Plot with K = 0.42 and L = 0.22 in Sagemath demonstrates the problem.</p>
<pre><code>Cs = ((K - 1)*L*cos((K - 1)*t/K) - (K - 1)*cos(t)) *
((K - 1)^2*L*cos((K - 1)*t/K)/K - (K - 1)*cos(t)) +
((K - 1)*L*sin((K - 1)*t/K) - K + 1) *
((K - 1)^2*L*sin((K - 1)*t/K)/K - (K - 1)*sin(t))
</code></pre>
<p>As K approaches 0, the results more closely agree. Is this possibly a roundoff problem because of the numerator in C?</p>
<p>I verified the difference between the two using both <a href="http://Sagemath.com">Sagemath.com</a> plot and Geogebra.</p>
https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/?comment=16231#post-id-16231There should be an "edit" button just under the tags you can click to edit your post.Wed, 19 Feb 2014 22:22:59 +0100https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/?comment=16231#post-id-16231Comment by jcfried for <p>I am using <a href="http://sagemath.com">sagemath.com</a> for this test on 19 Feb 2014. I applied Simplify to </p>
<pre><code>C = ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)) *
((K - 1)^2*L*sin(-(K - 1)*t/K)/K + (K - 1)*sin(t))) -
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t)) *
(-(K - 1)^2*L*cos(-(K - 1)*t/K)/K + (K - 1)*cos(t)))
/ ((((K - 1)*L*sin(-(K - 1)*t/K) + (K - 1)*sin(t))^2 +
((K - 1)*L*cos(-(K - 1)*t/K) - (K - 1)*cos(t))^2)^(3/2))
</code></pre>
<p>The result returned is about 10 times too small and the peaks shift position as K is increased toward 1. K and L are parameters that should be within (0,1). Plot with K = 0.42 and L = 0.22 in Sagemath demonstrates the problem.</p>
<pre><code>Cs = ((K - 1)*L*cos((K - 1)*t/K) - (K - 1)*cos(t)) *
((K - 1)^2*L*cos((K - 1)*t/K)/K - (K - 1)*cos(t)) +
((K - 1)*L*sin((K - 1)*t/K) - K + 1) *
((K - 1)^2*L*sin((K - 1)*t/K)/K - (K - 1)*sin(t))
</code></pre>
<p>As K approaches 0, the results more closely agree. Is this possibly a roundoff problem because of the numerator in C?</p>
<p>I verified the difference between the two using both <a href="http://Sagemath.com">Sagemath.com</a> plot and Geogebra.</p>
https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/?comment=16233#post-id-16233After examining the denominator of C carefully i've come to the conclusion this is not a problem with roundoff. If i can figure out how to edit my original statement, i will remove that suggestion.Wed, 19 Feb 2014 20:53:05 +0100https://ask.sagemath.org/question/11055/simplify-produces-an-incorrect-result/?comment=16233#post-id-16233