Showing posts with label absolute value. Show all posts
Showing posts with label absolute value. Show all posts

Thursday, March 17, 2022

March Calculus Madness Sweet Sixteen - Day 2: Derivative and Integral of the Absolute Value Function

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


Welcome to March Calculus Madness!


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


What is the derivative and the indefinite integral of the absolute value?


By defintion:


| x | = x when x ≥ 0, -x when x < 0


Hence:


d/dx | x | =   1 when x ≥ 0, and -1 when x < 0


and 


∫ | x | dx = x^/2 + C when x ≥ 0, abnd -x^2/2 + C when x < 0




What about |a∙x + b|?


The function |a∙x + b| hits the x-axis when:


a∙x + b = 0

a∙x = -b

x = -b/a


|a∙x + b| = 

(a∙x + b) when x ≥ (-b/a), 

and -(a∙x + b) when < (-b/a)


d/dx |a∙x + b| = 

a when x ≥ (-b/a),

and -A when < (-b/a)


∫ |a∙x + b| dx = 

A ∙ x^2/2 + C  when x ≥ (-b/a), 

and -A ∙ x^2/2 + C  when < (-b/a)



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, January 16, 2022

Lines with Opposite-Signed Slopes

 Lines with Opposite-Signed Slopes


Take two lines, each with opposite signed slopes.  One slope has a positive slope, the other has a negative slope.   In general, the pair of lines will always intersect at one point.


Define two lines as such:


y = m1 ∙ x  + b1,  where m is the slope and b is the y-intercept.   


y = m2 ∙ x + b2


Assume that m1 and m2 are not zero, and m1 > 0 and m2 < 0.


If m2 < 0, -|m2| < 0  (see Aside) 

and as a result, m2 = -|m2|   


Also,  since m1 > 0, |m1| > 0, and m1 = |m1|.   


Equating both lines and solving for x:   


m1 ∙ x + b1 = m2 ∙ x + b2

|m1| ∙ x + b1 = -|m2| ∙ x + b2

|m1| ∙ x + |m2| ∙ x = b2 - b1

x = (b2 - b1) ÷ (|m1| + |m2|)


Since m1 and m2 are not zero, the above solution is defined.   


QED


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

Aside:    If x < 0, then  -|x| < 0  


Assume x is not zero. 


By definition, the absolute value of x, denoted as |x|, is the defined as the distance x is from 0 and is always positive. 


Then:

|x| > 0 


Multiply both sides by -1:

-|x| < 0

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


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, March 7, 2021

Fun with the TI-73 Part II: Rolling Two Dice, Numerical Derivative, Rectangular/Polar Conversions

Fun with the TI-73 Part II: Rolling Two Dice, Numerical Derivative, Rectangular/Polar Conversions


TI-73 Program:  TWODICE - Rolling Two Dice


Introduction:


The program TWODICE will roll two regular dice and give the sum of those dice in three lists:


L_1: die 1

L_2: die 2

L_3: total


If there are seven rolls or less, the program displays the rolls.  In any case, the results are stored in the above lists.


Access L_1 by pressing [ 2nd ] [ STAT ] (LIST), 1

Access L_2 by pressing [ 2nd ] [ STAT ] (LIST), 2

Access L_3 by pressing [ 2nd ] [ STAT ] (LIST), 3


Program:


"EWS 2021"

Disp "ROLL THE DICE"

Input "ROLLS? ",X

dice(X)→L_1

dice(X)→L_2

L_1+L_2→L_3

If X≤7

Then

ClrScreen

For(A,1,X)

Output(A,1,L_1(A))

Output(A,3,L_2(A))

Output(A,6,L_3(A))

End

Pause

End

ClrScreen

Disp "L_1 = DIE 1","L_2 = DIE 2","L_3 = TOTAL"

Pause


Your results will vary.


TI-73 Program:  DERIVY1 - Numerical Derivative of y1(x)


The simple program DERIVY1 calculates the numerical derivatives of the equation stored in Y_1.  


Access Y_1 by pressing [ 2nd ] [ APPS ] (VARS), 2, 1


