Showing posts with label Fresnel integrals. Show all posts
Showing posts with label Fresnel integrals. Show all posts

Monday, January 5, 2026

Casio fx-CG 100 Python: Clothoid Curve Analysis

Casio fx-CG 100 Python: Clothoid Curve Analysis



Introduction



The clothoid is a mathematical curve where its curvature is in proportion to the distance traveled from the origin. This property allows the curve to serve many applications including connecting railways, designing roller coasters, and traffic distribution.







Let:

L: arc length of the curve traveled

R: radius from the center of the clothoid to the point on the curve

(x, y): point on the clothoid curve with curve length L and radius R

A: parameter, where A = √(R * L)

Θ: angle between the radius and line of the center point and a point on the x-axis, where Θ = L^2 ÷ (2 * A^2)



The point on the curve is determined by a variation of the Fresnel Integrals:

x = A * √2 * ∫( cos(u^2) du, u = 0 to u = t)

y = A * √2 * ∫( sin(u^2) du, u = 0 to u = t)



The Python program uses infinite series to calculate the point (x, y).



The Clothoid curve is also known as the Cornu spiral or the Euler spiral.


Casio fx-CG 100 Program: clothoid.py


# Clothoid Curve Analysis

# template of infinite series

# Eddie W. Shore, 11/23/2025


from math import *


# factorial function

def fact(n):

  f=1

  if n<=1:

    return 1

  else:

    for i in range(2,n+1):

      f*=i

    return f


# main program

print("Clothiod Analysis\nCornu Spiral")

r=eval(input("radius: "))

l=eval(input("arc length: "))

a=sqrt(r*l)

t=l**2/(2*a**2)


# c: cosine, s=sine

c=0

s=0

# set term artificially high

w=100

# set counter at beginning

n=0

# series loop

while abs(w)>=1e-20:

  cc=(-1)**n*t**(4*n+1)/(fact(2*n)*(4*n+1))

  ss=(-1)**n*t**(4*n+3)/(fact(2*n+1)*(4*n+3))

  w=max(cc,ss)

  c+=cc

  s+=ss

  n+=1

# answer

x=a*sqrt(2)*c

y=a*sqrt(2)*s

print("constant: {0:.12f}".format(a))

print("angle: {0:.12f}".format(t))

print("x: {0:.12f}".format(x))

print("y: {0:.12f}".format(y))


Example


Input:

Radius: r = 1.75

Arc Length: l = 4.00


Results:

constant (a): 2.645751311065

angle (degrees): 1.142857142857°

x: 3.602081584381

y: 1.646831998544



Sources


Autodesk, Inc. “About Spiral Definitions” Autodesk Civil 3D Help. https://help.autodesk.com/view/CIV3D/2025/ENU/?guid=GUID-DD7C0EA1-8465-45BA-9A39-FC05106FD822. 2025. Retrieved November 19, 2025.


Constantin. “The Clothoid” A railway track blog. https://railwaytrackblog.com/2016/07/03/the-clothoid/comment-page-1/ March 7, 2016. Retrieved November 19, 2025.


Gombáu, Alberto. “The clothoid: geometry that unites mathematics, engineer and design”. https://medium.com/@gombau/the-clothoid-geometry-that-unites-mathematics-engineering-and-design-6323de37e979. April 11, 2025. Retrieved November 19, 2025.



Eddie


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

Casio fx-CG 100 Python: Infinite Series and Fresnel Integrals

Casio fx-CG 100 Python: Infinite Series and Fresnel Integrals



Introduction



Many functions, such as the Fresnel Integrals, the Zeta function, and the error function, can be calculated using infinite polynomials by the sum:



f(x) = Σ( g(x, n) from n = 0 to n = ∞) or

f(x) = Σ( g(x, n) from n = 1 to n = ∞)



where:

f(x): the function to be calculated

g(x, n): the infinite series representative of (x)



g(x, n) often includes the factorial function n!, where n starts at either 0 or 1 to infinity. While I was programming on fx-CG 100, I did not find a factorial function in the math module that is included in the MicroPython. So I included a definition of the factorial function as:



