text:
# Differential Equation Hemispherical Bowl: show that k=3pia^2/2T given that x=0 when t=T and x=a when t=0.

#### Skelly4444

##### New member
Trying to solve the DE below and show that k=3pia^2/2T given that x=0 when t=T and x=a when t=0.

The DE given in the question is pi(2ax-x^2)dx/dt = -kx

Every time I try to solve it, I get the same answer which is not like the one I'm supposed to be showing.

#### MarkFL

##### Super Moderator
Staff member
Hello, and welcome to FMH!

I would write the ODE as:

$$\displaystyle \frac{\pi}{k}(x-2a)\,dx=dt$$

Integrating, we then get:

$$\displaystyle \frac{\pi}{2k}x\left(x-4a\right)=t+C$$

Now, using the given point $$(t,x)=(T,0)$$ we get:

$$\displaystyle 0=T+C\implies C=-T$$

And so we have:

$$\displaystyle \frac{\pi}{2k}x\left(x-4a\right)=t-T$$

Next, using the given point $$(t,x)=(0,a)$$ we get:

$$\displaystyle \frac{\pi}{2k}a\left(a-4a\right)=-T$$

Solving this for $$k$$, we obtain:

$$\displaystyle k=\frac{3\pi a^2}{2T}\quad\checkmark$$

#### Skelly4444

##### New member
Good morning Mark,
Thank you for your swift response.

Your integration decision slightly confuses me, as I always taught to separate the constant k and integrate the right hand side with respect to t.

When I separated my variables, I had pi(2ax-x^2) / x = -kt.

How can you write the bracketed terms as (x-2a)?

A little confused here if I'm honest.

Thanks
Simon

#### MarkFL

##### Super Moderator
Staff member
It seems you've introduced the variable $$t$$ and dropped the derivative $$\displaystyle \d{x}{t}$$ from the ODE. We begin with:

$$\displaystyle \pi(2ax-x^2)\d{x}{t}=-kx$$

Divide through by $$-kx$$:

$$\displaystyle \frac{\pi}{k}(x-2a)\d{x}{t}=1$$

Now, this may be written in the differential form:

$$\displaystyle \frac{\pi}{k}(x-2a)\,dx=dt$$

Does that make sense?

#### topsquark

##### Full Member
It seems you've introduced the variable $$t$$ and dropped the derivative $$\displaystyle \d{x}{t}$$ from the ODE. We begin with:

$$\displaystyle \pi(2ax-x^2)\d{x}{t}=-kx$$

Divide through by $$-kx$$:

$$\displaystyle \frac{\pi}{k}(x-2a)\d{x}{t}=1$$

Now, this may be written in the differential form:

$$\displaystyle \frac{\pi}{k}(x-2a)\,dx=dt$$
There is a detail here and I don't know how to fix it.

The original equaiton is $$\displaystyle \pi(2ax-x^2)\d{x}{t}=-kx$$ and an initial condition is (t, x) = (T, 0). But in your solution you divided both sides of the differential equation by x, which can't be done at the initial condition, as x = 0.

Could we use the initial condition as a limit? It's not quite correct but the only thing I can think of.

-Dan

#### MarkFL

##### Super Moderator
Staff member
There is a detail here and I don't know how to fix it.

The original equaiton is $$\displaystyle \pi(2ax-x^2)\d{x}{t}=-kx$$ and an initial condition is (t, x) = (T, 0). But in your solution you divided both sides of the differential equation by x, which can't be done at the initial condition, as x = 0.

Could we use the initial condition as a limit? It's not quite correct but the only thing I can think of.

-Dan
Good catch, Dan. I realized I was losing the trivial solution $$x\equiv 0$$, but didn't notice it coincided with an initial value. I suspect the author of the problem overlooked this as well. Offhand, I don't know how to fix this either.

#### Skelly4444

##### New member
Hi Mark,
I understand what you have done but I wasn't aware we could divide through by -kx and just leave a 1 on the right hand side with respect to t.
Like I said in my previous message, I always left k on the right side when separating the variables.
Thanks again.
Simon


text:
# Other articles

1. Published: Mon 27 August 2018

I love watching 8 Out Of 10 Cats Does Countdown. It's a british panel show where a few comedians solve word puzzles and mathematics puzzles. It's based on the game show Countdown that's been running since 1982.

And I also like the host Jimmy Carr very much.

## The Puzzles

The show consists of three different puzzles:

In the Letters round a team (or single contestant) picks 9 consonants and vowels from their respective piles. After the team chooses from one of both piles, the letter is revealed and put up on the board. They then choose again until 9 letters are on the board. After all letters are on the board, the teams have 30 seconds to form a word out of as many of the letters as possible. The team with the longest word scores that many points.

Letters Round

In the Conundrum a list of letters that already spell out a funny group of words is given by the host and the contestants try to find a 9 letter anagram. The first team to buzzer in the correct answer gains 10 points. This is the final round of the game.

Conundrum

In the Numbers round a team (or single contestant) picks 6 numbers from two piles. A random number is picked and the contestants have to create a mathematical formula out of the picked numbers that equal the target number. The specific rules follow.

Numbers Round

## Numbers Round

According to Wikipedia there are 6 columns of 4 numbers (4 rows). One column contains the numbers 25, 50, 75, and 100 and the other 5 columns contain the numbers 1 to 10 twice each. That's not exactly the same as on the show, as there appear to be 7 columns of 4 numbers but not every stack has all 4 number cards.

Contestants choose a total of 6 numbers from the "small" and "large" columns. The usual pick would be 2 to 3 "large" numbers and the rest small ones.

Then a random number between 100 und 999 is generated. The contestants try to create a mathematical formula that has the random number as the result. In the formulare only the following operations are allowed:

• Multiplication
• Subtraction (that does not result in a negative number)
• Division (that results in an integer)

The contestants do not have to use all the numbers to get the target number.

Finished Numbers Round

Since I am really not good at this, I wrote a solver for the numbers game in Haskell.

## Solver

How do we go about this problem? First of all, we have to decide on a data structure. Let's start with a traditional term structure where a Term is a binary operation and two terms, or an integer value. An Operation is the function mapping two integers to a third, and a string to pretty-print the operation. The mapping is not total and might fail.

data Term = Op Operation Term Term | Val Integer
data Operation = Operation {fun :: (Integer -> Integer -> Maybe Integer), name :: String}

instance Show Term where
show (Val x) = show x
show (Op op l r) = "(" ++ (show l) ++ (name op) ++ show r ++ ")"

Now we have to define our operations and what they should do. Since we're using Maybe, and it's a monad, we can use monadic notation where it suits us:

operations = [  Operation (\x y -> return (x + y)) "+"
,  Operation (\x y -> return (x * y)) "*"
,  Operation (\x y -> guard (x > y) >> return (x - y)) "-"
,  Operation (\x y -> guard (x mod y == 0) >> return (x div y)) "/"
]
eval :: Term -> Maybe Integer
eval (Val v) = Just v
eval (Op o l r) = do l' <- eval l
r' <- eval r
(fun o) l' r'

As we can see, the preconditions to the subtraction and division are encoded using the guard function. If the function returns true, the whole operation returns Nothing, otherwise it returns Just the value.

Since Haskell uses lazy evaluation, we can define a list of all possible terms given a list of integers and filter for the ones that evaluate to the correct number.