Program:


"EWS 2021"

Disp "D/DX Y_1"

Prompt X

10^(-8)→H

(2*H)^-1*(Y_1(X+H)-Y_1(X-H))→D

Disp "APPROX D/DX"

Pause D


Example:


Y_1 = (X^2-3)^2 + 1

Derivative at x = 0.95, Result:  -7.9705

Derivative at x = 2, Result:  8


Y_1 = e^(X^3/4)

Derivative at x = 0.46, Result: 0.16261

Derivative at x = 1.55, Result:  4.571295


TI-73 Program: RECPOL - Rectangular/Polar Conversion


This program has two conversions:


1.  >RECT:  Polar (r, θ) to Rectangular (x, y)

2.  >POLAR:  Rectangular (x, y) to Polar (r, θ)


This program works in either Degree or Radian mode.


I take a different approach to calculate angle than the atan2 method.  Approached this as calculating the angle between the vectors [ x, 0 ] and [ x, y].  The angle between vectors v1 and v2 is:


θ = acos( dot(v1, v2) / ( norm(v1) * norm(v2) ) = acos( x / √(x^2 + y^2))


The angle is negative if y<0.   


Like the argument and angle conversions, the point (0,0) is defined to have an angle of 0.


Since there is no theta character (θ) on the TI-73, I use the variable A instead.


Program:


"EWS 2021"

Lbl 0

Menu("MENU",">RECT",1,">POLAR",2,"EXIT",3)

Lbl 1

Input "R? ",R

Input "ANG? ",A

R*cos(A)→X

R*sin(A)→Y

Disp "X= ",X,"Y= ",Y

Pause

Goto 0

Lbl 2

Input "X? ",X

Input "Y? ",Y

√(X^2+Y^2)→R

If X=0 and Y=0

Then

0→A

Else

cos^-1(X/√(X^2+Y^2))→A

If Y<0

-A→A

End

Disp "R=",R,"ANG=",A

Pause

Goto 0

Lbl 3


Examples:


Examples are in Degree mode.


R = 19, ANG = 87.3°

Result:  X = 0.8950225635, Y = 18.97890762


X = -11.5, Y = 2.4

Result:  R = 1.74776575, ANG = 168.2118167



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. 


Saturday, August 22, 2020

HP Prime: Psuedo Ordering of Complex Numbers

HP Prime: Psuedo Ordering of Complex Numbers 


Can Complex Numbers be Ordered?

Not really, not if you consider what is required to be an ordered field.  The complex numbers can not be an ordered field, one counter example is illustrating the nonzero complex numbers i and 1, when squared and added together, you get zero.

i^2 + 1^2 = -1 + 1 = 0

If you order complex numbers by their modulus (absolute values) only, you run into the problem of having many complex numbers becoming equivalent.  Example:

2 + 3i  and 3 + 2i,  each with radius √13

One way to "psuedo" order complex numbers is to use the numbers looking at both their modulus and angle.   

z1  "<"  z2 if and only if one of the two conditions are met:

| z1 | < | z2 | or

| z1 | = | z2 | and atan(imag(z1)/real(z1)) < atan(imag(z2)/real(z2))

I believe we do not have about the unit of angle  (degrees vs. radians vs. grads) for this psuedo-ordering.

Please see the sources listed at the end of this article for more details. 


HP Prime Program:  CLESS

EXPORT CLESS(z1,z2)

BEGIN

// 2020-08-06 EWS

// psuedo ordering of 

// complex numbers

LOCAL a1,a2,t1,t2;

a1:=ABS(z1);

a2:=ABS(z2);

t1:=ATAN(IM(z1)/RE(z1));

t2:=ATAN(IM(z2)/RE(z2));

IF (a1<a2) OR ((a1==a2) AND (t1<t2)) THEN

RETURN "TRUE";

ELSE 

RETURN "FALSE";

END;

END;


Example (angle shown in radians, rounded to five decimal places):


These complex numbers are listed in order:

1 + i    (1.41421 ∠ 0.78540)

2 + i    (2.23067 ∠ 0.46365)

1+ 2i  (2.23607 ∠ 1.10715)

2 + 2i  (2.82843 ∠ 0.78540)

3 + i  (3.16228 ∠ 0.32175)

1 + 3i (3.16228 ∠ 1.24905)

3 + 2i (3.60555 ∠ 0.58800)

2 + 3i (3.60555 ∠ 0.98279)

4 + i (4.12311 ∠ 0.24498)


Sources:

Weimer, Richard C.   "Can the Complex Numbers Be Ordered?"  The Two-Year College Mathematics Journal, Dec. 1976, Vol. 7, No. 4.   Taylor & Francis, Ltd on behalf of the Mathematical Association of America.  https://www.jstor.org/stable/3027050?seq=1


Yada, Dharmendra Kumar.  "A New Approach to Ordering Complex Numbers"  International Journal of Mathematical Sciences and Engineering Applications (IJMSEA), Vol 2.  No. III (2008), pp. 221-223.   Article downloaded from ResearchGate:  https://www.researchgate.net/publication/267465398_A_new_approach_to_ordering_complex_numbers

Eddie

All original content copyright, © 2011-2020.  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. 


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

Saturday, August 5, 2017

HP Prime: abs(sqrt(z)) graph

HP Prime:  abs(sqrt(z)) graph



Marvel at the graph of complex numbers (really the magnitude of complex numbers) of the equation f = |√z|, where z = x + yi.   The graph takes place over the range of x: [-10, 10] and y: [-10, 10].  The lighter the shade, the higher the magnitude. Enjoy!

HP Prime Program MAGSQRT

EXPORT MAGSQRT()
BEGIN
// 2017-07-28 EWS
// TST4503
STARTAPP("Function");
Xmin:=−10; Xmax:=10;
Ymin:=−10; Ymax:=10;
LOCAL cx:=0.05,cy:=0.05,r,c;
LOCAL clr,b;


RECT();
FOR r FROM Xmin TO Xmax STEP cx DO
FOR c FROM Ymin TO Ymax STEP cy DO
clr:=ABS(√(r+c*i));
PIXON(r,c,RGB(60*clr,60*clr,60*clr));
END;
END;
TEXTOUT_P("ABS(√(a+bi)): [−10,10]"
,50,220);

WAIT(0);
END;

Replace the i with the complex symbol [Shift] [ 2 ].



Eddie


This blog is property of Edward Shore, 2017

Sunday, May 29, 2016

Solving Absolute Value Equations

Solving Absolute Value Equations

Introduction

There are several ways to solve absolute value equations.  One way we can take advantage that |x|^2 = x^2, but only if we are dealing with real numbers.  To see why, please see the link below:


However, the surest way to solve equations involving absolute value equations.  Steps:

1.  Isolate the expression with absolute value one side of the equation. Hence to the equation to read something like this:  |f(x)| = g(x).
2.  Solve two equations:  f(x) = +g(x) and f(x) = -g(x).

Some examples of how the method works:


Example 1:

|x| + x = 5
|x| = 5 – x

The next step to solve two equations:  x = +(5 – x) and x = -(5 – x)

x = +(5 – x)
x = 5 – x
2x = 5
x = 5/2 

x = -(5 – x)
x= -5 + x
0 = -5, but 0 ≠ -5, so no solution in this case.

In our final analysis, x = 5/2

Example 2:

3*|x-2| = 6 + 4x
|x-2| = 2 + 4/3 * x

Now we need to solve both x – 2 = +(2 + 4/3*x) and x – 2 = -(2 + 4/3*x)

x – 2 = 2 + 4/3*x
-4 = 1/3 * x
-12 = x

x – 2 = -(2 + 4/3*x)
x – 2 = -2 – 4/3*x
0 = -7/3*x
0 = x

Both valid, so our solutions are x = -12 and x = 0.

Example 3:

|x^2 + 5*x + 6| = x

We know the drill, solve x^2 + 5*x + 6 = x and x^2 + 5*x + 6 = -x.

x^2 + 5*x + 6 = x
x^2 + 4*x + 6 = 0
x = (-4 ± √(16 – 24))/2
x = (-4 ± √(-8))/2
x = -2 ± i*√2

x^2 + 5*x + 6 = -x
x^2 + 6*x + 6 = 0
x = ( -6 ± √(36 – 24))/2
x = (-6 ± √12)/2
x = -3 ± √3

Hope you find this helpful, in the near future I want to tackle other common problems found in algebra. 

Eddie



This blog is property of Edward Shore, 2016.

Wednesday, May 25, 2016

Absolute Value: Does |x|^2 = x^2?

Absolute Value:  Does |x|^2 = x^2?

Proof that |x|^2 = x^2, assuming x is a real number.

Note that |x| = x/sgn(x), where sgn(x) is the sign function where:

sgn(x) = -1 if x < 0,
sgn(x) = 0 if x = 0,
and sgn(x) = 1 if x > 0

Case: x = 0. 

Then:
|0| = 0 and |0|^2 = 0^2 = 0.

Case: x ≠ 0.  

Then:
|x|^2 = (x/sgn(x))^2
= x/sgn(x) * x/sgn(x)
= x^2/sgn(x)^2

If x < 0, sgn(x) = -1, and since -1 * -1 = 1, sgn(x)^2 = 1
If x > 0, sgn(x) = 1, and since 1 * 1 = 1, sgn(x)^2 = 1

Hence:
x^2/sgn(x)^2
= x^2

QED

Caution:  The statement |x|^2 = x^2 is not true for complex numbers where the imaginary part is nonzero. 

Let x = a + b*i

|x|^2 = |a + b*i|^2 = (√(a^2 + b^2))^2 = a^2 + b^2

x^2 = (a + b*i)^2 = a^2 + 2*a*b*i – b^2 ≠ a^2 + b^2   (b ≠ 0)


Conclude:  |x|^2 = x^2 only if x is a real number.


Eddie


This blog is property of Edward Shore, 2016

Saturday, November 22, 2014

Complex Analysis: The Conjugate, the Modulus, and its Properties

Blogging today from Last Drop Cafè in Claremont, CA. I think I found a new favorite drink: mint mocha made with soy milk.


Here are some basics of the conjugate and modulus of complex numbers.

Let z = x+i*y, with i=√-1

Conjugate

Usually labeled "z-bar" (z with a line over it), the conjugate is also labeled conj(z) and z*.

conj(z) = x - i*y

Modulus or Absolute Value

Not surprisingly, the modulus, also called the absolute value of the complex number z is defined as:

|z| = √(x^2 + y^2)

Properties

Let's explore some properties of the conjugate and modulus.

z + conj(z) = (x + i*y) + (x - i*y) = 2*x

z - conj(z) = (x + i*y) - (x - i*y) = 2*i*y

(conj(z))^2 = (x - i*y)^2 = x^2 - 2*i*x*y + (i*y)^2 = x^2 - y^2 - 2*i*x*y

conj(z)^2 + z^2 = (x - i*y)^2 + (x + i*y)^2 = x^2 - 2*i*x*y - y^2 + x^2 + 2*i*x*y - y^2
= 2*(x^2 - y^2)

conj(z) * z = (x - i*y) * (x + i*y) = x^2 + i*x*y - i*x*y - i^2*y^2 = x^2 + y^2 = |z|^2

which easily leads to: |z| = √(z * conj(z)) and

|z1 * z2| = √(z1 * conj(z1) * z2 * conj(z2)) = √(z1 * conj(z1)) * √(z2 * conj(z2)) = |z1| * |z2|

and:

|z1/z2| = √((z1 * conj(z1))/(z2 * conj(z2))) = √((z1 * conj(z1))/√((z2 * conj(z2)) = |z1|/|z2|


Source: Wuncsh, David A. Complex Numbers with Applications. 2nd Edition. Addison-Wesley Publishing Company. Reading, MA. 1994

Sunday, November 9, 2014

Two New Videos: Derivatives on the HP Prime, Derivative and Integral of abs(x)

Derivatives on the HP Prime Calculator

Video:  http://youtu.be/LXwLiPlKO2M

Notes:

Derivative Template:  Template Key, template is on the top row, 4th column

Numeric Format:  (d* function)/(d varaible = point), press Enter
In RPN Mode: You also need to press Shift+Comma (Eval)
Symbolic Format (CAS Mode):  (d function)/(d variable)

*d represents the derivative symbol

diff command:
diff(function, variable)


Derivative and Integral of abs(x)

Video:  http://youtu.be/8PikrlA5UlQ

A short derivation of the derivative and integral of absolute value function (abs(x)), and how the signum (sign(x)) function plays a part its calculation. 

Graphs made with the online Desmos calculator.  Please visit and explore at www.desmos.com
(This is NOT a paid endorsement)

Eddie


Blog Entry #403

This blog is property of Edward Shore.  2014

Monday, November 3, 2014

Derivative of abs(x) and Integrals of abs(x), abs(e^x), abs(e^(a*x) + e^(a*y))

Derivative of abs(x) and Integrals of abs(x), abs(e^x), abs(e^(a*x) + e^(a*y))

For this blog entry, assume that are functions are in terms of x and a, x, y represent real numbers.

Definition of abs(x) (also symbolized as |x|)

Piecewise definition:

abs(x) = x if x > 0
abs(x) = 0 if x = 0
abs(x) = -x if x < 0

Also:

abs(x) = x * sign(x)

Where the sign(x), sometimes labeled sgn(x), is the sign or signum function. It is defined as:

sign(x) = 1 for x > 0
sign(x) = 0 for x = 0
sign(x) = -1 for x < 0

d/dx sign(x)

We can clearly demonstrate that d/dx sign(x) = 0 since:

d/dx sign(x) = 0 for x > 0
d/dx sign(x) = 0 for x = 0
d/dx sign(x) = 0 for x < 0

d/dx abs(x)

Using the chain rule:
d/dx abs(x)
= d/dx (x * sign(x))
= d/dx (x) * sign(x) + x * d/dx (sign(x))
= sign(x)

This can also be done with the piecewise representation:

d/dx abs(x) = 1 if x > 0
d/dx abs(x) = 0 if x = 0
d/dx abs(x) = -1 if x < 0

∫ abs(x) dx

∫ abs(x) dx
= ∫ x * sign(x) dx

Using integration by parts:
where u = sign(x), dv = x dx
Then: du = 0 dx, v = x^2/2

∫ abs(x) dx
= ∫ x * sign(x) dx
= x^2/2 * sign(x) - ∫ 0 dx
= x^2/2 * sign(x) + C

C is the arbitrary integration constant

With the piecewise representation:

∫ abs(x) dx = x^2/2 if x > 0
∫ abs(x) dx = 0 if x = 0
∫ abs(x) dx = -x^2/2 if x <0

Note that this is x^2/2 * sign(x).

∫ abs(e^(a*x)) dx

∫ abs(e^(a*x)) dx
= ∫ e^(a*x) * sign(e^(a*x)) dx
= 1/a * e^(a*x) * sign(e^(a*x)) - ∫ 0 dx
= 1/a * e^(a*x) * sign(e^(a*x)) + C

∫ abs(e^(a*x) + e^(a*y)) dx

∫ abs(e^(a*x) + e^(a*y)) dx
= ∫ (e^(a*x) + e^(a*y)) * sign(e^(a*x) + e^(a*y)) dx
= (e^(a*x)/a + x*e^(a*y)) * sign(e^(a*x) + e^(a*y)) - ∫ 0 dx
= (e^(a*x) + a*x*e^(a*y))/a * sign(e^(a*x) + e^(a*y)) + C

Eddie

This blog is property of Edward Shore. 2014

(Blog Entry # 401)

Basic vs. Python: Circle Inscribed in Circle [HP 71B, Casio fx-CG 100]

Basic vs. Python: Circle Inscribed in Circle Calculators Used: Basic: HP 71B Python: Casio fx-CG 100 Introduction ...