text:
Dilogarithm (G Dataflow)

Version:

Computes the dilogarithm function, or Spence's Integral.

x

The input argument.

Default: 0

error in

Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

Default: No error

diln(x)

Value of the dilogarithm function.

error out

Error information. The node produces this output according to standard error behavior.

Algorithm for Computing the Dilogarithm Function

The following equation defines the dilogarithm function.

$\mathrm{diln}\left(x\right)=-{\int }_{1}^{x}\frac{\mathrm{ln}\left(t\right)}{t-1}dt$

The following intervals for the input values define the dilogarithm function.

$x\in \left[0,\infty \right)$

The function is defined for nonnegative real values of x.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported


text:
May 24, 2020, 11:58:36 PM
Forum Rules: Read This Before Posting

### Topic: Copper or brass?  (Read 10087 times)

0 Members and 1 Guest are viewing this topic.

#### ATM

• New Member
• Posts: 4
• Mole Snacks: +0/-0
• Gender:
##### Copper or brass?
« on: October 28, 2010, 11:14:18 PM »
I've got fifteen early 20th century Chinese coins that come in two varieties: copper or brass. I'm trying to tell them apart. That ought to be simple (brass should be yellow), but in these cases I'm not sure - they are maverick. Copper or bronze coins can occasionally turn partly yellowish when exposed to the elements. (The brass versions are the scarce ones, by the way).

Here's what I did: I grinded a tiny part of the edge to see what they were like under the patination. They were all sparkling peach-coloured. I figured they would turn darker through regular oxidation. So I exposed them to hydrogen-peroxide, with minimal effect. Then I rubbed them in my armpit, which had an effect ( ) - but I still can't say that they are clearly one thing or the other.

I refuse to give up (considering that this issue will arise again). So do any of you have a bright idea?

I should add that there probably were no officially prescribed compositions - or if there were, they probably weren't implemented. I suppose it boils down to testing for the presence of zinc. I'm a non-chemist.

#### DemonicAcid

• Regular Member
• Posts: 50
• Mole Snacks: +6/-4
• Gender:
##### Re: Copper or brass?
« Reply #1 on: October 29, 2010, 12:58:46 AM »
I should add that there probably were no officially prescribed compositions - or if there were, they probably weren't implemented. I suppose it boils down to testing for the presence of zinc. I'm a non-chemist.

Yup.

#### ATM

• New Member
• Posts: 4
• Mole Snacks: +0/-0
• Gender:
##### Re: Copper or brass?
« Reply #2 on: October 29, 2010, 11:04:56 PM »
Thank you, DemonicAcid. I've heard of a method called electrical conductivity test. By this method, the the composition can be estimated. So, I was thinking: 1) can I do such a test at home (accepting a modest investment in equipment), and 2) are there any alternative (easier or cheaper) methods that could be employed to detect the presence of zinc? I hope somebody can help - I've known for years that I needed to find an answer to this question sooner or later...  (It's a recurring issue).

#### Borek

• Mr. pH
• Deity Member
• Posts: 25767
• Mole Snacks: +1686/-400
• Gender:
• I am known to be occasionally wrong.
##### Re: Copper or brass?
« Reply #3 on: October 30, 2010, 04:09:34 AM »
I've heard of a method called electrical conductivity test. By this method, the the composition can be estimated. So, I was thinking: 1) can I do such a test at home (accepting a modest investment in equipment)

Somehow I doubt it will be possible. I guess it is based on precise measurement of the specific resistance of the alloy, I doubt it can be done without destroying coins. Problem is, you can measure some resistance, but the number you get depends on the coin geometry and size of contact between coins and electrodes used for measuring. Especially contacts will be highly variable leading to irreproducible results.

The only sure way I can think of would be some spectroscopic method - but these are expensive.
ChemBuddy chemical calculators - stoichiometry, pH, concentration, buffer preparation, titrations.info, pH-meter.info

#### ATM

• New Member
• Posts: 4
• Mole Snacks: +0/-0
• Gender:
##### Re: Copper or brass?
« Reply #4 on: October 30, 2010, 10:12:11 AM »
Thank you very much for elaborating on this, Borek! I'm not so worried about whether or not the conductivity test can be used, because it has been demonstrated that it can be successfully applied in this field. If there are no simpler alternatives ( ), I'm going to go for that one. I found this info on non-destructive conductivity testing. The test would be used to compare coins where all specifications are the same, except alloy.

I was thinking of something else - perhaps you geeks know the answer  . Suppose the test works and we have a coin that we know consists of an alloy of specified elements. Would the conductivity of the alloy be equal to the weighted average of the conductivity of the elements in the alloy?

#### Stepan

• Chemist
• Full Member
• Posts: 358
• Mole Snacks: +39/-4
• Gender:
• Air Chemistry Man
##### Re: Copper or brass?
« Reply #5 on: October 30, 2010, 11:45:25 AM »
When you measure conductivity be sure that the distance between probes is fixed: I would glue two needle probes into a holder with epoxy. Similar probe and conductivity technique is used to measure moisture content in wood. Be sure that your conductivity meter is sensitive enough. And probe conductivity is sufficiently higher that the one of the coin otherwise you will be measuring conductivity of the needle probe.

From time to time you will get very low conductivity. This can be due to cracks, cavities, heavy internal corrosion, and nonuniform composition of the metal.

Another test to confirm the composition of the alloy would be a metal density measurement. The density of the coin can be measured with high accuracy. There is 5-8% difference between copper and brass - you will have no problem to detect it.

The both tests are nondestructive, and can be used simultaneously to verify the results.

#### Borek

• Mr. pH
• Deity Member
• Posts: 25767
• Mole Snacks: +1686/-400
• Gender:
• I am known to be occasionally wrong.
##### Re: Copper or brass?
« Reply #6 on: October 30, 2010, 01:56:32 PM »
When you measure conductivity be sure that the distance between probes is fixed: I would glue two needle probes into a holder with epoxy. Similar probe and conductivity technique is used to measure moisture content in wood.

When using it for wood you can be sure contact surface is large as you are in fact putting electrodes deep into the wood, at least that was the case with the probe I have seen, it required use of a hammer. When applying to coin contact surface will be way too difficult to predict - at least that's what intuition tells me (intuition trained on determination of solution resistances).
ChemBuddy chemical calculators - stoichiometry, pH, concentration, buffer preparation, titrations.info, pH-meter.info

#### Stepan

• Chemist
• Full Member
• Posts: 358
• Mole Snacks: +39/-4
• Gender:
• Air Chemistry Man
##### Re: Copper or brass?
« Reply #7 on: October 30, 2010, 02:49:13 PM »
When using it for wood you can be sure contact surface is large as you are in fact putting electrodes deep into the wood, at least that was the case with the probe I have seen, it required use of a hammer. When applying to coin contact surface will be way too difficult to predict - at least that's what intuition tells me (intuition trained on determination of solution resistances).

This days, the wood probe is miniature and is basically two d=1.5 mm nail-like electrodes on the plastic handle. Contact is not the problem. Problem is very low resistance he needs to measure.

#### ATM

• New Member
• Posts: 4
• Mole Snacks: +0/-0
• Gender:
##### Re: Copper or brass?
« Reply #8 on: October 31, 2010, 12:30:42 PM »
Thank you for advice! I have now asked for a copy of the article in which the metal conductivity test (applied to coins) was described. So, hopefully we'll find out exactly how they did.

Regarding the metal density measurement, would it be applicable also in other situations, e.g. where two specified alloys exist, and a particular coin should be attributed to one or another of those alloys? Could I carry out such a test with a device on my own desk?

#### Stepan

• Chemist
• Full Member
• Posts: 358
• Mole Snacks: +39/-4
• Gender:
• Air Chemistry Man
##### Re: Copper or brass?
« Reply #9 on: October 31, 2010, 02:34:14 PM »
Generally speaking you should be able to distinguish two alloys if density difference is significant. Good lab can probably distinguish a 0.1% difference ($1000 investment. For semi-professional user - I would say 2% density difference is doable on instrument budget of$100-500 dollars.

You basically need scales.

#### Stepan

• Chemist
• Full Member
• Posts: 358
• Mole Snacks: +39/-4
• Gender:
• Air Chemistry Man
##### Re: Copper or brass?
« Reply #10 on: November 01, 2010, 07:41:09 PM »
Thank you for advice! I have now asked for a copy of the article in which the metal conductivity test (applied to coins) was described. So, hopefully we'll find out exactly how they did.

Regarding the metal density measurement, would it be applicable also in other situations, e.g. where two specified alloys exist, and a particular coin should be attributed to one or another of those alloys? Could I carry out such a test with a device on my own desk?

Sorry, I did not finish last reply. You need scales with readability of 0.001 mg and preferably with "under-the-scales weighing" capability. I offer similar scales from my web site: http://www.lcsairtest.com/laboratory-equipment/balances.html

The same manufacturer offers professional density measuring kit with scales and all accessories. If there is an interest - let me know.

format: plain


text:
# Find the Fat:Marinating (1sta. % of Fatb. % of Proteinb. Color of fillet before treatmentd. Color of fillet after treatmentQualities

###### Question:

Find the Fat: Marinating (1st a. % of Fat b. % of Protein b. Color of fillet before treatment d. Color of fillet after treatment Qualities of the fillet after grilling: 1. Color 2. Tenderness Amount of albumin 4. Flavor (taste, optional)

#### Similar Solved Questions

##### Oar 4 Tta0 }Etlaalaa
Oar 4 Tta0 } Etlaalaa...
##### Problem 8 Communication Link: Gain & Loss (14 points) You are given the receiver block as...
Problem 8 Communication Link: Gain & Loss (14 points) You are given the receiver block as schematically shown below. It consists of a receiving antenna which delivers a signal to a bandpass filter. The antenna feed has a loss of -1.15 dB and the filter's loss is -2.4 dB. The filter's out...
##### Conservation of Angular Momentum A star with an initial radius of 1.0 x 108 m and...
Conservation of Angular Momentum A star with an initial radius of 1.0 x 108 m and period of 30.0 Earth days collapses suddenly to a radius of 1.0 x 104 m, while keeping essentially the same mass. This collapsed star is known as a neutron star. (a) What will be the angular velocity of the neutron sta...
##### 7. For Ixlfind (-1)"x2n_ 1=0
7. For Ixl find (-1)"x2n_ 1=0...
##### Let X, Y be jointly continuous with joint density function (pdf) fx,y(x, y) *(1+xy) 05 x...
Let X, Y be jointly continuous with joint density function (pdf) fx,y(x, y) *(1+xy) 05 x <1,0 <2 0 otherwise (a) Find the marginal density functions (pdf) fx and fy. (b) Are X and Y independent? Why or why not?...
##### Suppoze the graph of f Is glven. Describe how the graph of each function can be obtalned from the graph of f Y-fr - 2) shlat right 2 units then stretch vertlcally bY factor of _ 5shlft Ieft- unlts, then shlft downunitsshift right unlts then shlft downunltsshift Ieht units, then shift uP unilsshift right units, then shft unltsYef* + 2) - 5shift right unlts then shift downunitsshlft lelt units; then shlft down unitsshlft right units, then shilt up unitsshilt left units; then shift uP unitsshift le
Suppoze the graph of f Is glven. Describe how the graph of each function can be obtalned from the graph of f Y-fr - 2) shlat right 2 units then stretch vertlcally bY factor of _ 5 shlft Ieft- unlts, then shlft down units shift right unlts then shlft down unlts shift Ieht units, then shift uP unils s...
##### What is the upper limit of water ?
what is the upper limit of water ?...
##### Comabuci CenlanoncintacanieteeBuainenJe Rantla]Hieulur jiiu4nCHEA Inan mot OnuIeet[RuunaWrir" Jucump cUR
Comabuci Cenlanoncintacanietee Buainen Je Rantla] Hieulur jiiu4n CHEA Inan mot Onu Ieet [Ruuna Wrir" Jucump cUR...
##### Consider a four-factor model with A and D fixed, each with three levels Factors B and are random with two levels each There is a total of 72 observations AlI factors are crossed. Standard five questions_
Consider a four-factor model with A and D fixed, each with three levels Factors B and are random with two levels each There is a total of 72 observations AlI factors are crossed. Standard five questions_...
##### Bonus Problem (1 extra point) Show that ((p->q) v (~(p ^ 7q) ^ T)) =-pv using the logical equivalences
Bonus Problem (1 extra point) Show that ((p->q) v (~(p ^ 7q) ^ T)) =-pv using the logical equivalences...
##### Let RIA) 0.53. AB) 0.28_ und AAn & 0.15. Calculate AA 1: (Round Your ansier t0 decimal Places |raleCalculate AA D1: (Round Your answtr t0 dacimel Places }RRUBiCalculate P( (A Risi (Round your answetdecImal places }P((A 8)6)
Let RIA) 0.53. AB) 0.28_ und AAn & 0.15. Calculate AA 1: (Round Your ansier t0 decimal Places | rale Calculate AA D1: (Round Your answtr t0 dacimel Places } RRUBi Calculate P( (A Risi (Round your answet decImal places } P((A 8)6)...
##### -fiorizontal sunace Fne bliiAbullet 0l mass m 0.Lkg Is shot Wlin speed ot 500 nus straighil and . exits Ihe box wilh speed ot 00 misDetern penelrales IhroughThe speed of the box after the bullet exlsts 6} The Ioss in kinetic cnergy during this Interaction Show Your detailed work
-fiorizontal sunace Fne blii Abullet 0l mass m 0.Lkg Is shot Wlin speed ot 500 nus straighil and . exits Ihe box wilh speed ot 00 misDetern penelrales Ihrough The speed of the box after the bullet exlsts 6} The Ioss in kinetic cnergy during this Interaction Show Your detailed work...
##### Problem 13-01A a-c (Part Level Submission) Bridgeport Corporation was organized on January 1, 2020. It is...
Problem 13-01A a-c (Part Level Submission) Bridgeport Corporation was organized on January 1, 2020. It is authorized to issue 14,500 shares of 8%, $100 par value preferred stock, and 464,000 shares of no-par common stock with a stated value of$3 per share. The following stock transactions were comp...
##### Identity the key attributes of f6x) including Ihe domain and range in set notation, the end behavion; and all interceptsDrag and drop each value into the correct box to complete the explanations: The domain IS and the range Is{vly >Asx approachesflx) approachesAsx approaches 1 , f(x) approachesintercepts but has ay intercept of; The graph of f (x ) does not have any x
Identity the key attributes of f6x) including Ihe domain and range in set notation, the end behavion; and all interceptsDrag and drop each value into the correct box to complete the explanations: The domain IS and the range Is{vly > Asx approaches flx) approaches Asx approaches 1 , f(x) approache...
##### Question3 3. * Let f be an entire function which restricts to a real function f:R...
question3 3. * Let f be an entire function which restricts to a real function f:R R on the real axis. Show that for all z e C, f(z) = f(z). (Hint: refer to Problem set 2 Qn 1.)...
##### The Sun is much larger and more massive than Earth. Do you think the average density of the Sun is larger or smaller than that of Earth? Write down your answer before you look up the densities. Now find the values of the densities elsewhere in this text. Were you right? Explain clearly the meanings of density and mass.
The Sun is much larger and more massive than Earth. Do you think the average density of the Sun is larger or smaller than that of Earth? Write down your answer before you look up the densities. Now find the values of the densities elsewhere in this text. Were you right? Explain clearly the meanings ...
##### Calculate the applied load F1 if the maximum bending moment in column EI is 30 k-ft...
Calculate the applied load F1 if the maximum bending moment in column EI is 30 k-ft SmartArt - add title A2> DOO - 3. 0 BC: - Drawing Styles Arrange Oude Shape F:-10k- Use the Portal Method to: i. Draw the bending moment diagrams of the top floor beams AB and li Calculate the applied load Fl if t...
##### You are a new manager in the department (either major or desired management position). You discover...
You are a new manager in the department (either major or desired management position). You discover that the majority of staff members have a negative attitude, they gossip, and have low morale. Many bring their home issues and problems to work. Explain each of the seven steps, including the sub ste...
##### Active ingredient of a pill comprises 45 % of the pill mass. if a pill contains...
active ingredient of a pill comprises 45 % of the pill mass. if a pill contains 325 mg of active ingredient, what is the total mass of pill...
##### TRIAL 1 TRIAL 2 TRIAL 3 TRIAL 4 15-O0 25.00 15.95.00 IS, O0 25.00 IS.00 25.00 Volume of HCl used (mL) Mean molarity...
TRIAL 1 TRIAL 2 TRIAL 3 TRIAL 4 15-O0 25.00 15.95.00 IS, O0 25.00 IS.00 25.00 Volume of HCl used (mL) Mean molarity of NaOH (M, four sig. figs!) 0.O68amo.0amo.o680.Ocbam 7.95m.30m24.90mL 0.15 mL Vinitial (mL, two decimals!) 18-10mL 23.65m 3a.30mL Vfinal (mL, two decimals!) 5600MC 4.1mL VNaOH used (m...
##### What role does the limbic system play in modulating stress and pain?
What role does the limbic system play in modulating stress and pain?...
##### Runaway truck ramps are used on mountain roads to stop trucks whose brakes fail. The ramps...
Runaway truck ramps are used on mountain roads to stop trucks whose brakes fail. The ramps work by using sand to increase the coefficient of kinetic friction between the truck and the road. Suppose that the ramp is flat and is d = 150 m long with a coefficient of kinetic friction μk = 4.0. Find t...
##### 4) A debit: A) Always decreases an account. B) Always increases an account. C) Is not...
4) A debit: A) Always decreases an account. B) Always increases an account. C) Is not needed to record a transaction. D) Is the left-hand side of a T-account. E) Is the right-hand side of a T-account. 5) Resources a company owns or controls that are expected to yield future benefits are: A) Liabilit...


