e^x/x

19 vues (au cours des 30 derniers jours)
ahmed
ahmed le 25 Déc 2016
Réponse apportée : John BG le 25 Déc 2016
how can i plot e^x/x code
syms x;
f=exp(x)/x
t3=taylor(f, 'order',4) ;
xd=-pi:pi/20:pi;
yd=subs(f,x,xd);
td3=subs(t3,x,xd);
plot(xd,yd);
error
Error using symengine
Cannot compute a Taylor expansion of the input.
Error in sym/taylor (line 128)
tSym = mupadmex('symobj::taylor',f.s,x.s,a.s,options);
Error in exp1 (line 3)
t3=taylor(f, 'order',4) ;

Réponse acceptée

John BG
John BG le 25 Déc 2016
function plot doesn't work with input type syms
Instead try the following
x=[-10:0.0001:10];
y=exp(x)./x;
plot(x,y);
axis([-10 10 -1e3 1e3])
grid on
title('e^x/x')
and the following doesn't crash
syms x x0;
y= exp(x-x0)/(x-x0)
x_tay4=taylor(y, 'order',4)
y =
exp(x - x0)/(x - x0)
x_tay4 =
(- exp(-x0)/(6*x0) - exp(-x0)/(2*x0^2) - exp(-x0)/x0^3 - exp(-x0)/x0^4)*x^3 + (- exp(-x0)/(2*x0) - exp(-x0)/x0^2 - exp(-x0)/x0^3)*x^2 + (- exp(-x0)/x0 - exp(-x0)/x0^2)*x - exp(-x0)/x0
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, if you find this answer of any help please click on the thumbs-up vote link,
thanks in advance for time and attention
John BG

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by