| 2 | 1/1 | 返回列表 |
| 查看: 486 | 回復(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 請(qǐng)指點(diǎn),為啥返回approx錯(cuò)誤,而且還沒返回terms值(請(qǐng)使用while loop解題) >> sine function(pi/5, 1e-6) approx = 1.256637061435917 ans = 1.256637061435917 |
新蟲 (初入文壇)
| 2 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 招收調(diào)劑碩士 +3 | lidianxing 2026-03-19 | 9/450 |
|
|---|---|---|---|---|
|
[考研] 294求調(diào)劑材料與化工專碩 +11 | 陌の森林 2026-03-18 | 11/550 |
|
|
[考研] 本科鄭州大學(xué)物理學(xué)院,一志愿華科070200學(xué)碩,346求調(diào)劑 +4 | 我不是一根蔥 2026-03-18 | 4/200 |
|
|
[考研] 328求調(diào)劑,英語六級(jí)551,有科研經(jīng)歷 +3 | 生物工程調(diào)劑 2026-03-17 | 7/350 |
|
|
[考研] 一志愿西南交大,求調(diào)劑 +4 | 材化逐夢(mèng)人 2026-03-18 | 4/200 |
|
|
[考研] 312求調(diào)劑 +8 | 陌宸希 2026-03-16 | 9/450 |
|
|
[考研] 280求調(diào)劑 +6 | 咕嚕曉曉 2026-03-18 | 7/350 |
|
|
[考研] 0703化學(xué)調(diào)劑 +3 | 妮妮ninicgb 2026-03-17 | 3/150 |
|
|
[考研] 268求調(diào)劑 +7 | 好運(yùn)連綿不絕 2026-03-12 | 8/400 |
|
|
[考研] 085601求調(diào)劑 +4 | Du.11 2026-03-16 | 4/200 |
|
|
[考研] 藥學(xué)383 求調(diào)劑 +3 | 藥學(xué)chy 2026-03-15 | 4/200 |
|
|
[考研] 機(jī)械專碩325,尋找調(diào)劑院校 +3 | y9999 2026-03-15 | 5/250 |
|
|
[考研] 318求調(diào)劑 +3 | Yanyali 2026-03-15 | 3/150 |
|
|
[考研] 070300化學(xué)學(xué)碩求調(diào)劑 +6 | 太想進(jìn)步了0608 2026-03-16 | 6/300 |
|
|
[考研] 294求調(diào)劑 +3 | Zys010410@ 2026-03-13 | 4/200 |
|
|
[考研] 297一志愿上交085600求調(diào)劑 +5 | 指尖八千里 2026-03-14 | 5/250 |
|
|
[考研] 一志愿哈工大材料324分求調(diào)劑 +5 | 閆旭東 2026-03-14 | 5/250 |
|
|
[考研] 304求調(diào)劑 +6 | Mochaaaa 2026-03-12 | 7/350 |
|
|
[考研] 304求調(diào)劑 +7 | 7712b 2026-03-13 | 7/350 |
|
|
[考研] 26調(diào)劑/材料科學(xué)與工程/總分295/求收留 +9 | 2026調(diào)劑俠 2026-03-12 | 9/450 |
|