# factorial function

def fact(n):

  f=1

  if n<=1:

    return 1

  else:

    for i in range(2,n+1):

      f*=i

  return f



While this function does not check for negative integers, it gives the default values 0! = 1! = 1.


The main program sets up a sum, ask for initial values, and set up a check variable w = g(x,n), with a high initial value to “fail” the loop test. The loop template is set up as:


w=initial value

n=0 (start value of n)

while abs(w)>=1e-20: (1e-20 is a tolerance value, which can be adjusted)

  w=g(x,n)

  s+=w

  n+=1



An Example: Cosine of x Squared



Radians mode is used and is the default angle mode in Python.



cos(x²) = 1 – x^4 ÷ 2 + x^8 ÷ 24 – x^12 ÷ 720 + x^16 ÷ 40320 - …

= Σ( x^(4*n) * (-1)^n ÷ (2n)!, n = 0 to n = ∞)



In this case, g(x,n) = x^(4*n) * (-1)^n ÷ (2 * n)!

I set accuracy tolerance of 1 * 10^-20 but formatted the answer to 12 decimal places.


Casio fx-CG 100 Micropython: cossq.py



# cosine of x squared by series

# template of infinite series

# math module so pi is allowed



from math import *



# factorial function

def fact(n):

  f=1

  if n<=1:

    return 1

  else:

    for i in range(2,n+1):

      f*=i

    return f



# main program

# setup sum

s=0

# ask for x

print("cos(x**2) by series")

x=eval(input("x radians: "))

# series

# set term artificially high

w=100

# set counter at beginning

n=0

# series loop

while abs(w)>=1e-20:

  w=x**(4*n)*(-1)**(n)/fact(2*n)

  s+=w

  n+=1

# answer

print("{0:.12f}".format(s))



Examples:

Example 1: Input: x = 0.5, Result: 0.968912421711

Example 2: Input: x = 1.7, Result: -0.968517164228



Fresnel Integrals



There are two Fresnel integrals.



Cosine Fresnel Integral:

C(x) = ∫( cos( t^2) dt, t = 0 to t = x)

This integral is represented by the infinite series:

C(x) = Σ( x^(4*n + 1) * (-1)^n ÷ ((2* n)! * (4 * n + 1)), n = 0 to n = ∞)



Sine Fresnel Integral:

S(x) = ∫( sin( t^2) dt, t = 0 to t = x)

This integral is represented by the infinite series:

S(x) = Σ( x^(4*n + 3) * (-1)^n ÷ ((2* n + 1)! * (4 * n + 3)), n = 0 to n = ∞)



Casio fx-CG 100 Micropython: fresnel.py



# Fresnel Integrals

# template of infinite series

# Eddie W. Shore, 11/23/2025



from math import *



# factorial function

def fact(n):

  f=1

  if n<=1:

    return 1

  else:

    for i in range(2,n+1):

      f*=i

    return f



# main program

# c: cosine, s=sine

c=0

s=0

# ask for x

x=eval(input("x radians: "))

# series

# set term artificially high

w=100

# set counter at beginning

n=0

# series loop

while abs(w)>=1e-20:

  a=(-1)**n*x**(4*n+1)/(fact(2*n)*(4*n+1))

  b=(-1)**n*x**(4*n+3)/(fact(2*n+1)*(4*n+3))

  w=max(a,b)

  c+=a

  s+=b

  n+=1

# answer

print("x:{0:.12f}".format(x))

print("Fresnel Cosine:\n{0:.12f}".format(c))

print("Fresnel Sine:\n{0:.12f}".format(s))


Examples:

Example 1: x = 0.4,

C(0.4) ≈ 0.398977212913, S(0.4) ≈ 0.021294355570

Example 2: x = 3.1,

C(3.1) ≈ 0.605132097879, S(3.1) ≈ 0.785491219284

Eddie


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

Casio fx-4000P: Antennas

Casio fx-4000P: Antennas Vertical and Horizontal Bandwidth Given the height (h) and length (l) of an antenna plate, along with w...