Showing posts with label integer part. Show all posts
Showing posts with label integer part. Show all posts

Saturday, March 26, 2022

March Calculus Madness Sweet Sixteen - Day 11: ∫ int(x) dx

 ------------


Welcome to March Calculus Madness!


------------


f(x) = IP(x), integer function, HP Prime



int(x):  integer part function


Domain:

0 ≤ x < 1;  int(x) = 0

1 ≤ x < 2;  int(x) = 1

2 ≤ x < 3;  int(x) = 2

3 ≤ x < 4;  int(x) = 3


Hence:


∫ int(x) dx for x = 1 to x = 2 

= lim a→2- ∫ 1 dx for x = 1 to x = a

= lim a→2-  a - 1

= 2 - 1

= 1


∫ int(x) dx for x = 2 to x = 3 

= lim a→3- ∫ 1 dx for x = 1 to x = a

= lim a→3-  2 * a - 2 * 2

= 2 * 3 - 4 

= 2


∫ int(x) dx for x = 3 to 4 

= lim a→4- ∫ 1 dx for x = 1 to a

= lim a→4-  3 * a - 3 * 3 

= 4 * 3 - 9

= 3


and so on...


∫ int(x) dx for x = 1 to x =3 

= (∫ int(x) dx for x =1 to x=2 )+ (∫ int(x) dx for x =2 to x=3) + (∫ int(x) dx for x=3 to x=4 )

= 1 + 2 + 3

= 6


The General Integral ∫ int(x) dx for x = 1 to x = t


∫ int(x) dx for x = 1 to x = t

= ∫ int(x) dx for x = 1 to x = int(t) + ∫ int(x) dx for x = int(t) to x = t

= lim a→int(t)- ∫ int(x) dx for x = 1 to x = a + ∫ int(x) dx for x = int(t) to x = t

= (1 + 2 + 3 + 4 + .... + t-1) + t * int(t) - int(t) * int(t)

= t * (t-1)/2 + t * int(t) - int^2(t)


Example:


∫ int(x) dx for x = 1 to x = 8.3

= (7 * 8)2 + (8.3 * 8 - 8^2)

= 30.4


Eddie 


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Sunday, August 1, 2021

Casio fx-115ES Plus: Ten Tips

 Casio fx-115ES Plus:  Ten Tips


This blog entry covers both the original and the current 2nd Edition of the Casio fx-115 ES Plus.  Here are ten things to help you know about some of the advanced features of the fx-115 ES Plus, including some things to watch out for.  


I believe this also covers the fx-991 ES Plus 2nd Edition (NOT the Classwiz).  


Tip 1:  Integer Division and Modulus


Find the quotient and remainder of a division problem by pressing [ALPHA] [ []/[] ] (÷R).   We can use this calculate the modulo of two positive numbers (use caution with negative numbers).


Example 1:  364 mod 20 = 4

364÷R20 returns 18, R = 4

(18 * 20 + 4 = 364)


Example 2:  178.5 mod 18.5 = 12 

178.5÷R18.5 returns 9,R=12

(9 * 18.5 + 12 = 178.5)


Tip 2:  Solving Quadratic Equations Also Calculates the Extrema Point


Solving quadratic equations in EQN mode will present the point of the parabola's extrema point (minimum or maximum).  Keep on pressing [ ↓ ] or [ = ].


[ Mode ],  5:  EQN,  3:  aX^2+bX+c=0


Example 1:  4 * x^2 + 13 * x + 5 = 0

[ 4, 13, 5]

X1 = (-13+√89)/8   (MthIO mode)

X2 = (-13-√89)/8

X-Value Minimum = -13/8

Y-Value Minimum = -89/16


Example 2:  -2 * x^2 + 5 * x + 10 = 0

[-2, 5, 10]

X1 = (5+√105)/4

X2 = (5-√105)/4

X-Value Maximum = 5/4

Y-Value Maximum = 105/8


Please note that results and coefficients are not stored in variables.  This goes for all the equations in EQN mode, including finding roots of a polynomial and solving simultaneous equations.  


Tip 3:  Solving Quadratic Inequalities


The Inequality mode solves inequalities for quadratic and cubic equations.  


[ MODE ], [ ↓ ], 1: INEQ,  1 for quadratic equation/2 for cubic equation, select inequality:


