<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164430</link>
    <title>MATLAB Central Newsreader - how come matlab drew this?</title>
    <description>Feed for thread: how come matlab drew this?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 24 Feb 2008 15:08:04 -0500</pubDate>
      <title>how come matlab drew this?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164430#417058</link>
      <author>Marcelo Tames</author>
      <description>Hi I saw a exercise in a book and asked me to plot these &lt;br&gt;
graphs togheter as abs(y1-y2):&lt;br&gt;
&lt;br&gt;
y1(x) =sqrt(x^2 + 1)- 1 &lt;br&gt;
&lt;br&gt;
and &lt;br&gt;
&lt;br&gt;
y2(x) =x^2/sqrt(x^2 + 1) + 1&lt;br&gt;
&lt;br&gt;
and I did the following:&lt;br&gt;
&lt;br&gt;
delta=10^(-3);&lt;br&gt;
x=linspace(10^(-4),10^(-3),100);&lt;br&gt;
y1 = sqrt(x.^2+1)-1;&lt;br&gt;
y2 = x.^2./(sqrt(x.^2+1)+1);&lt;br&gt;
z = abs(y1-y2)&lt;br&gt;
plot(x,z)&lt;br&gt;
ylabel('value');&lt;br&gt;
xlabel('x');&lt;br&gt;
title('compare');&lt;br&gt;
&lt;br&gt;
I get a graph but I don?t really understand why is that, I &lt;br&gt;
mean if one solves abs(y1-y2) by hand everything becomes &lt;br&gt;
zero, can anyone explain to me why matlab still graphs &lt;br&gt;
something and is what I did wrong? I?m a beginner so please &lt;br&gt;
understand that my reasoning is not that advanced&lt;br&gt;
&lt;br&gt;
thanks &lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 24 Feb 2008 20:22:04 -0500</pubDate>
      <title>Re: how come matlab drew this?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164430#417087</link>
      <author>Roger Stafford</author>
      <description>"Marcelo Tames" &amp;lt;jmarcelo.tb@mathworks.com&amp;gt; wrote in message &amp;lt;fps18k&lt;br&gt;
$dh3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi I saw a exercise in a book and asked me to plot these &lt;br&gt;
&amp;gt; graphs togheter as abs(y1-y2):&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; y1(x) =sqrt(x^2 + 1)- 1 &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; y2(x) =x^2/sqrt(x^2 + 1) + 1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and I did the following:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; delta=10^(-3);&lt;br&gt;
&amp;gt; x=linspace(10^(-4),10^(-3),100);&lt;br&gt;
&amp;gt; y1 = sqrt(x.^2+1)-1;&lt;br&gt;
&amp;gt; y2 = x.^2./(sqrt(x.^2+1)+1);&lt;br&gt;
&amp;gt; z = abs(y1-y2)&lt;br&gt;
&amp;gt; plot(x,z)&lt;br&gt;
&amp;gt; ylabel('value');&lt;br&gt;
&amp;gt; xlabel('x');&lt;br&gt;
&amp;gt; title('compare');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I get a graph but I don?t really understand why is that, I &lt;br&gt;
&amp;gt; mean if one solves abs(y1-y2) by hand everything becomes &lt;br&gt;
&amp;gt; zero, can anyone explain to me why matlab still graphs &lt;br&gt;
&amp;gt; something and is what I did wrong? I?m a beginner so please &lt;br&gt;
&amp;gt; understand that my reasoning is not that advanced&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks &lt;br&gt;
--------&lt;br&gt;
&amp;nbsp;&amp;nbsp;I assume from your remarks that you are aware that the two expressions in &lt;br&gt;
question are mathematically identically equal to one another, so you are &lt;br&gt;
apparently asking why you didn't get a graph showing a horizontal line of &lt;br&gt;
height zero.  If that is your question, the answer is round off error in &lt;br&gt;
computing the two quantities.  These involve differing mathematical &lt;br&gt;
operations and will produce slightly different results because of this round off &lt;br&gt;
error.  Note that the values you are getting in the graph are of size &lt;br&gt;
somewhere in the neighborhood of 10^(-16) which is a very small value &lt;br&gt;
indeed.  If you were to accompany this graph with another one that assumes &lt;br&gt;
values in the neighborhood of 1, the first graph would be squeezed down to &lt;br&gt;
the horizontal line you are expecting.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;If you are asking why the two expressions are identical, try multiplying the &lt;br&gt;
numerator and denominator of  y2 by (sqrt(x^2+1)-1) and simplify the result.  &lt;br&gt;
What you arrive at is precisely y1.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;By the way, in the first expression for y2, you appear to have left out a pair &lt;br&gt;
of parentheses, though that is corrected in the code.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 24 Feb 2008 21:03:06 -0500</pubDate>
      <title>Re: how come matlab drew this?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/164430#417094</link>
      <author>Marcelo Tames</author>
      <description>"Roger Stafford" &lt;br&gt;
&amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fpsjlc$q6q$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Marcelo Tames" &amp;lt;jmarcelo.tb@mathworks.com&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fps18k&lt;br&gt;
&amp;gt; $dh3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi I saw a exercise in a book and asked me to plot &lt;br&gt;
these &lt;br&gt;
&amp;gt; &amp;gt; graphs togheter as abs(y1-y2):&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; y1(x) =sqrt(x^2 + 1)- 1 &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; and &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; y2(x) =x^2/sqrt(x^2 + 1) + 1&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; and I did the following:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; delta=10^(-3);&lt;br&gt;
&amp;gt; &amp;gt; x=linspace(10^(-4),10^(-3),100);&lt;br&gt;
&amp;gt; &amp;gt; y1 = sqrt(x.^2+1)-1;&lt;br&gt;
&amp;gt; &amp;gt; y2 = x.^2./(sqrt(x.^2+1)+1);&lt;br&gt;
&amp;gt; &amp;gt; z = abs(y1-y2)&lt;br&gt;
&amp;gt; &amp;gt; plot(x,z)&lt;br&gt;
&amp;gt; &amp;gt; ylabel('value');&lt;br&gt;
&amp;gt; &amp;gt; xlabel('x');&lt;br&gt;
&amp;gt; &amp;gt; title('compare');&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I get a graph but I don?t really understand why is &lt;br&gt;
that, I &lt;br&gt;
&amp;gt; &amp;gt; mean if one solves abs(y1-y2) by hand everything &lt;br&gt;
becomes &lt;br&gt;
&amp;gt; &amp;gt; zero, can anyone explain to me why matlab still graphs &lt;br&gt;
&amp;gt; &amp;gt; something and is what I did wrong? I?m a beginner so &lt;br&gt;
please &lt;br&gt;
&amp;gt; &amp;gt; understand that my reasoning is not that advanced&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; thanks &lt;br&gt;
&amp;gt; --------&lt;br&gt;
&amp;gt;   I assume from your remarks that you are aware that the &lt;br&gt;
two expressions in &lt;br&gt;
&amp;gt; question are mathematically identically equal to one &lt;br&gt;
another, so you are &lt;br&gt;
&amp;gt; apparently asking why you didn't get a graph showing a &lt;br&gt;
horizontal line of &lt;br&gt;
&amp;gt; height zero.  If that is your question, the answer is &lt;br&gt;
round off error in &lt;br&gt;
&amp;gt; computing the two quantities.  These involve differing &lt;br&gt;
mathematical &lt;br&gt;
&amp;gt; operations and will produce slightly different results &lt;br&gt;
because of this round off &lt;br&gt;
&amp;gt; error.  Note that the values you are getting in the graph &lt;br&gt;
are of size &lt;br&gt;
&amp;gt; somewhere in the neighborhood of 10^(-16) which is a very &lt;br&gt;
small value &lt;br&gt;
&amp;gt; indeed.  If you were to accompany this graph with another &lt;br&gt;
one that assumes &lt;br&gt;
&amp;gt; values in the neighborhood of 1, the first graph would be &lt;br&gt;
squeezed down to &lt;br&gt;
&amp;gt; the horizontal line you are expecting.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   If you are asking why the two expressions are &lt;br&gt;
identical, try multiplying the &lt;br&gt;
&amp;gt; numerator and denominator of  y2 by (sqrt(x^2+1)-1) and &lt;br&gt;
simplify the result.  &lt;br&gt;
&amp;gt; What you arrive at is precisely y1.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   By the way, in the first expression for y2, you appear &lt;br&gt;
to have left out a pair &lt;br&gt;
&amp;gt; of parentheses, though that is corrected in the code.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
thanks Roger, I was suspecting that about the error but &lt;br&gt;
wasn?t sure. I?ll discuss these with my classmates. thanks &lt;br&gt;
again&lt;br&gt;
&lt;br&gt;
best regards &lt;br&gt;
Marcelo&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
