## Casson invariant and Euler characteristic

A slogan I frequently hear is: “the Casson invariant is the Euler characteristic of the Floer homology of flat SU(2)-connections on the integral homology sphere”. Is there a single paper/reference that essentially states this as a result? It has been difficult to locate precise definitions. In addition, a sketch of how this works would be very helpful.

## Derivation of the vortex filament equation from Euler equation

How can the vortex filament equation $$\partial_t \chi = \partial_s \chi \wedge \partial_{ss} \chi,$$ where $$\chi(t,s)$$ is a curve in $$\mathbb R^3$$, be derived from the Euler equation $$\partial_t \omega + v\cdot \nabla \omega = \omega \cdot \nabla v, \quad \operatorname{div} v = 0,$$ where $$v:\mathbb R \times \mathbb R^3 \to \mathbb R^3$$, and $$\omega = \operatorname{curl}(v):\mathbb R \times \mathbb R^3 \to \mathbb R^3.$$

I’ve asked a more general question at Survey on the vortex filament equation.

## Project Euler #357: Prime generating integers

Consider the divisors of 30: 1,2,3,5,6,10,15,30. It can be seen that for every divisor d of 30, $$d+30/d$$ is prime.

Find the sum of all positive integers n not exceeding 100 000 000 such that for every divisor d of n, $$d+n/d$$ is prime.

import time start = time.time()  import math  def divisor_generator(n):     '''Generates the divisiors of input num'''     large_divisors = []     for i in range(1, int(math.sqrt(n) + 1)):         if n % i == 0:             yield i             if i*i != n:                 large_divisors.append(n / i)     for divisor in reversed(large_divisors):         yield divisor  def is_prime(n):     '''simple prime tester'''     if n == 2 or n == 3 :         return True     for i in range(2,int(n**(1/2))+1):         if n % i == 0:             return False     return True  def test_condition (divisor_array, num):      ''' Testing the condition of d+n/d by taking the input as array of divisor and num'''      if len(divisor_array) %2 != 0: # the divisors of num = d3 is [1,d2,d3], and d2*d2=d3 hence d2+d3/d2 = 2d2 which is not prime         return False     if sum(divisor_array) %2 != 0: # the divisors of num = d4, [1,d2,d3,d4] (1+d4)=Prime and (d2+d3)==Prime hence sum([1,d2,d3,d4]) must be even         return False     if len(divisor_array)%2 == 0:         for i in range(len(divisor_array)//2):             if is_prime(divisor_array[i] + divisor_array[-i-1]) == False:                 return False         return True  Count = 0 for num in range(2,31,2): #since for odd num we do not have prime numbers       divisor_list_num = list(divisor_generator(num))      if test_condition(divisor_list_num,num) == True:          Count += num  print(Count) end = time.time() print(end-start,"sec") 

It’s good up to $$\text{num} = 10^6$$ but then it gets slow after that. I find that at it takes 16 min to find the $$\text{num} < 10^7$$.

How can I inrease the speed of my code ?

## Project Euler Task 42 Solution

So I am relatively new to programming and have been recommended to work through the many tasks in order, in order to better my skills. For some reason, problem 42 had me stumped for a while and, in retrospect, I should have probably reused some code from problem 22 since they involve the same skills and would have probably left me not as stumped. Oh well.

The following is my final – probably horrible – beginner-level code, and I was wondering whether any of you wonderful people would help me improve it and give me some tips for the future. I am learning Python, which is versatile as heck so here goes.

    def calculate_total(word):     alphabet = {'a':1, 'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8,'i':9,'j':10,'k':11,'l':12,'m':13,'n':14,'o':15,'p':16,'q':17,'r':18,'s':19,'t':20,'u':21,'v':22,'w':23,'x':24,'y':25,'z':26}     total = 0     index = 1     while word[index] != '"':         total += alphabet[word[index].lower()]         index += 1     return total  def gen_triangles(limit):     triangles = [0, 1]     index = 1     while triangles[index] <= limit:         triangles.append(((index ** 2) + index) // 2)         index += 1     return sorted(list(set(triangles))) 

So I have been teaching myself some computing theory and have seen that Python’s inbuilt searching keyword ‘in’ performs a linear search on the array so I decided to branch out and see if I can make my own binary search, it seemed to have worked 😀

def binary_search(aList, itemToFind, first, last):   if last < first:     #print(itemToFind + "not in list")     return False   else:     midpoint = (first + last)//2     if aList[midpoint] > itemToFind:       return binarySearch(aList, itemToFind, first, midpoint - 1)     else:       if aList[midpoint] < itemToFind:         return binarySearch(aList, itemToFind, midpoint + 1, last)       else:         #print(str(itemToFind) + " Found at position: " + str(midpoint))         return True   def solution():     myFile = open('Words.txt', 'r')     wordsArray = myFile.read().split(',')     for i in range(0, len(wordsArray)):         wordsArray[i] = calculate_total(wordsArray[i])      triangles = gen_triangles(max(wordsArray))      wordTriangles = []     lengthTriangles = len(triangles) - 1       for i in range(0, len(wordsArray)):         #print('i:', i, 'current index:', wordsArray[i])         if binarySearch(triangles, wordsArray[i], 0, lengthTriangles) == True:             wordTriangles.append(wordsArray[i])      print(len(wordTriangles))  solution() 

What was a surprise to me was that this actually runs really quickly. To all of you guys, though, this is probably a huge mess, but hey, that’s why I’m here!

For those of you who aren’t familiar with the problem, here is the synopsis:

The nth term of the sequence of triangle numbers is given by, t = ½n(n+1); so the first ten triangle numbers are:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …

By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the word value for SKY is 19 + 11 + 25 = 55 = t10. If the word value is a triangle number then we shall call the word a triangle word.

Using words.txt, a 16K text file containing nearly two-thousand common English words, how many are triangle words?

I can’t wait to see what you all suggest!

## Improved Euler convergence

Consider the butcher tableau for the improved Euler method

$$\begin{array} {c|cc} 0 & 0 & 0\ 1 &1 &0\ \hline & \frac{1}{2} & \frac{1}{2} \ \end{array}$$

I need to use taylor expansion to show that this method converges with order two. I am unsure how to go about this question.

## Largest Palindrome Product – Project Euler #4

This is my code for Project Euler Problem #4

The question:

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

My code:

function problem4(){     let product = 1;     let largest = 1;     for(let i = 100; i<1000; i++){         for(let j = i; j<1000; j++){             product = i*j;             if(("" + product) == ("" + product).split("").reverse().join("")){                 largest = Math.max(largest, product);} }     }     return largest; } console.log(problem4());

At present, it takes 311.5649999999732 ms for execution, but I think it can be better. So how can I make it more efficient and faster?

## Project Euler 76: Counting summations

How many different ways can one hundred be written as a sum of at least two positive integers?

My code is correct but just works slowly.

import time start = time.perf_counter()  def con(H):     J = []     Q = []     W = []     for i in H:         for j in range(len(i)-1):             Cop = i[::]             y = i[j]+i[j+1]             del Cop[j:j+2]             Cop.insert(j,y)             J.append(Cop)     for i in J:         y =(sorted("".join(str(j) for j in i)))         Q.append("".join(y))     T = list(set(Q))     for i in T:         y = [int(j) for j in i]         W.append(y)     return W  num = 5 K = [[1 for i in range(num)]] count = 0 for i in range(len(K[0])-2):     K = con(K)     print(K)     count = count + len(K) print(count+1) end = time.perf_counter() print(end-start,"second") 

Here what this code does. For example, let us say num = 4. Then it creates an array of

[[1,1,1,1]]. Then it sums the consecutive numbers so our result becomes (from line 9-14)

[[2,1,1],[1,2,1],[1,1,2]] Since they are all same my code (from line 15-18) makes them just one function and returns [“112”] and then from 18-21 turns [“112”] to [[1,1,2]] and then I do this whole process again for the [[1,1,2]] and then I count the number of these arrays (from 25-29). The problem is its fast up to num = 20-30 but then it really slows down. Is there a way to increase the speed of my code or should I try a different algorithm?

## Differential equations (euler, taylor series and runge-kutta)

Can anyone help me, the problem are..

(1) first, use the Euler method to solve the following differential equations: dy/dx = xy + y; y(0) = 2 to determine y(3) with h = 1

(2) second, use Taylor(series) method til fourth derivative to solve dif. eq. at question no.1

(3) third, solve dif. eq. no.1 using Runge-Kutta method, orde 2 and orde 4 to determine y(3) with h = 3

Best Regards,

Thanks

## Project Euler #5 in C++

I’m currently doing the Project Euler challenges to learn C++. The fifth problem is the following.

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

I thought of a loop between 20 and 10 as everything under 10 is a multiple of something under 10. At each iteration, the result is the lcm of the loop variable and the current result.

If I am correct, the complexity of this should be $$\mathcal{O}(n/2)$$. Am I right?

Is there any faster/better/cleaner implementation or another algorithm with a better complexity?

This is my code.

#include <iostream>  long gcd(long a, long b) {     long t;      if (b == 0) return a;      while (b != 0) {         t = b;         b = a % b;         a = t;     }     return a; }  long lcm(long a, long b) {     return (a * b) / gcd(a, b); }  int main() {     long n(20), result(1);     for (long i = n; i > n/2; --i) {         result = lcm(result, i);     }     std::cout << "Result: " << result << "\n"; } 

## Project Euler #1 in C++

I’m learning C++ and currently doing Project Euler challenges. The first challenge is the following.

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

I did a quite simple and stupid brute-force implementation by just looping from 1 to 999, checking if its divisible by either 3 or 5 and if it is, sum it with the result variable.

Is there any faster/better/cleaner implementation, maybe without a loop or with less division?

#include <iostream>  int main(int argc, char *argv[]) {     int result(0);     for (int i = 1; i < 1000; ++i) {         if (!(i % 3 && i % 5)) {             result += i;         }     }     std::cout << "Result: " << result << "\n";     return 0; }