text:
Linear Algebra

# Matrix Fun

$$\begin{pmatrix}2 & 1\\ 1 & 2 \end{pmatrix}$$

$\left[ \begin{array}{cccc} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ 9 & 10 & 11 & 12 \\ 13 & 14 & 15 & 16 \end{array} \right]$

$\left[ \begin{array}{cccc} 1 & 0 & -3 & 5 \\ 0 & 1 & 2 & 4 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 \end{array} \right]$

# 1/14/08

Identity Matrix (pg 22)
Rotation Matrices (pg 23)

# 1/23/08

Elementary row operations yield equivilent augmented matrices of a system of linear equations.

## Goal

Transform an augmented matrix into reduced row echelon form so as to easily see the solutions.

## Row Echelon Form

1. Each non-zero row is above every zero row
2. Leading entry of a non-zero row lies in a column to the right of that of the leading entry of any preceding row
3. If a column contains the leading entry of a row, then all entries below it in that column are 0. (follows from #2)

## Reduced Row Echelon Form

1. If a column contains the leading entry of a row, then all other entries of that column (below AND above) are 0
2. Leading entry of each non-zero row is 1

Express leading variables x1,x3,x5 (basic variables) in terms of the others (free variables).
Basic variables are columns containing only a leading entry

# 1/25/08

Every matrix can be transformed into 1 and only 1 matrix in reduced row echelon form by a sequence of elementary row operations

If we have Ax=b
1) Write augmented matrix [A b]

2) Find reduced RE
[Rc] of [Ab]

3) If [Rc] contains a row in which the only non-zero entry lies in the last column, then there's no solution (inconsistent).
Otherwise, there's at least 1 solution.
Then we write the equations corresponding to [Rc] and solve to obtain a general solution of Ax=b.

## Gaussian Elimination

Procedure for obtaining the reduced row echelon form of a matrix

$$\begin{pmatrix}0 & 0 & 2 & 4\\ 0 & 1 & -1 & 1 \\ 0 & 6 & 0 & -6 \end{pmatrix}$$

1) Determine leftmost non-zero column —> Pivot column
Top position in a pivot column is a pivot position
2) In a pivot column interchange rows (if necessary) to have a non-zero entry in the pivot position.

r1<—>r2
$$\begin{pmatrix}0 & 1 & -1 & 1 \\ 0 & 0 & 2 & 4 \\ 0 & 6 & 0 & -6 \end{pmatrix}$$

3) Zero out all entries below pivot position.

-6r1 + r3—>r3
$\bf{A} = $\begin{pmatrix}0 & 1 & -1 & 1 \\ 0 & 0 & 2 & 4 \\ 0 & 0 & 6 & -12\end{pmatrix}$$

4) Repeat procedure 1-3 with next pivot column and pivot position.

2 (3rd col, 2nd row) becomes the new pivot position.

-3r2+r3—>r3
$\bf{A} = $\begin{pmatrix}0 & 1 & -1 & 1 \\ 0 & 0 & 2 & 4 \\ 0 & 0 & 0 & 0\end{pmatrix}$$

# 1/28/08

