Re: [問題] 方程式多個根的處理

看板Mathematica作者 (1597463007)時間9年前 (2014/07/10 14:11), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《CUCUMBERER (瓜仔)》之銘言: : 大家好 : 不好意思占用大家的時間 : 在此先感謝各位進來看 : 目前我用Solve[]解了一個函數f(x) : 但是出來個根會有四個x1,x2,x3,x4 : 而我必須依照這四個不同根的大小順序,分別帶入四個不同的方程式中 : 列如 x1>x2>x3>x4 則我需要帶入g(x),h(x),i(x),j(x) : 形成g(x1),h(x2),i(x3),j(x4) : 問題: : 不知道是否可以指定解出來的數值為某些符號?如x1,x2,x3,x4 : 且這些符號具有大小上的關係 x1>x2>x3>x4 : 目前的作法是先用軟體解完後,再人工判斷每個根該帶入哪個方程式 : 謝謝大家 Solve 出來的東西長成這樣: {{x -> x1}, {x -> x2}, {x -> x3}, {x -> x4}} 所以 x /. 上面這一串 就會得到 {x1, x2, x3, x4} 然後你就可以對它 Sort (順帶一提, Sort[..., Greater] 可以由大排到小) 而對應代入的話可以使用 Inner, 這個是廣義內積, 其作用是 Inner[f, {a, b, c}, {p, q, r}, g] 會得到 g[f[a, p], f[b, q], f[c, r]] (跟一般內積比較可以看到 f 是"乘法", g 是"加法" 事實上 Inner[Times, list1, list2, Plus] 就等於 Dot[list1, list2] ) 所以你要的狀況就可以寫成 Inner[#1[#2]&, {g, h, i, j}, SortedSolutions, List] -- 'You've sort of made up for it tonight,' said Harry. 'Getting the sword. Finishing the Horcrux. Saving my life.' 'That makes me sound a lot cooler then I was,' Ron mumbled. 'Stuff like that always sounds cooler then it really was,' said Harry. 'I've been trying to tell you that for years.' -- Harry Potter and the Deathly Hollows, P.308 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.30.32 ※ 文章網址: http://www.ptt.cc/bbs/Mathematica/M.1404972673.A.7AC.html

07/10 14:26, , 1F
謝謝妳的解惑
07/10 14:26, 1F
文章代碼(AID): #1JlYw1Ui (Mathematica)
文章代碼(AID): #1JlYw1Ui (Mathematica)