Can I Find 21 Equidistant Roots Between [-1,1] of a Function in Matlab?

In summary, the conversation discusses finding 21 equidistant roots of a function f(x) = (1 − 6x^2)^-1 between the values of -1 and 1. The participants consider using the polyval and fsolve functions in Matlab, but ultimately use the linspace function to plug in values for x and find corresponding values for f(x). A function is created to assist in this process.
  • #1
kappa
7
0
i have this function f(x) = (1 − 6x^2)^-1
and I need 21 roots between [-1,1] equidistant (the points to be at same distance from one to another)

can i find the roots with some function in matlab? i found out just the polyval function for polynom
 
Physics news on Phys.org
  • #2
If you define the root to be the value of x such that f(x) = 0, there are no roots (do you see why?). Do you instead mean the values of x such that f(x) is undefined?
 
  • #3
gb7nash said:
If you define the root to be the value of x such that f(x) = 0, there are no roots (do you see why?). Do you instead mean the values of x such that f(x) is undefined?

yes i was rong i need the value of f(x)=... when x is from [-1,1] (for 21 values) I do it with fsolve?
 
  • #4
kappa said:
yes i was rong i need the value of f(x)=... when x is from [-1,1] (for 21 values) I do it with fsolve?

Do you just want to plug in 21 equidistant values of x between [-1,1] and find what f(x) is for each value? If so, you could use:


x_values = linspace(-1,1,21)
y_values = subs(y,x) 'y is the function in terms of x
 
  • #5
gb7nash said:
Do you just want to plug in 21 equidistant values of x between [-1,1] and find what f(x) is for each value? If so, you could use:


x_values = linspace(-1,1,21)
y_values = subs(y,x) 'y is the function in terms of x

yes so if I define my function so:

function y=f(x);
y=(1-6*x^2)^-1;

>> x_values = linspace(-1,1,21)

>> y_values= subs(? ?
 
  • #6
You might want to look up the syntax for subs. I don't currently have access to matlab, but I'm pretty sure this should work:

syms x;
x_values = linspace(-1,1,21)
y_values = subs((1 − 6x^2)^-1,x)
 
  • #7
gb7nash said:
You might want to look up the syntax for subs. I don't currently have access to matlab, but I'm pretty sure this should work:

syms x;
x_values = linspace(-1,1,21)
y_values = subs((1 − 6x^2)^-1,x)

I tried but didn`t work I managed to make a functions

function test;

f=inline('(1-6*x^2)^-1');
x_values =linspace(-1,1,21);
for i= 1:21
y_values(1,i)=f(x_values(1,i))

end;

thanks for the linspace code it helped me :]
 

Related to Can I Find 21 Equidistant Roots Between [-1,1] of a Function in Matlab?

1. What are the roots of a function?

The roots of a function, also known as the zeros or x-intercepts, are the values of x that make the function equal to zero. They can be found by setting the function equal to zero and solving for x.

2. How do you find the roots of a function?

To find the roots of a function, you can use a variety of methods such as factoring, the quadratic formula, or graphing. The method used depends on the type and complexity of the function.

3. Can a function have more than one root?

Yes, a function can have multiple roots, depending on its degree. For example, a quadratic function can have up to two roots, while a cubic function can have up to three roots.

4. What is the relationship between roots and factors of a function?

The roots of a function are the values of x that make the function equal to zero. Factors of a function are expressions that, when multiplied together, result in the function. The roots of a function are the same as the solutions to the factors of the function.

5. How do the roots of a function affect the graph?

The roots of a function represent the x-values of the points where the graph crosses the x-axis. The number of roots and their values can affect the shape and behavior of the graph. For example, if a function has two real roots, the graph will cross the x-axis at those points and form a "U" shape. If a function has no real roots, the graph will not intersect the x-axis at any point.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
477
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
Back
Top