Nothing interesting. Sick. =(

# 1/30/08

• Leading variables are basic variables. (x1,x3,x4,)

Others are free variables (x2,x5) Can be anything (0, 1, or infinite solutions)

• The rank of an m*n matrix A is the number of non-zero rows in the reduced row echelon form of A.
• Nullity of A is n-rank A. For the previous example rank=3; nullity=6(columns)-3=3. 6 is the number of columns.
• Equivalently: Rank equals the number of pivot columns in the close messagematrix. Nullity equals the number of non-pivot columns.
• If an m*n matrix has rank n, then it must be [e1 … en]m*n

If it is square(m*n), then [e1 ..en]m*n == In, identity matrix

Each basic variable corresponds to the leading entry of the augmented matrix Ax=b.

# of basic variables = # of non-zero rows == rank A.

# of free variables of Ax=b is n - # basic variables = n-rank A == nullity of A

• Consistency for Ax=b
1. # of basic variables = rank A.
2. # of free variables = nullity of A.

=> Unique solution iff (if and only if) the nullity of A is 0.

Infinity solutions iff nulity (free variables) of A is positive.

# 02/01/08

## Consistency for Ax=b

• # of basic variables = rank A
• # of free variables = nullity of A (not [Ab])

## Span of a set of vectors

For the non-empty set S={u1 …. uk} of vectors in Rn, the span of S (Span S) is
the set of all linear combinations of u1 … uk in Rn.
Span S = Span {u1 … uk}
Span{0}={0}

# 02/04/08

Test on Wed up to and including 1.4

Span S = set of all linear combinations of S={u1 … uk}
Span{0}={0}
S1={$\bf{A} = $\begin{pmatrix}1 \\ -1 \end{pmatrix}$$}
Span S1 = $\{a (scalar) * $\begin{pmatrix}1 \\ -1 \end{pmatrix}$ \}$
Span3= $\{a$\begin{pmatrix}1 \\ -1 \end{pmatrix}$ + b $\begin{pmatrix} -2 \\ 2 \end{pmatrix}$ + c $\begin{pmatrix} 2 \\ 1 \end{pmatrix}$ \}$
S3={u1,u2,u3}={u1,-2u1,u3}=R2

A vector V belongs to the span of S (S={u1 … uk}) if V can be expressed as the linear combination of the vectors u1 … uk in S.

Suppose A=[u1 … uk] in Rn
Then, V is in the span S iff (if and only if) Ax=v is consistent.

x1u1 … = V

# 02/08/08

V "belongs to" Span S = {u1 … uk}

V is a linear combination of the vectors u1 … uk.

• If A = [u1 … uk] then v is in the Span S if + only if Ax=v is consistent.

x1u1 + xkuk = v

Is V= $$\begin{pmatrix}3 \\ 0 \\ -5 \\ 1 \end{pmatrix}$$

# 02/13/08

If one of the u's is 0 then the set is always linear dependant.

The set {u1 .. uk} is linear dependant iff there exists a non-zero solution of _Ax=0__

A=$$\begin{pmatrix}1 & 1 & 1 & 1 \\ 2 & 0 & 4 & 2 \\ 1 & 1 & 1 & 3\end{pmatrix}$$

For an m x n matrix A the following are equivilent:

1. Columns of A are linear independant
2. Ax=b has at most 1 solution for each b in Rm.
3. Nullity of A is 0 (no free vars)
4. Rank=#columns - Nullity
5. Columns of RRE of A are distinct standard vectors in Rm
6. Only solution of Ax=0 is x=0
7. Pivot position in each column of A.

For linear independant/dependant we want to determine whether or not x=0 is the only solution to Ax=0 (homogeneous equation)

If there exist free variables => infinity solutions, linear dependant
*Vectors u1 … uk in Rn are linear dependant iff ui=0 or there exists i>=2 such that ui is a linear combination of the preceding vectors u1 .. ui-1

# 3/10/08

For a linear transf T, w is the range of T iff w (output) = T(v[input])

the range of a linear transformation equals thespan of the columns of its standard matrix A = [T(e1) T …]

A function f Rn —> Rm is onto if its range is all of Rm (range = co-domain)
if every vector in Rm is an image under f

page revision: 34, last edited: 10 Mar 2008 15:47


text: Abstract: We study the phase diagram of the standard pair approximation equations for two different models in population dynamics, the susceptible-infective-recovered-susceptible model of infection spread and a predator-prey interaction model, on a network of homogeneous degree $$k$$. These models have similar phase diagrams and represent two classes of systems for which noisy oscillations, still largely unexplained, are observed in nature. We show that for a certain range of the parameter $$k$$ both models exhibit an oscillatory phase in a region of parameter space that corresponds to weak driving. This oscillatory phase, however, disappears when $$k$$ is large. For $$k=3, 4$$, we compare the phase diagram of the standard pair approximation equations of both models with the results of simulations on regular random graphs of the same degree. We show that for parameter values in the oscillatory phase, and even for large system sizes, the simulations either die out or exhibit damped oscillations, depending on the initial conditions. We discuss this failure of the standard pair approximation model to capture even the qualitative behavior of the simulations on large regular random graphs and the relevance of the oscillatory phase in the pair approximation diagrams to explain the cycling behavior found in real populations.

format: plain


text:
# Solving a problem involving continuity of a piecewise function

I'm trying to solve the following problem:

Determine which $n\in\mathbb{N}$ make the following function $f:\mathbb{R}^3\rightarrow \mathbb{R}$ continuous at the origin:

$f(x,y,z)=\left\{ \begin{array}{cr} \frac{(\cos^2\left(|x|+|y|\right)-1)\sin(y^2+z^2)}{(x^2+y^2+z^2)^{n/2}} & \text{if } (x,y,z) \neq 0\\ 0 & \text{if } (x,y,z) = 0\\ \end{array} \right.$

It's obvious that $f$ is continuous at the origin if $n\leq 2$, since:

$\left|\frac{(\cos^2\left(|x|+|y|\right)-1)\sin(y^2+z^2)}{(x^2+y^2+z^2)^{n/2}}\right|\leq\frac{|\cos^2\left(|x|+|y|\right)-1|\,|y^2+z^2|}{|x^2+y^2+z^2|}\leq\frac{|\cos^2\left(|x|+|y|\right)-1|\,|y^2+z^2|}{|y^2+z^2|}=|\cos^2\left(|x|+|y|\right)-1|\rightarrow 0$

I'm almost sure the function isn't continuous if $n> 2$ but I can't seem to find a way to prove it.

-

I think it is continuous for $n=3$ too. If we let $r$ be the length of the vector $(x,y,z)$, then the expression for nonzero $r$ simplifies to $$\frac{(\cos^2(pr)-1)\sin(qr^2)}{r^n}$$ where $p\in[0,\sqrt 2]$ and $q\in[0,1]$ depend on the direction of $(x,y,z)$, but not on its magnitude. If we develop the cosine and sine to the second degree each, we get the approximation $$\frac{-(pr)^2\cdot qr^2}{r^n}=2p^2qr^{4-n}$$ so as long as $n<4$ this ought to converge towards $0$.

On the other hand for $n\ge4$ we can consider the ray $(x,y,z)=(0,r,0)$. Along this line $p=q=1$, so $f$ fails to go towards $0$ for $n=4$ and actually blows up for $n>4$.

Making this rigorous using L'Hôpital's rule is left as an exercise for the reader :-)

-
Thanks for your answer! If I understood correctly, you approximated the cosine and sine using its Maclaurin polynomial, right? (my English is a bit rusty lately and I want to make sure I got your idea). I'm thinking how this could be turned into a formal argument; maybe showing the error term is small enough? –  F M Oct 7 '11 at 22:30
Yes. Working out the error term explicitly should certainly work, but will probably be much more involved than just using L'Hôpital's rule. Which is easier than it may look -- note that $\frac{d^4}{dr^4}f(r)g(r)=\binom42 f''(r)g''(r)$ plus terms that include one of $f(r)$, $g(r)$, $f'(r)$, or $g'(r)$ and so vanish for $r=0$. –  Henning Makholm Oct 7 '11 at 22:41
Thanks a lot! [some more text here] –  F M Oct 7 '11 at 22:45

The question is for $n$ integer, but we can take $a\in\mathbb R$ instead of $n$. We denote $f_a$ the corresponding function. We have for $(x,y,z)\neq (0,0,0)$ $$f_a(x,y),z)=-\frac{\sin^2(|x|+|y|)\sin (y^2+z^2)}{(x^2+y^2+z^2)^{a/2}}.$$ Now, fix a real number $m$. We have $$f_a(x,mx,mx)=-\frac{\sin(2|mx|)\sin(2m^2x^2)}{(1+2m^2)^{a/2}|x|^a}\overset{0}{\sim}-\frac{4|m^3||x|^{3-a}}{(1+2m^2)^{a/2}},$$ hence $f_a$ cannot be continuous if $3-a\leq 0$ hence $a\geq 3$. Conversely, if $a<3$ we have thanks to then inequality $|\sin t|\leq |t|$: \begin{align*} |f_a(x,y,z)|&\leq\frac{(|x|+|y|)(y^2+z^2)}{(x^2+y^2+z^2)^{a/2}}\\ &\leq \sqrt 2\frac{\sqrt{x^2+y^2}(y^2+z^2)}{(x^2+y^2+z^2)^{a/2}}\\ &\leq \sqrt 2(x^2+y^2+z^2)^{\frac{3-a}2}, \end{align*} and we can conclude since the exponent is positive.