As we create a Term we have to be careful to not use any of the numbers again. So we will split our numbers in two sets. One that can be used in the left Term of an Operation and the rest can be used in the right Term. We will create all terms using our definition. A Term is either the Value of one of the numbers for that subterm, or an operation with some numbers reserved for the left term and some numbers reserved for the right term.

terms :: [Integer] -> [Term]
terms nums =  do  n <- nums -- choose a number
[Val n] -- one solution
++
do  op <- operations -- choose an operation
(l, r) <- subset_split nums -- choose a split
guard $l /= [] guard$ r /= []
ls <- (terms l) -- choose a term for the left side
guard (eval ls /= Nothing)
rs <- (terms r) -- choose a term for the right side
guard (eval rs /= Nothing)
[Op op ls rs] -- one solution

For performance reasons we already evaluate the generated subterms in order to check whether the operations are valid. There are a lot of terms that can not be evaluated and we want to throw them out as early as possible (or not even generate them).

We haven't defined subset_split yet. The idea is, to just split the list of numbers in two groups in every possible way:

subsets :: [Integer] -> [[Integer]]
subsets []  = [[]]
subsets (x:xs) = subsets xs ++ map (x:) (subsets xs)

subset_split nums = do l <- subsets nums
return (l, nums \\ l)

Now all that remains is to generate all terms given a set of numbers, evaluate them, filter out the ones that don't have the correct value, and return the first one:

solve :: [Integer] -> Integer -> Maybe Term
solve nums target = let possible_solutions = map (\x -> (x, eval x)) (terms nums)
solutions = filter (\x -> (snd x) == (Just target)) possible_solutions
in listToMaybe $map fst solutions  And in our main we only read the list of numbers and the target as arguments and print the solution: main = do args <- getArgs let nums = (read (args !! 0))::[Integer] target = (read (args !! 1))::Integer print$ solve nums target

And there we go:

$./countdown "[100, 75, 2, 10, 3, 8]" 746 Just (8+(3+((75*(100-2))/10)))  Our solution is $$8+3+{{75*(100-2)} \over 10}$$ while the solution from the show was $$10*75 - {8 \over 2}$$. As you can see, we do not always get the easiest solution but we usually have a solution quite fast. This one took about a tenth of a second. The 30 seconds given to the contestant are usually quite enough. To make sure we had the "nicest" solution, we probably would need to generate all terms and sort them by size. The smallest one should be the nicest one. 2. Published: Sat 11 August 2018 # Lost in Localisation - Ordering a Taxi while on Holiday I was on holiday in England this summer. I arrived in Worthing by bus from London, had a full day there, and wanted to take the train the following day to Bristol. The bus route from my BnB to the station was inconvenient and expensive. Ordering a taxi was my next idea. I wanted to do that without human interaction the evening before. This is the story of how that did not work. I name the taxi company in this article. This is not to shame them. I hope they just fix the issues, which I believe present in many applications, because localisation is hard. Quite a Promise ## The Mobile App Before analyzing why ordering a taxicab through their website did not work, I wanted to try the mobile app. I was hopeful, considering their promise that I could "book a car in seconds and don't even need to ring us!". As it turns out, this app is not available through the German Google Play Store. This means, you won't find it when you search for it and if you have the correct URL, you can't install the app through the web interface on a device that is connected to the German Google Play Store (so all of mine). But this is not a problem since you can download any APK that is available from any app store through a third-party service like APKPure (unendorsed). So knowing the name of the app in the Play Store I did that and installed the app. That is the App You're presented with a registration screen where you have to enter your phone number to receive a confirmation SMS. My (international) phone number didn't take and I was not able to complete the process. We will later see why. Being unable to register via the app, I return to the web site. The website looks quite modern ## The Web Site The first part of the order form As you can see, to order a taxi you first have to enter where you want to be picked up and where you want to go. The system then calculates the distance between both points, estimates the cost, and then you can go on to the next step. In order to calculate the distance, the web site uses the Google Maps API to create a route between both points and calculates a cost. Here's the corresponding code from the site: journey['distance'] = response.routes[0].legs[0].distance; journey['duration'] = response.routes[0].legs[0].duration; journey['miles'] = ( journey['distance'].value * 0.000621371192 ); journey['price'] = CurrencyFormatted(2.90); journey['total'] = CurrencyFormatted( journey['price'] + 1.90 * ( journey['miles'] - 0.2 )); journey['start_address'] = response.routes[0].legs[0].start_address; journey['end_address'] = response.routes[0].legs[0].end_address;  This looks okay. It is to note that the site takes the addresses returned by google as the canonical start and end of the journey. So in principle, you could enter the name of a shop or restaurant as the target location of your taxicab ride and as long as google knows it, the taxi service is booked to the actual and correct address. Then there's another step of validation: Since the taxicab company only operates in Worthing in the south of England, they do not want to accept rides that are outside a specific area. They want to achieve this by parsing the post code from the canonical google response and compare it to a set of given post codes that correspond to the Worthing area: journey['start_postcode'] = journey['start_address'].match(/([A-Z]?\d(:? \d[A-Z]{2})?|[A-Z]\d{2}(:? \d[A-Z]{2})?|[A-Z]{2}\d(:? \d[A-Z]{2})?|[A-Z]{2}\d{2}(:? \d[A-Z]{2})?|[A-Z]\d[A-Z](:? \d[A-Z]{2})?|[A-Z]{2}\d[A-Z](:? \d[A-Z]{2})?),\s*UK$/)[0]. That's quite a large regular expression and I give you a visualisation powered by Regexper:

This does correspond in some fashion (but not exactly [1]) to the valid UK post codes followed by ", UK" and the end of the input.

I give you part of the google response for a ride between some random house and the train station and let you figure out why this step fails for me:

{ "routes" : [
{ "legs" : [
{
"distance" : {
"text" : "1,7 km",
"value" : 1654
},
"duration" : {
"text" : "5 Minuten",
"value" : 292
},
"end_address" : "Worthing BN11 1AA, Vereinigtes Königreich",
"start_address" : "Harrow Rd, Worthing BN11 4RB, Vereinigtes Königreich"
}
]}
]}

Google does return the post code correctly, but since my browser is set to German, Google's response is in German as well. The regular expression only matches strings ending in "UK", while my German response ends in "Vereinigtes Königreich" ("United Kingdom" in German).

The fix seems easy enough. Just set the browser language to UK English and do the whole thing again and there we go:

Success?

Okay, good. Let's book the taxi.

Now we just have to enter our name, email address, and phone number and we're good and finally can go by taxi wherever we want to go (within the greater Worthing area). As I enter my phone number, starting with +49 or 0049 for Germany, followed by three digits for the service provider [2], and seven or eight digits for the user, it dawns on me that it might not be that easy (as if it had been up to this point) and I take another glance at the code:

function validateTelephone(telephone){
var re = /^(?:\W*\d){11}\W*$/; return re.test(telephone); }  Oh oh. Okay. Yeah. About that... My phone number does not fit that scheme (while 00000000000 does). If I get any confirmation code I need to respond to, or they want to call back for some additional questions, they won't be able to reach me. This is probably also the reason why the app did not work and why I couldn't receive an SMS with a confirmation code. I won't be able to order a taxi online. To recap the two main reasons why: • Because my browser is set to something else than English, the website can not verify that the cab journey takes place within the serviced area. Solution: Google provides GPS coordinates for the legs of the journey. One can easily check whether they are contained within a rectangle or convex polygon. • Because I have an international phone number, I can't interact with the parts of the process that depend on my cellphone. Solution: Allow for international phone numbers or make the process not depend on them. In the end I called them by phone, which took a whopping 25 seconds and the taxi arrived on time to bring me to the train station.  [1] According to Wikipedia, the UK government has provided a regular expression that can be used for the purpose of validation: ^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$
 [2] It's a little bit more complicated but sufficient for this story.

