ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 15 Aug 2012 08:34:28 -0500Deriving Data and Plottinghttps://ask.sagemath.org/question/9236/deriving-data-and-plotting/In the following x means multiply.
Let
z1=2 x pi x 650 x 10^6
p1=2 x pi x 1.9 x 10^9
p2=2 x pi x 5 x 10^9
adc=.667
deltaF=.2 x 10^9
In the following j is the imaginary representation
Now let `N=(adc x p1 x p2)/z1` and
M=(-2 x j x pi x freq x z1)/((-2 x j x pi x freq+p1) x (-2 x j x pi x freq+p2))
The base formula is abs(20 x log(N x M,10)) or the absolute value of 20 log(N x M) where the log base is base 10. Within the base formula is *freq* (the value of the frequency) which will be swept from 10^8 to 10^11 in steps of deltaF (.2 x 10^9)
The vertical range is from -25 to 5 (linear scale) and the horizontal range is from 10^8 to 10^11 (log scale)
The horizontal axis as stated is a **Log** scale as opposed to Linear.
How do I set this up in Sage to plot per the above? Thanks.
Tue, 14 Aug 2012 09:15:56 -0500https://ask.sagemath.org/question/9236/deriving-data-and-plotting/Answer by calc314 for <p>In the following x means multiply.</p>
<p>Let</p>
<pre><code>z1=2 x pi x 650 x 10^6
p1=2 x pi x 1.9 x 10^9
p2=2 x pi x 5 x 10^9
adc=.667
deltaF=.2 x 10^9
</code></pre>
<p>In the following j is the imaginary representation
Now let <code>N=(adc x p1 x p2)/z1</code> and </p>
<pre><code>M=(-2 x j x pi x freq x z1)/((-2 x j x pi x freq+p1) x (-2 x j x pi x freq+p2))
</code></pre>
<p>The base formula is abs(20 x log(N x M,10)) or the absolute value of 20 log(N x M) where the log base is base 10. Within the base formula is <em>freq</em> (the value of the frequency) which will be swept from 10^8 to 10^11 in steps of deltaF (.2 x 10^9)</p>
<p>The vertical range is from -25 to 5 (linear scale) and the horizontal range is from 10^8 to 10^11 (log scale)</p>
<p>The horizontal axis as stated is a <strong>Log</strong> scale as opposed to Linear.</p>
<p>How do I set this up in Sage to plot per the above? Thanks.</p>
https://ask.sagemath.org/question/9236/deriving-data-and-plotting/?answer=13923#post-id-13923I'm not getting the vertical range that you are specifying, but here is what I've got. Note that the log plot only works in the latest release (5.2) of Sage.
z1=2 * pi * 650 * 10^6
p1=2 * pi * 1.9 * 10^9
p2=2 * pi * 5 * 10^9
adc=.667
deltaF=.2 * 10^9
N=(adc * p1 * p2)/z1
M(freq)=(-2 * i * pi * freq * z1)/((-2 * i * pi * freq+p1) * (-2 * i * pi * freq+p2))
g(frq)=20*abs(log(N*M(frq),10))
pts=[(frq,g(frq).n()) for frq in srange(10^8,10^11,deltaF)]
list_plot(pts, scale='semilogx')
Tue, 14 Aug 2012 15:50:51 -0500https://ask.sagemath.org/question/9236/deriving-data-and-plotting/?answer=13923#post-id-13923Answer by gjm for <p>In the following x means multiply.</p>
<p>Let</p>
<pre><code>z1=2 x pi x 650 x 10^6
p1=2 x pi x 1.9 x 10^9
p2=2 x pi x 5 x 10^9
adc=.667
deltaF=.2 x 10^9
</code></pre>
<p>In the following j is the imaginary representation
Now let <code>N=(adc x p1 x p2)/z1</code> and </p>
<pre><code>M=(-2 x j x pi x freq x z1)/((-2 x j x pi x freq+p1) x (-2 x j x pi x freq+p2))
</code></pre>
<p>The base formula is abs(20 x log(N x M,10)) or the absolute value of 20 log(N x M) where the log base is base 10. Within the base formula is <em>freq</em> (the value of the frequency) which will be swept from 10^8 to 10^11 in steps of deltaF (.2 x 10^9)</p>
<p>The vertical range is from -25 to 5 (linear scale) and the horizontal range is from 10^8 to 10^11 (log scale)</p>
<p>The horizontal axis as stated is a <strong>Log</strong> scale as opposed to Linear.</p>
<p>How do I set this up in Sage to plot per the above? Thanks.</p>
https://ask.sagemath.org/question/9236/deriving-data-and-plotting/?answer=13925#post-id-13925Thanks for the answer. I actually needed to have the absolute value of N x M(freq) and that should give me the right range.
What is the correct syntax? I have tried log(abs(N x M(freq)),10)) and that does not seem to work and I get an error.
Also, is there a reason for the change from freq to frq? Thanks!
Wed, 15 Aug 2012 08:18:15 -0500https://ask.sagemath.org/question/9236/deriving-data-and-plotting/?answer=13925#post-id-13925Answer by gjm for <p>In the following x means multiply.</p>
<p>Let</p>
<pre><code>z1=2 x pi x 650 x 10^6
p1=2 x pi x 1.9 x 10^9
p2=2 x pi x 5 x 10^9
adc=.667
deltaF=.2 x 10^9
</code></pre>
<p>In the following j is the imaginary representation
Now let <code>N=(adc x p1 x p2)/z1</code> and </p>
<pre><code>M=(-2 x j x pi x freq x z1)/((-2 x j x pi x freq+p1) x (-2 x j x pi x freq+p2))
</code></pre>
<p>The base formula is abs(20 x log(N x M,10)) or the absolute value of 20 log(N x M) where the log base is base 10. Within the base formula is <em>freq</em> (the value of the frequency) which will be swept from 10^8 to 10^11 in steps of deltaF (.2 x 10^9)</p>
<p>The vertical range is from -25 to 5 (linear scale) and the horizontal range is from 10^8 to 10^11 (log scale)</p>
<p>The horizontal axis as stated is a <strong>Log</strong> scale as opposed to Linear.</p>
<p>How do I set this up in Sage to plot per the above? Thanks.</p>
https://ask.sagemath.org/question/9236/deriving-data-and-plotting/?answer=13926#post-id-13926It's okay, I got it to work with the abs defined where I wanted it and had one minor change to the equation to get the correct range. Now I need to find out how to get Sage 5.2.Wed, 15 Aug 2012 08:34:28 -0500https://ask.sagemath.org/question/9236/deriving-data-and-plotting/?answer=13926#post-id-13926