-
Thanks a lot for your help! –  F M Oct 7 '11 at 22:45
@FernandoMartin You're welcome. –  Davide Giraudo Oct 7 '11 at 22:46


text:
Now showing items 1-1 of 1

• #### Fairest edge usage and minimum expected overlap for random spanning trees

(Elsevier, 2021-05)
Random spanning trees of a graph $G$ are governed by a corresponding probability mass distribution (or "law"), $\mu$ defined on the set of all spanning trees of $G$ This paper addresses the problem of choosing $\mu$ in ...


text:
# Thread: Prove the Fundamental Theorem of Calculus

1. ## Prove the Fundamental Theorem of Calculus

Hi,

I would like to know how to prove the following generalization of the Fundamental Theorem of Calculus using the method below.
Suppose there is a finite set E in [a,b] and functions f,φ : [a,b]—> R (reals) such that

(a) φ is continuous on [a,b]
(b) φ'(x) = f(x) for all x ∈[a,b]\E
(c) f ∈R[a,b] (i.e. f is Riemann integrable)

Then

∫f (from a to b) = φ(b) - φ(a)

Method :Start by assuming E = {a,b} and remember that the Mean Value Theorem for derivatives applied to a (closed) interval [c,d], say, requires continuity on all of [c,d] but only requires differentiability on (c,d).
Once you have done it for this special case, explain why it is still true if you add another point to E. The general case then follows.

I am a bit confuse about the method specified by my teacher.
It would be helpful if someone can guide me through this.
Thank you very much.

2. Anyone would have an idea of how my teacher would want the proof to be?


text:
# Chain dimensions near the critical point

Biswas, Parbati and Cherayil, Binny J (1994) Chain dimensions near the critical point. In: The Journal of Chemical Physics, 100 (6). pp. 4665-4673.

 PDF Chain_dimensions-59.pdf Restricted to Registered users only Download (929Kb) | Request a copy

## Abstract

We calculate the average end-to-end distance $\langle R^2\rangle$ of a polymer in a semidilute solution that is near the temperature $T_c$ at which phase separation occurs. The calculation is carried out within the usual canonical partition function formalism, the Hamiltonian of the system being taken to comprise a reference term, in which the chains are represented as collapsed coils, and a pertur- bation, which originates in repulsive excluded volume interactions between different monomers. The description of the reference state employs the fractional Brownian walk approach developed in an earlier paper, while the perturbation is modeled by delta function pseudopotentials. The treatment of excluded volume follows the methods developed by Edwards, Singh, and Jeffers, which make use of the equations derived for an effective step length and an effective monomer-monomer potential to determine various polymer properties. In this way, we find that near $T_c,$ R scales with chain length N as $N^{0.462}$.