3. Published: Wed 18 July 2018

# Prolog Programs, Order of Evaluation, and Functional Equivalents

While teaching Prolog this semester I had a few thoughts about Prolog programs and their equivalent programs in a functional programming language like Haskell.

## The Peano Naturals

The Peano numbers are a unary number system for positive natural numbers where the zero is represented by a Z (or 0, or any atom - it doesn't matter) and every successor of a natural number N is the function S applied to N. We would therefore represent the natural number 3 with the term S(S(S(Z))). To look at it differently: in the Peano axioms, the naturals are defined as the set that contains zero and a closure over the successor function. In haskell we would define the type of the naturals like this:

data N = Z | S N

In Prolog we don't need a type definition for the naturals, as terms are generated without types. Now we want a predicate that checks whether our input is a natural number as we've defined it. The idea is that the term is a natural, iff either the term is a Z or it has an S as its root and its parameter is a natural. In Prolog we would write it intuitively like this:

naturals(z).
naturals(s(X)) :- naturals(X).

And indeed this checks whether our input is a natural number. The query naturals(s(s(z))). returns true while naturals(foo). does not. Writing down this program in Haskell is not very useful since the type system does not allow us to have anything else but a natural as the function parameter but let's pretend:

naturals v = case v of
S x -> naturals x
Z -> True
_ -> False

And of course, calling naturals $S$ S Z in haskell has the correct type and returns true. But this haskell program only corresponds to the case where we actually call the Prolog predicate with a bound parameter. We could call the prolog predicate with a free binding pattern like naturals(X). and get bindings for X for every solution, so every natural number. The corresponding Haskell programm would be:

naturals_f  = [ Z ] ++ map S naturals_f

This might need some explaining: The list corresponds to some notion of non-determinism. In Prolog the non-determinism is baked into the language due to backtracking from failed predicate evaluations and us asking for more answers. The Prolog program essentially says: Z is a solution. Everything with an S is a solution, if the "content" of the S is a solution as well. That's the same for our haskell programm. In our list of solutions we know that Z is in it and for every solution we have, adding an S leads to another one. And evaluating naturals_f starts to calculate the infinite list of natural numbers.

Now consider the following Prolog program where we switched the order of the clauses:

naturals(s(X)) :- naturals(X).
naturals(z).

This still works nicely for the bound case where we call naturals(s(s(z)). But if we now call naturals(X) we quickly get ERROR: Out of local stack. The natural intuition might be that the order of clauses does not matter but it does in this case. Writing down the equivalent Haskell programm we are able to see why:

naturals_f  = map S naturals_f ++ [ Z ]

We have the recursion before we have any solution. Well, the solution is easy: just write the simple case in the first line and the recursive case in the second. But let's consider another problem.

## Repeated Printing

Consider the problem of repeatedly printing a character:

repeat(0, _).
repeat(N, C) :- write(C), NN is N - 1, repeat(NN, C).

This looks very correct and is very wrong.

?- repeat(5, f).
fffff
true ;
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

Now we see why it's nice to represent the naturals als Peano numbers. After hitting 0 there's a choice point left and asking for another solution leads to the negatives and printing our character in an infinite loop. So let's augment the second rule to prevent us from going into the negatives.

repeat(0, _).
repeat(N, C) :- N > 0, write(C), NN is N - 1, repeat(NN, C).
% query:
?- repeat(5, f).
fffff
true ;
false.

This looks better but we still have a choice point left over which might be not so nice. The problem is that the matched patterns are not disjoint and after the end of the recursion there's still a pattern left over that fits. We can't encode that N should be larger than 0 in the head of the rule. Remember that we can match naturals larger than 0 (or any other number) in the rule head using Peano numbers - that's why they are so cool.

But how do we fix our problem with the left-over choice point? There are two ways we can do it. We can either introduce a cut or reorder the rules.

% Variant 1a: The order doesn't matter but we introduce a cut
repeat(0, _) :- !.
repeat(N, C) :- N > 0, write(C), NN is N - 1, repeat(NN, C).

% Variant 1b: If we promise to be good and only call repeat with a positive numeric argument, we can even leave out the range check
repeat(0, _) :- !.
repeat(N, C) :- write(C), NN is N - 1, repeat(NN, C).

% Variant 2: The order does matter
repeat(N, C) :- N > 0, write(C), NN is N - 1, repeat(NN, C).
repeat(0, _).

I personally think that the variant without the cut is nicer. So for terminating rules, it might be better to have the "smaller" rule last as to not leave choice-points hanging around. Of course, this only works if the matched terms in the rules are proper subsets of each other so that we actually can order the rules in that fashion. In general, that might not be possible.

## Conclusion

• The order of rules can (in theory) not affect termination. But if our rules are already non-terminating for our query, the order and timeliness of results does matter. Then order does matter.
• Disjoint rule heads are important to not have left-over choice points.
• If rules are terminating but the rule heads are not disjoint, they still should be ordered carefully.
• Implicit conditions (N > 0) can lead to non-obvious non-termination if they are not made explicit.
• By encoding data properties in the term structure we can make some implicit conditions explicit and make rule-heads disjoint.
• Having numerical conditions in rule-heads would be really nice. Maybe some Prolog implementation in the future allows for that.

Page 1 / 7 »

format: plain


text:
# Calculate Integral using residue theorem

I want to verify the following result using the residue theorem:

$$\int_0^\infty \frac{\log(x)}{x^2+a^2}dx = \frac{\pi}{2a}\log a, \, a > 0.$$

Here are my ideas:

At first I might want to show that this function is in fact a well defined improper Riemann integral, but I didn't come up with any nice solution yet.

I want to integrate the function $f(z) := \frac{\log(z)}{z^2+a^2}$ along the contour $C:= \gamma_1 \cup \gamma_2 \cup \gamma_3 \cup \gamma_4$ constisting of to semicircles with center at 0 around the upper half plane and radius $R$ and $\epsilon$ (resp.) as well as the intervals $[-R, -\epsilon]$ and $[\epsilon, R]$.

For the complex logarithm, use the branch $\log z = \log|z| + i\theta, \theta \in [-\pi/2, 3\pi/2)$ so we don't get any problems on the real line (is this choice correct?).

Note that I have one pole in my contour, namely $z = ia$. The Residue theorem yields $$\int_C f(z) dz= 2\pi i \text{ Res}(f, ia) = 2\pi i\lim_{z\to ia}(z-ia) \frac{\log z}{(z-ia)(z+ia)} = 2\pi i\frac{\log(ia)}{2ia} = \pi \frac{\log(a)+ i\pi/2}{a}$$ Proceeding, we choose the following parametrizations:
$$\gamma_1 : [-R,0] \to \mathbb C, \quad t\mapsto -\frac{\epsilon t}{R} + (t-\epsilon) \\ \gamma_2 : [0, R] \to \mathbb C, \quad t\mapsto -\frac{\epsilon t}{R} + (\epsilon+t) \\ \gamma_3: [0, \pi]\to \mathbb C, \quad t\mapsto \epsilon e^{it} \\ \gamma_4:[0,\pi] \to \mathbb C, \quad t \mapsto Re^{it}$$ Now here's what I am unsure about. To show that the big and the small circle vanish as $R\to \infty$ and $\epsilon \to 0$ is not too hard, but how to deal with the other integrals? Can I just say $$\int_{\gamma_1} f(z)dz = \int_0^R \frac{\log(-\frac{\epsilon}{R}t+\epsilon+t)}{(-\frac{\epsilon}{R}t + \epsilon + t)^2 + a^2}(\frac{\epsilon}{R}+1)dt \xrightarrow{\epsilon \to 0} \int_0^R \frac{\log t}{t^2 + a^2}dt$$ or what kind of reasoning should be used to interchange limit and integral?Also, I then finally I get $$\int_0^\infty \frac{\log(x)}{x^2+a^2}dx = \pi \frac{\log a + i\frac{\pi}{2}}{2a}$$ almost what I want, but where does $i\pi /2$ come from?

• Is the real-analysis tag appropriate here? Jun 6, 2017 at 13:22
• I was unsure since we talk about a real integral. I can remove it though. Jun 6, 2017 at 13:23
• Check your work on $\int_{\gamma_1}f(z)~\mathrm dz$. You should have a $\log(-t)$ in the numerator, which should cancel off the imaginary part you are confused about. Jun 6, 2017 at 13:26

Along the real axis, we have

\begin{align} \int_{-R}^R \frac{\log(x)}{x^2+a^2}\,dx&=\int_{-R}^0 \frac{\log(x)}{x^2+a^2}\,dx+\int_0^{R} \frac{\log(x)}{x^2+a^2}\,dx\\\\ &=\int_0^R \frac{\log(-x)+\log(x)}{x^2+a^2}\,dx\\\\ &=2\int_0^R \frac{\log(x)}{x^2+a^2}\,dx+i\pi\int_0^R\frac{1}{x^2+a^2}\,dx\\\\ &=2\int_0^R \frac{\log(x)}{x^2+a^2}\,dx+\frac{i\pi\arctan(R/a)}{a}\tag1 \end{align}

As $R\to \infty$, we find that

$$\int_{-\infty}^\infty \frac{\log(x)}{x^2+a^2}\,dx=2\int_0^\infty \frac{\log(x)}{x^2+a^2}\,dx+\frac{i\pi^2}{2a}\tag 2$$

Setting $(2)$ equal to $\frac{\pi \log(a)}{a}+i\frac{\pi^2}{2a}$, we find that

$$\int_0^\infty \frac{\log(x)}{x^2+a^2}\,dx=\frac{\pi \log(a)}{2a}$$

I thought it might be instructive to evaluate the integral of interest using real analysis only. To that end, we enforce the substitution $x\to a/x$ to find that

$$\int_0^\infty \frac{\log(x)}{x^2+a^2}\,dx=\frac1a \int_0^\infty \frac{\log(a)-\log(x)}{x^2+1}\,dx \tag2$$

For $a=1$, we see from $(2)$ that $\int_0^\infty \frac{\log(x)}{x^2+1}\,dx =0$. Thus, solving $(2)$ for integral of interest, and using $\int_0^\infty \frac{\log(x)}{x^2+1}\,dx =0$, we find that

$$\int_0^\infty \frac{\log(x)}{x^2+a^2}\,dx=\frac{\pi \log(a)}{2a}$$

as expected!

• That makes sense, I accidentally thought that the integral was symmetric. Could you possibly say anything about exchanging the limits and that the integral is well-defined? Jun 6, 2017 at 13:51
• The integral is well defined since $\log(x)$ is integrable on $[,1]$ (so, there is no problem at $0$) and since $\log(x)<\sqrt{x}$, $\frac{\log(x)}{x^2+a^2}=O\left(\frac{1}{x^{3/2}}\right)$ as $x\to \infty$. Jun 6, 2017 at 13:59
• Thank you very much! Does that also justify that I can just exchange Integral and limit or do I need to apply some theorem like dominated convergence? I wouldn't really want to find an integrable majorant... Jun 6, 2017 at 14:10
• Change the parameterization to $t$ so that the integral becomes $\int_{\epsilon}^R \frac{\log(t)}{t^2+a^2}\,dt$. Then, there is no need to interchange the order of integration and limits. Jun 6, 2017 at 14:25
• You're welcome. My pleasure. If one insists on using the parameterization, then noting that the integrand as a function of $\epsilon$ and $t$ is continuous on $[0,R]$ for $\epsilon>0$. Therefore since it is continuous on the closed bounded interval, it is uniformly continuous there. This is enough to justify the interchange of the limit on $\epsilon$ and the integral on $t$. Jun 6, 2017 at 14:33

For any $a>0$, through the substitution $x=a e^t$ we have

$$I(a) = \int_{0}^{+\infty}\frac{\log x}{a^2+x^2}\,dx = \frac{1}{2a}\int_{-\infty}^{+\infty}\frac{\log a+ t}{\cosh t}\,dt \tag{1}$$ and $\frac{t}{\cosh t}$ is an odd integrable function over $\mathbb{R}$. It follows that $$I(a) = \frac{\log a}{2a}\int_{-\infty}^{+\infty}\frac{dt}{\cosh t}=\frac{\log a}{2a}\left[2\arctan\tanh\frac{t}{2}\right]^{+\infty}_{-\infty}=\color{red}{\frac{\pi\log a}{2a}} \tag{2}$$ without even resorting to the residue theorem, but just exploiting symmetry.

• It's even easier to exploit symmetry through the substitution $x\to a/x$. ;-)) Jun 6, 2017 at 17:17
• @MarkViola: of course, this is almost the same. Jun 6, 2017 at 17:17
• Yes, it is the same upon letting $x=a\sinh(t)$ in the integral $\int_0^\infty \frac{1}{x^2+a^2}\,dx=\frac{\pi}{2a}$ Jun 6, 2017 at 17:25
• How did $\int_{0}^{\infty}$ change to $\int_{-\infty}^{\infty}$ m Jun 13, 2017 at 8:09
• I think mockingbird meant how did $\int_{0}^{\infty}$ become $\int_{-\infty}^{\infty}$? Jun 13, 2017 at 8:15

Using a semi-circular contour in the upper half plane that rests on the real axis we obtain

$$\int_0^\infty \frac{1}{x^2+a^2} \; dx = \frac{1}{2} \int_{-\infty}^\infty \frac{1}{x^2+a^2} \; dx \\ = \frac{1}{2} \times 2\pi i \frac{1}{2\times ai} = \frac{\pi}{2a}.$$

Next using a keyhole contour with the slot on the positive real axis and the branch of the logarithm where $0\le \arg\log z\lt 2\pi$ (branch cut on the positive real axis) we obtain integrating

$$f(z) = \frac{\log^2 z}{z^2+a^2}$$

the integrals

$$\int_0^\infty \frac{\log^2 x}{x^2+a^2} \; dx + \int_\infty^0 \frac{\log^2 x + 4\pi i \log x - 4\pi^2 }{x^2+a^2} \; dx \\ = 2\pi i \left(\frac{\log^2(ai)}{2\times ai} + \frac{\log^2(-ai)}{2\times -ai}\right).$$

This yields

$$-4\pi i \int_0^\infty \frac{\log x}{x^2+a^2} \; dx + 4\pi^2 \times \frac{\pi}{2a} = \frac{\pi}{a} ((\log a + \pi i/ 2)^2 - (\log a + 3\pi i/2)^2) \\ = \frac{\pi}{a} (\log a \times \pi i (1-3) + \pi^2 (-1/4 + 9/4)).$$

We thus obtain

$$4\pi i \int_0^\infty \frac{\log x}{x^2+a^2} \; dx = 4\pi^2 \times \frac{\pi}{2a} - \frac{\pi}{a} (-\log a \times 2\pi i + 2 \pi^2) \\ = \frac{\pi}{a} \log a \times 2\pi i.$$

Dividing by $4\pi i$ we finally obtain

$$\bbox[5px,border:2px solid #00A000]{ \frac{\pi}{2a}\log a.}$$

The bounds on the circular components that we used here were

$$2\pi R \times \frac{\log^2 R}{R^2} \rightarrow 0 \quad\text{and}\quad 2\pi \epsilon \times \frac{\log^2 \epsilon}{a^2} \rightarrow 0.$$


text:
A few weeks ago, Mozilla pulled the plug on its Connected Devices Experiment: a bunch of internal non-profit hardware-related startups. One of our main objectives was to determine if we could come up with designs that could help turn the tide against the spyware-riddled and gruyère-level security devices that are currently being offered (or pushed) to unwary users.

One of the startups was Project Lighthouse. We tried to provide an affordable, simple and privacy-friendly tool for people suffering from vision impairment and who needed help in their daily life. While Mozilla closed the experiment before we could release anything useful, we still came up with a few nifty ideas. Here is a post-mortem, in the hope that, maybe, someone will be able to succeed where we couldn’t.

# The problems at hand

If you suffer from sever enough vision impairment, there are many things that you can do on your own, but also many things for which you need help. Things such as interacting with printed text, with identical-to-the-touch bottles or cereal boxes, with the color of your clothes, etc.

The World Health Organization estimates that there are ~285 millions of vision-impaired people in the world, including ~30 millions who are entirely blind. Roughly 85% of them live below poverty level, which means that they cannot afford a helper (unless it’s a family member), nor an expensive gadget.

So, how can we help them?

# Real-life text recognition

At first, we considered helping vision-impaired people interact with printed text. The general idea was to develop a camera that could read out the text from an image, and then iterate on accessibility and form factor.

I have written in details about the difficulties of the operation in another blog entry.

Among the questions at hand:

• is it feasible?
• would such a device need an Internet connection?
• how much CPU/memory would the device need?
• what accuracy could we expect?
• would it be limited to English?

## Results

We concluded that we could finish implementing a reasonable text extraction with a few more weeks of work. This extraction would work just as well if the object was held upside-down or in diagonal, and should, in theory, work with all the common fonts used for indo-european languages. We suspected that the algorithms would need additional work for semitic or asian languages.

We also realized that the underlying algorithms relied upon a number of magic constants (e.g. contrast) and that we would need additional work to tune these constants to actual use cases. We could not rely upon stock pictures, for instance, as we could expect that vision-impaired users would not be sensitive the lighting conditions, or shadows or the framing in the same manner as professional or even casual photographers. It was not clear how we could capture a sample sufficiently large to extract relevant constants.

We benchmarked that text extraction needed lots of CPU, so would probably rely either upon a cloud service (bad for privacy, expensive for many users) or upon a beefy cellphone (expensive for many users).

Further, we determined that extraction would be unfeasible when the orientation of a single line of text changed too much, e.g. on round pill bottles, or on bags of potato chips.

Finally, it was clear that extracting texts and recognizing logos were two very different issues. No amount of text extraction would be able to parse the calligraphy of the Coca-Cola logo, or to understand that a “G” with a specific color combination could mean “Google”, or that “moz://a” could mean “Mozilla”.

## Conclusions

We decided that text extraction should not be the main feature of the device, but rather something that we would add at a later stage, probably after logo recognition.

# Object tagging

A second avenue was helping vision-impaired users interact with objects that are difficult to differentiate by touch.

We envisioned three possible ways to proceed in this direction:

1. let the user take pictures of the objects, recognize what the object was;
2. let the user take pictures of the objects, record a description ( “noodles, they need to cook 10 minutes”, “hat, goes well with my bowtie”, …), use computer vision algorithms to later recognize objects from the internal database;
3. let the user take pictures of the objects, record a description, use deep learning to later recognize objects from the internal database.

We decided to avoid 1. for a minimal viable product, as it would require either a large database and a cloud service, or reliance upon third-party cloud services, which in turn meant:

• dependency on an always-present internet connection;
• many potential privacy issues.

We also decided to avoid 3. for a minimal viable product, as we did not have the in-team skills to proceed with deep learning. We meant to return to 3. in a relatively close future, though.

So, we went ahead with option 2. Among the questions at hand:

• is it feasible?
• would such a device need an Internet connection?
• how much CPU/memory would the device need?
• what accuracy could we expect?

## Results

After a few weeks of coding, we managed to produce a pretty nice prototype, using a Raspberry Pi, OpenCV and Python. In this limited span of time, we did not seriously attempt to resolve issues such as shaky cameras, but otherwise, the prototype worked nicely. Recording or finding an object in the database was nearly instantaneous (for a database of a dozen recorded objects only), without an internet connection, and accuracy was good (we did not attempt to quantify it).

We needed to come up with a method to let the camera differentiate the object from its background. In the absence of sophisticated stereoscopic cameras, we used two tricks:

• ask the user to show the object, then hide it; or
• ask the user to shake the object in from of the camera.

We tested some of the prototypes with real users, got good feedback and figured that we could iterate from there. Our prototypes cost ~$50 to build, a far cry from the$1,500+ we found for other devices for vision-impaired users.

Also, other tests with a few fully blind users confirmed that aiming with a camera was not a problem. There were difficulties with judging distance or light, of course, but we expected that these could be mitigated by judicious algorithms.

So, we decided to proceed from this prototype.

# Form factor

Once we were reasonably convinced that we could come up with a technology to make the device work, we started working on the form factor. We came up with several ideas:

• a camera in a necklace;
• a camera attached to the user’s glasses;
• a camera that could attach to many places, including a supermarket trolley.

Unfortunately, the project was canceled before we could make much headway in the form factor.

An important lesson, though, is that going from design to industrial prototype takes lots of time. I do not have hard numbers, as we didn’t reach that stage, but my personal estimate puts this around 6 months. Which means that we needed a way to test our code and our form factor prototypes with real users.

We did not get the opportunity to test the form factor, although I discussed in another post some of the techniques that we could have used for this purpose.

# App

It would have been unrealistic to wait for the industrial prototypes before proceeding, so we came up with an idea to test our code in parallel with the external and industrial design.

The idea was to port our algorithms to a device that a sufficiently large number of our user base already owned. While developing for Android would have been nice, our statistics (US only) showed almost all vision-impaired users who owned a smartphone were using iPhones, so we did not have much of a choice. We decided to develop an application for iPhone, release it first on Apple’s TestFlight (for alpha-testers), then the App Store.

Additionally, we expected that some users who already owned an iPhone could be interested in the application, even without an optimal form factor. For other users, we still intended to provide an inexpensive full-featured device.

## Results

We managed to port our code relatively easily from Linux to iOS but the project was canceled while we were still 1-2 weeks away from a first pre-alpha release, an estimated 4-6 weeks before we could go beta.

Performance was excellent, which is no surprise as iPhones are largely more powerful than Raspberry Pis.

While population numbers make it clear that iOS was the right platform for early testing and would be the only reasonable target for a smartphone-only application for vision-impaired people in the US, we had a terrible experience developing for iPhone.

Since we needed to interact with a C++ library for computer vision, we needed to code in three languages: C++ (for the computer vision), Swift (for the UX) and Obj-C++ (the unnatural grandchild of C), with two different threading models and three different memory management paradigms (C, C++, Swift/Obj-C). Getting to a stage at which we could perform callbacks from C++ to Swift took some serious digging and understanding Obj-C++’s very interesting memory model.

The signature mechanism seems to be designed largely to get developers to pay (either $99 per developer or$199 per team), which is quite adverse to both open-source contributions and to continuous integration. It also makes it hard/impossible to distribute binaries for testing, even to your non-developer teammates.

Also, the command-line tools offer now reliable way to launch unit/integration tests, plus they have breaking syntax changes – these two points contribute to making continuous integration needlessly difficult.

# Not tested: Crowdsourcing help

One of the features we were considering was a way to crowdsource requests for assistance. Consider a vision-impaired user with a question that cannot be easily answered by a computer: “My arm hurts, is there anything strange on it?”, “Does this dress match this hat?”, etc. How can we put the user in touch with someone willing to help?

Broadly speaking, our idea was the following:

• extend the camera device and application with the ability to record a question;
• develop a web service to gather the questions, their answers, moderation, meta-moderation, …;
• develop a web application front-end to the web service;
• wrap this web application as smartphone apps and browser add-ons for all major browsers, designed so that a user could spend ~5-20 seconds helping whenever they felt like it.

This left many issues unanswered, such as how to avoid spamming users with inappropriate content, how to handle privacy (“I have photographed my credit card by accident”), etc.

We only had time for the first paper explorations of the topic, but we believed that such an open-source crowdsourcing platform for requesting 5-20 seconds help could have become very useful for many projects.


text:
View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

# How would you fix this?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1noatom  Members

Posted 20 December 2013 - 01:06 PM

#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))

#define list_for_each_entry_safe(pos, n, head, member)   \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head);      \
pos = n, n = list_entry(n->member.next, typeof(*n), member))

list_for_each_entry_safe(ent, iter, &(tq->q), q_node) {
list_del(&ent->q_node);
free(ent);
}

The errors:

1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1226): error C2059: syntax error : ')'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1229): error C2059: syntax error : ')'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1231): warning C4552: '!=' : operator has no effect; expected operator with side-effect
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1232): error C2059: syntax error : ')'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2059: syntax error : 'for'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2059: syntax error : '&'
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2065: 'iter' : undeclared identifier
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2099: initializer is not a constant
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2100: illegal indirection
1>c:\users\enjoydrama\documents\visual studio 2013\projects\test\test\util.c(1243): error C2059: syntax error : ')'