text:
# A way to check off todonotes

I recently discovered the todonotes package. It would be great to somehow check the notes as done. I know the creator has this on his "todo list" (funny), but right now its not implemented. My idea was to hide it in the document and to strike it out in the listoftodos. Below you see a minimum working example. This is how I do it now.

Thanks for the help in advance!

\documentclass[a4paper,12pt,captions=tableheading,abstracton,
%draft,
%final,

\usepackage{ulem}
\usepackage[obeyFinal,textsize=footnotesize]{todonotes}
\newcommand{\done}{\todo[disable]{Test}
}%this shouldnt show up in document and be striked out in listoftodos

\begin{document}
\listoftodos\clearpage
\todo{ToDo}

\done{Done}
\end{document}

In an older version of the question I also asked for the color in listoftodos. This is not the case anymore.

I would suggest something like this. The idea is to add the striked out line in the list of todos manually.

\documentclass{article}

\usepackage{ulem}
\usepackage{todonotes}

\begin{document}
\listoftodos

Some text\todo{ToDo}.
More text that needs a reference\addref{paper}.
\done{Write text with reference}
\end{document}

The output looks like this.

If you want to have the completed todos at the end of the list of todos (which was requested in a comment), the following approach can be used. The idea is to have a separate list of completed todos (.tdod instead of .tdo).

\documentclass{article}

\usepackage{ulem}
\usepackage{todonotes}

\begin{document}
\listoftodos
\makeatletter
\@starttoc{tdod}
\makeatother


text:
# Reading random text file in R

I have about 500 text documents stored in a directory. I want to randomly select one to read in the contents (this process will be repeated several times). The names of the files are not sequential. By this I mean they are not named something like 1.txt, 2.txt, 3.txt,... The names are basically random characters.

How can I do this?

Thanks

-

First, select one file randomly from the current directory:

file <- sample(list.files(), 1)

Then do whatever you want with it, e.g. read all lines:

readLines(file)

If you want to repeat this several times, you could do it in one step:

readLines(sample(list.files(), 1))

-

Do a list.files and then access each file by its index.

 lisfil <- list.files("E:\\Data") #Replace E:\\Data with your directory name
lenlisfil <- length(lisfil)
for (i in 1:lenlisfil) {
#Do something to the current file such as:
print(lisfil[i])
}

-
You need to shuffle listfil somewhere in your code. –  chl Jan 26 '11 at 8:17
@chl: I assumed that getting the filenames into a variable was his main question. –  bill_080 Jan 26 '11 at 16:15
Yes, I just re-read the question and it makes sense as filenames are assumed to follow no particular order. –  chl Jan 26 '11 at 18:33


text:
# $X$ is defined as the collection of sets $X = \{X_i: i \in [0, 1] \}$ where each set has cardinality $c$

$$X$$ is defined as the collection of sets $$X = \{X_i: i \in [0, 1] \}$$ where each set has cardinality $$c$$ of the continuum and each pair is disjoint.

How do I prove that for each $$i \in [0, 1]$$, the set $$[0, 1] \times \{i\}$$ has the same cardinality as $$X_i$$(which can therefore be replaced by any cardinality)?

I know that the general idea is that the union clearly has a subset of cardinality $$c$$ and so the union must have a cardinality greater than or equal to $$c$$. So if I am able to show that this union also has cardinality less than or equal to $$c$$, I can probably use the Schröder–Bernstein Theorem to deduce the result.

The cardinality of X$$_i$$ is c.
Clearly #([0,1]×{i}) = c×1 = c = #X$$_i$$.


text:
Filtered By: Money
Money
AS MALAMPAYA NEARS DEPLETION

# DOE cites need to expand LNG facilities

The Malampaya gas reserves will be depleted within the next 10 years, highlighting a pressing need to expand the country's liquefied natural gas (LNG) facility so as to accommodate and imported shipments of the commodity, the Department of Energy (DOE) said on Thursday.

"By 2024, the Malampaya gas field is expected to be depleted until 2027. There is a need to expand its facilities for LNG expansion and importation, and for further exploration," Energy Undersecretary Felix Fuentebella said in a press conference.

The Malampaya gas-to-power facility fuels three gas-fired power plants with a total generating capacity of 2,700 megawatts (MW) to provide 30 percent of the power generation requirements of Luzon.

Connected to an onshore gas plant in Batangas, the Malampaya offshore facility in Northern Palawan was inaugurated in 2001. Estimates showed its gas reserves will be sufficient only until 2022 to 2024.

Fuentebella said the Philippine LNG infrastructure plan was among the topics discussed by the Philippines and Singapore in a bilateral meeting under the auspices of the ASEAN Energy Ministers Meeting on Thursday.

"The Singapore government and Philippine government are looking into more ways to complement each other's programs as far as LNG is concerned," he said.

In June, Energy Secretary Alfonso Cusi said the DOE is eyeing to make the Philippines the LNG hub of Southeast Asia.

Estimated to cost P100 billion, a planned LNG plant consists of a gas storage facility with a rated capacity of 5 million tons per year, and a power plant with an initial capacity of 200 MW which could later be expanded to 1,000 MW.

Cusi earlier said China, Japan, and Russia are interested in joining  the LNG terminal project. — VDS, GMA News


text:
# Can Jimmy escape the ghosts?

It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy escape the ghosts?

## Challenge:

Input:

A board showing position of Jimmy, ghosts, solid objects and empty spaces.

An example 10x5 board, o is Jimmy (we needed a single character Jimmy), gs are ghosts, #s are solid objects and .s are empty spaces:

##########
......g...
#.o.......
#.....g...
##########

Output:

A truthy value if Jimmy can escape at least in one scenario, otherwise a falsy value.

## How things work:

Ghosts and Jimmy can move one space each turn. There are 4 possible movements: left, right, up, down (no diagonal movements, no skipping).

On each turn, first ghosts move one space towards Jimmy. Ghosts always select the closest path to Jimmy, if two possible moves towards Jimmy have the same cost, the move going to left or right is chosen. Ghosts can go through solid objects, meaning at the end of a turn a ghost can be on same space as a solid object. Multiple ghosts can stay on same space too. This basically means all the ghosts on the same space will move exactly like each other after that point (they are all like a single ghost now).

After all ghosts have moved, if any of the ghosts ends up on the same space as Jimmy, Jimmy is caught and you have to try another scenario.

If Jimmy is not caught, he moves next. You have to decide on Jimmy's moves. Jimmy cannot go through solid objects. If Jimmy moves to a space with a ghost, he is caught. Jimmy cannot move into a space he has already visited. If Jimmy has no valid moves, consider him caught.

After Jimmy has moved, if he ends up on an empty border space (i.e. a space on the edge of the grid without a ghost on it), he has escaped.

If you can find at least one scenario where Jimmy can escape, output a truthy value. Also if the input position before doing any moves is already an escape position, it is valid and you should return truthy. If Jimmy is caught or out of valid moves in all possible scenarios, then return a falsy value.

## Challenge rules:

• You can use any consistent characters that you like for Jimmy, ghosts, solid objects and empty spaces in the input. You cannot use same character for different types of items though.
• The input board is always a rectangle or square with a minimum size of 2x2 and a maximum size of 10x10.
• Input is flexible as long as you don't include anything more than initial board information (for example, you cannot include if the initial board is already an escape position or not). It can be a multi-line string, a list of strings, a 2d array or matrix of characters or numbers, etc. It can also be position of items, for example a (x, y) for Jimmy and two lists of (x, y)s for ghosts and solid objects. You can also pass board size as a separate input if you like. Basically any format and combinations of inputs that don't include more than the initial board information are allowed.
• Input is guaranteed to always have a single Jimmy.
• Input always has at least one ghost.
• Input always has at least one solid object.
• Input can never start in a position where more than one item is on same space.
• Input can start in a position which already is an escaped position for Jimmy (any input with Jimmy on a border space), you should return truthy for cases like this.

## General rules:

• This is , so shortest answer in bytes for every language wins. Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
• Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
• Default Loopholes are forbidden.
• If possible, please add a link with a test for your code (i.e. TIO).
• Also, adding an explanation for your answer is highly recommended.

## Test cases:

Truthy:

Jimmy can move left, up, left to escape:

##########
......g...
#.o.......
#.....g...
##########

Jimmy is already on a border space, this is an escape:

#.
og

If Jimmy moves only left or only right, he escapes:

#########
.........
....g....
...g.g...
....o....
...g.g...
....g....
.........

Jimmy has only two ways, one of them is an escape:

##########
#g.o.....#
########.#
#........#
#.########
#........#
########.#
#........#
#.########

Falsy:

Jimmy is caught by first move of any of the ghosts:

.....
..g..
.go..
.....
.....

Jimmy has no valid moves:

###.......
#o#......g
###.......

Jimmy will run out of valid moves before ghost can catch him:

#####.....
#o..#....g
#####.....

Remember, ghosts can go through solid objects:

g#.#
.#.#
.#.#
.#o#
.#.#
.#.#
g#.#

Oh poor Jimmy! It is a dead end...

##########
#...o....g
##########

Jimmy!!? How did you get there in the first place?

#.########
#g.......#
#....g...#
#......g.#
#..g.....#
#....g...#
#........#
#....g...#
#..g....o#
##########
• Jimmy will run out of valid moves before ghost can caught him. – a'_' Oct 28 '19 at 8:59
• @A_ fixed, sorry for my poor English. – Night2 Oct 28 '19 at 9:02
• Is the rule "Jimmy cannot move into a space he has already visited" necessarily? Could anyone find an input which may yield different result when this rule is removed? – tsh Oct 28 '19 at 9:58
• @tsh I believe it makes a difference. Without that rule, Jimmy can go left and right infinitely against a single ghost without escaping or getting caught. I put that rule in place to prevent infinite loops or very long scenarios that would make TIO not work for them. – Night2 Oct 28 '19 at 10:06
• @tsh example of infinite loop: i.imgur.com/66ZlURr.gif – Night2 Oct 28 '19 at 10:27

# Python 2, 236235227 212 bytes

def f((x,y),G,M,U=[]):
R=1-(len(M[0])-1>x>0<y<len(M)-1);H=[(u+cmp(x,u),v+cmp(y,v)*(u==x))for u,v in G];d,e=0,1
for _ in' '*4*(R<1>((x,y)in H)):J=z,w=x+d,y+e;d,e=-e,d;R|=M[w][z]>(J in U)<f(J,H,M,U+[J])
return R

Try it online!

-15 bytes thx to Bubbler

As input, takes a tuple (x,y) as jimmy's initial position, a list G == [(g1x,g1y), ...] of initial ghost positions, and a list of lists M which is the 2-dimensional binary matrix where cells are 0 if they contain "an object" (i.e., #) and 1 otherwise.

Returns 1 for truthy, 0 for falsey.

Loosely speaking, the idea here is that we're going to depth-first recurse over down, left, up, right to seek a border cell. To start,

R=1-(len(M[0])-1>x>0<y<len(M)-1)

R is truthy if jimmy starts on a border cell. We could just return R if he does, but that would add an additional return. So in any case, we calculate where the ghosts would move to next.

H=[(u+cmp(x,u),v+cmp(y,v)*(u==x))for u,v in G]

cmp(a,b) returns the sign of a-b as -1,0,1; so this updates the ghosts positions with preference for horizontal movement if possible. Next,

for _ in' '*4*(R<1>((x,y)in H)):

executes a loop 4 times (' '*4 is shorter than range(4)). Note that if jimmy is on the boundary (not R<1) or a ghost has landed on jimmy (not 1>((x,y)in H), then we skip the for loop and so we return 1 if jimmy has escaped, or 0 if a ghost got him.

J=z,w=x+d,y+e;d,e=-e,d

d,e is the offset to jimmy's next position, starting as 0,1; and each time through the loop, d,e=-e,d rotates us through the 4 possible orthogonal positions.

R|=M[w][z]>(J in U)<f(J,H,M,U+[J])

R gets set to truthy if jimmy's next position J is not an on "object" (M[w][z]>0), AND we haven't visited this position before (1>(J in U)), AND via recursion, jimmy can escape starting at position J with ghosts at H (0<f(J,H,M,U+[J])).

• Well done! I tested with some more random test cases and could not break it. – Night2 Oct 31 '19 at 4:23
• Change the third line to for _ in' '*4*(R<1>((x,y)in H)):J=z,w=x+d,y+e;d,e=-e,d;R|=M[w][z]>(J in U)<f(J,H,M,U+[J]) for 212 bytes. – Bubbler Oct 31 '19 at 7:00

# Python 2, 199 bytes

def g(I,G,W,w,h):
u,v=I.real,I.imag;R=1-(w-1>u>0<v<h-1);H=[z+cmp(u,z.real)+cmp(v,z.imag)*(u==z.real)*1jfor z in G]
for d in(R<1>(I in H+W))*range(4):J=I+1j**d;R|=(J in W)<g(J,H,W+[I],w,h)
return R

Try it online!

Rewrite of Chas Brown's solution using complex numbers.

All the coordinates are represented as a complex number x+y*1j. I is Jimmy's position, G is the list of ghosts and W is the list of walls. w and h are the width and height of the board, respectively.

The output values and the algorithm are the same as the linked solution.

# Javascript (ES6), 208 bytes

Recursive, depth-first search. A breadth-first approach would be probably faster, but less golfy. Input: a multi line string, using 1 for ghosts, 4 for solid objects, 6 for Jimmy and 2 for empty space.

f=(s,l=-~s.search
,j=s.search(6),g=[...s],x=j%l)=>j<l|!g[j+l]|!x|x>l-3||(g[j]=6,![...g].some((a,i)=>a&1&&(g[--g[i],t=i%l,i+=t<x?1:t>x?-1:i<j?l:i>j?-l:0]|=1,i==j))&&[l,-l,1,-1].some(d=>2==g[d+=j]&&f(g,l,d)))

Less golfed

// using parameters with default values instead of declared variables

f = (s,  // input board (as a string at first call, then as an array)
l = -~g.search('\n'), // line size +1, that is distance to next line
// at first call it is calculated, for recursive calls is passed
j = g.search(6), // position of jimmy in grid
// at first call it is calculated, for recursive calls is passed
grid = [...s], // modifiable copy of board (converted to char array)
x = j % l, // x position of jimmy, always obtained from j
) =>
{
// first, check if Jimmy is out
if (j<l | !grid[j+l] | !x | x>l-3) // top,bottom,left,right border
{
return true
}
// move all ghosts and check if some ghost can take Jimmy
// the loop is on a copy of grid, so I can safely modify grid during the loop
var taken = [...grid].some( // check all ghosts
(a,i) => a & 1 && ( // is it a ghost?
--grid[i], // remove ghost from grid, as it will move
t = i % l, // x position of ghost
// move ghost towards Jimmy
i += t < x
? 1
: t > x
? -1
: i < j
? l
: i > j
? -l
: 0,
grid[i] |= 1, // put ghost on grid in its new position
i == j // return true if it reached Jimmy
)
return !taken && // if taken return false immediately
// else recurse
[l,-l,1,-1].some( // try to move Jimmy in all directions
d => (
d+=j, 2==g[d] && f(grid, l, d))
)
)
}

Test

cases=['##########\n......g...\n#.o.......\n#.....g...\n##########\n'
,'#.\nog\n'
,'#########\n.........\n....g....\n...g.g...\n....o....\n...g.g...\n....g....\n.........\n'
,'##########\n#g.o.....#\n########.#\n#........#\n#.########\n#........#\n########.#\n#........#\n#.########\n'
,'.....\n..g..\n.go..\n.....\n.....'
,'###.......\n\#o#......g\n###.......\n'
,'#####.....\n#o..#....g\n#####.....\n'
,'g#.#\n.#.#\n\.#.#\n.#o#\n.#.#\n.#.#\ng#.#\n'
,'##########\n#...o....g\n##########\n'
,'#.########\n#g.......#\n#....g...#\n#......g.#\n#..g.....#\n#....g...#\n#........#\n#....g...#\n#..g....o#\n##########\n'
]

f=(s,l=-~s.search
,j=s.search(6),g=[...s],x=j%l)=>j<l|!g[j+l]|!x|x>l-3||(g[j]=6,![...g].some((a,i)=>a&1&&(g[--g[i],t=i%l,i+=t<x?1:t>x?-1:i<j?l:i>j?-l:0]|=1,i==j))&&[l,-l,1,-1].some(d=>2==g[d+=j]&&f(g,l,d)))

cases.forEach(x=> (
console.log(x,
f(x.replace(/#/g,4).replace(/\./g,2).replace(/o/,6).replace(/g/g,2|1)))
))

# Jelly, 94 89 bytes

Ø.,U$;N$+®ŒṬ€×8+®ŒṬ¤+&7$Ç€Ẹ &Ɱ8,2ŒṪ€Ḣ©_¥/Ṡ01¦Ạ¡€+ƲṪŒṬḤ+&13$ÑÇFṀ>8Ʋ?
|Ø.¦4Z\$⁺FṀ=12ƲÇFṀ>8Ʋ?

Try it online!

A full program that takes an integer matrix as its argument, with 0 as space, 1 as wall, 2 as ghost and 8 as Jimmy. Returns 1 for escape and 0 for no escape.


text:
# Complex integration by shifting the contour

In section 12.11 of Jackson's Classical Electrodynamics, he evaluates an integral involved in the Green function solution to the 4-potential wave equation. Here it is:

$$\int_{-\infty}^\infty dk_0 \frac{e^{-ik_0z_0}}{k_0^2-\kappa^2}$$

where $k$ and $z_0$ are real constants.

Jackson considers two open contours: one above and one below the real axis. I understand that in order to use Jordan's lemma, when $z_0 < 0$ we have to close the contour in the upper half of the complex plane whereas if $z_0 > 0$ we have to close the contour in the lower half plane.

What I don't understand is why it's OK to consider contours above and below the real axis when the original integral is along the real axis. As I understand it, the necessity to deal with poles like this also arises a lot in QFT, so perhaps it is well understood from that point of view.

• Hi. Thanks for your comment. I don't think I've been clear in my question. I understand Jordan's lemma which allows us to let the radius of the semicircular bit of the closed contour tend to infinity which vanishes its contribution to the integral. What I don't understand is that the original open contours he considers before choosing how to close them up, are above and below the real axis. – user2582713 Sep 15 '14 at 18:55
• Thanks. No worries. Do you think the way I've phrased the question is clear enough? Might add an edit. Also, do you have an answer? – user2582713 Sep 15 '14 at 18:58
• As in the principle value of the integral? I don't think it does for reasons based on the derivation in the book. Do you have it? – user2582713 Sep 15 '14 at 19:04
• To anyone considering posting an answer: Presumably, the answer is provided by choosing a so called $i\epsilon$- or pole prescription to deal with the integral, and then taking the limit where the deformation vanishes afterwards. I think this question deserves a thorough explanation which (at least) covers the following: 1) What is the pole prescription (i.e. a basic description of the method). 2) Why does the pole prescription work? Is it to be expected, etc. 3) What do pole prescriptions mean physically (relate them to boundary conditions, perhaps)? – Danu Sep 15 '14 at 19:35

# A simple reference problem

Suppose we want to analyse the problem of a forced harmonic oscillator. Denote as $\phi(t)$ the time dependent position of the oscillator. The oscillator experiences two forces, the spring force $-k\phi(t)$ and an external force $F_{\text{ext}}(t)$. Newton's law says

\begin{align} F(t) &= m a(t) \\ -k \phi(t) + F_{\text{ext}}(t) &= m \ddot{\phi}(t) \\ F_{\text{ext}}(t)/m &= \ddot{\phi}(t) + (k/m) \phi(t) \\ j(t) &= \ddot{\phi}(t) + \omega_0^2 \phi(t) \tag 1 \end{align}

where $\omega_0$ is the free oscillation frequency and $j(t)\equiv F_{\text{ext}}/m$. We use the following Fourier transform convention: \begin{align} f(t) &= \int_\omega \tilde{f}(\omega) e^{i\omega t} \frac{\mathrm d\omega}{2\pi} \\ \tilde{f}(\omega) &= \int_t f(t) e^{-i\omega t}~\mathrm dt . \end{align}

With this convention on Eq. $(1)$, and defining $$\omega_{\pm} \equiv \pm \omega_0,$$ we find $$\tilde{\phi}(\omega) = \frac{\tilde{j}(\omega)}{\omega_0^2-\omega^2} = \frac{-\tilde{j}(\omega)}{(\omega-\omega_+)(\omega-\omega_-)}. \tag 2$$ From Eq. $(2)$ we see that the Green's function is $$\tilde{G}(\omega) = \frac{-1}{(\omega-\omega_+)(\omega-\omega_-)}$$ which has poles on the real axis. If we want to compute $\phi(t)$ we do a Fourier transform

$$\phi(t) = \int_\omega \frac{-\tilde{j}(\omega)e^{i\omega t}}{(\omega-\omega_+)(\omega-\omega_-)} \frac{\mathrm d\omega}{2\pi} = \int_\omega e^{i\omega t}\tilde{j}(\omega) \tilde{G}(\omega)\frac{\mathrm d\omega}{2 \pi}. \tag{*}$$

This integral is tricky because of the poles on the axis. The solution everyone knows is to push the poles off the axis by adding an imaginary part to $\omega_{\pm}$, or by moving the contour above or below the real axis, but what does this actually mean physically? How do we choose which direction to push the poles or move the contour?

# Damping to the rescue

In a real system, we always have some damping. In our oscillator model, this could come in the form of a velocity dependent friction $F_{\text{friction}} = -\mu \dot{\phi}(t)$. Defining $2\beta = \mu/m$, the equation of motion becomes

$$\ddot{\phi}(t) + 2\beta \dot{\phi}(t) + \omega_0^2\phi(t) = j(t) . \tag 3$$

Fourier transforming everything again leads to Eq. $(2)$ but now with $$\omega_{\pm} = \pm \omega_0' + i\beta$$ where $$\omega_0' = \omega_0\sqrt{1-(\beta/\omega_0)^2}.$$

Therefore, we see that adding damping moves the poles a bit toward the origin along the real axis, but also gives them a positive imaginary component. In the limit of small damping (i.e. $\beta \ll \omega_0$), we find $\omega_0' \approx \omega_0$. In other words, the frequency shift of the poles due to the damping is small. So let's ignore that and focus on the added imaginary part.

Ok, suppose we want to do the integral $(*)$ in the case that $j(t)$ is a delta function at $t=0$. In that case, $\tilde{j}=1$ (I'm ignoring units) and we have $$\phi(t) = \int_\omega \frac{e^{i\omega t}}{(\omega-\omega_+)(\omega-\omega_-)} \frac{\mathrm d\omega}{2\pi}$$ As you noted, for $t<0$ you have to close the contour in the lower plane in order to use Jordan's lemma. There aren't any poles in the lower half plane, so we get $\phi(t<0)=0$. This makes complete sense: the driving force is a delta function at $t=0$ and there shouldn't be any response of the system before the driving happens. This means that our introduction of friction imposed a causal boundary condition to the system! For $t>0$, you close in the upper half plane where there are poles, and so you get some response out of the integral.

# Damping as a tool

In many cases, you don't naturally have damping in the system. For example, the Green's function from the question, $$\int^{\infty}_{-\infty}~\mathrm dk_0 \frac{e^{−ik_0 z_0}}{k_0^2 − \kappa^2}$$ doesn't have any damping and thus the poles sit on the real axis. So what you do is just bump the contour a bit up or down, or equivalently add $\pm i \beta$ to the poles (most people write $i \epsilon$ instead of $i \beta$), then do the integral, and finally take $\beta \rightarrow 0$. In doing this, you're solving the problem in the presence of damping (or anti-damping), and then taking the damping to zero in the end to recover the no-damping case.

Choosing to push the contour up or down, or equivalently choosing the sign of $\pm i \beta$, corresponds to imposing either friction or anti-friction, causal or anti-causal boundary conditions. If you pick the "causal" boundary condition, you find that the response of the system to a delta function in time and space is an outgoing spherical wave which starts at the delta function source. This gives you the so-called "retarded Green's function". If you pick the other condition, you find that the solution for a point source is actually an incoming spherical wave which converges right onto the point of the source. This gives you the so-called "Advanced Green's function".

The thing is, you can solve a problem using either Green's function. You're "allowed" to push the contour up or down (or add $+i\beta$ or $-i\beta$ to the poles) because you invented that as a trick to do the integral; it's not representing a real factor in your physical system. Of course, in problems where there is damping, the choice is made for you. When you have damping, you can't have fields at infinity; they'd be damped away by the time they interact with your sources.

I hope this was helpful, and I really hope if someone finds mistakes they'll jump in and fix 'em.

• You can also put one pole above and the other below the real axis (Feynman prescription). – Adam Sep 16 '14 at 8:08
• @DanielSank : the $i\epsilon$ Feynman prescription, in your case $p^2- m^2 \to p^2- m^2 + i\epsilon$, is done to be sure of the convergence of the QFT partition function $Z = \int D\Phi e^{iS(\phi)}$, with $S(\phi) = - \phi (\square + m^2) \phi$, so this has the effect to add a term $e ^{-\epsilon \phi^2}$ in the integral, making the integral convergent. An other point of view is that, with the Feynman contour, you may do a Wick rotation ($90°$ rotation), going to a imaginary (euclidean) energy , without crossing the poles. – Trimok Sep 16 '14 at 9:26
• @Trimok: Ah, so the idea is to rotate the contour instead of translating it up or down int he complex plane. I never actually understood that before, so thanks. – DanielSank Sep 16 '14 at 9:43
• There is a "simple" way to understand what the Feynman propagator is doing: While the advanced and retarded propagators propagate all energy modes forward/backward in time (corresponding to shifting both poles up/down), the Feynman propagator propagates the "positive energy modes" (right pole, shifted down) forward and the "negative energy modes" (left pole, shifted up) backward in time, corresponding to the picture of antiparticles being 'holes' of negative energy travelling backwards in time. – ACuriousMind Oct 1 '14 at 20:02
• @ACuriousMind: Alas! That techniques like this should be introduced and understood only in such a narrow slice of the physics pie is so incredibly frustrating. – DanielSank Oct 6 '14 at 15:37

I think this question has been basically answered. There is a lot of mathematical stuff above (contours, etc.) but the initial question posted was a physics question.

Briefly: you have a differential equation describing some physical problem. You find the solution. In this case it is an integral that is "funny" and requires some choices to be made to make it unique and meaningful. The physics questions is why the choices are made and what do they mean?

Remember, a differential equation by itself is not a full description of physical reality. Solving the differential equation gives you all potential solutions to a problem which is nice but sort of too much. Differential equations always come hand in hand with boundary conditions. The boundary conditions are equally important. They tell you which solution is the meaningful one for your problem.

In this case, as explained above, the boundary condition is retarded versus advanced solution. When you bang on the system at t=0 (with delta function forcing), does the system response go forwards in time or backwards? I.e., was it doing nothing prior to t=0 and then does stuff (retarded)? Or was it doing stuff for t<0 and then you banged it just right to make it stop for t>0 and do nothing (advanced)? The final prescription (Feynman one of moving one pole up and one pole down) is called "time-ordered": you make a new kind of boundary condition that glues the retarded and advanced solutions together in a particular way at t=0.

As explained above, there is no "right" answer or "right" way of doing the integral. It depends on the boundary conditions. Without boundary conditions, all ways are OK.

If you think this boundary condition stuff is just for this case and nothing very common, please reconsider. For example, we all know intuitively that when you talk about eigenstates of some Hamiltonian in physics, they are normalized. That gives us meaning and allows us to compute probabilities. Also that for a finite system the energies are discretized. But mathematically it is totally not like this: if you just solve the Schrodinger equation as a mathematical entity, you will get solutions at all energies and associated eigenfunctions. Only those special ones with just the right energies are normalizable. Here the boundary condition is the wave function is normalizable (goes to zero fast enough at infinity). Without it, you can't calculate anything or make any real predictions of probability sine you can't figure out what is what or normalize things. So boundary conditions are pretty important and basic!

As written, the integral simply doesn't exist in the Riemann sense: there's a singularity at $k_0=\pm\kappa$. So really we're looking at the Cauchy Principle part, which is defined by:

$$\int_{-\infty}^\infty dk_0 \frac{e^{-ik_0z_0}}{k_0^2-\kappa^2}=\lim_{\epsilon\rightarrow 0}\left(\int_{-\infty}^{-\kappa-\epsilon}+\int_{-\kappa+\epsilon}^{\kappa-\epsilon}+ \int_{\kappa+\epsilon}^{\infty}\right)dk_0\frac{e^{-ik_0z_0}}{k_0^2-\kappa^2}.$$

For fixed $\epsilon$, each integrand is nice and continuous (near $\epsilon$ of the real axis), so if we integrate on a contour that's slightly above the real axis, we'll get something very close to the original integral, in terms of $\epsilon$. If you now control the error in terms of epsilon, you can make the whole argument rigorous and subsequently take $\epsilon\rightarrow 0$.

• Thanks for your answer. Aren't the first and last spans of the integral still along the real axis? The open contours in Jackson which he closes up are above and below the real axis. – user2582713 Sep 15 '14 at 19:11
• @user2582713: Perhaps I did bad job of explaining. If you have a nice continuous functionf $f(x)$, with integral $\int_{\mathbb{R}}f(x)dx$, then it's going to be close to $\int_{\mathbb{R}+i\delta}f(z)dz$, for $\delta$ small. It sounds like Jackson is trying to skirt the issue of having a singularity on the real line by considering the integrals just slightly above, which sounds like considering first the principle part and then doing the integrals mentioned. – Alex R. Sep 15 '14 at 19:28
• But isn't $f(x)$ discontinuous in this case? – user2582713 Sep 15 '14 at 20:41
• @user2582713: This is why you're looking at the integral up to $-\kappa-\epsilon$, so it doesn't hit the singularity. – Alex R. Sep 15 '14 at 20:43
• OK. So you can evaluate the first and last integrals slightly above or below the real axis and then let the deformation tend to zero? And then what do you do around the singularities? – user2582713 Sep 15 '14 at 20:52

Essentially what is happening is that we deform the integration contour near the pole by adding a semicircle of radius $\varepsilon$ centered on the pole either above or below the real axis. We can then calculate the integral via the residue theorem and take the limit $\varepsilon \rightarrow 0$ corresponding to the original contour.


text:
# Inverse Kinematics with more than 2 segments

I'm building a 2D inverse kinematics system and can't figure out how to find all the joint positions. I have the math to make a typical IK set up with a single bend (e.g. arm, leg), but I get stuck when adding another bend.

How do I find the position of all joints for an inverse kinematic chain that is longer than 2 segments?

Here's an example of the planar solution I'm looking for: https://youtu.be/3sqd_CZNq7s?t=6s

I'm building this in Adobe After Effects so using an existing IK solver isn't going to work.

Here's my visual setup for reference:

What I'm aiming for is that when the blue box is moved (target) joints 2 and 3 bend appropriately to maintain their length. Joint 1 is static and doesn't move.

To make this work, I need x,y coordinates to be calculated in real time. No need to render anything on screen—just the position values for each joint.

Here's my javascript so far:

var angle1, angle2, angle3, theta1, theta2, theta3, targetSqrDist;

// joints
var joint1 = thisComp.layer("joint 1");
var joint2 = thisComp.layer("joint 2");
var joint3 = thisComp.layer("joint 3");
var joint4 = thisComp.layer("joint 4");

// segment lengths
var segment1Len = length(joint2.transform.position, joint1.transform.position);
var segment2Len = length(joint3.transform.position, joint2.transform.position);
var segment3Len = length(joint4.transform.position, joint3.transform.position);

// target position
var target = thisComp.layer("target");
var ix = target.transform.position[0] - joint1.transform.position[0];
var iy = target.transform.position[1] - joint1.transform.position[1];

// target square distance
targetSqrDist = ix * ix + iy * iy;

// Segment 1
angle1 = Math.max(-1, Math.min( 1,
(targetSqrDist + (segment1Len*segment1Len) - (segment2Len*segment2Len)) / (2 * segment1Len * Math.sqrt(targetSqrDist))
));

theta1 = Math.atan2(iy, ix) - Math.acos(angle1);

var s1X = joint1.transform.position[0] + segment1Len * Math.cos(theta1);
var s1Y = joint1.transform.position[1] + segment1Len * Math.sin(theta1);

// Segment 2
angle2 = Math.max(-1, Math.min( 1,
(targetSqrDist - (segment1Len*segment1Len) - (segment2Len*segment2Len)) / (2 * segment1Len * segment2Len)
));

theta2 = Math.acos(angle2);

var s2X = s1X + segment2Len * Math.cos(theta2 + theta1);
var s2Y = s1Y + segment2Len * Math.sin(theta2 + theta1);

// Segment 3
angle3 = Math.max(-1, Math.min( 1,
(targetSqrDist - (segment2Len*segment2Len) - (segment3Len*segment3Len)) / (2 * segment2Len * segment3Len)
));

theta3 = Math.acos(angle3);

var s3X = s2X + segment3Len * Math.cos(theta3 + theta2);
var s3Y = s2Y + segment3Len * Math.sin(theta3 + theta2);

This code would be applied to each joint with a unique position value assigned to it, depending on the joint's location.

• To be honest, I didn't read the code. Can you first clarify your question? – StinkySkunk Feb 28 '17 at 11:49
• Sorry, things got muddled while writing. How do I find the position of all joints for an inverse kinematic chain that is longer than 2 segments? – Greg Gunn Feb 28 '17 at 18:14
• I think you can perhaps find explicit formulas here courses.csail.mit.edu/6.141/spring2011/pub/lectures/… starting on slide 32. Tell me if it's not what you're looking for. – StinkySkunk Feb 28 '17 at 19:41
• It's close, but not exactly it. These formulas illustrate a typical 3 joint IK solve (e.g. arm, leg) with a single bend. I'm looking for the formula that factors in additional joints and bends in the IK solve (e.g. 4 joints with 2 bends). – Greg Gunn Mar 1 '17 at 2:18

What you have here is an underconstrained problem*. To solve this problem you do what you do to any other underconstrained system. This is also why you mostly only see the 2 joint version as it is not underconstrained in the planar solution, and in any case the preregistration is trivial.

Basically you have 2 options:

• Add more constraints
• Deal with the freedom

Adding more constraints to the system reduces the degrees of freedom. For example if you only permit one of the joints to rotate about its z axis and the another around its x axis then y then you have reduced the problem to the same 2 member problem. Another way to constrain it is to force the orientation of the last link. This also reduces it to the same case as 2 links. But there are other meaningful ways to reduce complexity that depend on your application.

Image 1: Constraining one member reduces the problem to a 2 member problem. In the planar case that means 2 solutions (other in blue).

Dealing with the freedom just means that your answer is going to be a family of answers. Then you develop a way to choose the solution from that family. Letting the user adjust the parameter is equivalent to adding one more constraint. But there are other methods such as least squares, or energy methods that yield different results. Sky is the limit here. For example I have worked with robot controllers that decided the parameter based on what was the least amount of rotation on joints. The problem was that this wasn't entirely deterministic so over time the robot ended up doing things differently...

* This is more suited to Engineering.SE but since IK is a common graphics problem lets deal with it here.

• Do you mean underconstrained? – StinkySkunk Mar 1 '17 at 12:25
• @StinkySkunk oh yes – joojaa Mar 1 '17 at 12:46
• To be honest, I'm not sure which option I'm searching for. What I do know is that I'm after a planar solution that moves like this: youtu.be/3sqd_CZNq7s?t=6s It's short, but I'm looking at the part where the color chain is red-orange-yellow-blue. – Greg Gunn Mar 1 '17 at 18:12
• That does not seem very useful @GregGunn It does not even seem to solve any ik. Atleast we do not know if it is because we cant see the target. It looks more like a system that moves the links based on proxility which is more like hbrid fk/ik. the only reason we even suspect its ik is because the title says so... Titles lie. – joojaa Mar 1 '17 at 19:00
• @joojaa If that reference is my goal—regardless of it's IK or not—how would you suggest I build something that moves like that? – Greg Gunn Mar 1 '17 at 19:30


text:
Powerful dishes
Tag(s):

## Algorithms, Binomial Coefficients, Eulerian number, Fast Fourier transform, Generating Functions, Hard, Stirling Numbers

Problem
Editorial
Analytics

Monica is a chef. Today, she wants to create dishes consisting of n ingredients. x grams of $i^{\text{th}}$ ingredient has energy $x^{a_i}$. Use $0 ^ 0 = 1$. Two dishes are different if the amount of an ingredient differs in them. The energy of a dish is equal to product of energies of individual ingredients. Also, each dish is to be packed in a different container which can afford a weight of upto y grams.

She makes all distinct dishes with weight(= sum of amounts of ingredients) $\le y$. Find the sum of energies of all the dishes made by her modulo $10^9 + 7$. Note that an empty dish(one in which all ingredients have amount 0) is also valid.

Input:
The input consists of two lines:

• The first line contains two integers, n and y
• The second line contains n space separated integers, $i^{\text{th}}$ of which is equal to $a_i$

Output:
Print only one line containing the sum of energies of all the dishes made by Monica modulo $10^9 + 7$

Constraints:

• $1 \le n \le 10^5$

• $0 \le a_i \le 10^5$

• $\sum_{i=1}^{n} a_i \le 10^5$

• $0 \le y \le 10^9$

SAMPLE INPUT
2 3
1 2
SAMPLE OUTPUT
7
Explanation

There are ten distinct dishes possible with total weight $\le 3$ :

1. 0 grams of ingredient one and 0 grams of ingredient 2. Energy = $0^1 0^2 = 0$
2. 0 grams of ingredient one and $p(1 \le p \le 3)$ grams of ingredient 2. Energy = $0^1 p^2 = 0$
3. $p(1 \le p \le 3)$ grams of ingredient one and 0 grams of ingredient 2. Energy = $p^1 0^2 = 0$
4. 1 grams of ingredient one and 1 grams of ingredient 2. Energy = $1^1 1^2 = 1$
5. 1 grams of ingredient one and 2 grams of ingredient 2. Energy = $1^1 2^2 = 4$
6. 2 grams of ingredient one and 1 grams of ingredient 2. Energy = $2^1 1^2 = 2$

The sum of energies is thus $1 + 4 + 2 =7$

Time Limit: 1,0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

August Circuits '17

OTHER PROBLEMS OF THIS CHALLENGE
• Basic Programming > Implementation
• Algorithms > Graphs
• Algorithms > Dynamic Programming
• Math > Combinatorics


text:
What to do for the right FFT in Matlab (two peaks and incorrect amplitude)?

This is the FFT I'm using. But two peaks (did not expect the one in the beginning) are occurring and the amplitude is not as specified (expecting a value of 2). Any help is much appreciated!

Amp = 2;
freqHz = 10000;
fsHz = freqHz*2+1;
dt = 1/fsHz;

sine = Amp*sin(2*pi*freqHz*(0:dt:1-dt));

transform = fft(sine,fsHz)/fsHz;
magTransform = abs(transform);

faxis = linspace(0,fsHz/2,fsHz);
plot(faxis,fftshift(magTransform));
xlabel('Frequency')

• Please clarify what your problem is: how many peaks did you expect (and why) vs how many you're getting; and what amplitude did you expect (and why) vs what you're actually getting. Do not add this information as a comment; rather, edit your question. – MBaz Jun 26 '18 at 17:09
• Please see the picture I've uploaded – mldmnn Jun 26 '18 at 19:00

You need to use complex signal for that. Use this

Amp = 2; freqHz = 10000; fsHz = freqHz*2+1; dt = 1/fsHz; sine = Amp*exp(2i*pi*freqHz*(0:dt:1-dt)); transform = fft(sine,fsHz)/fsHz; magTransform = abs(transform); faxis = linspace(-fsHz/2,fsHz/2,fsHz); plot(faxis,fftshift(magTransform)); xlabel('Frequency')

The somehow symeetric aspect of the complex DFT might be misleading, so in the past I shared a simple Matlab function FFTR.m for real signals only, that might yield the result you'd expect ($2$ magnitude at peak frequency):

as long as you don't try bordeline endeavours. That requires a little normalization and a special care at DC and Nyquist. The code could be:

% Signal definition
Amp = 2;
freqHz = 10000;
fsHz = freqHz*2+1;
dt = 1/fsHz;
sine = Amp*sin(2*pi*freqHz*(0:dt:1-dt));

% Graphic part
[fftR,fftAxe] = FFTR(sine',dt);
plot(fftAxe,fftR,'o-');
xlabel('Frequency')
ylabel('Magnitude')

• Thanks! How can I achieve this with the built in function? – mldmnn Jun 26 '18 at 19:02
• Just explore the FFT.m link I gave as a link, and steal the code :) – Laurent Duval Jun 26 '18 at 19:03
• And if you like it, don't hesitate to upvote! – Laurent Duval Jun 30 '18 at 11:38
• Unfortunately my rep is not sufficient :/ – mldmnn Jul 1 '18 at 11:44


text:
# What is the difference between Selections and Arrangements/Permutaions?

Printable View

• November 5th 2009, 09:47 PM
22upon7
Probability Application help
Hi,

I'm revising for my Maths exam on Tuesday and I really need help with this question:

Three letters are chosen at random from the word "HEART" and arranged in a row. Find the probability that:

a. the letter H is first
b. the letter H is chosen
c. both vowels are chosen

I think this is how you work a. out:

HEART has 5 letters, so 1/5 = 0.2

I'm not sure how to work b. and c. out though, I think it needs permutation and/or combinations but I can't work out the correct answer.

Any help would be greatly appreciated, and I'm sure I'll have more questions to come.

Thanks,

Dru
• November 5th 2009, 11:10 PM
Robb
Quote:

Three letters are chosen at random from the word "HEART" and arranged in a row. Find the probability that:

a. the letter H is first

So, three letters are chosen randomly and arranged in a row. There are $5P3=60$ ways they can be arranged... Since you want the first letter to be a H, there is only one way that can happen, and there is $4P2=12$ ways that can happen. So $Pr(\mbox{H is first})=\frac{1\cdot 12}{60}=\frac{1}{5}$

Quote:

b. the letter H is chosen
Letter H can now be in 1 of 3 places, so
$P(\mbox{Letter H is chosen})=\frac{3\cdot 12}{60}=\frac{3}{5}$

Quote:

c. both vowels are chosen
So there is $2P2=2$ ways to arrange the 2 vowels, and the remaining 3 characters can be arranged in any of the 3 positions, so there are 9 ways for the other letter to be positioned.
So $P(\mbox{both vowels are chosen})=\frac{2\cdot 9}{60}=\frac{3}{10}$
• November 5th 2009, 11:49 PM
22upon7
Quote:

Originally Posted by Robb
So, three letters are chosen randomly and arranged in a row. There are $5P3=60$ ways they can be arranged... Since you want the first letter to be a H, there is only one way that can happen, and there is $4P2=12$ ways that can happen. So $Pr(\mbox{H is first})=\frac{1\cdot 12}{60}=\frac{1}{5}$

Thanks Robb, I didn't understand this bit though, could you help me out with it?:

Quote:

Originally Posted by Robb
Since you want the first letter to be a H, there is only one way that can happen, and there is $4P2=12$ ways that can happen.

Thanks again,

Dru
• November 6th 2009, 12:02 AM
Robb
Just the permuation formula,
$\frac{4!}{(4-2)!}=\frac{24}{2}=12$
• November 6th 2009, 12:28 AM
22upon7
yes, but how did you get those values? The 4 and the 2?

Thanks again,

Dru
• November 6th 2009, 12:48 AM
Robb
Oh, sorry. Orignally you had 5 letters to choose from, and you were selecting 3. But because the first one is a H, you are now selecting 2 letters from the remaining 4.
So the probability is just the ways you can arrange H with 2 other letters, divided by the total number of ways you could arrange 3 letters from 5
• November 6th 2009, 01:17 AM
22upon7
No worries, Thanks again mate!


text:
# Equation xʸ=yˣ

Graph of xy = yx.

In general, exponentiation fails to be commutative. However, the equation ${\displaystyle x^{y}=y^{x}}$ holds in special cases, such as ${\displaystyle x=2,\ \ y=4.}$[1]

## History

The equation ${\displaystyle x^{y}=y^{x}}$ is mentioned in a letter of Bernoulli to Goldbach (29 June 1728[2]). The letter contains a statement that when ${\displaystyle x\neq y,}$ the only solutions in natural numbers are ${\displaystyle (2,4)}$ and ${\displaystyle (4,2),}$ although there are infinitely many solutions in rational numbers.[3][4] The reply by Goldbach (31 January 1729[2]) contains general solution of the equation obtained by substituting ${\displaystyle y=vx.}$[3] A similar solution was found by Euler.[4]

J. van Hengel pointed out that if ${\displaystyle r,n}$ are positive integers with ${\displaystyle r\geq 3}$ then ${\displaystyle r^{r+n}>(r+n)^{r};}$ therefore it is enough to consider possibilities ${\displaystyle x=1}$ and ${\displaystyle x=2}$ in order to find solutions in natural numbers.[4][5]

The problem was discussed in a number of publications.[2][3][4] In 1960, the equation was among the questions on the William Lowell Putnam Competition[6][7] which prompted Alvin Hausner to extend results to algebraic number fields.[3][8]

## Positive real solutions

Main source:[1]

An infinite set of trivial solutions in positive real numbers is given by ${\displaystyle x=y.}$

Nontrivial solutions can be found by assuming ${\displaystyle x\neq y}$ and letting ${\displaystyle y=vx.}$ Then

${\displaystyle (vx)^{x}=x^{vx}=(x^{v})^{x}.}$

Raising both sides to the power ${\displaystyle {\tfrac {1}{x}}}$ and dividing by ${\displaystyle x,}$

${\displaystyle v=x^{v-1}.}$

Then nontrivial solutions in positive real numbers are expressed as

${\displaystyle x=v^{\frac {1}{v-1}},}$
${\displaystyle y=v^{\frac {v}{v-1}}.}$

Setting ${\displaystyle v=2}$ or ${\displaystyle v={\tfrac {1}{2}}}$ generates the nontrivial solution in positive integers, ${\displaystyle 4^{2}=2^{4}.}$

Other pairs consisting of algebraic numbers exist, such as ${\displaystyle {\sqrt {3}}}$ and ${\displaystyle 3{\sqrt {3}}}$, as well as ${\displaystyle {\sqrt[{3}]{4}}}$ and ${\displaystyle 4{\sqrt[{3}]{4}}}$.

The trivial and non-trivial solutions intersect when ${\displaystyle v=1}$. The equations above cannot be evaluated directly, but we can take the limit as ${\displaystyle v\to 1}$. This is most conveniently done by substituting ${\displaystyle v=1+1/n}$ and letting ${\displaystyle n\to \infty }$, so

${\displaystyle x=\lim _{v\to 1}v^{\frac {1}{v-1}}=\lim _{n\to \infty }\left(1+{\frac {1}{n}}\right)^{n}=e.}$

Thus, the line ${\displaystyle y=x}$ and the curve for ${\displaystyle x^{y}-y^{x}=0,\,\,y\neq x}$ intersect at x = y = e.

## Similar graphs

The equation ${\displaystyle {\sqrt[{x}]{y}}={\sqrt[{y}]{x}}}$ produces a graph where the line and curve intersect at ${\displaystyle 1/e}$. The curve also terminates at (0,1) and (1,0), instead of continuing on for infinity.

The equation ${\displaystyle \log _{x}(y)=\log _{y}(x)}$ produces a graph where the curve and line intersect at (1,1). The curve (which is actually the positive section of y=1/x) becomes asymptotic to 0, as opposed to 1.

## References

1. ^ a b Lóczi, Lajos. "On commutative and associative powers". KöMaL. Archived from the original on 2002-10-15. Translation of: "Mikor kommutatív, illetve asszociatív a hatványozás?" (in Hungarian). Archived from the original on 2016-05-06.
2. ^ a b c Singmaster, David. "Sources in recreational mathematics: an annotated bibliography. 8th preliminary edition". Archived from the original on April 16, 2004.
3. ^ a b c d Sved, Marta (1990). "On the Rational Solutions of xy = yx" (PDF). Mathematics Magazine. Archived from the original (PDF) on 2016-03-04.
4. ^ a b c d Dickson, Leonard Eugene (1920), "Rational solutions of xy = yx", History of the Theory of Numbers, II, Washington, p. 687
5. ^
6. ^ Gleason, A. M.; Greenwood, R. E.; Kelly, L. M. (1980), "The twenty-first William Lowell Putnam mathematical competition (December 3, 1960), afternoon session, problem 1", The William Lowell Putnam mathematical competition problems and solutions: 1938-1964, MAA, p. 59, ISBN 0-88385-428-7
7. ^ "21st Putnam 1960. Problem B1". 20 Oct 1999. Archived from the original on 2008-03-30.
8. ^ Hausner, Alvin (November 1961). "Algebraic Number Fields and the Diophantine Equation mn = nm". The American Mathematical Monthly. 68 (9): 856–861. doi:10.1080/00029890.1961.11989781. ISSN 0002-9890.


text:
# Approximating this integral

1. May 24, 2007

### e12514

If g maps a closed bounded subset of R to R^n
g : [a,b] -> R^n
and g is continuous,

can the definite integral
(integral from a to b) g(t) dt

be approximated by
(SUM from 0 to n-1 ) ( g(t) (b-a)/n ) ?
(because as taking n->oo gives the integral?)

If so, what are the steps needed to go from the integral to the sum (obviously it's not valid just to claim they're eqaul)?
Or if not, what's the finite sum that approximates that integral?

And also, how do we actually rigourously show that the approximation sum converges to a limit equal to the integral?

2. May 25, 2007

### AiRAVATA

Isn't that almost a Riemann sum?

(if instead of taking $\sum g(t)\frac{b-a}{n}$ you take $\sum g(\xi_n)\frac{b-a}{n}$ where $\xi_n$ is in each interval of the partition, then, in the limit, is exactly the Riemann sum.)


text:
145 0. Pete L. Clark Pete L. Clark. Proving a Function is Riemann Integrable Thread starter SNOOTCHIEBOOCHEE; Start date Jan 21, 2008; Jan 21, 2008 #1 SNOOTCHIEBOOCHEE. Finding Riemann Integrable Function - Please help! Then, prove that h(x) = max{f(x), g(x)} for x $$\in$$ [a, b] is integrable. now prove f is riemann integrable on [0,1] and determine $$\displaystyle \int^1_0f(x)dx$$ i've worked it out but im not sure if this is correct since it not clear whether the function is non negative: so here goes my solution: Or if you use measure theory you can just use that a function is Riemann-integrable if it is bounded and the points of discontinuity have measure 0. [1]. We will use it here to establish our general form of the Fundamental Theorem of Calculus. Non integrable functions also include any function that jumps around too much, as well as any function that results in an integral with an infinite area. The algebra of integrable functions Riemann sums are real handy to use to prove various algebraic properties for the Riemann integral. Forums. The simplest examples of non-integrable functions are: in the interval [0, b]; and in any interval containing 0. That is a common definition of the Riemann integral. This is not the main result given in the paper; rather it is a proposition stated (without proof!) okay so there is a theorem in my book that says: Let a,b, and k be real numbers. When we try to prove that a function is integrable, we want to control the di erence between upper and lower sums. The function $\alpha(x) = x$ is a monotonically increasing function and we've already see on the Monotonic Functions as Functions of Bounded Variation page that every monotonic function is of bounded variation. This is just one of infinitely many examples of a function that’s integrable but not differentiable in the entire set of real numbers. A MONOTONE FUNCTION IS INTEGRABLE Theorem. The methods of calculus apply only to SMOOTH functions. Some authors use the conclusion of this theorem as the deﬁnition of the Riemann integral. The proof is much like the proof of theorem 2.1 since it relates an ϵ−δstatement to a statement about sequences. We see that f is bounded on its domain, namely |f(x)|<=1. The proof will follow the strategy outlined in [3, Exercise 6.1.3 (b)-(d)]. R is Riemann integrable i it is bounded and the set S(f) = fx 2 [a;b] j f is not continuous at xg has measure zero. Now for general f and g, we apply what we have just proved to deduce that f+g+;f+g ;f g+;f g (note that they are all products of two nonnegative functions) are Riemann-integrable. A function f is Riemann integrable over [a,b] if the upper and lower Riemann integrals coincide. When I tried to prove it, I begin my proof by assuming that f is Riemann integrable. Incidentally, a measurable function f: X!R is said to have type L1 if both of the integrals Z X f+ d and Z X f d are nite. University Math Help. X. xyz. a< b. But by the hint, this is just fg. Apparently they are not integrable by definition because that is not how the Riemann integral has been defined in that class. function integrable proving riemann; Home. Any Riemann integrable function is Lebesgue integrable, so g is Lebesgue integrable implying f is Lebesgue integrable. Doing this will mean that we’re taking the average of more and more function values in the interval and so the larger we chose $$n$$ the better this will approximate the average value of the function. It is necessary to prove at least once that a step function satisfies the conditions. I think the OP wants to know if the cantor set in the first place is Riemann integrable. share | cite | improve this answer | follow | answered Apr 1 '10 at 8:46. Indeed, if f(x) = c for all x ∈ [a;b], then L(f;P) = c(b − a) and U(f;P) = c(b − a) for any partition P of [a;b]. The link I gave above tells what it takes to prove that a Riemann integral exists in terms the OP is using . Okay so this makes sense because if the integral of f exists then kf should exist if k is an element in the reals. With this in mind, we make a new de nition. Theorem. So, surprisingly, the set of differentiable functions is actually a subset of the set of integrable functions. We denote this common value by . A necessary and sufficient condition for f to be Riemann integrable is given , there exists a partition P of [a,b] such that . A bounded function f on [a;b] is said to be (Riemann) integrable if L(f) = U(f). That's the bad news; the good news will be that we should be able to generalize the proof for this particular example to a wider set of functions. Do the same for the interval [-1, 1] (since this is the same example as before, using Riemann's Lemma will hopefully simplify the solution). TheEmptySet. If f is Riemann integrable, show that f² is integrable. We can actually simplify the previous proof because we now have Riemann's lemma at our disposal. Let f: [a, b] rightarrow R be a decreasing function. The proof for increasing functions is similar. University Math Help. Calculus. We will now adjust that proof to this situation, using uniform continuity instead of differentiability. Since {x_1,...x_n} is finite, it's Lebesgue measure is 0, so that g is continuous almost everywhere on [a, b]. Prove the function f is Riemann integrable and prove integral(0 to 1) f(x) dx = 0. 1 Theorem A function f : [a;b] ! As it turns out, to prove that this simple function is integrable will be difficult, because we do not have a simple condition at our disposal that could tell us quickly whether this, or any other function, is integrable. Yes there are, and you must beware of assuming that a function is integrable without looking at it. To do this, it would help to have the same for a given work at all choices of x in a particular interval. Equivalently, f : [a,b] → R is Riemann integrable if for all > … By definition, this … First note that if f is monotonically decreasing then f(b) • f(x) • f(a) for all x 2 [a;b] so f is bounded on [a;b]. A short proof … Oct 2009 24 0. If f² is integrable, is f integrable? Examples 7.1.11: Is the function f(x) = x 2 Riemann integrable on the interval [0,1]?If so, find the value of the Riemann integral. In this case, we write ∫ b a f(x)dx = L(f) = U(f): By convention we deﬁne ∫ a b f(x)dx:= − ∫ b a f(x)dx and ∫ a a f(x)dx:= 0: A constant function on [a;b] is integrable. The function y = 1/x is not integrable over [0, b] because of the vertical asymptote at x = 0. To prove f is Riemann integrable, an additional requirement is needed, that f is not infinite at the break points. Let f be a monotone function on [a;b] then f is integrable on [a;b]. Nov 8, 2009 #1 the value of a and b is not given. Examples: .. [Hint: Use .] Proof. I don't understand how to prove. Then a function is Riemann integrable if and only if for every epsilon>0 there exists a partition such that U(f,P) - L(f,P) < epsilon. kt f be Riernann integrable on [a, b] and let g be a function that satisfies a Lipschitz condition and fw which gt(x) =f(x) almost everywhere. If we then take the limit as $$n$$ goes to infinity we should get the average function value. Let f be a bounded function on [0,1]. Proof: We have shown before that f(x) = x 2 is integrable where we used the fact that f was differentiable. Let f and g be a real-valued functions that are Riemann integrable on [a,b]. inﬁnitely many Riemann sums associated with a single function and a partition P δ. Deﬁnition 1.4 (Integrability of the function f(x)). Prove the function ##f:[a,c]\rightarrow\mathbb{R}## defined by ##f(x) =\begin{cases} f_1(x), & \text{if }a\leq x\leq b \\f_2(x), & \text{if } b
Pelham Hotel New Orleans History, Spider-man Remastered Ps5 Update, Thor Face Paint, Billy Beane Salary, Hinterland Dipping Duplex, Bbc Weather Jeju, Wcu Fall 2020 Classes, Slim Wide Leg Jeans Old Navy, Weather In Israel In April, Pelham Hotel New Orleans History, Premier Bet Jackpot,


text:
mPDF Manual – Troubleshooting

# Memory problems

mPDF uses a lot of memory on the server. If you get an error message that you have exceeded your memory limits, try the following:

It is more efficient in very long documents to process the HTML code in small chunks rather than as one large HTML string use ini_set("memory_limit","128M") or similar at the top of your script to allocate more memory generate a smaller mpdf.php file.

• see Reducing Memory Usage avoid using GIF image files, or PNG images with the alpha channel (transparency) or interlaced PNG images
• set simpleTables if you are using large tables and do not require complex borders or padding setting
• packTabledata can save considerably on memory usage, BUT at a significant cost in processing time

## PHP 5.3.x on Windows

Memory can become exhausted rapidly when running PHP 5.3.x on Windows. I believe this may be a bug in the Windows version of PHP. A script that exhausts 256 MB memory on Windows may only use 18 MB when run on Linux. It appears to happen most often (or exclusively) when using tables.

So if you are only using Windows in a test environment and use Linux for production, you should consider setting the memory limit to maximum on Windows e.g. ini_set("memory_limit","-1").

Small changes to your code e.g. the CSS applied to table elements can have dramatic, but unpredictable effects on the memory usage. For example changing an attribute on a table cell to a css style.

Otherwise you will need to refer to the tips above, especially simpleTables or packTabledata

One user has reported this problem disappearing when updating from 5.3.8 to PHP 5.3.10, so this may be a bug that is fixed?


text:
# A concentrated mass m is attached at the center of a rod of length 2 L as shown in figure. The rod is kept in a horizontal equilibrium position by a spring of stiffness 4 k. For very small amplitude of vibration, neglecting the weight of the rod and spring, the undamped natural frequency (wn) of the system is

This question was previously asked in
ISRO Refrigeration and Air Conditioning 2019 Official
View all ISRO Scientist ME Papers >
1. $$\sqrt {\frac{{2k}}{m}}$$
2. $$\sqrt {\frac{{4k}}{m}}$$
3. $$\sqrt {\frac{{8k}}{m}}$$
4. $$\sqrt {\frac{{16k}}{m}}$$

Option 4 : $$\sqrt {\frac{{16k}}{m}}$$
Free
ISRO Scientist ME 2020 Paper
1355
80 Questions 240 Marks 90 Mins

## Detailed Solution

Explanation:

taking torque about the hinged end

$$I\ddot θ + \left\{ {\left( {4k} \right) \times \left( {2lsin~{\rm{θ}}} \right) \times \left( {2lcos~{\rm{θ }}} \right)} \right\} = 0$$

∵ θ is very small

∴ sinθ ≈ 1; cosθ ≈ θ

∴ $$m{l^2}{\rm{\ddot \theta }} + 16k{l^2}\theta = 0$$

$$mθ ̈+ 16 k θ=0$$

$$\ddot \theta + \frac{{16k}}{m}\theta = 0$$ ........(1)

$$\ddot \theta + w_n^2\theta = 0$$ ........(2)

By comparing (1) and (2)

$${w_n} = \sqrt {\frac{{16k}}{m}}$$


text:
# Geometry problem, median,altitudes

I tried to use the angle property by which AD=4 and DB=5,but since F is not given as mid point I don't know how to proceed to find length of DG.I think AED as 90 degree is important but I am unable to figure out its use.

angle FCE=$C/2$ also FEC=$C/2$ implies FC=EF and also FAE=FEA=$90-C/2$ So EF=AF implies F is the midpoint.

• Sorry I didn't get how FEC=C/2? – swapedoc Jun 23 '14 at 9:16
• AFE=FEC+FCE but AFE=C – happymath Jun 23 '14 at 9:18
• Oh yes and also BEC and FEC are alternate angles – swapedoc Jun 23 '14 at 9:19

Referring to the figure (with added constructions) below.

CONSTRUCTION : extend $AE$ to $BC$ where it intersects $BC$ at $X$.

consider $\triangle AEC$ and $\triangle XCE$.

$\triangle AEC$ and $\triangle XCE$ are congruent by $ASA$.

therefore by CSCTC, $AE = EX$

therefore $E$ is the mid-point of $AX$.

given: $EF$ and $EG$ are parallel to $BC$

therefore by converse of mid-point theorem in $\triangle ACX$ and in $\triangle ABX$, $F$ is the mid-point of $AC$ and $G$ is the mid-point of $AB$.

therefore, $AG = BG = 4.5$

since, you found out $AD = 4$.

therefore,

$DG = AG - AD = 0.5$


text:
### D.24 Hydrogen molecule ground state and spin

The purpose of this note is to verify that the inclusion of spin does not change the spatial form of the ground state of the hydrogen molecule. The lowest expectation energy , characterizing the correct ground state, only occurs if all spatial components of the ground state with spin,

are proportional to the no-spin spatial ground state .

The reason is that the assumed Hamiltonian (5.3) does not involve spin at all, only spatial coordinates, so, for example,

and the same for the other three terms in . So the expectation value of energy becomes

Because of the orthonormality of the spin states, this multiplies out into inner products of matching spin states as

In addition, the wave function must be normalized, 1, or

Now when , , , and are each proportional to the no-spin spatial ground state with the lowest energy , their individual contributions to the energy will be given by , the lowest possible. Then the total energy will be . Anything else will have more energy and can therefore not be the ground state.

It should be pointed out that to a more accurate approximation, spin causes the electrons to be somewhat magnetic, and that produces a slight dependence of the energy on spin; compare addendum {A.38}. This note ignored that, as do most other derivations in this book.


text:
# Solved – Why doesn’t the gamma density plot match the histogram of samples

data visualizationhistogram

I'm confused as to why plot is showing such a steep curve for the gamma PDF. I thought that plotting the draws from an inverse-gamma should approximate the PDF, however it doesn't match the plotted PDF given the same parameters. I take the inverse of the rgamma(), which makes more sense if you can see the variables I'm using. However, I've replaced variables with hard-coded values to keep my MWE brief. I am using R and my code is below:

grid <- seq(0,100,by=0.1) # hard-coded for MWE
sig.post.shape <- 91 # hard-coded for MWE
sig.post.rate <- 1247.52 # hard-coded for MWE
set.seed(1)
hist(1/rgamma(grid, shape = sig.post.shape, rate = sig.post.rate), breaks=10)
plot(grid,1/dgamma(grid, shape = sig.post.shape, rate = sig.post.rate), type = "l")

The resulting graph is:

#### Best Answer

If $X$ has density (pdf) $f$ then $1/X$ does not have density $1/f$ (which is not even a density). Indeed, the change-of-variables formula teaches us that $Y:=h(X)$ has density $$\bigl|{(h^{-1})}'(y)\bigr|f(h^{-1}(y))$$ when $h$ is a "nice" invertible transformation.

I gave the formula for a general $h$, because $h^{-1}(y)=1/y$ when $h(x)=1/x$, and that could cause some confusion.

Then denoting by $f$ the density of your simulated Gamma distribution (rgamma), you have to compare your histogram with the density $$\frac{1}{y^2} f\left(\frac{1}{y}\right)$$ :

grid <- seq(0,100,by=0.1)
sig.post.shape <- 91
sig.post.rate <- 1247.52
set.seed(1);
hist(1/rgamma(grid, shape = sig.post.shape, rate = sig.post.rate), breaks=10, prob=TRUE)
lines(grid,1/grid^2*dgamma(1/grid, shape = sig.post.shape, rate = sig.post.rate), type = "l")


text:
# Topological spaces admitting an averaging function

Let $M$ be a topological space. Define an averaging function as a continuous map $f:M \times M \to M$ which satisfies $f(a,b) = f(b,a)$ for all $a,b \in M$ and $f(a,a) = a$ for all $a \in M$.

These seem like reasonable properties for a function which deserves the name "average" to have, since they are enjoyed by the usual averaging functions on $\mathbb{R}^n$.

One can rule out an averaging function on both $S^1$ and $S^2$ by some cohomological arguments. I have not worked out whether any sphere admits an averaging function, but I suspect not.

Euclidean spaces all do (given by the usual average).

Does anyone have a characterization of spaces which admit an averaging function?

• It comes up every so often that someone wants to average two angles, or average points on the globe, for one purpose or another. I usually try to reason with them first that there is no canonical average between $0$ and $\pi$, and when that fails I intimidate them with cohomology. I would like a complete listing of spaces with averages, since averaging seems like something people often want to do, but the structure of their space might not allow it. Aug 24, 2015 at 0:43
• At least for spaces with a Reimannian metric (surely you only want to consider those!), it might also be reasonable to say that if there's a unique shortest geodesic from $a$ to $b$, then $f(a, b)$ should lie on that geodesic. And it's probably also reasonable to insist that $f$ be continuous in its arguments, at least on the set of pairs for which there's a unique geodesic; I think your cohomology proof relies on this hidden assumption. Aug 24, 2015 at 1:02
• I think that @StevenGubkin meant to implicitly include the idea that $f$ should be continuous. It's "proto-averaging" in the sense that the usual notion of "midpoint" in $R^n$ satisfies these two properties, and you'd like any averaging map on any space to do the same. So having such a function is a bare minimum for having a true "averaging" function, which probably should have lots of other properties as well. If you can show that a space admits no function of Steven's kind, you can stop right there. Aug 24, 2015 at 1:13
• Yes, I should have required continuity! Otherwise, no need to have it be a topological space at all. @JohnHughes I agree that property is nice for metric spaces, but I am mostly interested in just the topological question (at least for starters). Aug 24, 2015 at 2:25
• A trivial but perhaps helpful reformulation is that $X$ has an averaging function iff the diagonal is a retract of $X\times X/\Sigma_2$ Aug 24, 2015 at 2:25

Here is a proof that no sphere (of dimension $>0$) admits an averaging function. Suppose there is an averaging function $f:S^n\times S^n\to S^n$. Let $T(x_0,x_1,x_2,\dots,x_n)=(-x_0,-x_1,x_2,\dots,x_n)$; then $T:S^n\to S^n$ is homotopic to the identity and satisfies $T(T(x))=x$. Now consider the map $g:S^n\to S^n$ given by $g(x)=f(x,T(x))$. Since $T$ is homotopic to the identity, $g$ is homotopic to $x\mapsto f(x,x)=x$, and so $g$ has degree $1$. But note that $$g(T(x))=f(T(x),T(T(x)))=f(T(x),x)=f(x,T(x))=g(x),$$ so $g$ factors through the quotient $S^n\to S^n/{\sim}$, where $\sim$ identifies $x$ with $T(x)$. It is easy to see that $S^n/{\sim}\cong S^n$ and the quotient map has degree $2$. Thus $g$ must have even degree, which is a contradiction.

On the other hand, here are some spaces that have means. First, suppose $M=|X|$ is the geometric realization of a countable contractible simplicial set. The functor $X\mapsto X\times X/\Sigma_2$ commutes with geometric realization for countable simplicial sets, so we get a CW-complex structure on $M\times M/\Sigma_2$ such that the diagonal $M\to M\times M/\Sigma_2$ is a subcomplex. Since $M$ is contractible, it follows by obstruction theory that $M$ is a retract of $M\times M/\Sigma_2$. But such a retraction is exactly a mean on $M$. (The restriction to countable simplicial sets is just so that the product has the right topology; if you work in the category of compactly generated spaces rather than all spaces, you can remove the countability hypothesis. I also suspect that this argument works for arbitrary contractible CW-complexes (not just realizations of simplicial sets), but in that case it is not obvious how to get a CW-structure on $M\times M/\Sigma_2$ with the diagonal as a subcomplex).

There are also some spaces with means with more interesting homotopical properties. For instance, let $(A_n)_{n\geq 0}$ be a sequence of countable $\mathbb{Z}[1/2]$-modules (as above, the countability hypothesis can be dropped if you work with compactly generated spaces). Consider the bounded chain complex of $\mathbb{Z}[1/2]$-modules whose objects are the $A_n$ and whose maps are all zero. Via the Dold-Kan correspondence, we obtain from this chain complex a countable simplicial $\mathbb{Z}[1/2]$-module $X$ such that $\pi_n(X)=A_n$. The geometric realization $M=|X|$ is then a topological $\mathbb{Z}[1/2]$-module with $\pi_n(M)=A_n$. We can then define a mean on $M$ by $f(a,b)=(a+b)/2$.

• Thanks! I had (apparently different) ad hoc cohomological proofs for $S^1$ and $S^2$. This nicely takes care of the spheres. Aug 24, 2015 at 2:26
• This is really great. You guys made it hard to figure out which answer to accept, but I am going with this one. I will try to see if I can construct a mean on the whitehead manifold along these lines. Aug 24, 2015 at 12:40

Such functions are called means. The earliest paper on the subject that I’ve seen is G. Aumann, Über Räume mit Mittelbildungen, Mathematische Annalen (1943), Vol. 19, 210-215. He shows inter alia that no $S^k$ has a mean; that the only $2$-dimensional manifold with a mean is the open disk; and that if $X$ has a mean, then so does every retract and every component of $X$.

Three relatively recent papers that I was able to find fairly quickly:

Mirosław Sobolewski, Means on chainable continua, Proc. Amer. Math. Soc., Vol. 136, Nr. 10, October 2008, 3701-7, shows that a chainable continuum that admits a mean is homeomorphic to the interval.

T. Banakh, R. Bonnet, W. Kubiś, Means on scattered compacta, Topological Algebra and its Applications (2014), Vol. 2, Nr. 1, 5-10, construct a scattered compact space admitting no mean.

Section 6 of Janusz J. Charatonik, Selected problems in continuum theory, Topology Proceedings, Vol. 27, Nr. 1, 2003, 51-78, lists some known results and open questions concerning means on continua.

All have some references that may be of interest.

I’ve a faint recollection that in the 1970s or 1980s Jan van Mill or some of the Dutch topologists around him did some work on means, but I can’t at the moment locate any of it.

• Thanks. These are really helpful, and it is good to know some official terminology for research purposes. Aug 24, 2015 at 10:18
• @Steven: You're welcome. Aug 24, 2015 at 12:05

Edit: This post has been edited to take Eric Wofsey's comments into account. The end result is the following theorem:

Suppose $X$ is a closed manifold of positive dimension. Then $X$ does NOT admit an averaging function.

If an averaging $f:X\times X\rightarrow X$ exists, it induces a map $f_\ast: \pi_k(X)\oplus \pi_k(X)\rightarrow \pi_k(X)$.

Observation 1: $f_\ast(g,g) = g$. Proof: Consider the composition $X\rightarrow X\times X\rightarrow X$, where the first map is the diagonal embedding. By assumption, this composition is the identity. Now, apply functoriality.

Observation 2: $f_\ast(g,h) = f_\ast(h,g)$. Proof: Consider the composition $X\times X\rightarrow X\times X\rightarrow X$ where the first map swaps the two factors and apply functoriality.

These two observations together have very strong consequences. For example:

Corollary: Suppose $G$ is a group with a homomorphism $f: G\times G\rightarrow G$ satisfying both observations. Then $G$ is abelian and every element of $G$ is twice another element of $G$.

Proof: First we show that every element of $G$ is twice another, or, in multiplicative notation, that for any $g\in G$, $g = h^2$ for some $h\in G$. In fact, setting $h = f(g,e)$, we see $h^2 = f(g,e)f(g,e) = f(g,e)f(e,g) = f(g,g) = g$.

Now we show that $G$ is abelian. We have \begin{align*} [f(g,1)f(h,1)]^2 &= f(gh, 1)^2 \\ &= f(gh,1)f(1,gh) \\ &=f(gh,gh)\\ &= gh \\ &= f(g,1)^2 f(h,1)^2\end{align*} so $[f(g,1)f(h,1)]^2 = f(g,1)^2 f(h,1)^2$. Writing these out an canceling, this reduces to $f(h,1)f(g,1) = f(g,1)f(h,1)$. Replacing $h$ and $g$ with $h^2$ and $g^2$, this becomes $hg = gh$, so $G$ is abelian. $\square$

Now, it is easy to see that in a cyclic group, every element is twice another iff the group has odd order. It follows that a finitely generated abelian groups for which every element is twice another is a direct sum of cyclic groups of odd order. In particular, it is finite.

Theorem: If $X^n$ is a closed manifold of positive dimension $n > 0$, then $X$ does not admit an averaging function.

Proof: Since $X$ is closed, $\pi_1(X)$ is finitely generated, and hence finite for all $k$. Since $\pi_k(X)$ is finitely generated as a $\pi_1(X)$ module, it follows that $\pi_k(X)$ is is finitely generated for all $k$. Pass to the universal cover $\tilde{X}$, which is closed because $\pi_1(X)$ is finite. By the Hurewicz Theorem mod $\mathcal{C}$), it follows that all the homology groups of $\tilde{X}$ are finite. But, by Poincare duality, $H_n(\tilde{X})\cong \mathbb{Z}$. This is a contradiction, unless $n = \dim X = 0$. $\square$

These ideas can also be used to show that $\mathbb{R}^2$ is the only surface (no boundary) admitting an averaging function.

Sketch: We have already ruled out closed manifolds, so we assume $X$ is a non-compact manifold. Then, it is relatively well known that $X$ deformation retracts onto its $1$-skeleton. If follows that $\pi_1(X;\mathbb{Z})$ is a free abelian group. This contradicts the corollary, unless $\pi_1(X;\mathbb{Z})$ is trivial. This, in turn implies that $X$ deformation retracts onto its $0$-skeleton, that is $X$ is contractible. This implies $X$ is homeomorphic to $\mathbb{R}^2$.

• So, having ruled out many manifolds from admitting averaging functions, the natural question is: Does anything other than Euclidean space support an averaging function? Note that if a compact manifold admits an averaging function, then every $\pi_k$ with $k\geq 2$ is a finite group of odd order. Can this actually occur? Aug 24, 2015 at 4:20
• This is very nice. I agree that it seems more an more unlikely that any manifold other than a Euclidean space supports an averaging function. In some of Brian Scott's resources there are constructions of spaces with means which are not manifolds. It would be a pretty nice way to characterize Euclidean space among manifolds, if true. Aug 24, 2015 at 10:08
• @StevenGubkin: Yes, for any finite abelian group $G$ of odd order and any $n$ there is a $K(G,n)$ which admits a mean; see the update to my answer for a stronger result. There are also other (non-compact) manifolds with means, since my answer implies any contractible triangulable manifold has a mean. Aug 24, 2015 at 11:25
• @JasonDeVito: Your argument shows not just that every element of $G$ has a square root, but that it is abelian and a $\mathbb{Z}[1/2]$-module. Indeed, $gh=f(gh,e)^2=(f(g,e)f(h,e))^2$ implies $f(g,e)$ and $f(h,e)$ commute, and hence so do $g$ and $h$, and then $g\mapsto f(g,e)$ makes $G$ a $\mathbb{Z}[1/2]$-module. Aug 24, 2015 at 11:39
• It follows that no closed manifold admits a mean, since its universal cover would be a simply connected closed manifold all of whose homotopy groups are all finite of odd order. But this implies the homology groups are also all finite (by the Serre spectral sequence, for instance), and this is incompatible with Poincare duality. Aug 24, 2015 at 11:58

The paper

B.Eckmann, Räume mit Mittelbildungen, Comment.Math.Helv. 28(1954), 329-340

contains most of the answers given so far. The results of this paper are summarized in the following very interesting note of Benno Eckmann:

B. Eckmann, Social choice and topology.

where he defines $n$-means as symmetric functions $\prod_{i=1}^nX\to X$ such that precomposing with the diagonal gives the identity. The means in this mathoverflow question are, in this new language, $2$-means. He proves:

Theorem 6: If a finite polyhedron admits $n$-means for some $n$, then it is contractible.

Theorem 7 + Theorem 4: A polyhedron $X$ admits $n$-means for all $n$ if and only if either it is contractible or it has the homotoy type of a product of rational Eilenberg Mac Lane spaces.

Theorem 2. If a space $X$ admits an n-mean for some n ≥ 2 then $\pi_1(X)$ is Abelian, multiplication by n is an automorphism of $\pi_k(X)$ for all $k$, and $\pi_k(X)$ is uniquely divisible by $n$.

• Thank you. This is an incredibly well written paper, and certainly answers most my questions. I have switched my accepted answer to yours, because I think you are unlikely to get as many upvotes as the older answers. Dec 30, 2015 at 17:14


text:
# Arithmetic genus

In mathematics, the arithmetic genus of an algebraic variety is one of a few possible generalizations of the genus of an algebraic curve or Riemann surface.

## Complex projective manifolds

The arithmetic genus of a complex projective manifold of dimension n can be defined as a combination of Hodge numbers, namely

pa = hn,0hn − 1, 0 + ... + (−1)n − 1h1, 0.

When n = 1 we have[clarification needed] χ = 1 − g where g is the usual (topological) meaning of genus of a surface, so the definitions are compatible.

## Kähler manifolds

By using hp,q = hq,p for compact Kähler manifolds this can be reformulated as the Euler characteristic in coherent cohomology for the structure sheaf ${\displaystyle {\mathcal {O}}_{M}}$:

${\displaystyle p_{a}=(-1)^{n}(\chi ({\mathcal {O}}_{M})-1).\,}$

This definition therefore can be applied to some other locally ringed spaces.