Item Type: Journal Article The copyright belongs to American Institute of Physics. Division of Chemical Sciences > Inorganic & Physical Chemistry 15 Nov 2006 19 Sep 2010 04:29 http://eprints.iisc.ernet.in/id/eprint/7629


text:
# C++ Win32 Winsock sending a file

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

## Recommended Posts

nBuffer is from recv. I open it with the mode binary.

client:
if(std::string(nBuffer)=="FILE_DONE_DOWN") { std::cout<<"Finnished Downloading File: "<<this->Files_To_Update[0]<<'\n'; this->Files_To_Update.erase(this->Files_To_Update.begin()); if(this->Files_To_Update.size()>0) { std::cout<<"Downloading File: "<<this->Files_To_Update[0]<<'\n'; this->Send_Client(this->Files_To_Update[0]); this->WriteToFile.open(this->Files_To_Update[0],this->WriteToFile.binary); } else { std::cout<<"Downloading Executable...\n"; this->Doing="DOWNLOAD_EXE"; this->Send_Client("EXE"); } } else { nBuffer[Size]='\0'; this->WriteToFile.write(nBuffer,Size); this->Send_Client("OK"); std::cout<<nBuffer<<'\n'; }

host:
if(SendFile.is_open()) { char SendBuf[Buff_Size]; //SendFile.seekg(std::ios::beg+DoingAt*Buff_Size); SendFile.read(SendBuf,Buff_Size); APP.Send_Server(SendBuf,p); DoingAt++; if(SendFile.eof()) { SendFile.close(); } std::cout<<SendBuf<<'\n'; } else { APP.Send_Server("FILE_DONE_DOWN",p); DoingAt=0; SendFile.close(); Doing="SEND_FILES"; }

i dont know if this is right, nor if this is the right approach. i was sort of following this tutorial:

but instead of using a CFile i just used a fstream.

Oh, and by files i mean .png,.wav,.ogg, etc.

##### Share on other sites
Does it work? If so, it's probably OK, assuming you give the user proper progress indication, protect against disruptive downloaders on your server, etc.

##### Share on other sites
I really dont know if it works or not. it will start downloading (gibberish, of course) then pause... i know both have to be actively talking to eachother otherwise they both stop, waiting for one to send something when they never will... so as long as i read and write in binary, the files should be ok? i dont know, because you have to have a null terminated string for things... :-\

i really just need to know if this is the right way to read and write any file, and be able to send it.

##### Share on other sites
Sending a binary file but trying to receive it as a null terminated string will not work. Nor will trying to read a binary file and then send it as a null terminated string. The reason is that the binary data may contain zeros, which would screw everything up. You need to first send the number of bytes of the file (either as a string or as binary data), and then when the client receives this they know exactly how many bytes they need to download and don't have to rely on things being null terminated. When sending data, your Send_Server will have to know how many bytes the chunk is that it's sending. I don't know what p is, but it looks like Send_Server is expecting a null terminated C-style string, and binary data does not fit this description.

##### Share on other sites
Ah... how would i read/send/write this binary data? or would it be better to read the files as a actual string?

EDIT:

CFile is a file class that allows binary reading and writing, which is what was used in the tutorial. i have 1 more question though: if you read any file from binary, send it, then write it back in binary, will any file work 100%?

##### Share on other sites
Sending and receiving blocks of bytes is very similar to using void pointers and memcpy(). As long as you can copy data around with memcpy() and void pointers, you can probably also send and receive it on sockets. Or, for that matter, write data to a file and then read it back.
There are some differences:
- if there's a point inside the block of data, that pointer will mean nothing on the other end
- send() may not send everything you ask it to; recv() may receive less than you asked for
- you need to know how much data is to be received, so you know when the next message starts

##### Share on other sites
Well i just learned that CFile is not included with microsoft visual c++ 2010 express, so that wont work. If you know about window sockets (which you probly do), you have to store the recv in a char-array. so how would i store the recv as binary? and the same with send(), how would i send the binary information?

##### Share on other sites
You still store it in a char array. And you still send the data from a char array. It's just not a string. There's a difference between a string and a char array. A C-style string is a special type of char array, but a char array is not necessarily a string (it's kinda like how a square is rectangle, but a rectangle isn't necessarily a square). You just can't treat it as a normal C-style string when you send or receive it though. send() and recv() have absolutely no clue what a string is. All they see is binary data. So even when you send/receive a string with them, all the see it as is a plain old binary char array.

##### Share on other sites
Yeah, i sort of figured that out now. I knew that a string is always null terminated, etc etc... i just now tested with a .txt file, and works well. but when its other files, like .wav s and .png s, it gets buggy. also, i tried getting the file size by doing:
SendFile.open(nMess,SendFile.binary); std::stringstream LengthBuf; SendFile.seekg(std::ios::end); LengthBuf<<SendFile.tellg(); std::cout<<"Sending File Length: "<<LengthBuf.str()<<'\n'; SendFile.seekg(std::ios::beg);

and always calls it 2... but otherwise... regular text files work... how would i do this with others?

EDIT:

I found out how to get the size... now i just have to work on the other types of files...

##### Share on other sites
Is there any reason you are doing this in-band? If you were to host the files on a web server, you could use a simple HTTP library to manage most of this for you. In addition, you might want to separate the updater from the game. Doing this will keep each component simpler.

##### Share on other sites
XD i dont have any money to do anything like that. and if i did, i dont think it would be worth it since no body really plays my game. i mean, if you ever heard of N8, they started kinda like me... but once they started getting players and more money they could spend it on stuff like that. but for now, im trying to do it as easy and free as possible.

##### Share on other sites
Could anyone post some example code for both the client and host that uses fstream to read,send,receive,and write binary files?

##### Share on other sites
If it works for text files, and not for arbitrary data, then you must be relying on some property in text - an assumption that "binary" data violates. The most obvious example would be assuming that the 0 byte cannot occur in the data. That or accidentally treating the data as if it were a string, for example using the strlen() function.

##### Share on other sites
Nevermind, works perfectly!
Im proud of myself.


text:
# Dividing by 0

We are told over and over of the fact that you just cannot divide by 0. Why? Yes, I know it doesn't make sense to divide by 0, but really, there has to be a mathematical reasoning of why this cannot be accomplished.

Because this is what may happen in the real world

Last edited by a moderator:
Funny : )

