e^x/x

17 次查看(过去 30 天)
ahmed
ahmed 2016-12-25
回答: John BG 2016-12-25
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) ;

采纳的回答

John BG
John BG 2016-12-25
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by