how to define the function y so that when I type (x) I get the value of this function and not its formula, please help :(
syms x
T = taylor (asinh (x), x, 'Order' ,16);
x=input('indicate the value of x = ');
if x>-1 || x<1
y= T ??????????????????????
g=asinh(x);
end
if x<=(-1) || x>=1
y='error!';
g='error'!';
end

 採用された回答

Star Strider
Star Strider 2021 年 5 月 26 日

1 投票

Define it as a function. (This has been possible since R2012a.)
syms x
T(x) = taylor (asinh (x), x, 'Order' ,16);
figure
fplot(T, [-1 1]*1.35)
hold on
fplot(asinh(x), [-1, 1]*1.35)
hold off
grid
hl = legend('16-Term Taylor Series', 'Analytic Function', 'Location','best');
title(hl, 'sinh(x)^{-1}')
.

5 件のコメント

Szczepan Michura
Szczepan Michura 2021 年 5 月 26 日
thank you for this useful graph, but that's not quite what I had in mind, I wanted a numerical value for the Term Taylor Series variable
Szczepan Michura
Szczepan Michura 2021 年 5 月 26 日
so that it can be compared with that calculated by the trigonometric functions of matlab
Star Strider
Star Strider 2021 年 5 月 26 日
My pleasure!
Perhaps —
syms x
T(x) = taylor (asinh (x), x, 'Order' ,16);
xv = 0.5
xv = 0.5000
y = T(xv)
y = 
y = vpa(y)
y = 
0.48121175225884076267834812756688
is the desired result?
.
Szczepan Michura
Szczepan Michura 2021 年 5 月 26 日
yes thank you, that's what I meant
Star Strider
Star Strider 2021 年 5 月 26 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by