| 2 | 1/1 | 返回列表 |
| 查看: 487 | 回復(fù): 1 | ||
livin325新蟲 (初入文壇)
|
[求助]
Sine Approximation 已知angle&閾值,返回terms值
|
|
輸入兩個(gè)參量X 和 threshold. 逐漸添加terms值,直到滿足 abs((true 􀀀-approx)/true)< threshold ; true 是系統(tǒng)built-in 方程式sin(x)。 sin(x) = x 􀀀- x^3/3! + x^5/5! - x^7/7!+... 方程式要返回2值。 approx和terms(添加了幾個(gè)數(shù)) 輸入X=pi/5, threshold=1e-6時(shí),顯示如下: >> format long >> x = pi/5; >> threshold = 1e-6; >> [approx, terms] = approx_sine(x, threshold) approx = 0.587785210384344 terms = 3 以下是本人方程式: 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 請指點(diǎn),為啥返回approx錯(cuò)誤,而且還沒返回terms值(請使用while loop解題) >> sine function(pi/5, 1e-6) approx = 1.256637061435917 ans = 1.256637061435917 |
新蟲 (初入文壇)
| 2 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 085601材料工程專碩求調(diào)劑 +10 | 慕寒mio 2026-03-16 | 10/500 |
|
|---|---|---|---|---|
|
[考研] 一志愿天津大學(xué)化學(xué)工藝專業(yè)(081702)315分求調(diào)劑 +11 | yangfz 2026-03-17 | 11/550 |
|
|
[考研] 286求調(diào)劑 +6 | lemonzzn 2026-03-16 | 10/500 |
|
|
[考研] 化學(xué)求調(diào)劑 +3 | 臨澤境llllll 2026-03-17 | 4/200 |
|
|
[考研] 294求調(diào)劑材料與化工專碩 +11 | 陌の森林 2026-03-18 | 11/550 |
|
|
[考研] 材料考研調(diào)劑 +3 | xwt。 2026-03-19 | 3/150 |
|
|
[考研] 材料專碩英一數(shù)二306 +5 | z1z2z3879 2026-03-18 | 5/250 |
|
|
[考研] 0703化學(xué)調(diào)劑,求各位老師收留 +10 | 秋有木北 2026-03-14 | 10/500 |
|
|
[考研] 311求調(diào)劑 +11 | 冬十三 2026-03-15 | 12/600 |
|
|
[考博] 環(huán)境領(lǐng)域全國重點(diǎn)實(shí)驗(yàn)室招收博士1-2名 +3 | QGZDSYS 2026-03-13 | 5/250 |
|
|
[考研] 0703化學(xué)調(diào)劑 +3 | 妮妮ninicgb 2026-03-17 | 3/150 |
|
|
[考研] 265求調(diào)劑 +3 | 梁梁校校 2026-03-17 | 3/150 |
|
|
[考研] [導(dǎo)師推薦]西南科技大學(xué)國防/材料導(dǎo)師推薦 +3 | 尖角小荷 2026-03-16 | 6/300 |
|
|
[考研] 304求調(diào)劑 +4 | ahbd 2026-03-14 | 4/200 |
|
|
[考研] 321求調(diào)劑 +5 | 大米飯! 2026-03-15 | 5/250 |
|
|
[考研] 0703一志愿211 285分求調(diào)劑 +5 | ly3471z 2026-03-13 | 5/250 |
|
|
[考研] 327求調(diào)劑 +6 | 拾光任染 2026-03-15 | 11/550 |
|
|
[考研] 329求調(diào)劑 +3 | miaodesi 2026-03-12 | 4/200 |
|
|
[考研] 295求調(diào)劑 +3 | 小匕仔汁 2026-03-12 | 3/150 |
|
|
[考研] 333求調(diào)劑 +3 | 152697 2026-03-12 | 4/200 |
|