I did not write the code,I'm just trying to make it compile.

### #2King Mir  Members

Posted 20 December 2013 - 01:31 PM

Check that there's no whitespace after the \'s. If there is, that might be screwing VS up. It seems to have copy pasted without it, but maybe to original has it.

Edited by King Mir, 20 December 2013 - 01:31 PM.

### #3jjd  Members

Posted 20 December 2013 - 01:36 PM

You could try putting the macros all on one line to rule out odd whitespace or indentation issues.

-Josh

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet

### #4noatom  Members

Posted 20 December 2013 - 01:56 PM

...that did not work either

### #5King Mir  Members

Posted 20 December 2013 - 01:59 PM

Maybe the problem is on a line above the posted code.

### #6noatom  Members

Posted 20 December 2013 - 02:19 PM

above the posted code there are just comments

### #7SeanMiddleditch  Members

Posted 20 December 2013 - 03:24 PM

What lines are those errors actually in? The error may be caused by the context in which you're expanding them.

Game Developer, C++ Geek, Dragon Slayer - http://seanmiddleditch.com

C++ SG14 "Games & Low Latency" - Co-chair - public forums

Wargaming Seattle - Lead Server Engineer - We're hiring!

### #8Anthony Serrano  Members

Posted 20 December 2013 - 04:54 PM

