Showing posts with label circle. Show all posts
Showing posts with label circle. Show all posts

Saturday, April 26, 2025

Casio fx-991CW: The Inequalities Mode

Casio fx-991CW: The Inequalities Mode



Solving Inequalities


The Casio fx-991CW, along with other high-end scientific calculators from Casio has an Inequalities mode.


The inequalities mode solves quadratic, cubic, and quartic polynomials. The mode works similar to Equation-Polynomial module. Below is an example (all screenshots were created in Casio’s classpad.net website):


Casio fx-991CW: Introduction to the Inequality Mode


The Inequalities mode can assist in calculus and geometry problems.



Circle Problem


Task: Find valid points (x, y) that fit in the circle:


x^2 / 3 + y^2 / 6 = 1


Step 1: We can use the Inequalities mode to find the allowed x values.


Start by solving for y:

x^2 / 3 + y^2 / 6 = 1

6 × (x^2 / 3 + y^2 / 6) = 1 × 6

2 × x^2 + y^2 = 6

y^2 = 6 – 2 × x^2

y = √(6 – 2 × x^2)


For the equation to be “valid”, or to not return complex numbers, find all x where 6 – 2 × x^2 is not negative.


6 – 2 × x^2 ≥ 0


We find that the allow range is -√3 ≤ x ≤ √3.


Step 2: Store the Equations


We can do define f(x) in any mode. To do this, press [ f(x) ], select Define f(x). Press [ OK ] to store the function. The fx-991CW allows for two functions, f(x) and g(x).


In this example, we defined f(x) and g(x) as follows:


f(x) = √(6 – 2 × x^2)

g(x) = -f(x)


Step 3: Use the Table mode to find values in the appropriate range.


Set the Table Type as f(x)/g(x). Set the Table Range as Start: -√(3), End: √(3), Step: 2×√(3)÷5


Table:


x ≈

f(x) ≈

g(x) ≈

1

-1.732

0

0

2

-1.0392

1.9595

-1.9595

3

-0.3464

2.4

-2.4

4

0.3464

2.4

-2.4

5

1.0392

1.9595

-1.9595

6

1.732


0

0






The Area Between f(x) and x ≥ 0


Find the area between the curves:

f(x) = -x^4 + 2 × x^3 + 25 × x^2 – 26 × x – 120 and x ≥ 0.


Step 1: Find the boundaries.


With the Inequalities mode, we can find the boundaries and intersection points where f(x) ≥ 0. We find that: -4 ≤ x ≤ -2 and 3 ≤ x ≤ 5. Write down these results. The area will be in the intervals [-4, -2] and [3, 5].


Confession: I ultimately chose this function because of its integer roots. Unfortunately we are not able to store coefficients or roots in variables directly on the fx-991CW to variables.


Step 2: Store the Equations


Store -x^4 + 2 × x^3 + 25 × x^2 – 26 × x – 120 to f(x). This will allow us to save keystrokes while calculating the area.


Step 3: Calculate the Area in the Calculate Mode


Use the integral function from the Catalog - Func Analysis menu.


∫( f(x), -4, -2) + ∫( f(x), 3, 5)


The area is: 1928/15 ≈ 128.5333333

Hint: To always get a decimal approximation (skipping the exact result), press [SHIFT] [ = ] ( ≈ ).




Another example:

Find the area between the curves:

f(x) = x^3 + 8 × x^2 – 3 and x ≥ 0.


The boundaries are: -7.952564217 ≤ x ≤ -0.63837179, 0.5909359176 ≤ x


Which means the intervals are: [ -7.952564217, -0.63837179] and [ 0.5909359176, ∞). We can see that the area given these boundaries, the area will approach infinity.  


Eddie


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

Casio Python with fx-CG 50: Drawing Shapes with Casioplot (draws.py)

Casio Python with fx-CG 50: Drawing Shapes with Casioplot (draws.py)


The Casio file draws.py is a file that use both the casioplot and math modules and contains four drawing functions.


The plot functions uses the pixel system.


Upper left hand corner: (0, 0)

Upper right hand corner: (383, 0)

Lower left hand corner: (0, 191)

Lower right hand corner: (383, 191)


The x axis increases going right and the y axis increases going down. This orientation is common for a pixel-orientated coordinate system.


Note that the pixels must be integers. A non-integer value for a pixel will cause an error.



