Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

Equation of the third degree. Find similar branches


mashinist   (2001-12-16 23:16) [0]

I’m here, it seems like everyone is already sick of it with my math, but still. Does anyone have a piece of code to solve a third-degree equation of the form ax ^ 3 + bx ^ 2 + cx + d = 0, with a, b, c, d: extended;

Help



Builder   (2001-12-17 02:35) [1]

But isn’t it easier than fucking, sitting down and writing yourself?

Take any book on numerical methods - this is in the first section.



mashinist   (2001-12-17 11:58) [2]

Does not work.
Already tried.



Romkin   (2001-12-17 12:19) [3]

http://alglib.chat.ru/equat/index.html#cube
In my opinion, exhaustively
But, in general, equations above the second degree are usually solved not by exact formulas, but by algorithms for finding the roots of polynomials of the nth degree



savva   (2001-12-17 12:31) [4]

this is what the block diagram editor suggested
Procedure CubeEquation (a, b, c: real; var nr: byte; x: array [1..3] of real); // for some reason, the 8 parameters are not described for some reason)) you yourself will describe begin p: = - a * a / 3 + b; q: = 2 * a / 3 * a / 3 * a / 3-a * b / 3 + c; QH: = (p / 3) * (p / 3) * (p / 3) + (q / 2) * (q / 2); if QH = 0 then begin nr: = 3; AH: = abs (q / 2); if AH <> 0 then begin AH: = sign (q) * exp (ln (AH) / 3) end; x [1]: = 2 * AH-a / 3; x [2]: = - AH-a / 3; x [3]: = - AH-a / 3 end else begin if QH> 0 then begin AH: = - q / 2 + sqrt (QH); AH: = sign (AH) * exp (ln (abs (AH)) / 3); BH: = - q / 2-sqrt (QH); BH: = sign (BH) * exp (ln (abs (BH)) / 3); x [1]: = AH + BH-a / 3; if AH = BH then begin nr: = 3; x [2]: = - (AH + BH) / 2-a / 3; x [3]: = - (AH + BH) / 2-a / 3 end else begin nr: = 1; x [2]: = - (AH + BH) / 2-a / 3; x [3]: = (AH-BH) / 2 * sqrt (3) end; end else begin nr: = 3; u: = - q / 2 / sqrt (-p * p * p / 27); u: = arccos (u); x [1]: = 2 * sqrt (abs (p / 3)) * cos (u / 3) -a / 3; x [2]: = - 2 * sqrt (abs (p / 3)) * cos (u / 3 + Pi / 3) -a / 3; x [3]: = - 2 * sqrt (abs (p / 3)) * cos (u / 3-Pi / 3) -a / 3 end; end; end;

I don’t know whether to trust ...



SergVlad   (2001-12-17 13:58) [5]

To mashinist
Still struggling with your regulators?



Юрий Зотов   (2001-12-17 14:59) [6]

> Romkin © (17.12.01 12: 19)

I allow myself an amendment - above the third, and not the second. For cubic equations, however, there are exact formulas - for example, the Cardano formula. It is much simpler, faster and more accurate.



mashinist   (2001-12-17 15:40) [7]

Thank you!




Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top





Memory: 0.56 MB
Time: 0.034 c
14-22354
Nemesis
2001-10-08 13:02
2002.01.08
Mobile


1-22113
Yuraz
2001-12-19 20:25
2002.01.08
Brothers why


3-21934
Alexsyy
2001-12-04 08:52
2002.01.08
Help me please


1-22138
Serg5
2001-12-20 09:22
2002.01.08
People, tell me, and how to clear Image1, Clear did not find the function ...


14-22337
Alexander
2001-11-05 13:20
2002.01.08
Print Server DP-101 (D-Link) and printing from under DOS





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Spanish swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada Khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish