Delayed Newton Force (DNF)

runs in python 3 after

pip3 install vpython


# from math import *
# from visual import *
# from visual.graph import * 
from vpython import *
# import vpython

scene.fullscreen = True

G = 10
c = 100


spheres = [
sphere(pos=vector(0,0,0),radius =6,color=color.red,charge=1000,mass=7200,velocity=vector(0,0,0),a = vector(0,0,0),trail=curve(color=color.red,ratain=1000)),
sphere(pos=vector(0,100,-1),radius=2,color=color.blue,charge=-1,mass=1,velocity=vector(10,0,0),a=vector(0,0,0),trail=curve(color=color.blue,retain=1000)),
#sphere(pos=vector(0,12,0),radius=.08,color=color.green,mass=sqrt(4),velocity=vector(1.2,0,0.6),a=vector(0,0,0),trail=curve(color=color.green)),
sphere(pos=vector(0,100,1),radius=2,color=color.white,charge=-1,mass=1,velocity=vector(-10,0,0),a=vector(0,0,0),trail=curve(color=color.white, retain=1000)),
#sphere(pos=vector(0,28,0),radius=.4,color=color.orange,mass=sqrt(80),velocity=vector(0.7,0,0.4),a=vector(0,0,0),trail=curve(color=color.orange)),
#sphere(pos=vector(0,32,0),radius=0.2,color=color.white,mass=-sqrt(10),velocity=vector(1.5,0,0.4),a=vector(0,0,0),trail=curve(color=color.white))
]

#print(spheres[0].a)

#print(len(spheres))


# undelayed flying start
def acceleration1on2(sphere2,sphere1):
    r = sphere2.pos - sphere1.pos
    return ((G*sphere1.charge*sphere2.charge)/pow(mag(r),2))/sphere2.mass*norm(r)
    
    
t = 0
dt = .01


for index in range(1,1001):
    rate(2500)

    for i in spheres:
        i.a = vector(0,0,0)
        for j in spheres:
            if i!=j:
                i.a = i.a + acceleration1on2(i,j)
            
          
                
                
    for i in spheres:
        i.velocity = i.velocity + i.a *dt
        i.pos = i.pos+i.velocity*dt
        i.trail.append(pos=i.pos)
        



def acceleration1on2(sphere2,sphere1):
    npoints= sphere1.trail.npoints
    should_be_zero = 100000000
    should_be_zero_previous = 10000000000000
    for n in range(npoints):
        r = sphere2.pos - sphere1.trail.point(npoints-n-1)["pos"]
        r_mag = mag(r)  
        should_be_zero = abs( r_mag - c*n*dt )
        if ( should_be_zero > should_be_zero_previous ):
            normal_r = norm(r)
            break

        should_be_zero_previous = should_be_zero

    return ( (G*sphere1.charge*sphere2.charge) /pow(r_mag,2) ) /sphere2.mass * normal_r
    



while 1:
    rate(250)
    
                

    for i in spheres:
        i.a = vector(0,0,0)
        for j in spheres:
            if i!=j:
                i.a = i.a + acceleration1on2(i,j)
            
          
                
                
    for i in spheres:
        i.velocity = i.velocity + i.a *dt
        i.pos = i.pos+i.velocity*dt 
        i.trail.append(pos=i.pos)   


 

3D Charge Simulator

Paste the code at the end of this post here:

https://www.beautifulmathuncensored.de/static/GlowScript/GlowScript.html

And press “Run”.

Edit “pos” (position), “velocity”, “charge” and “mass” parameters to simulate a different set of charged particles.
Add a sphere with all the parameters (followed by a “,”) to add an additional charged particle to the simulation.

I hope people will play around and have fun!
(If you have questions, you can ask in the comments.)

Code:

# from math import *
# from visual import *
# from visual.graph import * 
from vpython import *
# import vpython

scene.fullscreen = True

G = 10


# edit initial conditions here	 	 
##########
spheres = [
sphere(pos=vector(0,0,0),radius =6,color=color.red,charge=1000,mass=7200,velocity=vector(0,0,0),a = vector(0,0,0),trail=curve(color=color.red)),
sphere(pos=vector(0,100,-1),radius=2,color=color.blue,charge=-1,mass=1,velocity=vector(10,0,0),a=vector(0,0,0),trail=curve(color=color.blue)),
#sphere(pos=vector(0,12,0),radius=.08,color=color.green,mass=sqrt(4),velocity=vector(1.2,0,0.6),a=vector(0,0,0),trail=curve(color=color.green)),
sphere(pos=vector(0,100,1),radius=2,color=color.white,charge=-1,mass=1,velocity=vector(-10,0,0),a=vector(0,0,0),trail=curve(color=color.white)),
#sphere(pos=vector(0,28,0),radius=.4,color=color.orange,mass=sqrt(80),velocity=vector(0.7,0,0.4),a=vector(0,0,0),trail=curve(color=color.orange)),
#sphere(pos=vector(0,32,0),radius=0.2,color=color.white,mass=-sqrt(10),velocity=vector(1.5,0,0.4),a=vector(0,0,0),trail=curve(color=color.white))
]