Importing the draws module


After copying the file draws.py to your calculator, type: from draws import *


The casioplot and math modules will also be imported because the draws module is imported. This is the case of the fx-CG 50, and I’m pretty sure it will work with the other Casio calculators with Python (fx-9750GIII, fx-9860GIII, fx-CG 100, Graph Math+).


To clear the drawing screen, use the casioplot’s command clear_screen().


To show the picture, use the casioplot’s command show_screen().


The functions from the draws must be manually typed, as they will not appear in the catalog or VARS menu.



sline(x,sx,y,sy,l,c)


Draws a line from (x,y) of length l and color c. The color is a three-element tuple in the RGB format ((red, green, blue)).


The arguments sx and sy are direction/slope arguments which dictate the direction of the line.


To draw a line going left (←)

Set sx = -1 and sy = 0

To draw a line going right (→)

Set sx = 1 and sy = 0

To draw a line going up (↑)

Set sx = 0 and sy = -1

To draw a line going down (↓)

Set sx = 0 and sy = 1

To draw a line going right and up (↗)

Set sx = 1 and sy = -1

To draw a line going left and up (↖)

Set sx = -1 and sy = -1

To draw a line going right and down (↘)

Set sx = 1 and sy = 1

To draw a line going left and down (↙)

Set sx = -1 and sy = 1


Examples:

sline(1,1,1,0,140,(255,0,0)) draws a red line starting from (1,1) going right with length of 140 pixels


sline(180,0,100,-1,50,(0,255,0)) draws a green line starting from (180,100) going up with length of 50 pixels





The sample file draw1.py is a demonstration of the sline command.






box(x,xl,y,yl,c)


The box function draws a box with the upper left hand corner (x,y) with color c, horizontal length (width) xl, and vertical length (height) yl. The box draws to the right and down. The box is filled with the specified color. If xl = yl, the function will draw a square.


Example:

box(20,100,40,150,(128,128,128)) draws a gray rectangle with upper-left corner at (20,40) with horizontal length of100 and vertical length of 150.


box(300,60,0,60,(0,0,0)) draws a black square with upper-left corner at (300, 0) with the side length of 60.





The sample file draw2.py uses the box function to generate a random game map of land (green) and water (blue).






tri(x,xd,y,yd,l,c)


The tri function draws a 45-45-90 right triangle. The point (x,y) is the corner point that contains the right angle of 90°. The arguments xd and yd dictate the direction of the triangle (see table below).





The triangle is filled with color c. The sides of the triangle will be drawn with length l.


Example:


tri(80,1,80,-1,75,(0,128,128)) draws a teal 45-45-90 right triangle with the right angle located at (80, 80). The length is 75 pixels.





The sample file draw3.py uses the tri function to draw four triangles, one with each proper orientation.






circ(x,y,r,c)


The circ function draws a circle centered at (x, y) with radius r and color c. The circle is drawn as outline and not filled. To make the circle appear as smooth as possible, 720 points are plotted.


Example:

circ(190,100,85,(255,128,0)) draws an orange circle with radius 85, centered at (190, 100).





The file draw4.py demonstrates the circ function.






Casio fx-CG 50 Python: draws.py code


# drawing utilities

# 12-04-2024


from casioplot import *

from math import *


def sline(x,sx,y,sy,l,c):

  for i in range(l+1):

    set_pixel(x+sx*i,y+sy*i,c)


# upper left corner

def box(x,xl,y,yl,c):

  for i in range(xl+1):

    for j in range(yl+1):

      set_pixel(x+i,y+j,c)


# right triangle

# (x,y) point with right angle

# l=length

# xd=1 right, xd=-1 left

# yd=1 down, yd=-1 up

def tri(x,xd,y,yd,l,c):

  for i in range(l+1):

    k=l-i

    for j in range(k+1):

      set_pixel(x+xd*i,y+yd*j,c)


# hallow circle

def circ(x,y,r,c):

for i in range(721):

  t=2*pi*i/720

  xr=int(x+r*cos(t))

  yr=int(y+r*sin(t))

  set_pixel(xr,yr,c)



You can download the draws.py and the example Python files here:

https://drive.google.com/file/d/1rGQHa60V7ZCE9Vs0kYy0cfIe0pOXqVaZ/view?usp=sharing


