How to find f(x)*g(x)

10 次查看(过去 30 天)
Tran
Tran 2015-3-25
Hi!
If i have f(x) = 1 + x and g(x) = 1 - x, i want to find h(x) = f(x)*g(x) = (1+x)*(1-x)=1-x.^2 What should i do?
Thanks!

回答(2 个)

Star Strider
Star Strider 2015-3-25
It looks like you already did it. To code it using anonymous functions:
f = @(x) 1 + x;
g = @(x) 1 - x;
h = @(x) f(x).*g(x);
x = linspace(-10, 10);
figure(1)
plot(x, f(x), x, g(x), x, h(x))
grid
legend('f(x)', 'g(x)', 'h(x)', 'Location', 'south')
  11 个评论
Tran
Tran 2015-3-25
Thank you so much James Tursa!
Star Strider
Star Strider 2015-3-25
@James — Thank you!
@Tran — My pleasure!

请先登录,再进行评论。


Tanveer ul haq
Tanveer ul haq 2021-4-6
syms x
f = 1 + x;
g = 1 - x;
h = simplify(f*g)
  1 个评论
John D'Errico
John D'Errico 2021-4-6
Note that this does not actually solve the problem as asked.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by