| ²é¿´: 488 | »Ø¸´: 1 | ||
livin325гæ (³õÈëÎÄ̳)
|
[ÇóÖú]
Sine Approximation ÒÑÖªangle&ãÐÖµ£¬·µ»ØtermsÖµ
|
|
ÊäÈëÁ½¸ö²ÎÁ¿X ºÍ threshold. Öð½¥Ìí¼ÓtermsÖµ,Ö±µ½Âú×ã abs£¨(true 􀀀-approx)/true)< threshold ; true ÊÇϵͳbuilt-in ·½³Ìʽsin(x)¡£ sin(x) = x 􀀀- x^3/3! + x^5/5! - x^7/7!+... ·½³ÌʽҪ·µ»Ø2Öµ¡£ approxºÍterms£¨Ìí¼ÓÁ˼¸¸öÊý£© ÊäÈëX=pi/5, threshold=1e-6ʱ£¬ÏÔʾÈçÏ£º >> format long >> x = pi/5; >> threshold = 1e-6; >> [approx, terms] = approx_sine(x, threshold) approx = 0.587785210384344 terms = 3 ÒÔÏÂÊDZ¾ÈË·½³Ìʽ£º function [approx, terms] = approx_sine(x, threshold) approx = x; % ³õʼ approximation terms = 0; % Number of additional terms added to improve the approximation while threshold > abs((sin(x)-approx)/sin(x)) terms = terms + 1; approx = approx + (-1)^(terms)*x.^(2*terms+1)/factorial(2*terms+1) end end ÇëÖ¸µã£¬ÎªÉ¶·µ»Øapprox´íÎ󣬶øÇÒ»¹Ã»·µ»ØtermsÖµ£¨ÇëʹÓÃwhile loop½âÌ⣩ >> sine function(pi/5, 1e-6) approx = 1.256637061435917 ans = 1.256637061435917 |
» ²ÂÄãϲ»¶
324·Ö 085600²ÄÁÏ»¯¹¤Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
Ò»Ö¾Ô¸»ªÖпƼ¼´óѧ£¬080502£¬354·ÖÇóµ÷¼Á
ÒѾÓÐ5È˻ظ´
Ò»Ö¾Ô¸ÎäÀí²ÄÁÏ305·ÖÇóµ÷¼Á
ÒѾÓÐ7È˻ظ´
271²ÄÁϹ¤³ÌÇóµ÷¼Á
ÒѾÓÐ8È˻ظ´
¡¾¿¼Ñе÷¼Á¡¿»¯Ñ§×¨Òµ 281·Ö£¬Ò»Ö¾Ô¸ËÄ´¨´óѧ£¬³ÏÐÄÇóµ÷¼Á
ÒѾÓÐ8È˻ظ´
Ò»Ö¾Ô¸»ªÄÏʦ´ó 070300£¨»¯Ñ§£©304·ÖÇóµ÷¼Á
ÒѾÓÐ3È˻ظ´
Ò»Ö¾Ô¸ Î÷±±´óѧ £¬070300»¯Ñ§Ñ§Ë¶£¬×Ü·Ö287£¬Ë«·ÇÒ»±¾£¬Çóµ÷¼Á¡£
ÒѾÓÐ3È˻ظ´
Ò»Ö¾Ô¸ÖØÇì´óѧ085700×ÊÔ´Óë»·¾³×¨Ë¶£¬×Ü·Ö308Çóµ÷¼Á
ÒѾÓÐ3È˻ظ´
354Çóµ÷¼Á
ÒѾÓÐ8È˻ظ´
304Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
livin325
гæ (³õÈëÎÄ̳)
- Ó¦Öú: 0 (Ó×¶ùÔ°)
- ½ð±Ò: 82
- Ìû×Ó: 7
- ÔÚÏß: 3.9Сʱ
- ³æºÅ: 4215547
- ×¢²á: 2015-11-13
- רҵ: »·¾³¹¤³Ì
2Â¥2015-12-02 05:49:27













»Ø¸´´ËÂ¥