The best solution is to compile it with gcc like it was meant to be.

The Microsoft and gcc preprocessors do not work identically. This code fragment (the macro definitions themselves actually come from the linux kernel) was written to compile with gcc, and so in the Microsoft compiler the macros do not get expanded as intended. It will likely take much more work to rewrite them to expand properly with the Microsoft compiler than to use to right compiler to begin with.

### #9zaphod2  Members

Posted 21 December 2013 - 08:05 AM

Because this is a compilation error of the precompiled source, the precompiled source is already available. Just dump the precompiled source to a file, and look at the line where the bug happens. Possibly you can find out what was the bug with this.

In the C or C++ file's Property sheet select C/C++ in the tree and then select Preprocessor. There is a switch 'Preprocess to a File'. When you switch it on, it will generate a preprocessed output, instead of compiling the file at the next build. The file will be named after your source file with a .i extension and is put in the intermediate directory where the object files are. (I think it's possible to put elsewhere with a different name, but not in the Express version.)

### #10Pink Horror  Members

Posted 21 December 2013 - 07:48 PM

I believe the problem comes from using "typeof", which is a C extension of GCC.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


text:
# Basic probability - picking cards

I could really use some help with this homework question.

There are 100 cards in a raffle. 1 of them is the winning card. There are $$i$$ participants, each one buys 1 card. What is the probability the no one wins?

