Search code examples
scilab

How to plot the function 4(x)^2 = ((y)^2/(1-y))?


I want to plot the function

4(x)^2 = ((y)^2/(1-y));

how can I plot this?

--> 4*(x) = ((y^2)*(1-y)^-1)^0.5;
4*(x) = ((y^2)*(1-y)^-1)^0.5;
      ^^
Error: syntax error, unexpected =, expecting end of file

Solution

  • Well, you have to first create a function and for that you have to express one variable in terms of the other.

    function x = f(y)
       x = (((y^2)*(1-y)^-1)^0.5)/4;
    endfunciton
    

    Then you need to generate the input data (i.e, the points at which you want to evaluate the function)

    ydata = linspace(1, 10)
    

    Now you push your input point through the function to get your output points

    xdata = f(ydata)
    

    Then, you can plot the pairs of x and y using:

    plot(xdata, ydata)
    

    Or even easier, without the intermediate step of generating the output data, you can simply do:

    plot(f(ydata), ydata)
    

    BTW. I find it strange that the function you are trying to plot is x in terms of y, usually, x is the input variable, but I hope you know what you are trying to accomplish.

    Reference: https://www.scilab.org/tutorials/getting-started/plotting