Path: news.mathworks.com!not-for-mail
From: "Marcelo Tames" <jmarcelo.tb@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: how come matlab drew this?
Date: Sun, 24 Feb 2008 15:08:04 +0000 (UTC)
Organization: M&#65533;lardalen University
Lines: 28
Message-ID: <fps18k$dh3$1@fred.mathworks.com>
Reply-To: "Marcelo Tames" <jmarcelo.tb@mathworks.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1203865684 13859 172.30.248.38 (24 Feb 2008 15:08:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 24 Feb 2008 15:08:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1272310
Xref: news.mathworks.com comp.soft-sys.matlab:453393


Hi I saw a exercise in a book and asked me to plot these 
graphs togheter as abs(y1-y2):

y1(x) =sqrt(x^2 + 1)- 1 

and 

y2(x) =x^2/sqrt(x^2 + 1) + 1

and I did the following:

delta=10^(-3);
x=linspace(10^(-4),10^(-3),100);
y1 = sqrt(x.^2+1)-1;
y2 = x.^2./(sqrt(x.^2+1)+1);
z = abs(y1-y2)
plot(x,z)
ylabel('value');
xlabel('x');
title('compare');

I get a graph but I don?t really understand why is that, I 
mean if one solves abs(y1-y2) by hand everything becomes 
zero, can anyone explain to me why matlab still graphs 
something and is what I did wrong? I?m a beginner so please 
understand that my reasoning is not that advanced

thanks