#print(spheres[0].a)

#print(len(spheres))


def acceleration1on2(sphere2,sphere1):
    r = sphere2.pos - sphere1.pos
    r_mag = mag(r)
    normal_r = norm(r)
    g = ((G*sphere1.charge*sphere2.charge)/pow(r_mag,2))/sphere2.mass*normal_r
    #print(g)
    return g
    
    
t = 0
dt = .01
while 1:
    rate(100)
    for i in spheres:
        i.a = vector(0,0,0)
        soi = vector(0,0,0)
        for j in spheres:
            if i!=j:
                i.a = i.a + acceleration1on2(i,j)
            
          
                

                
    for i in spheres:
        #print(i.velocity)
        i.velocity = i.velocity + i.a *dt
        i.pos = i.pos+i.velocity*dt
        #print(i.a)
        i.trail.append(pos=i.pos)
        
            
    scene.center=vector(spheres[0].pos.x,spheres[0].pos.y,spheres[0].pos.z)


                
    # print(i.a)

 

Hyperoperation Notation LaTeX

Result:
inverse_hyperoperator_arithmetic

Source:

\documentclass[]{article}

\usepackage{amsmath}
\usepackage{tikz}
\usepackage{listings}

\newcommand{\HO}[1]{%
\begin{tikzpicture}[#1]%
\draw (0,1.3ex) — (3ex,1.3ex);%
\draw (1.5ex,1ex) — (1.5ex,1.6ex);%
\end{tikzpicture}%
}
\newcommand{\IHO}[1]{%
\begin{tikzpicture}[#1]%
\draw (0,0.4ex) — (3ex,0.4ex);%
\draw (1.5ex,0.025ex) — (1.5ex,0.05ex);%
\end{tikzpicture}%
}

\begin{document}

\section{Notation}

\subsection{Hyperoperation}

\begin{equation}
a+b = a {\overset{1}{\HO{scale=2}}} b
\end{equation}

\begin{equation}
\label{hyperoperator}
a {\overset{n}{\HO{scale=2}}} a {\overset{n}{\HO{scale=2}}} … a = a {\overset{n+1}{\HO{scale=2}}} b
\end{equation}

\subsection{Inverse-hyperoperation}

\begin{equation}
c \overset{1}{\IHO{scale=2}} b =c-b
\end{equation}

\begin{equation}
\label{hyperoperator}
c {\overset{n}{\IHO{scale=2}}} b = a
\end{equation}

\end{document}

 

 

Wiederholungsrechenzeichen in Python

# -*- coding: utf-8 -*-
# Wiederholungsrechenzeichen alias Metaoperatoren alias Hyperoperatoren mit Invers

#Logarithmus nimmt 1. Argument des Exponentials und gibt 2. Argument zurück.

#Mit 0 kann es aber noch nicht so gut umgehen, also nur "einfache" Zahlen (positiv "natürlich").

#log_1(1) gibt 0 aus, was als Fehlermeldung zu werten ist.

#Meta-Operator n-ter Stufe
def MO(a,n,b):     #a (|^n) b
    r=a
    if (n<1):
        r+=1        
    if (n==1):
        r=a+b 
    if (n==2):
        r=a*b
    if (n==3):
        r=a**b
    if (n>3):
        for i in range(1,b): #b-1 mal, also z.B.: a°a°a mit b=3, dann 2-mal °a ausführen
            r=MO(a,n-1,r)    #a und r vertauscht damit bei Exponential "unten angebaut" wird   
            #print r
    #print "MO Ergebnis="+str(r)
    return r
    
    
#Inverser Meta-Operator n-ter Stufe
def IMO(r,n,l):     # r (|v n) l
    z=0
    if (n<1):
        z=r-1       
    if (n==1):
        z=r-l 
    if (n==2):
       while (r>0):
            r=r-l
            z+=1
            #print z
            #print r 
    if (n==3):
        while (r>1):
            r=r/l
            z+=1
            #print z
            #print r
    if (n>3):
        while (r>1):
            r=IMO(r,n-1,l)
            z+=1
            #print z
            #print r
    return z
  
    
#Test        
#jetzt richtig
for i in range(1,4):
    for j in range(1,4):
        for k in range(1,4):
            print i,j,k,IMO(MO(i,j,k),j,i)