1:  >0

2:  <0

3:  ≥0

4:  ≤0


Example:  Solve x^3 + 2 * x - 3 > 0

[1, 0, 2, -3], option 2

Result:  1<X


Tip 4:  The Percent Function


The percent function ( [ SHIFT ] [ ( ] (%) ) just divides the argument by 100.  This can lead to puzzling results when working addition and subtraction problems involving percent.


8 + 10% returns 8.1   (10% converts it to 0.1)

8 - 10% returns 7.9


To add and subtract percents properly, do this instead:


8(1 + 10%) returns 8.8

8(1 - 10%) returns 7.2


Tip 5:  Limited Powers in Complex Mode


In complex mode (CMPLX), the only powers available to be calculated are x^2 and x^3.   To take any complex number to any real power will require the use of De Moivre's formula:


(x + yi)^n = r^n * cos θ + i * r^n * sin θ


My suggestion to use COMP mode, with the Rec and Pol conversions.  In CMPLX mode, rectangular/polar conversions do not store results.  In COMP mode, rectangular/polar conversions store results in the following variables:


X:  x, r

Y:  y, θ


Tip 6:  Solve Equations for Any Variable


We can use the general solver in COMP mode to solve for any variable.  The syntax is:


equation, variable;  press [ SHIFT ], [ CALC ] (SOLVE)


If variable is omitted, the variable to be solved for assumed to be X.


If the equation does not contain an equals sign (=), the solver finds the root for equation, assuming equation=0.


The entries and results are stored in variables. 


In Radians mode:

Example 1: y = x * sin x  with y =0.5

We are solving for x, so we can eliminate the variable argument.


Y=X*sin(X), [ SHIFT ], [ CALC ]

Enter 0.5 for Y

Enter a guess for X, I chose 1.

Result:  X = 0.7408409551, L-R = 0


Example:  2 * a - b = 3 * c, solve for b when a = 2 and c = -1.

2A-B=3C, B, [ SHIFT ], [ CALC ]

Enter 2 for A

Enter -1 for C

Enter a guess for B, I chose 1 (again).

Result:  B = 7, L-R = 0


Caution:  Some equations can not be solved on the fx-115 ES Plus.  In particular, involving integrals and derivatives.  


Tip 7:  The Repeating Decimal Bar


I think this may be only calculator (yet), that allows the use to easily type in a bar to represent repeating decimals.  


Example:

1.45454545454545454545....   can be typed with 1.45 with the bar over the 45, or 1, [ . ], [ ALPHA ], [ √ ] ( bar ) 45


Pressing [ = ] returns 16/11 (assuming MthIO is set).  Repeated uses of [ S←→D ] gives 1.(45), 1.454545455, 16/11.


Tip 8:  Integer Part and Greatest Integer Function (Floor)


Int ( [ ALPHA ] [ + ] ):  Returns the integer part of a number


Intg ( [ALPHA] [ - ] ):  Returns the floor function of a number, the largest integer that does not exceed the given number.  


Example 1:

Int(-12.96) returns -12

Intg(-12.96) returns -13


To find the (calculator) fractional part of a number, enter n - Int(n).  


Tip 9:  Use CALC to Formula Evaluation


In addition to the Table mode, using [ CALC ] in COMP mode allows the user to evaluate a formula using different expressions.   As long as you keep pressing [ = ], the prompting for variables and calculations repeat.  The latest values are updated in the memory registers.


Expressions may take the form of:


variable = expression


To results are stored in the designated variable.


Example:   Evaluate for y when x = 0.2, x = 0.7, and x = 1.2 when y = x^3 + 15 * log x

Y=X^3+15*log(X)   

[ CALC ]

Enter 0.2 for X, [ = ]

Result #1: -10.49255007, [ = ]

Enter 0.7 for X, [ = ]

Result #2: -2.6665294, [ = ]

Enter 1.2 for X, [ = ]

Result #3:  -0.5402813093 


Press [ AC ] to exit.


Tip 10:  Previous Answers are Stored Two-Deep in COMP Mode


In COMP mode, we have both Ans and PreAns ([ALPHA], [ Ans ]).  PreAns recalls the answer from two calculations ago.  


Be careful, switching modes with most likely clear the PreAns register (zero).  Also, PreAns is only available in COMP mode.


Bonus:  Checking the fx-115ES Plus 2nd Edition's ID  (2nd Edition only)


You can see the calculator's ID along with a bar code which allows to test whether the calculator is a genuine Casio calculator.  


I hope you find these tips helpful,


Eddie


All original content copyright, © 2011-2021.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author

Sunday, November 4, 2018

HP Prime Firmware Update: Firmware 14181

HP Prime Firmware Update



The newest firmware update (version 14181) is now released.  Changes include:

* New function UVAL and UPART.  UVAL extracts the value from a unit object (example:  10 from 10_m) while UPART extracts the unit part (example 1_m from 10_m).

* The DMS key [Shift] (° ' '' )  now will work everywhere.  

* The fraction part (FP) and integer part (IP) functions will work with unit objects.

* Large matrices, strings, and other objects will now be displayed with an ellipsis (...).  To see the full object, scroll up, select the big expression and press on the soft key (Show). 


Link to the updated firmware:  ftp://ftp.hp.com/pub/calculators/Prime/



Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Friday, March 30, 2018

Retro Review: Texas Instruments TI-54

Retro Review:  Texas Instruments TI-54



General Information

Company:  Texas Instruments
Type:  Scientific
Memory:  7 memory registers
Battery:  2 x LR-44 or 2 x AR-76
Years:  1981 - 1983
Original Cost: $40
Operating System: AOS, Immediate Execution
Storage Arithmetic:  +, -, *, ÷, ^, roots, percent change

It’s good to finally to get the calculator that accompanies the Scientific Calculator Sourcebook that I bought years ago. 

Features

The TI-54 is a scientific calculator with a lot of additional features over the typical non-programming scientific calculator that was released at the time. 

Percent Key (Δ%) 

I think the percent works backwards than modern calculators.   Press the new value first, then [2nd] ( Δ% ), then old value, [ = ].

Example:  Percent change from 32 to 56:  56 [2nd]  (Δ%) 32 [ = ] 75  (75% increase)

Combinations and Permutations

Like the TI-55 III, the arguments for combination and permutation functions take one argument in the form of nnn.rrr.  

Example:

Combination where n = 25, r = 5 is entered as 25.005 [2nd] [ 9 ] (nCr)  
(Result: 53,130)

Permutation where n = 25, r = 5 is entered as 25.005 [2nd] [ 8 ] (nPr)  
(Result:  6,375,600)

Rectangular/Polar Conversion

[2nd] [x<>y] (P-R):  to Rectangular.  Input:  r [x<>y] θ [2nd] [x<>y] (P-R).  Result: y [x<>y] x.

[INV] [2nd] [x<>y] (P-R):  to Polar.   Input x [x<>y] y [INV] [2nd] [x<>y] (P-R).  Result:  θ [x<>y] r.

Statistics

The TI-54 has one variable and two variable statistics, with linear regression of the equation y = a * x + b.   The b/a key gives the intercept and slope.  Predictive values and correlation are also available.

Extra Functions

The TI-54 also has percent change, absolute value, fractional part, and integer part. 

Other Functions

Other functions include degree/degree-minutes-seconds conversions and constant operations with [ K ].

Complex Numbers

Perhaps the biggest attraction of the TI-54 is the complex number mode.  Complex mode is activated as soon as the complex number is entered.

To enter complex numbers:

Rectangular:  b [ Img ] a

Polar:  θ [ θ ] r

Since the display is one number, the real part/magnitude is default shown.  To show the complex part, press [ EXC ] [ Img ]/[ θ ] to show the imaginary part/angle.  The user will know if that the imaginary part/angle is shown by the CMPLX indicator is flashing.

The amount of functions to complex functions offered are greater than most scientific calculators would offer, which is impressive at the time:  arithmetic, power, natural logarithms, exponentials, square root, and square.

Keyboard

Scientific calculators that were produced from Texas Instruments in that era (early 1980s) had a reputation for their not so great keyboards, affecting TI-54, TI-55 II, and TI-57.  Unfortunately, the keyboard is the Achilles’ Heel for this model.  On occasion, pressing the key doesn’t register, and occasion the key registers twice.  This problem is prevalent on the number keys.   So operating the TI-54 will require patience and maybe a few extra presses of the [ON/C] key.  Other than this, the TI-54 worked well. 

Verdict

If you are to purchase a TI-54, please be aware of possible keyboard issues, other than that it is a good calculator.

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions

Sunday, October 8, 2017

Adventures in Python: Generating Random Numbers

Adventures in Python:  Generating Random Numbers

This program generates a list of random numbers between 0 and 1, using the pseudo-random number generator frac((π + t)^5). 

To use a pseudo-random number generator, you will need an initial seed.  This program uses the fractional part of the number of ticks from January 1, 1970.  To get ticks, you will need to import the time module.  Call the number of ticks by the time.time() function.

Python has no native fractional part.  To extract the fractional part of a number, the following formula is required, where t is any variable:

t = t – math.trunc(t)

The function math.trunc(t) truncates t and returns the integer part.

Keep in mind, to generate n items, use the for loop with the in range(0, n-1)

# Program 006 - Random Number Generation
print("Random number generation")

# import time, use as a seed
import time
t = time.time()
print

# since t is a floating number
# lets import math and use
# math.trunc

import math
t = t - math.trunc(t)

# We are going to use a psuedo-random
# formula to generate n numbers.  n
# will be an integer as range requires.
n = int(input("How many random numbers?"))
for k in range(0,n-1):
     t = (math.pi + t)**5
     t = t - math.trunc(t)
     print(t)

Output (15 numbers generated):

Random number generation
How many random numbers?15
0.8619577822222482
0.5526325838995945
0.045018018769951595
0.5829554424582284
0.7503835409480644
0.9988016770092827
0.770091723446285
0.8387765088751848
0.11795716208871454
0.9494124177641083
0.9088916269388392
0.2717401531838277
0.3329376152682926
0.38460892637095867
(your answers will vary)

Eddie


This blog is property of Edward Shore, 2017.

Sunday, September 4, 2016

HP 12C Platinum: Finding the Day of Easter

HP 12C Platinum:  Finding the Day of Easter

An Easter Algorithm

One can figure out when Easter is by the following algorithm:

  c = y / 100

    n = y - 19 * ( y / 19 )

    k = ( c - 17 ) / 25

    i = c - c / 4 - ( c - k ) / 3 + 19 * n + 15

    i = i - 30 * ( i / 30 )

    i = i - ( i / 28 ) * ( 1 - ( i / 28 ) * ( 29 / ( i + 1 ) )

        * ( ( 21 - n ) / 11 ) )

    j = y + y / 4 + i + 2 - c + c / 4

    j = j - 7 * ( j / 7 )

    l = i - j

    m = 3 + ( l + 40 ) / 44

    d = l + 28 - 31 * ( m / 4 )
“  (see the Source below, http://aa.usno.navy.mil/faq/docs/easter.php )

The only input is y, the four digit year (1997, 2015, etc).   Each of the slashes “/” in the above text refers to integer division.  Hence in this case:  a/b refers to INTG(a ÷ b).

Other things I noticed while porting this algorithm to the HP 12C Platinum:

The line y - 19 * ( y / 19 ) can be expressed as y MOD 19 and 19 * fPart(y ÷ 19).   This happens in three other lines (2nd, 5th, and 8th).  See how to calculate the MOD function, when both arguments are positive on the HP 12C here:  http://edspi31415.blogspot.com/2016/07/hp-12c-programming-part-i-modulus-gcd.html

On the HP 12C Platinum, the LSTx function moved to [ g ] [ + ].  (Code 43, 40)

After the 5th line, the variable i will between 0 and 29.  If i ≤ 27, the 6th line can be skipped entirely since iPart(i/28) = 0.  Otherwise, iPart(i/28) = 1.  This cuts on down the number of steps needed.

I was also to combine some steps in the beginning by computing c and k while building i at the same time.

Storage arithmetic is allowed on R0 – R4 on both the HP 12C Platinum and the classic HP 12C.  By the way, the reason why I mention the HP 12C Platinum is that this program is 133 steps.  Only 99 steps are possible on the classic HP 12C.

Store registers:
R0: four digit year
R1:  c, m (result: month)
R2:  n, j, d (result: day)
R3: k, l
R4: i

Instructions:  Enter the four digit year.  Press [ R/S ].  The month will be displayed (stored in R1).  Press [ R/S ] to get the day (stored in R2).

HP12C Platinum Program:  Easter

STEP
CODE
KEY
Notes
001
44, 0 
STO 0
Store year (y)
002
1
1

003
25
%

004
43, 25
INTG

005
44, 1
STO 1
Store c
006
44, 4
STO 4
Start i
007
 36
ENTER
To fill the stack
008
36
ENTER

009
4
4

010
10
÷

011
43, 25
INTG

012
44, 30, 4
STO- 4

013
33
R↓

014
36
ENTER

015
36
ENTER

016
1
1

017
7
7

018
30
-

019
2
2

020
5
5

021
10
÷

022
43, 25
INTG

023
44, 3
STO 3
Store k
024
30
-

025
3
3

026
10
÷

027
43, 25
INTG

028
44, 30, 4
STO- 4

029
1
1

030
5
5

031
44, 40, 4
STO+ 4

032
45, 0
RCL 0

033
1
1

034
9
9

035
10
÷

036
43, 40
LSTx
LSTx is [ g ] [ + ] on the Platinum
037
34
X<>Y

038
43, 24
FRAC

039
20
*
 y MOD 19
040
44, 2
STO 2
 Store n
041
1
1

042
9
9

043
20
*

044
44, 40, 4
STO+ 4

045
45, 4
RCL 4

046
3
3

047
0
0

048
10
÷

049
43, 40
LSTx

050
34
X<>Y

051
43, 24
FRAC

052
20
*

053
44, 4
STO 4
i MOD 30
054
2

055
7
7

056
45, 4
RCL 4

057
43, 44
x≤y
Is i≤27?
058
43, 33, 080
GTO 080
If so, go to step 080
059
2
2

060
9
9

061
45, 4
RCL 4

062
1
1

063
40
+

064
10
÷

065
43, 25
INTG

066
20
*

067
1
1

068
34
X<>Y

069
30
-

070
2
2

071
1
1

072
45, 2
RCL 2

073
30
-

074
1
1

075
1
1

076
10
÷

077
43, 25
INTG

078
20
*

079
44, 30, 4
STO- 4

080
45, 0 
RCL 0

081
45, 2
STO 2
Start j
082
4
4

083
10
÷

084
43, 25
INTG

085
 44, 40, 2
STO+ 2

086
45, 4
RCL 4

087
2
2

088
40
+

089
45, 1
RCL 1

090
30
-

091
44, 40, 2
STO+ 2

092
45, 1
RCL 1

093
4
4

094
10
÷

095
43, 25
INTG

096
44, 40, 2
STO+ 2

097
45, 2
RCL 2

098
7
7

099
10
÷

100
43, 40
LSTx

101
34
X<>Y

102
43, 24
FRAC

103
20
*

104
44, 2
STO 2
j MOD 7
105
 45, 4
RCL 4

106
34
X<>Y

107
30
-

108
44, 3
STO 3
Store l
109
4
4

110
0
0

111
40
+

112
4
4

113
4
4

114
10
÷

115
43, 25
INTG

116
3
3

117
40
+

118
44, 1
STO 1
Store month (m)
119
31
R/S
Displays m
120
4
4

121
10
÷

122
43, 25
INTG

123
3
3

124
1
 1

125
20
*

126
16
CHS

127
2
2

128
8
8

129
40
+

130
45, 3
RCL 3

131
40
+

132
44 , 2
STO 2
Store day (d)
133
43, 33, 000
GTO 000
Stop, display d


Examples and Test Data:

2016: 3, 27
Keystrokes:  2016 [R/S] [R/S]

1995: 4, 16
2124: 4, 2
1977: 4, 10
2017: 4, 16
1826: 3, 26

These results have been verified. 

Now we can determine when is Easter at any year.  Happy Easter in advance!

Eddie

Source:    The United States Naval Observatory  “The Date of Easter”  March 11, 2016.  http://aa.usno.navy.mil/faq/docs/easter.php  Retrieved September 2, 2016



This blog is property of Edward Shore, 2016.

Earth's Radius by Latitude

Earth's Radius by Latitude Introduction: Calculating the Earth’s Radius In quick, general calculations, we assume that the...