I hope you enjoy this program as much as I have making it,



Eddie


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

TI-84 Plus CE Python: Drawing Shapes with the ti_plotlib module

 TI-84 Plus CE Python: Drawing Shapes with the ti_plotlib module


Introduction


Here are four scripts to draw shapes:


RECT8: rectangles and squares centered at (0, 0)

ELLIPSE8: ellipses and circles centered at (0, 0)

POLYGON8: polygons given the vertex points and number of vertices

INVFUNC8: draws a function f(x) and it’s inverse f^-1(x). Define the function is defined in the f(x) subroutine in the program.


The plot window is sized in sync with the TI-84’s screen size (320 pixels x 220 pixels) so that squares look like squares and circles look like circles. The window parameters are set as such:

Xmin = -16, Xmax = 16

Ymin = -10.5, Ymax = 10.5



TI-84 PLUS CE Python Script: RECT8.py





import ti_plotlib as plt

from math import *


# draw an rectangle using ti_plqtlib

# get parameters

print("Press [clear] to \nexit the graph.")

print("x:[-16,16] \ny:[-10.5,10.5]")

a=eval(input("horiz. length? "))

b=eval(input("vert. length? "))


# plot routine

plt.cls()

plt.title("Rectangle")

plt.window(-16,16,-10.5,10.5)

plt.axes("on")

plt.grid(1,1,"dot")


# color: blue

plt.color(0,0,192)


# pen size

plt.pen("medium","solid")


plt.line(-a/2,b/2,a/2,b/2,"")

plt.line(-a/2,-b/2,a/2,-b/2,"")

plt.line(-a/2,-b/2,-a/2,b/2,"")

plt.line(a/2,-b/2,a/2,b/2,"")


plt.show_plot()


TI-84 PLUS CE Python Script: ELLIPSE8.py





import ti_plotlib as plt

from math import *


# draw an ellipse using ti_plqtlib

# get parameters

print("Press [clear] to \nexit the graph.")

print("x:[-16,16] \ny:[-10.5,10.5]")

a=eval(input("x axis? "))

b=eval(input("y axis? "))


# plot routine

plt.cls()

plt.title("Ellipse")

plt.window(-16,16,-10.5,10.5)

plt.axes("on")

plt.pen("medium","solid")

plt.grid(1,1,"dot")


# color: green

plt.color(0,192,0)


for i in range(128):

  x=a*cos(i*pi/64)

  y=b*sin(i*pi/64)

  plt.plot(x,y,"o")


plt.show_plot()



TI-84 PLUS CE Python Script: POLYGON8.py





import ti_plotlib as plt

from math import *


# draw an rectangle using ti_plqtlib

# get parameters

print("Press [clear] to \nexit the graph.")

print("x:[-16,16] \ny:[-10.5,10.5]")


n=int(input("# of vertices? "))

a=eval(input("x1? "))

b=eval(input("y1? "))


x=[a]

y=[b]


for i in range(n-1):

  print("vertex ",i+2)

  c=eval(input("x? "))

  d=eval(input("y? "))

  x.append(c)

  y.append(d)

x.append(a)

y.append(b)



# plot routine

plt.cls()

plt.title("Polygon")

plt.window(-16,16,-10.5,10.5)

plt.axes("on")

plt.grid(1,1,"dot")

plt.color(75,0,130)

plt.pen("medium","solid")


for i in range(n):

  x0=x[i]

  y0=y[i]

  x1=x[i+1]

  y1=y[i+1]

  plt.line(x0,y0,x1,y1,"")


plt.show_plot()



TI-84 PLUS CE Python Script: INVFUNC8.py





Define f(x) in the def f(x) function routine. The math module is imported.



import ti_plotlib as plt

from math import *


# f(x) and f**-1(x)

# define f(x)

def f(x):

  return x**2+6


# plot routine

plt.cls()

plt.title("f(x) and its inverse")

plt.window(-16,16,-10.5,10.5)

plt.axes("on")

plt.grid(1,1,"dot")


plt.pen("medium","solid")


for i in range(320):

  x=-16+i*32/320

  y=f(x)

  plt.color(0,0,192)

  plt.plot(x,y,"o")

  plt.color(255,165,0)

  plt.plot(y,x,"o")



plt.show_plot()



