Showing posts with label Desmos. Show all posts
Showing posts with label Desmos. Show all posts

Saturday, September 16, 2023

Integrating Absolute Value Functions

Integrating Absolute Value Functions



Calculating ∫ abs(f(x)) dx


The function abs(f(x)) can be broken into two parts, depending on the sign of f(x):


abs(f(x)) = 

{   f(x)  when f(x) > 0

{  -f(x)  when f(x) < 0



General procedure:


1.  Find the roots of f(x).  

2.  Split the integral at the roots.

3.  For areas where f(x)>0, calculate the sub-area ∫ f(x) dx.

4.  For areas where f(x)<0, calculate the sub-area ∫ -f(x) dx.

5.  Total all the sub-areas.



Let's illustrate this with examples.  Screen shots are made with the HP Prime emulator.  The absolute value function |f(x)| is graphed in blue, while f(x) is graphed in red (for illustrative purposes).  



Example 1:  ∫ |4x- 2| dx from x = 0 to x = 5





∫ |4x- 2| dx from x = 0 to x =5


The root of (4x - 2) is x = 1/2.     

When x < 1/2, (4x - 2) < 0.   

When x > 1/2, (4x - 2) > 0.


Break down the integral into:


∫ (|4x- 2| dx from x = 0 to x =5)

= ∫ ( -(4x- 2) dx from x = 0 to x =1/2) + ∫ (4x- 2 dx from x = 1/2 to x =5)

=  1/2 + 81/2

=  82/2

=  41


We can type in the entire integral into a calculator or app.  Depending on the function and the advanced engine of the calculator, the accuracy may be affected.   Calculators and apps with advanced engines include the HP Prime, Wolfram Alpha, and Desmos.   (Your mileage may vary)



Example 2:  ∫ |x^3 - 28x + 48| dx from x = 0 to x = 3





∫ |x^3 - 28x + 48| dx from x = 0 to x = 3


The roots of x^3 - 28x + 48 are at x = -6, x = 2, and x = 4.   Since the root x = 2 is the only root in the interval [0, 3], this is the one root we are working with.  


With root x = 2, 

When x < 2, x^3 - 28x + 48 > 0

When x > 2, x^3 - 28x + 48 < 0


Then:

∫ ( |x^3 - 28x + 48| dx from x = 0 to x = 3 ) 

= ∫ ( (x^3 - 28x + 48) dx from x = 0 to x = 2 ) 

+ ∫ ( -(x^3 - 28x + 48) dx from x = 2 to x = 3 ) 

= 44 + 5.75

= 49.75



Example 3:  ∫ |e^(2x) - 2| dx from x = 0 to x = 2





The root of e^(2x) - 2 is x = ln 2 ÷ 2 ≈ 0.34657


Let A = ln 2 ÷ 2, and with root x = A,

When x < A, e^(2x) - 2 < 0

When x > A, e^(2x) - 2 > 0


∫ ( |e^(2x) - 2| dx from x = 0 to x = 2 )

=  ∫ ( -(e^(2x) - 2) dx from x = 0 to x = A ) + ∫( (e^(2x) - 2) dx from x = A to x = 2)

≈ 0.193147 + 22.99222

≈ 23.18537


Where is where this method returns approximates and using different calculators and apps may not produce the same results.  


HP Prime:  23.1853693777

Desmos:  23.1853693777

Wolfram Alpha:  23.1853693776920

TI-30X Pro MathPrint:  23.18537052



Hope this technique helps, 


Eddie



All original content copyright, © 2011-2023.  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, October 30, 2016

(Maybe Not So Well Known?) Mathematical Curves

(Maybe Not So Well Known?) Mathematical Curves

Here are some mathematical curves graphed on the Desmos website (https://www.desmos.com/calculator ).   Enjoy!

For the following curves, the angle mode is radians.

The equations shown on this blog entry can be plotted on any graphing calculator that has function, polar, and parametric modes.  I will post the links to the pages on Desmos with each curve.  For parametric curves, I set the range to -4*π ≤ t ≤ 4*π.  The variables a, b, c, and n can be changed in the links for you to explore the graphs. 

Without further ado:

Arachnida

Polar Curve:
r = 2 * a * sin(n*θ)/sin((n-1)*θ)
a > 0, n ∈ N  (N:  natural numbers (1, 2, 3, …))



Example:  a = 3, n = 6
 

Conchoid of Dürer
(Dürer’s Shell Curve)

Parametric Curve:
x = (a * cos(t))/(cos(t) – sin(t)) + b * sin(t)
y = b * sin(t)
a > 0, b > 0



Example:  a = 6.1, b = 8.84

Cornoid

Parametric Curve:
x = a * cos(t) * (1 – 2 * (sin(t))^2)
y = a * sin(t) * (1 + 2 * (cos(t))^2)
a > 0



Example:  a = 5.89 

Nodal Curve

Polar Curve:
r = a * cot(n * θ)
or  r = a/(tan(n*θ))
a > 0, n ∈ N



Example:  a = 2.67, n = 8


Right Trifolium

Polar Curve:
r = a * cos(θ) * cos(2*θ)
a > 0



Example:  a = 3.79

Sand Glass Curve

Parametric Curve:
x = a * cos(2*t)/cos(t)
y = b * tan(t)
a > 0, b > 0



Example:  a = 6.6, b = 3.9

Scarabaeus

Polar Curve:
r = a * cos(2*θ) – c * cos(θ)
a > 0, c ∈ R  (real numbers)



Example:  a = 3.64, c = 1.11


Deltoid Curve
(Three-Cuspid Hypocycloid)

Parametric Curve:
x = a * (2 * cos(t) + cos(2*t))
y = a * (2 * sin(t) – sin(2*t))
a > 0



Example:  a = 3.14


Windmill

Polar Curve:
r = a * cot(2*θ)
or r = a/tan(2*θ)

a > 0



Example:  a = 3

Trichoidal Rose

Polar Curve:
r = 2 * a * (q + 1) * sin(θ/(2*q + 1))
a > 0
q = m/n where m ∈ Z, n ∈ Z, and GCD(m,n) = 1, but q ≠ 1 nor q ≠ 1/2



Example: a = 2.14, q = 2/5  (n = 2, m = 5).

My favorites are the Arachnida, Sand Glass, and Scarbaeus.  Feel to free to play with the curves and see what you get. 

Eddie

Source:

Shinkin, Eugene V.  Handbook and Atlas of Curves  CRC Press:  Boca Raton.  1995  ISBN 0-8493-8963-1

This blog is property of Edward Shore, 2016




Saturday, July 12, 2014

Geometry: Brining Circles Together (Illustrations done with Desmos)

Before I get started with today's blog post, I want to share an awesome online mathematical application.  All illustrations on this blog entry were done with the Desmos free on-line graphing calculator.  You can graph functions, parametric equations, table plots, and polar equations – complete with shading.  Many users have fun using Demos to draw interesting and fun graphics.  There is no monetary cost to signing an account.  You can check out Desmos at www.desmos.com.  

The Desmos Screen







The Two Circles
Suppose we have two circles, both having a radius of 1 and are touching at the origin of the Cartesian plane. (The origin is point (0,0).)

An equation that describes the two circles are:
Red Circle (on the left):  y^2 + (x + 1)^2 = 1
Blue Circle (on the right):  y^2 + (x – 1)^2 = 1


The two circles:  each of them are touching at the origin.


Simply put, the area of the two circles is 2*π. 

Moving the Red Circle In

What happens to the total area when I move the red circle to the right?  A portion of the circles will overlap, as illustrated below:

Moving the red circle to the right - note the overlapping ellipse shaded in purple.
 
If we want the total area, we have to take the overlapping ellipse (now shaded in purple) in mind.    One approach to calculating the area of the shape would be:

A = area of the two circles – area of the overlapping ellipse

A = 2 * π  - E

Where E = area of the ellipse

This ensures that there is not a portion of the shape, particularly the purple overlap that otherwise would get counted twice.   Let the variable p represent the distance that the red circle moves.  

The equations become:

Red Circle (on the left):  y^2 + (x + 1 - p)^2 = 1

Blue Circle (on the right):  y^2 + (x – 1)^2 = 1

In general, the area of any ellipse is:  A = π*a*b, where a and b are the length of the semi-major and semi-minor axes.  

The horizontal length of the ellipse is p.  Hence the semi-horizontal (semi-major or semi-minor depending on p) axis of the overlapping ellipse is p/2.  

Finding the semi-vertical axis will require finding the points where the two circles intersect.  Interestingly, the circles intersect when x=p/2.  The center point of the ellipse is (p/2, 0)
Using the equation for the red circle:

y^2 + (x + 1 – p)^2  = 1
y^2 + (p/2 + 1 – p)^2 = 1
y^2 + (1 – p/2)^2 = 1
y^2 = 1 – (1 – p/2)^2
y = ±√(1 – (1 – p/2)^2)
y = ±√(1 – (1 – p + p^2/4))
y = ±√(-p^2/4 + p)

To verify that we get the same answer, let’s substitute x=p/2 for the blue circle:

y^2 + (x – 1)^2 = 1
y^2 + (p/2 – 1)^2 = 1
y^2 = 1 – (p/2 – 1)^2
y = ±√(1 – (p/2 – 1)^2)
y = ±√(1 – (p^4/2 – p + 1))
y = ±√(-p^2/4 + p)

Hence the points where the circles interest are (p/2, ±√(-p^2/4 + p)).  The semi-vertical axis has a length of √(-p^2/4 + p).  The area of the overlapping ellipse, E, is:

E = π*p/2*√(-p^2/4 + p)

Overall, the area of the shape is:

A = 2*π - π*p/2*√(-p^2/4 + p)


Example:  p = 1/2
A = 2*π - π*(1/2)/2*√(-(1/2)^2/4 + 1/2)
A = 2*π – π/4*√(-1/16 + 1/2)
A = 2*π  - π/4 * √7/4 ≈ 5.76370

Eddie


This blog is property of Edward Shore. 2014


Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...