Solution attempt:

I solved it the following way:

The probability the no one wins:

$$\frac{99}{100} \frac{98}{99} \frac{97}{98} \frac{96}{97} \dots =\frac{\frac{99!}{i!}}{\frac{100!}{i!}} = \frac{99!}{100!} = 0.01$$

The problem is that the solution I was given by my teacher is: $$\frac{\binom{99}{i}}{\binom{100}{i}}$$

I seems like the order of choices doesn't matter in this solution. My question is - why? I thought that I should count all the different orders.

Any help would be greatly appreciated!!

Edit: I finally understood my mistake!!

$$\frac{99}{100} \frac{98}{99} \frac{97}{98} \frac{96}{97} \dots =\frac{\frac{99!}{(90-i)!}}{\frac{100!}{(100-i)!}}$$ and this is equivalent..

Thanks for trying to help :)

• Somehow I would have thought the quicker answer was the number of unsold tickets divided by the total number of tickets $\dfrac{100-i}{100}$. Your answer does not seem to depend on $i$ – Henry Apr 5 '19 at 17:34
• Could you explain why? – PhysicsPrincess Apr 5 '19 at 17:35
• There are $100$ tickets or cards. $i$ are sold and $100-i$ are not. Each is equally likely to be the winning ticket – Henry Apr 5 '19 at 17:36
• Okay I understand this solution from this point of view.. But why is the mistake in my first attempt? – PhysicsPrincess Apr 5 '19 at 17:38
• @PhysicsPrincess: Not really, because if the first one buys a winning card, we know for sure that the second won't win. It's like you have $i$ attempts to win. Anyway, your mistake is that the denominators in your expressions should be $(99-i)!$ and $(100-i)!$ – Vasya Apr 5 '19 at 17:47


