Post Reply 
(11C) CUBIC EQUATION
06-09-2018, 06:05 PM (This post was last modified: 06-09-2018 07:14 PM by Dieter.)
Post: #6
RE: (11C) CUBIC EQUATION
(06-09-2018 12:54 PM)Dieter Wrote:  Maybe I can post a program that calculates the solutions directly. This should be much faster.

OK, here it is. This should run on various classic RPN HPs, including the 11C, 15C, 67/97, 41 and maybe others.

Code:
001  LBL C
002  STO 3
003  R↓
004  STO 2
005  R↓
006  STO 1
007  R↓
008  STO/1
009  STO/2
010  STO/3
011  RCL 1
012  ENTER
013  x^2
014  4
015  .
016  5
017  /
018  RCL 2
019  -
020  RCL 1
021  3
022  /
023  STO 1
024  *
025  STO+3
026  R↓
027  RCL 1
028  *
029  STO-2
030  RCL 2
031  3
032  /
033  ENTER
034  X^2
035  *
036  STO 0
037  RCL 3
038  2
039  /
040  x^2
041  +
042  x<0?
043  GTO 3
044  SQRT
045  ENTER
046  ENTER
047  RCL 3
048  2
049  /
050  -
051  X<>Y
052  LastX
053  +
054  CHS
055  GSB 0
056  STO 2
057  STO 3
058  X<>Y
059  GSB 0
060  STO+2
061  STO-3
062  LBL 2
063  RCL 2
064  RCL 1
065  -
066  R/S
067  RCL 2
068  2
069  /
070  RCL 1
071  +
072  CHS
073  RCL 3
074  .
075  7
076  5
077  SQRT
078  *
079  ABS
080  PAUSE
081  X<>Y
082  R/S
083  GTO 2
084  LBL 0
085  x=0?
086  RTN
087  ENTER
088  ABS
089  /
090  LastX
091  3
092  1/x
093  Y^X
094  *
095  RTN
096  LBL 3
097  RCL 3
098  CHS
099  2
100  /
101  RCL 0
102  CHS
103  SQRT
104  /
105  COS-1
106  3
107  STO/2
108  /
109  STO 3
110  RCL 2
111  CHS
112  SQRT
113  2
114  *
115  STO 2
116  LBL 1
117  RCL 2
118  RCL 3
119  COS
120  *
121  RCL 1
122  -
123  R/S
124  ENTER
125  .
126  5
127  CHS
128  COS-1
129  STO-3
130  GTO 1

The program determines the roots for ax³+bx²+cx+d.
It uses the data registers 0...3. "COS-1" is the inverse cosine (cos–1).
If you want to see the discriminant you may insert a PAUSE between line 041 and 042.
Even on slow machines like the 11C or 67/97 the program should run within a few seconds.

Usage:
a [ENTER] b [ENTER] c [ENTER] d

[C] => first real root

- if three real roots exist:
[R/S] => second root
[R/S] => third root

- if the other two roots are complex (conjugate):
[R/S] => "imaginary part", real part
Both parts can be reviewed with the [X<>Y] key.

Examples:

2x³ + 3x² – 6x – 5

2 [ENTER] 3 [ENTER] 6 [CHS] [ENTER] 5 [CHS]
  [C]    1,5297
[R/S] –0,7022
[R/S] –2,3275

x³ + x² + x – 1

1 [ENTER] 1 [ENTER] 1 [ENTER] 1 [CHS]
  [C]    0,5437
[R/S] "1,1151"  –0,7718

So the real root is at 0,5437 and the two others are –0,7718 ±1,1151 i.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) CUBIC EQUATION - Gamo - 06-09-2018, 11:49 AM
RE: (11C) CUBIC EQUATION - Gamo - 06-09-2018, 12:34 PM
RE: (11C) CUBIC EQUATION - Dieter - 06-09-2018, 12:54 PM
RE: (11C) CUBIC EQUATION - rprosperi - 06-09-2018, 01:00 PM
RE: (11C) CUBIC EQUATION - Dieter - 06-09-2018 06:05 PM
RE: (11C) CUBIC EQUATION - Dieter - 06-09-2018, 07:50 PM
RE: (11C) CUBIC EQUATION - Dieter - 06-10-2018, 07:15 AM
RE: (11C) CUBIC EQUATION - Dieter - 06-10-2018, 09:17 PM
RE: (11C) CUBIC EQUATION - Albert Chan - 07-20-2021, 10:12 PM
RE: (11C) CUBIC EQUATION - Gamo - 06-10-2018, 02:42 AM
RE: (11C) CUBIC EQUATION - Gamo - 06-10-2018, 02:36 PM
RE: (11C) CUBIC EQUATION - Dieter - 06-10-2018, 03:34 PM
RE: (11C) CUBIC EQUATION - Dieter - 06-10-2018, 09:35 PM
RE: (11C) CUBIC EQUATION - Gamo - 06-11-2018, 02:16 AM
RE: (11C) CUBIC EQUATION - Dieter - 06-11-2018, 07:04 AM
RE: (11C) CUBIC EQUATION - Gamo - 06-11-2018, 08:19 AM
RE: (11C) CUBIC EQUATION - Dieter - 06-11-2018, 08:19 PM
RE: (11C) CUBIC EQUATION - Gamo - 06-12-2018, 07:02 AM



User(s) browsing this thread: 2 Guest(s)