what is the figure for $f(x)=|\sqrt{x}|$

65 Views Asked by At

what is the figure of $f(x)=|\sqrt{x}|$ ? when I run y=abs(sqrt(x)) to matalab, i take this but I believe that is not the correct answer. Please give me a help: enter image description here

1

There are 1 best solutions below

5
On BEST ANSWER

You don't need to take the absolute value here, the function $f(x) = \sqrt{x}$ is always positive in the real space. Try typing the following code in to matlab and running it, it will produce the correct graph.

a = 10;
x =  linspace(0,a,1000); %creates a vector from 0 to a with 1000 discrete points
y =  sqrt(x);
plot(x,y);

However, to answer your question, If correctly inputted, matlab should produce exactly the same plot for $|\sqrt{x}|$ for that of $\sqrt{x}$. Perhaps you're doing something incorrectly. Try the following code -

a = 10;
x =  linspace(0,a,1000); %creates a vector from 0 to a with 1000 discrete points
y =  abs(sqrt(x));
plot(x,y);

and if that doesn't work, try this

a = 10;
x =  linspace(0,a,1000); %creates a vector from 0 to a with 1000 discrete points
h =  sqrt(x); y = abs(h);

plot(x,y);