CodeBus
www.codebus.net
Search
Sign in
Sign up
Hot Search :
Source
embeded
web
remote control
p2p
game
More...
Location :
Home
Search - compare d
Main Category
SourceCode
Documents
Books
WEB Code
Develop Tools
Other resource
Sub Category
ARM-PowerPC-ColdFire-MIPS
Embeded Linux
SCM
VxWorks
uCOS
DSP program
Windows CE
VHDL-FPGA-Verilog
Other Embeded program
QNX
hardware design
Open-source hardware
Search - compare d - List
[
Embeded Linux
]
misc2
DL : 0
Simple exercise that calculate the Taylor expansion of the exponential function. Input variables: degree N vector of evaluation points, x At each step plots the Taylor polynomial and compare with the real function function y=taylor_exp(N,x) printf("Order of the expansion: d ", N) size(x) y=ones(size(x)) plot(x,y,"r-",x,exp(x),"b-") legend("n=0,exp(x)") for n=1:N y+=(1/factorial(n))*(x.^n) plot(x,y,"r-",x,exp(x),"b-") xlabel("x") ylabel("f(x)") legend("approx","exp(x)") pause end endfunction - Simple exercise that calculate the Taylor expansion of the exponential function. Input variables: degree N vector of evaluation points, x At each step plots the Taylor polynomial and compare with the real function function y=taylor_exp(N,x) printf("Order of the expansion: d ", N) size(x) y=ones(size(x)) plot(x,y,"r-",x,exp(x),"b-") legend("n=0,exp(x)") for n=1:N y+=(1/factorial(n))*(x.^n) plot(x,y,"r-",x,exp(x),"b-") xlabel("x") ylabel("f(x)") legend("approx","exp(x)") pause end endfunction
Date
: 2025-12-26
Size
: 9kb
User
:
ali
CodeBus
is one of the largest source code repositories on the Internet!
Contact us :
1999-2046
CodeBus
All Rights Reserved.