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

 Risposta accettata

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 Commenti

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
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?
.
yes thank you, that's what I meant
Star Strider
Star Strider il 26 Mag 2021
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by