Multiplying f(x) with f(-x)
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Omar Decevic
el 23 de Abr. de 2022
Editada: Bruno Luong
el 23 de Abr. de 2022
I need to write a code that will multiply function f(x) with f(-x)
Function is always inputed by user in form of an array.
coefficients = input('Enter the coefficients of the function with [ ] around them');
example: If user inputs [1 15 7 2] I would want to mutliply with .
Is there any way for this to be doen without writting a tone of code?
Thank you
0 comentarios
Respuesta aceptada
Más respuestas (2)
Sam Chak
el 23 de Abr. de 2022
You can try this and take over from here:
x = -16:0.01:16;
f = @(x) x.^3 + 15*x.^2 + 7*x + 2;
plot(x, f(x).*f(-x), 'linewidth', 1.5)
grid on
xlabel('x')
ylabel('y')
title('f(x)*f(-x)')
0 comentarios
Bruno Luong
el 23 de Abr. de 2022
Editada: Bruno Luong
el 23 de Abr. de 2022
For polynomial funtions with coefficients in P, f(x)*f(-x) is a polynomial as well with coefficients Q that can be computed like this
P=[1 15 7 2];
Pm=P.*(-1).^(length(P)-1:-1:0);
Q=conv(P,Pm)
hold on; ezplot(@(x)polyval(P,x).*polyval(P,-x)); ezplot(@(x)polyval(Q,x));
0 comentarios
Ver también
Categorías
Más información sobre Polynomials en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!