Download the four scripts here: https://drive.google.com/file/d/1ELL6mEzMXrIJlOSSFocOZGJTza-kBZoU/view?usp=sharing



Eddie


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

Numworks: Drawing Simple Shapes with Pyplot

 Numworks: Drawing Simple Shapes with Pyplot


Welcome to a special edition of our blog.


The goal of today’s blog is provide templates to draw simple shapes such as ellipses, circles, rectangles, squares, equilateral triangles, and 45-45-90 right triangles. Adjust the position, screen size, and colors as you see fit.


The module is used is pyplot.



Ellipses and Circles with drawellipse.py


Draw an ellipse given the length of x and y radii. If x and y are equal, a circle is drawn. The screen is set up to fit the proportion of the 320 x 220 screen. The vertical axis ranges from y = -44 to y = 44 while the horizontal axis ranges from x = -64 to x = 64. The ellipse is centered at (0,0).


Numworks script: https://my.numworks.com/python/ews31415/drawellipse


Script: drawellipse.py


from math import *
from matplotlib.pyplot import *

print("Draw an ellipse\nusing pyplot")
a=eval(input("x axis? "))
b=eval(input("y axis? "))

# set axis
axis((-64,64,-44,44))

# set points
tl=[i/128*2*pi for i in range(129)]
xl=[a*cos(i) for i in tl]
yl=[b*sin(i) for i in tl]

# draw the ellipse
c='purple'
plot(xl,yl,c)
show()




Rectangles and Squares with drawrect.py


Draw a rectangle given its horizontal length (h) and vertical length (v). If the horizontal and vertical lengths are equal, a square is drawn. The rectangle is centered at (0, 0). The screen is set up to fit the proportion of the 320 x 220 screen. The vertical axis ranges from y = -44 to y = 44 while the horizontal axis ranges from x = -64 to x = 64.


Numworks script: https://my.numworks.com/python/ews31415/drawrect


Script: drawrect.py


from math import *
from matplotlib.pyplot import *

print("Draw a rectangle\nusing pyplot")
h=eval(input("horiz. length? "))
v=eval(input("vert. length? "))

# set axis
axis((-64,64,-44,44))

# set points
xl=[-h/2,h/2,h/2,-h/2,-h/2]
yl=[v/2,v/2,-v/2,-v/2,v/2]

# color
c='green'

# draw rectangle
plot(xl,yl,c)
show()




Equilateral Triangles with drawtrieq.py


Draws an equilateral (60-60-60) triangle. Enter the length of the side (s). The base is set on the x-axis. The screen is set up to fit the proportion of the 320 x 220 screen. The vertical axis ranges from y = -44 to y = 44 while the horizontal axis ranges from x = -64 to x = 64.


Numworks script: https://my.numworks.com/python/ews31415/drawtrieq


Script: drawtrieq.py


from math import *
from matplotlib.pyplot import *

print("Draw an equilateral triangle\nusing pyplot")
s=eval(input("side length? "))

# set axis
axis((-64,64,-44,44))

# set points
t=s*sqrt(3)/2
xl=[-s/2,s/2,0,-s/2]
yl=[0,0,t,0]

# draw the triangle
c='brown'
plot(xl,yl,c)
show()




45-45-90 Degree Right Triangles with drawtrit.py


Draws an 45-45-90 degree right triangle. Enter the length of the one of the legs (s), not the hypotenuse. The base is set on the x-axis. The screen is set up to fit the proportion of the 320 x 220 screen. The vertical axis ranges from y = -44 to y = 44 while the horizontal axis ranges from x = -64 to x = 64.


Numworks Script: https://my.numworks.com/python/ews31415/drawtrirt


Script: drawtrit.py


from math import *
from matplotlib.pyplot import *

print("Draw a 45-45-90 triangle\nusing pyplot")
s=eval(input("short length? "))

# set axis
axis((-64,64,-44,44))

# set points
xl=[-s/2,s/2,-s/2,-s/2]
yl=[0,0,s,0]

# draw the triangle
c='blue'
plot(xl,yl,c)
show()




Enjoy and I hope you find these scripts useful in your drawing scripts.


Eddie


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

HP 15C: The I Squared Rule and HHC 2026

HP 15C: The I Squared Rule and HHC 2026 HHC 2026 Videos Before we start, the videos for HHC 2026 are up! Please take a look, ev...