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

 Réponse acceptée

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 commentaires

Szczepan Michura
Szczepan Michura le 26 Mai 2021
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 le 26 Mai 2021
so that it can be compared with that calculated by the trigonometric functions of matlab
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 le 26 Mai 2021
yes thank you, that's what I meant
Star Strider
Star Strider le 26 Mai 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by