l46kok, think on how do you define division, in the first place. When you divide two numbers, say a / b, you are looking for another number such that, multiplied by b, gives you a.

Now imagine b is zero. What number, multiplied by zero, gives you some particular number a?

If a is not zero too, then there is not such a number. No number multiplied by zero gives non-zero, that's why a / 0 has no result if a is non-zero.

And if a is also zero, then any number would do. 0 / 0 is considered undefined, since it has not an unique solution.

Hope this helps.

442nick
arildno
Homework Helper
Gold Member
Dearly Missed
We are told over and over of the fact that you just cannot divide by 0. Why? Yes, I know it doesn't make sense to divide by 0, but really, there has to be a mathematical reasoning of why this cannot be accomplished.

Sure it is:

1. Having no reference to division at all, we may prove by standard properties of real numbers that for any real "a", a*0=0.

2. If therefore, for real numbers b and for real numbers c, the division b:c shall equal a number k so that c*k=b, it follows that for any non-zero b, we cannot in general let c=0,
since we already have proven that..c*k=0.

Therefore, in order to maintain consistency of our mathematical operations we see that division by 0 is prohibited

Hurkyl
Staff Emeritus
Gold Member
We are told over and over of the fact that you just cannot divide by 0. Why? Yes, I know it doesn't make sense to divide by 0, but really, there has to be a mathematical reasoning of why this cannot be accomplished.
Because division is defined to operate on nonzero denominators -- your question is like asking why we use the word "blue" to decribe light with a wavelength of 465 nm.

There are lots of reasons why this definition is a useful one -- the other posts demonstrate some bad things that we would face if we attempted to define a new division operator that allowed division by zero.

Zurtex
Homework Helper
Because division is defined to operate on nonzero denominators -- your question is like asking why we use the word "blue" to decribe light with a wavelength of 465 nm.

There are lots of reasons why this definition is a useful one -- the other posts demonstrate some bad things that we would face if we attempted to define a new division operator that allowed division by zero.

To be fair that's not entirely true. While you can look it that way, just dryly, saying that "because that's the way it's defined".

A more interesting way to look at it is to consider the Field of real numbers, which have a certain set of properties that must obey. Then it's non-trivial to show that 0 has no multiplicative inverse, you tackle it much the way arildno has.

arildno
Homework Helper
Gold Member
Dearly Missed
I think Hurkyl was very fair, Zurtex; because he is right.

Although we shouldn't throw out the idea of mathematical consistency, I'm sure we could throw out the distributive law of multiplication, say, and preserve a "division" concept applicable for zero.

(But then, multiplication is no longer what it once was..)

Essentially, therefore, the ultimate justification for why division by 0 is prohibited is DEFINING the operation in such a way that it remains consistent/meaningful with whatever other axioms are held to be true.

If we choose to change those axioms themselves, we might not need to exclude 0 from being a divisor in our definition of division.

Last edited:
Zurtex
Homework Helper
I know it's true just to say "division isn't defined for 0", I'm not arguing otherwise.

My quible, if any, was to do the the analogy:

'your question is like asking why we use the word "blue" to decribe light with a wavelength of 465 nm.'

The reason it's called blue is arbitrary, we could call it green, we could it elephant, we could call it awoejhropwiheroiuwheifuwheoifugwoeifugilqhwb4ihfbghfwiherbfwihebfiwhegbf. The reason our definition of division doesn't allow for for divide by 0 isn't arbitrary, 0 has special properties in a field and it wouldn't make sense for us to choose some other qualitatively different number.

We are told over and over of the fact that you just cannot divide by 0. Why? Yes, I know it doesn't make sense to divide by 0, but really, there has to be a mathematical reasoning of why this cannot be accomplished.

Because that’s how fields are defined.

Zurtex
Homework Helper
Because that’s how fields are defined.

I know you can define a field like that, but I was always taught to define a field by these:

http://mathworld.wolfram.com/FieldAxioms.html