text:
# ContourPlot - plot contour lines for minimum of list of functions == 2nd minimum of list of functions

I have a list of (ten or so) functions of two variables (x and y, say). I would like to plot the boundaries on the x y plane where two functions have the same value - but only the two functions in the list which have the smallest values at that particular point. Can this be done? (The Physics application - I have a number of states with different energies (the list of functions), and I am trying to plot the different regions where different states are the ground state.)

Edit follows,

Thanks for your help. I have made some progress with this - functions are parabola. Here is my code so far.

Clear[a, x, y, m, n, p, l]
m[x_, y_] := x^2 + y^2;
n[x_, y_] := x^2 + (2 y + 1)^2;
p[x_, y_] := (x + 1)^2 + y^2;
l = {m[x, y], n[x, y], p[x, y]};
ContourPlot[l[[First[Ordering[l, 2]]]] == l[[Last[Ordering[l, 2]]]], {x,-4,4}, {y,-4,4}, PlotPoints -> 200]
RegionPlot[l[[Last[Ordering[l, 2]]]]-l[[First[Ordering[l, 2]]]]<0.05,{x,-4,4},{y, -4, 4},PlotPoints->200]

The ContourPlot does not work - I get a blank plot - but the RegionPlot does show the regions where the lowest two functions are approximately equal. So is this something to do with the precision at which the calculation is carried out?

I did try the solution provided by Verde - thankyou very much for that - but I didn't fully understand it, and had trouble integrating it with the rest of my code.

Any further help would be much appreciated!

Nick

-
Could you give some basic examples of functions and study cases? This would be helpful if given in Mathematica code. –  Vitaliy Kaurov Aug 8 '12 at 19:28
Sound possible. But it might be helpful for others to be sure what exactly you want if you give an example. And welcome to Mathematica.SE! –  Silvia Aug 8 '12 at 19:34
See edit above! –  Nick Lambert Aug 9 '12 at 15:07

RankedMin may be convenient in this context:

ClearAll[m, n, p, diftwomins];
m[x_, y_] := x^2 + y^2;
n[x_, y_] := x^2 + (2 y + 1)^2;
p[x_, y_] := (x + 1)^2 + y^2;
diftwomins[x_, y_] := (RankedMin[#, 2]-RankedMin[#, 1]) &@(#[x, y] & /@ {m, n, p});
GraphicsRow[{Plot3D[diftwomins[x, y], {x, -4, 4}, {y, -4, 4},
BoxRatios -> 1, PlotPoints -> 100, ImageSize -> 300],
ContourPlot[diftwomins[x, y], {x, -4, 4}, {y, -4, 4},
PlotPoints -> 200, ImageSize -> 300]}]

-

Here's one way using ContourPlot:

Clear[a, x, y, m, n, p, l]
m[x_, y_] := x^2 + y^2;
n[x_, y_] := x^2 + (2 y + 1)^2;
p[x_, y_] := (x + 1)^2 + y^2;
l = {m[x, y], n[x, y], p[x, y]};
ContourPlot[
Evaluate[Table[l[[i]] - Min[Delete[l, i]] == 0, {i, Length[l]}]],
{x, -2, 2}, {y, -2, 2}, Exclusions -> None]

-
Wonderful - very elegant! Thank you very much indeed. –  Nick Lambert Aug 9 '12 at 16:01
l = {Sin[#], Sin[#] UnitBox[Norm@{#} ], 3, Sin[ Norm@#]} &;
b[l_] := Count[Chop[Min[l[x y]] - l[x y]], 0] >= 2.
RegionPlot[b[l], {x, -3, 3}, {y, -3, 3}, PlotPoints -> 100]

-


text:
Matrix multiplication question

This topic is 676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi guys,

From what I understand the correct multiplication order to get a WVP matrix is;

Projection * View * World

To multiply this against the identity matrix do you multiply that last? Like;

Projection * View * World * Identity

Or does it not matter?

Thanks in advance (a matrix math newbie)

Share on other sites

From what I understand the correct multiplication order to get a WVP matrix is;

Depends on which mathematical conventions you're using.

If you're using column-major mathematical conventions, your matrices look like below and you use: Projection * View * World
$$\begin{bmatrix} Xx & Yx & Zx & Tx\\ Xy & Yy & Zy & Ty\\ Xz & Yz & Zz & Tz\\ 0 & 0 & 0 & 1 \end{bmatrix}$$

If you're using row-major mathematical conventions, your matrices look like below and you use: World * View * Projection
$$\begin{bmatrix} Xx & Xy & Xz & 0\\ Yx & Yy & Yz & 0\\ Zx & Zy & Zz & 0\\ Tx & Ty & Tz & 1 \end{bmatrix}$$

n.b. this is completely unrelated to whether you're using row-major array storage or column-major array storage.
e.g. Bullet uses column-major mathematical conventions (the top kind of matrix), but stores the values in row-major arrays. That's just an implementation detail, which should have no impact on your math.

note#2 - you'll find lots of crap on the internet saying "D3D uses row major, GL uses column major!!" but it's not true any more (ever since fixed-function graphics was replaced by shaders).

Your mathematical convention is dictated only by how you write your shader code (and how your matrix library has been written to populate translation/rotation/projection matrices...) -- e.g. do you write W*V*P or P*V*W in your shaders, and does your library fill in the values to look like the top matrix or the one below it...

Your array storage convention is controlled by keywords in GLSL/HLSL -- e.g. you can write "column_major matrix4x4 fooBar;" to choose column-major array indexing in HLSL.

To multiply this against the identity matrix do you multiply that last?

Multiplying against identity is the same as multiplying a regular number by 1 -- it does nothing, ever.
Identity * World * Identity * View * Identity * Projection * Identity == World * View * Projection

Edited by Hodgman

Share on other sites

I am now trying to understand what part the identity matrix plays then.

I often read that you need to set the identity matrix to prevent transforms, rotations, etc taking effect on the next model you are rendering.

Is this purely because of optimisations? So that you can re-use the same matrix assuming you want two objects to have the same transforms applied?

Share on other sites

I am now trying to understand what part the identity matrix plays then.

I often read that you need to set the identity matrix to prevent transforms, rotations, etc taking effect on the next model you are rendering.

Is this purely because of optimisations? So that you can re-use the same matrix assuming you want two objects to have the same transforms applied?

Identity usually used like a default value. Imagine you had a 'scale' value, one model might have scale of 2, the next model might not specify the value and so you need to use the default value. What is an appropriate default? In that case 1. If you used a default of 0 then it would flatten the model to nothing. The same holds true with matrix transforms, if you use a zero matrix then it will flatten the model to nothing (all vertices will end up being zero) and so you need to choose a sensible default that does nothing (0 has side effects), in this case that default is the identity matrix. It has other uses from an algebraic point of view: matrix*matrix_inverse=identity but as far as how you will be using them they are just the best choice of default values. '1' is the identity for real numbers.

There is never any need to multiply by an identity matrix for the sake of multiplying by an identity matrix, though if one of your transforms is an identity matrix then multiplying by it won't hurt. That's perhaps the most useful part about it, multiplying by a zero matrix WILL hurt.

Edited by Nanoha

Share on other sites

This topic is 676 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628642
• Total Posts
2983998

• 9
• 9
• 10
• 21
• 20


text:
# 125 kilometers in meters

## Conversion

125 kilometers is equivalent to 125000 meters.[1]

## Conversion formula How to convert 125 kilometers to meters?

We know (by definition) that: $1\mathrm{km}=1000\mathrm{m}$

We can set up a proportion to solve for the number of meters.

$1  km 125  km = 1000  m x  m$

Now, we cross multiply to solve for our unknown $x$:

$x\mathrm{m}=\frac{125\mathrm{km}}{1\mathrm{km}}*1000\mathrm{m}\to x\mathrm{m}=125000\mathrm{m}$

Conclusion: $125  km = 125000  m$

## Conversion in the opposite direction

The inverse of the conversion factor is that 1 meter is equal to 8e-06 times 125 kilometers.

It can also be expressed as: 125 kilometers is equal to $\frac{1}{\mathrm{8e-06}}$ meters.

## Approximation

An approximate numerical result would be: one hundred and twenty-five kilometers is about one hundred and twenty-five thousand meters, or alternatively, a meter is about zero times one hundred and twenty-five kilometers.

## Footnotes

[1] The precision is 15 significant digits (fourteen digits to the right of the decimal point).

Results may contain small errors due to the use of floating point arithmetic.


text:
# Brane

In string theory and related theories such as supergravity theories, a brane is a physical object that generalizes the notion of a point particle to higher dimensions. Branes are dynamical objects which can propagate through spacetime according to the rules of quantum mechanics. They have mass and can have other attributes such as charge.

Mathematically, branes can be represented within categories, and are studied in pure mathematics for insight into homological mirror symmetry and noncommutative geometry.

## p-branes

A point particle can be viewed as a brane of dimension zero, while a string can be viewed as a brane of dimension one.

In addition to point particles and strings, it is possible to consider higher-dimensional branes. A p-dimensional brane is generally called "p-brane".

The term "p-brane" was coined by M. J. Duff et al. in 1988;[1] "brane" comes from the word "membrane" which refers to a two-dimensional brane.[2]

A p-brane sweeps out a (p+1)-dimensional volume in spacetime called its worldvolume. Physicists often study fields analogous to the electromagnetic field, which live on the worldvolume of a brane.[3]

## D-branes

Open strings attached to a pair of D-branes

In string theory, a string may be open (forming a segment with two endpoints) or closed (forming a closed loop). D-branes are an important class of branes that arise when one considers open strings. As an open string propagates through spacetime, its endpoints are required to lie on a D-brane. The letter "D" in D-brane refers to Dirichlet boundary condition, which the D-brane satisfies.[4]

One crucial point about D-branes is that the dynamics on the D-brane worldvolume is described by a gauge theory, a kind of highly symmetric physical theory which is also used to describe the behavior of elementary particles in the standard model of particle physics. This connection has led to important insights into gauge theory and quantum field theory. For example, it led to the discovery of the AdS/CFT correspondence, a theoretical tool that physicists use to translate difficult problems in gauge theory into more mathematically tractable problems in string theory.[5]

## Categorical description

Mathematically, branes can be described using the notion of a category.[6] This is a mathematical structure consisting of objects, and for any pair of objects, a set of morphisms between them. In most examples, the objects are mathematical structures (such as sets, vector spaces, or topological spaces) and the morphisms are functions between these structures.[7] One can also consider categories where the objects are D-branes and the morphisms between two branes ${\displaystyle \alpha }$  and ${\displaystyle \beta }$  are states of open strings stretched between ${\displaystyle \alpha }$  and ${\displaystyle \beta }$ .[8]

A cross section of a Calabi–Yau manifold

In one version of string theory known as the topological B-model, the D-branes are complex submanifolds of certain six-dimensional shapes called Calabi–Yau manifolds, together with additional data that arise physically from having charges at the endpoints of strings.[9] Intuitively, one can think of a submanifold as a surface embedded inside of a Calabi–Yau manifold, although submanifolds can also exist in dimensions different from two.[10] In mathematical language, the category having these branes as its objects is known as the derived category of coherent sheaves on the Calabi–Yau.[11] In another version of string theory called the topological A-model, the D-branes can again be viewed as submanifolds of a Calabi–Yau manifold. Roughly speaking, they are what mathematicians call special Lagrangian submanifolds.[12] This means among other things that they have half the dimension of the space in which they sit, and they are length-, area-, or volume-minimizing.[13] The category having these branes as its objects is called the Fukaya category.[14]

The derived category of coherent sheaves is constructed using tools from complex geometry, a branch of mathematics that describes geometric curves in algebraic terms and solves geometric problems using algebraic equations.[15] On the other hand, the Fukaya category is constructed using symplectic geometry, a branch of mathematics that arose from studies of classical physics. Symplectic geometry studies spaces equipped with a symplectic form, a mathematical tool that can be used to compute area in two-dimensional examples.[16]

The homological mirror symmetry conjecture of Maxim Kontsevich states that the derived category of coherent sheaves on one Calabi–Yau manifold is equivalent in a certain sense to the Fukaya category of a completely different Calabi–Yau manifold.[17] This equivalence provides an unexpected bridge between two branches of geometry, namely complex and symplectic geometry.[18]

## Notes

1. ^ M. J. Duff, T. Inami, C. N. Pope, E. Sezgin [de], and K. S. Stelle, "Semiclassical quantization of the supermembrane", Nucl. Phys. B297 (1988), 515.
2. ^ Moore 2005, p. 214
3. ^ Moore 2005, p. 214
4. ^ Moore 2005, p. 215
5. ^ Moore 2005, p. 215
6. ^ Aspinwall et al. 2009
7. ^ A basic reference on category theory is Mac Lane 1998.
8. ^ Zaslow 2008, p. 536
9. ^ Zaslow 2008, p. 536
10. ^ Yau and Nadis 2010, p. 165
11. ^ Aspinwal et al. 2009, p. 575
12. ^ Aspinwal et al. 2009, p. 575
13. ^ Yau and Nadis 2010, p. 175
14. ^ Aspinwal et al. 2009, p. 575
15. ^ Yau and Nadis 2010, pp. 180–1
16. ^ Zaslow 2008, p. 531
17. ^ Aspinwall et al. 2009, p. 616
18. ^ Yau and Nadis 2010, p. 181

## References

• Aspinwall, Paul; Bridgeland, Tom; Craw, Alastair; Douglas, Michael; Gross, Mark; Kapustin, Anton; Moore, Gregory; Segal, Graeme; Szendröi, Balázs; Wilson, P.M.H., eds. (2009). Dirichlet Branes and Mirror Symmetry. Clay Mathematics Monographs . 4. American Mathematical Society. ISBN 978-0-8218-3848-8.
• Mac Lane, Saunders (1998). Categories for the Working Mathematician. ISBN 978-0-387-98403-2.
• Moore, Gregory (2005). "What is ... a Brane?" (PDF). Notices of the AMS. 52: 214. Retrieved June 7, 2018.
• Yau, Shing-Tung; Nadis, Steve (2010). The Shape of Inner Space: String Theory and the Geometry of the Universe's Hidden Dimensions. Basic Books. ISBN 978-0-465-02023-2.
• Zaslow, Eric (2008). "Mirror Symmetry". In Gowers, Timothy (ed.). The Princeton Companion to Mathematics. ISBN 978-0-691-11880-2.