Where devision is defined through the multiplicative inverse, the Field Axioms then imply division by 0 isn't possible because 0 has no multiplicative inverse. Sorry I may seem a little over the top about this, I just don't feel in this case it's a very sufficient answer for someone who is trying to learn something new.

It can also nicely be shown that a field becomes inconsistent if you allow 0 to have a multiplicative inverse.

I know you can define a field like that, but I was always taught to define a field by these:

http://mathworld.wolfram.com/FieldAxioms.html

Where devision is defined through the multiplicative inverse, the Field Axioms then imply division by 0 isn't possible because 0 has no multiplicative inverse. Sorry I may seem a little over the top about this, I just don't feel in this case it's a very sufficient answer for someone who is trying to learn something new.

It can also nicely be shown that a field becomes inconsistent if you allow 0 to have a multiplicative inverse.
I think my answer is the best one to this question because it lets him go as deep as he wants it has the: “Because that’s how we define it” element but if he wants to know WHY we define it that way he need to study fields.

CRGreathouse
Homework Helper
Let's try to define a field-like object with a multiplicative inverse. To start with, let's give it two distinct elements, the 0 and the 1.

0 + 1 = 1 + 0 = 1 (additive identity)
Thus 1 + 1 = 0 because otherwise there is no additive inverse.
Distributing, (1 + 1) * 0 = (1 * 0) + (1 * 0).
1 * 0 = 0 (multiplicative identity)
So (1 + 1) * 0 = 0 + 0 = 0 (additive identity for the last step)
Of course we also know that 1 + 1 = 0, so (1 + 1) * 0 = 0 * 0.
If 0 has a multiplicative inverse, it must be 0 (1 doesn't work by multiplicative identity). Thus 0 * 0 = 1.

So 0 = (1 + 1) * 0 = 1. But we know that 1 and 0 are distinct.

We are told over and over of the fact that you just cannot divide by 0. Why? Yes, I know it doesn't make sense to divide by 0, but really, there has to be a mathematical reasoning of why this cannot be accomplished.

i dunno what the big deal is. when we say:

$$Q = \frac{N}{D}$$

we are saying that quotient Q is such a number that when multiplied by denominator D, you get numerator N. there is a clear problem with this, if N is not zero, yet D is zero, no?

do you accept first that zero times anything is zero? it has to be if the distributive property is true. so if you accept that

$$0 \times Q = 0$$

then there is no way for

$$D \times Q = N$$

if N is not 0 and D is 0. you get to a self-contradictory state, given such a premise (that we can divide by zero). hence the premise must be an unsupportable premise.

CRGreathouse
Homework Helper
Let's try another way. Consider working with subsets of the real numbers instead of real numbers directly. Let $A+B$ be $\{a+b:a\in A,b\in B\}$, $A-B$ be $\{c:c+b=a,a\in A,b\in B\}$, $A\cdot B$ be $\{ab:a\in A,b\in B\}$, and $A/B$ be $\{c:cb=a,a\in A,b\in B\}$. Then $\{1\}+\{1\}=\{2\}$, and in general
$$\{a\}\oplus\{b\}=a\oplus b$$ where $\oplus$ is +, -, or *.

Then $\{a\}/\{0\}=\mathbb{R}$ if $a=0$ and $\{a\}/\{0\}=\emptyset$ otherwise.

Let's try another way.

Then $\{a\}/\{0\}=\mathbb{R}$ if $a=0$ ..

this is potentially true (but i always worry about what it is in the limit, but there doesn't appear to be a limit here), but there is no way we can tell what particular real number $\{a\}/\{0\}$ is. it could be anything, making $\{a\}/\{0\}$ pretty meaningless whether a is zero or not.

morphism
Homework Helper
this is potentially true (but i always worry about what it is in the limit, but there doesn't appear to be a limit here), but there is no way we can tell what particular real number $\{a\}/\{0\}$ is. it could be anything, making $\{a\}/\{0\}$ pretty meaningless whether a is zero or not.
?

What CRGreathouse did was define operations on sets. What he wrote down isn't "potentially true", it's absolutely true. Under his definitions, {a}/{0} is not a real number, it's a set.

I prefer to use layman's terms in this case. Dividing is essentially a partition into equal parts. So, if you have A/B, you are essentially dividing A into equal parts of size B, and A/B represents the number of these equal parts. For a concrete example, take 16/2:

If you partition 16 into equal parts of size 2, then you would need 8 such equal partitions. However, what happens when you try to form partitions of size 0. How many would you need? An infinite number of them (and intuitively, even an infinite number of them may not be enough, which leads to indeterminate forms -- but that's for another rainy day). Unfortunately, infinity isn't a number -- it's a concept (at least as far as I am concerned; though it's considered a number in the extended reals).

CRGreathouse
Homework Helper
What CRGreathouse did was define operations on sets. What he wrote down isn't "potentially true", it's absolutely true. Under his definitions, {a}/{0} is not a real number, it's a set.

Yeah, my operations are just direct and indirect images in disguise. I hoped the form of it would show that even in that extension there can be no single element that will work.

You could try adding in ur-elements, but I think you'd find the same problems -- it you have division by zero your other properties fall apart. You could have x / 0 = 3 or x / 0 = $\mathcal{U}\!\mathcal{R}_1$ (some arbitrary ur-element), but then you have to abandon the idea that 0x = 0 for all x, which means you can't have additive inverses. By fixing up a small hole in multiplicative inverses you blow a huge one in the additive inverses -- is it worth it?

I prefer to use layman's terms in this case. Dividing is essentially a partition into equal parts. So, if you have A/B, you are essentially dividing A into equal parts of size B, and A/B represents the number of these equal parts. For a concrete example, take 16/2:

If you partition 16 into equal parts of size 2, then you would need 8 such equal partitions. However, what happens when you try to form partitions of size 0. How many would you need? An infinite number of them (and intuitively, even an infinite number of them may not be enough, which leads to indeterminate forms -- but that's for another rainy day). Unfortunately, infinity isn't a number -- it's a concept (at least as far as I am concerned; though it's considered a number in the extended reals).

This is not a mathematical argument, and it assumes too much. It may be easier to think about it in terms of metaphors, but that is not mathematics, it is philosophy!

Why use "laymen's terms" when we have an exact construction and contradiction in proof by CRGreathouse?

This is not a mathematical argument, and it assumes too much. It may be easier to think about it in terms of metaphors, but that is not mathematics, it is philosophy!

I do not claim that this is a mathematical argument; hence "in layman's terms." Metaphors? Partitions are well known notions in mathematics (e.g. combinatorics). Given a/b, where a and b are positive real numbers, division is equivalent to partitioning a into equal parts of size b, and then counting the number of parts. There is nothing metaphorical about this approach. Philosophy? To someone lacking the mathematical background (esp. someone without the mathematical background needed to understand that the $$\mathbb{R}$$ is a field), the other approaches naturally raise the question: why are fields important?

Why use "laymen's terms" when we have an exact construction and contradiction in proof by CRGreathouse?

My point is that one can deduce inconsistencies with lesser tools if division by zero is allowed. I have nothing against rigorous proofs, and as a mathematician, encourage rigorous arguments. However, proofs are generally the end result of mathematical understanding. (How often is it that you solve a problem by jumping straight to the proof?) I prefer to use "layman's terms" because the OP's question can be addressed without resorting to more abstract objects such as fields; basic intuition about partitions and positive real numbers is sufficient for showing that inconsistencies occur if we extend the notion of division to include 0. After that comes a proof.

CRGreathouse
Homework Helper
CRGreathouse said:
Let's try another way.

Then $\{a\}/\{0\}=\mathbb{R}$ if $a=0$..

this is potentially true (but i always worry about what it is in the limit, but there doesn't appear to be a limit here), but there is no way we can tell what particular real number $\{a\}/\{0\}$ is. it could be anything, making $\{a\}/\{0\}$ pretty meaningless whether a is zero or not.

It took me a few readings, but I think I see what you're getting at. I'm not claiming that {a}/{0} is a real number ($\{a\}/\{0\}\in\mathbb{R}$) but that {a}/{0} is the set of real numbers ($\{a\}/\{0\}=\mathbb{R}$).

In fact, I showed that there's no real number to which {a}/{0} corresponds:
$$\not\exists e\in\mathbb{R}:\{a\}/\{0\}=\{e\}$$

?

What CRGreathouse did was define operations on sets. What he wrote down isn't "potentially true", it's absolutely true. Under his definitions, {a}/{0} is not a real number, it's a set.

It took me a few readings, but I think I see what you're getting at. I'm not claiming that {a}/{0} is a real number ($\{a\}/\{0\}\in\mathbb{R}$) but that {a}/{0} is the set of real numbers ($\{a\}/\{0\}=\mathbb{R}$).

In fact, I showed that there's no real number to which {a}/{0} corresponds:
$$\not\exists e\in\mathbb{R}:\{a\}/\{0\}=\{e\}$$

yup, i needed to be prodded to read it again, carefully. what CRG said, with the notation he used (which i was not being careful with) is precisely true.

$$\{a\}/\{0\}=\mathbb{R}$$ if $$a =0$$

hell, it could be $$\{a\}/\{0\}=\mathbb{C}$$ if $$a = 0$$

which means that $\{a\}/\{0\}$ is sorta meaningless since it cannot resolve to any smaller set of values other than anything and

$$\{a\}/\{0\}=\emptyset$$ if $$a \ne 0$$

which says that $\{a\}/\{0\}$ can't be anything.

One case, $a = 0$, says that $\{a\}/\{0\}$ can be anything (but you don't have the foggiest which of the anything it is), while the other case $a \ne 0$, says that $\{a\}/\{0\}$ can't be anything. the former case means really that 0/0 leads to a loss of information that sometimes gets you into trouble (such as this famous flawed proof):

Let a and b be equal non-zero quantities
$$a = b$$
Multiply through by a
$$a^2 = ab$$
Subtract $$b^2$$
$$a^2 - b^2 = ab - b^2$$
Factor both sides
$$(a - b)(a + b) = b(a - b)$$
Divide out $(a - b)$
$$a + b = b$$
Observing that $a = b$
$$b + b = b$$
Combine like terms on the left
$$2b = b$$
Divide by b
$$2 = 1 \,$$

and if 2 = 1, then 1 = 0, then $\infty$ = 0, "yes" = "no", "right" = "wrong", Hitler was right all along, and George W. Bush really is a legitimate and good U.S. president. The most righteous, honest, and competent U.S. president ever in U.S. history. :rofl:

Last edited:
Because division is defined to operate on nonzero denominators .

Good point. With regard to fractions, it's imposible to have a zero deniminator. You can not have any value "out of" zero.

Hurkyl
Staff Emeritus
Gold Member
Just to introduce more perspective...

In commutative algebra, there is a procedure called "localization". Given a ring R (such as the integers, rationals, reals, complexes, or other interesting things), you can select a set of elements S that's closed under multiplication, and then you can compute a new ring $S^{-1}R$ allows you to divide by any of the elements in S.

For example, if we let R be the integers and S be the positive integers, then $S^{-1} R$ is isomorphic to the rational numbers.

In this construction, you are to put zero in S. This has a rather drastic effect on arithmetic, however; it makes all elements of $S^{-1} R$ equal.

Let me say that again, with an example: if we start with the integers, and we construct a new ring from the integers where division by zero is allowed, then in this new ring, all numbers are equal. For example, $0 = 1$ in this ring.

Last edited:


text:
# Diffuse lighting calculations in ray-tracer

I am trying to write a ray-tracer. The lighting part is proving to work but not accurately. To debug I simplified the scene to a single sphere centered at the origin with a radius of 1 and a point light shining from above (0, 2, 0). The camera is at (0, 0, 4).

ambient 0.2 0.2 0.2 specular 0 0 0 shininess 1 emission 0 0 0 diffuse 0 1 1

The image I'm rendering seems wrong - should its cutoff be lower closer to the equator of the sphere?

Any help would be appreciated.

Some elementary trigonometry tells you what to expect from this situation.

The angle to see the shadow terminator is marked on the diagram, and a use of SOHCAHTOA tells you it's $$\cos^{-1}\tfrac{1}{2} = 60^\circ$$. Yours looks higher than that so your intuition seems correct. Stepping through the lighting code will help you see where it's going wrong, and you should consider writing unit tests for it, so that it's easier to provoke bugs like this in isolation.

Something else you might try to help narrow down the problem space is replacing the diffuse calculation with 1 iff $$L.N > 0$$ (i.e. if the light is in front of the surface), 0 o/w. That will give you a sharp line instead of a gradient, and if that sharp line is in the wrong place, you know the input vectors are wrong. If it's in the right place, the problem is in the diffuse shader itself.

• Just wanted to ask, wouldn't the shadow terminator also depend on the intensity of the light? I mean theoretically no, but practically speaking if there is a very dim light we wouldn't be able to perceive the slightly lit up surface above the terminator making it look like the terminator was way up ? – gallickgunner Aug 22 '19 at 6:00
• @gallickgunner That's true. You should be able to tell the difference though, because normally you only get the $L.N$ diffuse contribution approaching zero towards the terminator (or whatever BRDF you use), whereas in this case, you'd also see the $\tfrac{1}{r^2}$ fall-off of the light intensity. You could work out the expected pixel values on the back of an envelope if you could be bothered, but it's probably easier to just debug the code. – Dan Hulme Aug 22 '19 at 9:25

Thanks so much for everyone's replies. It really helped to see any reply that kind of encouraged me to continue.

So after some hours of working out the issue it turns out this is correct on the sphere. The above image is correct. As Dan kindly pointed out and as I later drew it out on paper and tried lights of different heights, the higher the light, the lower the cutoff. Because the light was so close to the sphere only its top was intensely illuminated.

The thing I had gotten incorrect were actually the ellipses normal transforms, which I didn't include in the post because I thought it was more complex, get the basics right first. So it turns out I had to create a different stack to store the non-uniform transforms as it was being read from the file so that the ellipses' normals could be transformed correctly.

So lesson learned - understand all the cases before implementing them.

But I really appreciate this platform! Thanks and cheers to all


text:
# Keras EarlyStopping callback: Why would I ever set restore_best_weights=False?

The point of EarlyStopping is to stop training at a point where validation loss (or some other metric) does not improve.

If I have set EarlyStopping(patience=10, restore_best_weights=False), Keras will return the model trained for 10 extra epochs after val_loss reached a minimum. Why would I ever want this? Has this model not just trained for 10 unnecessary epochs? Wouldn't it make more sense to give me back the model that was trained at the lowest validation loss i.e. with restore_best_weights=True?

Would love to hear situations where doing those extra 10 epochs of training is better than not doing them.

• – WBM
Apr 12, 2021 at 13:29
• Great thanks! It looks like this is the default behavior to save memory. Though, there seem to be no arguments for restore_best_weights=False other than that. Apr 13, 2021 at 10:25

The default value is restore_best_weights=False.
Despite the default value, I would say that, if you have no problem in keeping another copy of the model in memory (i.e. because it is a huge model), the most sensible value is restore_best_weights=True.