text:
# Talk:Riemann sum

WikiProject Mathematics (Rated C-class, High-importance)
This article is within the scope of WikiProject Mathematics, a collaborative effort to improve the coverage of Mathematics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Mathematics rating:
 C Class
 High Importance
Field:  Applied mathematics

## Merge?

I think the Riemann sum and the Riemann integral have too much in common. I suggest merging information from them into Riemann integral, and make Riemann sum a redirect. Please see discussion at talk:Riemann integral.(Igny 21:51, 5 December 2005 (UTC))

Yes I was looking for this article but found that one instead. Very confusing. If you knew the difference between a Riemann sum and an integral why would you need to look it up?Circuitboardsushi (talk) 21:56, 7 April 2012 (UTC)

## Clarification

I think it would be worth clarifying that the distance between the points (x1, x2, xi-1, xi) have to be a uniform distance, and it is done for simplicities sake. The graphs would give that idea as well, which isn't really true of Riemann's original "Riemann sums." --AstoVidatu 04:47, 7 December 2006 (UTC)

 ==Error Estimation==

Are the error estimation formulas correct for the "middle sum" and "trapezoidal sum" methods? The "middle sum" error estimate is currently quoted as :${\displaystyle \left\vert \int _{a}^{b}f(x)-A_{\mathrm {mid} }\right\vert \leq {\frac {M_{2}(b-a)^{3}}{(24n^{2})}},}$

...and the "trapezoidal sum" error estimate is :${\displaystyle \left\vert \int _{a}^{b}f(x)-A_{\mathrm {trap} }\right\vert \leq {\frac {M_{2}(b-a)^{3}}{(12n^{2})}},}$

I don't have a calculus book handy, but it doesn't make intuitive sense that the "trapezoidal sum" error could be twice the size of the "middle sum" error. Is this right? Is there a handy reference online where these formulas are derived?

--Imperpay 22:30, 26 March 2007 (UTC)

The formulae are correct. http://people.hofstra.edu/stefan_Waner/realworld/integral/numint.html Accuracy of Trapezoid and Simpson Approximations lists the formula for the trapezoidal error as ${\displaystyle \left\vert \int _{a}^{b}f(x)-A_{\mathrm {trap} }\right\vert \leq {\frac {M_{2}(b-a)^{3}}{(12n^{2})}},}$

It may not be intuitive, but oddly enough, the consideration of multiple derivatives and the fact that the middle sum method overlaps in both directions makes the error bound for the middle sum method smaller.

-- Icedemon —Preceding unsigned comment added by 98.226.21.88 (talk) 09:35, 25 December 2007 (UTC)

## Examples

how have you guys not added the limit of the Riemann sum, which solves the integral with no error? can someone please add this vital information? --69.125.25.190 (talk) 23:49, 1 November 2008 (UTC)

I've added an example but I need some help with the formatting. If someone could clean it up for me, that would be great. Thanks. Dwees (talk) 04:53, 26 November 2008 (UTC)

Would you be able to include sigma notation of the series in the written the examples? Stevescott517 (talk) 03:09, 30 July 2015 (UTC)

## Subsets or elements?

Regarding:

Because P is a partition with n elements of I, the Riemann sum of f over I with the partition P is defined as

Should that be "n subsets of I" instead of "n elements of I"? 76.175.72.51 (talk) 17:06, 14 October 2009 (UTC)

## Simpson's Rule is Blank!

There are examples of using Simpson's Rule, but there is no theory under the blue heading like the other Reimann sum methods, just examples. —Preceding unsigned comment added by 134.114.119.6 (talk) 03:14, 14 March 2010 (UTC)

The article located here http://en.wikipedia.org/wiki/Archimedes_Palimpsest states, "When rigorously proving theorems, Archimedes often used what are now called Riemann sums."

I think Archimedes' use of this method should be noted in this article so as to make it clear that Reimann did not originate Reimann Sums. — Preceding unsigned comment added by 50.46.144.101 (talk) 11:34, 24 December 2011 (UTC)

## Merge in Rectangle method

The Rectangle method and Riemann sum are the same; I propose that they should be merged. Klbrain (talk) 20:55, 26 April 2016 (UTC)

The Riemann sum is a more technical and complicated way of explaining integrals. I do believe, however, that Rectangle method should be merged instead with Trapezoidal rule. Both these quadrature methods are very similar and at the same level. ReallyFat B. 11:46, 17 May 2016 (UTC)
Support merge with Riemann sum. Oppose with merge Trapezoidal rule. The "rectangle method" (a name I've never heard used in seriousness) is, as proposer suggests, exactly the same as Riemann sums. The Trapezoidal rule however is the first in a series of methods that attempt to improve on the accuracy of Riemann sums (with Simpson's rule etc following as the order of the function at the "top of the box" gets higher). The trapezoidal rule is literally not a rectangular sum and therefore it should not be merged there. Jason Quinn (talk) 17:38, 11 June 2016 (UTC)
I still support the merge of Rectangle method to Riemann sum (in agreement with Jason Quinn). The argument that the Riemann sum is a "more technical and complicated wat of explaining integrals" is, in some ways, an argument for merging Rectangle method into Riemann sum, making the final article statisfy WP:ACCESSIBILITY. In general, pages covering the same topic with different level of complexity are better discussed together. I can't see that merging Rectangle method and Trapezoidal rule would work as they are different methods, unless they were both merged to Numerical integration (which is the relevant target from the Quadrature dab page) (and it was then argued that all such methods should be on one page).Klbrain (talk) 13:03, 27 September 2016 (UTC)

────────────────────────────────────────────────────────────────────────────────────────────────────  Done I've gone ahead and performed this merge. I saw no text immediately incorporable so I merge no text. Some of the error stuff might be useful but would need to be customized for this article. Jason Quinn (talk) 21:52, 27 July 2017 (UTC)


text:
An ARM On Four Cylinders

Iwzxhzdk:14ve been trying out a Ferrari.

Well, sort of. Letwzxhzdk:15s put it this way: If the [Raspberry Pi][rpi] is todaywzxhzdk:16s ARM computing equivalent of the Volkswagen, then the [ODROID-U2][od] is probably its Ferrari, at least under the hood.

Hardware

Physically, the thing looks like the result of an unlikely marriage between an oversized postage stamp and a heat sink.

The PCBwzxhzdk:18s somewhat smaller than a [Raspberry Pi][rpi], but even considering this is a development board, the end result is a lot tidier wzxhzdk:17 the heat sink actually makes it somewhat reminiscent of a shrunken down NeXTCube, and tacking on a couple of pieces of matte black cardboard on the open sides completes the effect.

But the most important hardware characteristic of the [ODROID-U2][od] is its quad-core [Exynos 4412][ex] CPU, which is very snappy indeed. In fact, this is the fastest [Android][an] device I’ve used yet by all accounts, although the 8GB EMMC I ordered along with it has to take part of the credit (running the OS from an SD card works fine, but is somewhat slower).

I hooked mine up to a full HD (1920x1080) monitor via an HDMI-DVI adapter[^1], plugged in a Bondi Blue iMac USB keyboard I had lying around as well as a bog-standard USB webcam and mouse, and stuck to Ethernet for connectivity.

Software

So what do you run on it? Well, I chose [Android][an] wzxhzdk:19 in fact, part of the reason I got one was that [Ricardo Cerqueira][rc] ported [CyanogenMod][cm] 10.1 to it with nearly complete hardware support (more on that in a moment), so I pretty much ignored the stock AOSP version and the (then incipient) [Ubuntu][ub] port and just went ahead and flashed that.

Most people would probably look at using this as a media centre (for which it is eminently suitable), to run arcade emulators (which I did, but mostly to be amazed at the speed of the thing), and, of course, for testing apps.

Me, I set up [Evernote][ev], Facebook Messenger and Flipboard on it (besides a number of Google Apps and a couple of terminal emulators), and soon had a couple of [Android][an] apps of my own running on it wzxhzdk:20 one of them compiled locally using [AIDE][aide].

Given my [previous dalliance][b1] in [Android][an] for [x86][x86], using [Android][an] as a “desktop” is hardly a problem klzzwxh:0007 aside from somewhat oversized fonts and lack of multitouch (or even a working secondary mouse button), switching between apps with Alt+Tab works smoothly and intuitively enough, and most well-written apps support a minimal amount of keyboard navigation – so (rather ironically) moving about with a keyboard alone is a more viable proposition than on an [iPad][ipa].

Zooming (which can only really be handled via pinching) remains the only hassle, but there are a few nice touches ’ for instance, and rather unexpectedly, I can switch it ’on– and ”off’ (i.e., switch off the display via DPMS) using the power button on the USB keyboard, and most ’normalwzxhzdk:9 key combinations for caret movement and text handling just work.

Remote Access

One of the reasons I bought an [ODROID-U2][od] was that itwzxhzdk:11s a perfect, zero-hassle smart terminal wzxhzdk:10 I just sit, tap the power button on the keyboard and get instant access to a decent default desktop with a few different browsers[^3], a perfectly usable terminal emulator[^2] and working builds of tmux and [ssh][ssh], so the basics were covered right off the bat.

Running [Android][an] is just the icing on the cake, really. But full HD is sort of wasted on terminal windows, so I also looked for ways to replicate [my remote desktop setup][rdppi].

After some experimentation, I settled on [Jump Desktop][jd] as my [VNC][vnc] and [RDP][rdp] client wzxhzdk:12 it not only handles [ssh][ssh] tunnelling without any issues and is very speedy, it also works well in uncommon configurations (such as using VNC with Mac authentication or RDP-over-SSH to a Linux machine).

And, of course, it blows [my earlier Raspberry Pi setup][rdppi] out of the water in terms of speed and flexibility.

Interestingly enough, despite Android not supporting more than one mouse button and handling the scroll wheel inconsistently, [Jump Desktop][jd] handles right-clicking and scrolling without any issues, and (much to my delight) had no trouble whatsoever with Portuguese keyboard layouts at any end.

So this VPS (where I keep a container with Chrome and development tools to use on the go) and a number of other servers are just a couple of clicks away, and itwzxhzdk:13s awesome.

Kinks

There are a few minor niggles with the whole setup, though.

The first is that Android applications are (naturally) unprepared for being used in a desktop environment and/or with a physical keyboard klzzwxh:0024 even [Jump Desktop][jd] persists in displaying an on-screen toolbar and keeps trying to “help out” by adding a black margin around the remote display (likely to allow your finger to touch the very edges of the screen), something I worked around by setting my remote desktops to be 1920x1016 (i.e., exactly the right size).

Also, [Bluetooth][bt] is, alas, not supported yet, for changes in the Android 4.2 [Bluetooth][bt] stack mean that USB dongles (the only practical way to add a transceiver) require a substantial bit of internal re-plumbing at the kernel and driver levels to get working.

But overall, and considering that Iwzxhzdk:14m running [CyanogenMod][cm] nightly builds, the whole thingwzxhzdk:16s a lot more stable than youwzxhzdk:15d expect.

Penguin Inside

Using the [ODROID-U2][od] as an Android desktop and thin client was all fine and good for a few weeks, but this weekend I decided Iwzxhzdk:23d have a go at running [Python][p] on it locally wzxhzdk:22 partly because I like to pull weird stunts like that, and partly because Iwzxhzdk:24ve been porting stuff from threading to the multiprocessing module and it was a good opportunity to get a better feel for the [Exynos][ex] quad-core.

[Python for Android][pya] worked fine (after some tweaking), but I then realised I was going to need to install some packages locally.

So I started thinking about setting up a chroot environment of some sort, gradually drifted onto the notion of using standard Linux ARM binaries and after a few (mercifully short) tries eventually came across [Linux on Android][loa], which is nothing more than a chroot environment mounted from a filesystem image[^4].

As it turns out, running a [Ubuntu][ub] userland alongside Android processes works very well indeed (since itwzxhzdk:20s all running atop the same kernel, therewzxhzdk:21s zero overhead). So much so that even though Iwzxhzdk:19m not interested in running X applications locally, setting up a [VNC][vnc] server and running Firefox just worked wzxhzdk:18 and at impressively snappy speeds, too.

wzxhzdk:13

The only serious drawback with this is the amount of extra storage required for the extra luggage a [Linux][l] system brings along with it, but itwzxhzdk:17s perfectly doable and, at least for my purposes, much better than trying to install [Ubuntu][ub] natively.

So I can see myself getting quite some mileage from this as soon as I get my hands on a largeish SD card and move the [Ubuntu][ub] filesystem over to it.

Who knows, I might even go crazy and try to run Unity on it, just for kicks[^5].

format: plain


text:
I have forgotten

• https://me.yahoo.com

# Internal Combustion Engine Cycles

A discussion on the thermodynamic cycles of internal combustion engines, including the Otto cycle, the Joule cycle, and the Diesel cycle.
View other versions (3)

## Overview

Definitions

Working substance (WS). The WS is used as the carrier for heat energy. The heat engine carries out the conversion process by a series of changes of state of the WS. The state of the WS is defined by the values of its properties, e.g. pressure, volume, temperature, internal energy, enthalpy. These properties are also sometimes called functions of state.

<br/>

Key facts

Examples of internal combustion engine cycles are the Otto cycle (also known as the Constant Volume cycle), the Joule cycle (also known as the Brayton cycle, or the Constant Pressure cycle), and the Diesel cycle.

The thermal efficiency of the Otto cycle is given by:

where is the compression ratio, and the heat capacity ratio.

The thermal efficiency of the Joule cycle is given by:

where is the pressure ratio, and the heat capacity ratio.

The thermal efficiency of the Diesel cycle is given by:

where is the compression ratio, the expansion ratio during heating (also known as the cut-off ratio), and the heat capacity ratio.

A thermodynamic cycle comprises a series of operations carried out on the working substance (WS) during which heat is supplied, and after which the WS is returned to its original state (for a more comprehensive introduction to thermodynamic cycles also see Thermodynamic Cycles ).

An example of a thermodynamic cycle is the internal combustion engine. In this case, the WS is treated as pure air, the expansions and compressions are reversible and adiabatic, and heat can be added instantaneously if desired. Applications of such cycles are the Otto cycle, the Joule cycle, and the Diesel cycle.

Before discussing these cycles, we first have to introduce the thermal efficiency of a cycle.

The thermal efficiency of a cycle, also denoted by , is a measure of the ability to convert heat energy into work. Therefore, the thermal efficiency can be defined as:

where is the work output and the heat energy supplied. As the work done can also be expressed as:

where is the heat rejected in the WS and in losses (for a more detailed discussion see Thermodynamic Cycles ). The thermal efficiency from (2) becomes:

or furthermore,

## Otto Cycle

The Otto cycle (also sometimes called the Constant Volume cycle) is diagramed on a pressure - volume () plot in Figure 1, and on a temperature - entropy () plot in Figure 2.

This cycle consists of an adiabatic compression of the WS (step ), followed by an isochoric heating, i.e. heating at constant volume (step ), then an adiabatic expansion of the WS (step ), and ended with an isochoric cooling which reverts the system back to its original condition (step ).

We know that the heat added or removed from the WS during a process at constant volume can be written as:

where is the number of moles of the WS, the heat capacity at constant volume, and the change in temperature. Hence, for the Otto cycle depicted in Figure 1 and Figure 2, we have that the heat supplied is:

and the heat rejected is:

Therefore, the thermal efficiency of the Otto cycle becomes (see equation 5):

from which we obtain:

As in this case the WS is treated as pure air, we can write for the adiabatic compression that:

and for the adiabatic expansion that:

In (11) and (12), is the heat capacity ratio defined as:

where is the heat capacity at constant pressure, and the heat capacity at constant volume.

Equations (11) and (12) can also be written as:

and,

respectively. As and (steps and of the Otto cycle are isochoric - see Figure 1), we can rewrite equations (14) and (15) as:

and,

respectively, where is called the compression ratio.

By subtracting equation (16) from equation (17), we get that:

or furthermore, that:

By using (20) in equation (10), we obtain the thermal efficiency of the Otto cycle as:

It can be noted that the compression ratio for carburettor engines is about , while for fuel injector engines it increases to around . By using these figures, and also considering a value for the heat capacity ratio of , the thermal efficiency of a petrol/gasoline engine is found to be between and . It can also be noted that for an Otto cycle engine, the ignition is usually performed by using a spark plug ("spark ignition").

## Joule Cycle

The Joule cycle (also sometimes called the Brayton cycle, or the Constant Pressure cycle) is a thermodynamic cycle that describes the workings of the gas turbine engine. The Joule cycle is depicted on a plot in Figure 3, and on a plot in Figure 4.

This cycle consists of a reversible adiabatic (i.e. isentropic) compression of the WS (step ), followed by an isobaric heating (i.e. heating at constant pressure) (step ), then a reversible adiabatic (isentropic) expansion of the WS (step ), and ended with an isobaric cooling which reverts the system back to its initial state (step ).

Similar to equation (6), we can write the heat added or removed from the WS during a process at constant pressure as:

where is the number of moles of the WS, the heat capacity at constant pressure, and the change in temperature. Therefore, for the Joule cycle depicted in Figure 3 and Figure 4, the heat supplied becomes:

and the heat rejected:

Hence, the thermal efficiency of the Joule cycle becomes (see equation 5):

from which we obtain:

As for the Joule cycle the WS is also treated as pure air, we can write for the isentropic compression that:

and for the isentropic expansion that:

where is the heat capacity ratio (see equation 13).

Equations (27) and (28) can also be written as:

and,

respectively.

By raising equations (29) and (30) to the power, we respectively get that:

and,

As and (steps and of the Joule cycle are isobaric - see Figure 3), we can rewrite equations (31) and (32) as:

and,

respectively, where is called the pressure ratio.

By subtracting equation (33) from equation (34), we get that:

or furthermore, that:

By using (37) in equation (26), we obtain the thermal efficiency of the Joule cycle as:

## Diesel Cycle

The Diesel cycle is diagramed on a plot in Figure 5, and on a plot in Figure 6.

This cycle consists of a reversible adiabatic (isentropic) compression of the WS (step ), followed by an isobaric heating (step ), then a reversible adiabatic (isentropic) expansion of the WS (step ), and ended with an isochoric cooling which returns the system back to its original state (step ).

Taking into account equations (6) and (22), we can write the heat supplied (at constant pressure, step ) as:

and the heat rejected (at constant volume, step ) as:

where is the number of moles of the WS, the heat capacity at constant pressure, and the heat capacity at constant volume.

Therefore, the thermal efficiency of the Diesel cycle becomes (see equation 5):

which can also be written as:

where is the heat capacity ratio (see equation 13).

As for the Diesel engine the WS is again treated as pure air, we can write for the isentropic compression that:

for the isobaric heating that:

and for the isentropic expansion that:

which can also be written as:

where is the compression ratio.

From equation (44) we obtain:

which can also be written as:

where is the expansion ratio during heating (also called the cut-off ratio).

The temperature from (49) can further be expressed by considering the expression of from (47), as:

which can also be written, by considering the expression of from (50), as:

We can write equation (52) in an analogous form as:

and furthermore, to:

Thus, we managed to express , , and all in function of (see equations 47, 50, and 55 respectively). By using these expression forms in equation (42), we get:

from which we obtain the thermal efficiency of the Diesel cycle as:

It can be noted that the ignition for the Diesel internal combustion engines is done by using a higher compression of the fuel, rather than by using a spark plug as in the case of gasoline powered Otto cycle engines. Therefore, the ignition for Diesel engines is sometimes called a "slow speed compression ignition", in contrast to the "spark ignition" of the Otto engines.

Example:

[imperial]
##### Example - Properties of a Diesel cycle
Problem
An engine operates under a Diesel cycle with a top pressure of (). The compression ratio is , and the air at the start of compression is at and . If are added during combustion and expansion in accordance to the law , the clearance volume is , the specific heat at constant pressure during combustion is , and also if we are to ignore the fuel mass, find:

A) the pressure, volume, and temperature at each change point in the cycle;

B) the work output of the cycle (in );

C) the thermal efficiency of the cycle.

The corresponding Diesel cycle is diagramed on a plot in Figure E1.

Workings
A) We are going to consider below each stage of the cycle separately.

Stage 1

We know from the hypothesis that the air at the start of compression is at and . Therefore, the initial pressure is:

while the initial temperature in kelvins () is:

We also know from the hypothesis that the compression ratio is . As the compression ratio is defined as:

we obtain the initial volume:

which becomes, by taking into account that and that is the clearance volume ():

Therefore , , and .

Stage 2

We have from the hypothesis that the top pressure is . Hence:

Also from the hypothesis we have that the clearance volume is . Thus:

By taking into account that:

we can write as:

By replacing the numerical values (see 1, 2, 5, 6, and 7), we obtain:

from which:

Therefore , , and .

Stage 3

As step of the Diesel cycle is isobaric (see Figure E1), we have that:

from which we obtain, by taking into account (6), that:

For step of the cycle we can also write that:

where is the heat supplied (), the specific heat at constant pressure (), and is the temperature difference expressed in , while is the quantity of gas which is present at a pressure of and at a temperature of . In order to calculate , we can write that:

from which:

Taking into account that:

and also replacing the other numerical values (see 1, 2, and 5), we get that:

from which we obtain:

By using the value of from (19) in equation (14), and also considering that , , and that , we get that:

or, by converting the temperature difference into kelvins, to:

As (see 11), we obtain as:

Still for step of the cycle we can write that:

from which becomes:

or, by replacing numerical values (see 7, 11, and 23):

Therefore , , and .

Stage 4

As step of the Diesel cycle is isochoric (see Figure E1), we have that:

from which we obtain, by taking into account (5), that:

As for step of the cycle we have that:

we can write:

from which becomes:

or, by replacing numerical values (see 13, 27, and 29):

From equation (33) we obtain:

We know that Therefore, we can divide equation (30) by and still obtain a constant:

Equation (35) can also be written as:

from which we obtain, for step of the cycle, that:

Hence, we can write that:

from which becomes:

or, by replacing numerical values (see 23, 27, and 29):

From equation (40) we obtain:

Therefore , , and .

B) The work output of the cycle is given by:

where (as ). In order to calculate , we can write that:

By applying the function to equation (44), we get:

from which we obtain:

or, by replacing numerical values (see 1, 5, 6, and 7):

By replacing all the numerical values in equation (42) (see 1, 5, 6, 7, 13, 27, 29, and 34), and also taking into account that , (see 48), and that , we get the work done in as:

from which we obtain:

C) We know that the thermal efficiency is defined as:

where is the work output, and the heat supplied.

As, in our case, (see 50) and , and also taking into account that , we get the thermal efficiency of the Diesel cycle as:

from which we obtain:

or, expressed as percentage:

Solution


text:
Homework Help: Extrema of Two Variable Bounded Function

Tags:
1. Mar 2, 2017

Kaura

1. The problem statement, all variables and given/known data

Find the maximum and minimum value attained by f(x, y) = x2 + y2 - 2x over a triangular region R with vertices at (0, 0), (2, 0), and (0, 2)

2. Relevant equations

partial x = 0 and partial y = 0 at extrema

3. The attempt at a solution

partial x = 2x - 2
partial y = 2y
2x - 2 = 0
2y = 0
2x - 2 = 2y
x - 1 = y
me = lost
I really have no idea how to do these bounded problems so any help on a method or something would be much appreciated

2. Mar 2, 2017

Math_QED

From $2x - 2 = 0$, we find that $x=1$. From $2y = 0$, we find that $y = 0$. Therefore, we have found a stationary point at $(1,0)$. Can you proceed now? Do you know how to know what kind of extremum this is?

3. Mar 2, 2017

Kaura

Ah that makes sense, I think that would be a minimum correct?

4. Mar 2, 2017

Math_QED

Correct! (I had to look up the formulas haha)

5. Mar 2, 2017

Kaura

So then for the maximum do I just check each vertex and find which one gives the largest value?

6. Mar 2, 2017

Ray Vickson

Forget about setting the partial derivatives to zero: that often does not apply when you have constraints. For example, the solution of the problem $\max / \min f_1(x) = x,\;\; 0 \leq x \leq 1$ is easily seen to be: $\min$ at $x = 0$, $\max$ at $x = 1$, but the derivative is $f'_1(x) = 1$ at both of those points. For the problem $\max /\min f_2(x) = (x-1)^2\; \; 0 \leq x \leq 3$ there is a minimum at $x = 1$, and the derivative = 0 there. However, there are two local maxima on $[0,3]$, one at $x = 0$ and the other at $x = 3$. We have $f'_2(0) < 0$ and $f'_2(3) > 0$. Furthermore, by calculating $f_2$ at $x=0$ and $x=3$ we see that the solution is at $x=3$.

In your case the solution is either (1) in the interior of the triangle---and the derivatives = 0 in that case; (2) on one of the sides---the derivatives need not be zero there, but the gradient vector of $f$ must be perpendicular to the side (another way of stating the Lagrange multiplier rule); or (3) at one or more of the three corners. At a corner you have a (local) minimum if the gradient of $f$ points into the triangle and a (local) max if the negative of the gradient points into the triangle. Basically, though, if the solution is not in the interior or on one of the sides, it must be at a corner and you don't really need to look at derivatives there at all (why?).

7. Mar 2, 2017

Math_QED

There are formulas involving the partial derivatives from which you can easily see what extremum it is. You can also look at the values of f in a neighbourhood of $(1,0)$ and try to convince yourself that $f(1,0) < f(x,y)$ for all $(x,y)$ in that neighbourhood. One has to be careful using this technique though, as your stationary point might be a saddle point.

8. Mar 2, 2017

Ray Vickson

This is not quite true: for maximizing a convex function over a convex polyhedron, the solution is at one of the extreme points (corners), but in the worst case the only known algorithm is to evaluate the function at each corner and take the best value! This really is true: there are no derivative tests that can tell you whether one corner is better than another one a long way off in another part of the region. The OP's function is (strictly) convex and his feasible region is convex, so the general result applies.

However, if you meant that there are derivative formulas that tell you whether you have a local max or min, then I agree: that is certainly true.

Techincally, the problem of maximizing a convex function over a convex polyhedron is NP-hard, which means that it is unlikely that any efficient algorithm can be found for the problem; that applies even for functions as simple as $f = x_1^2+x_2^2+ \cdots + x_n^2$. For more on this, see, eg.,
https://en.wikipedia.org/wiki/NP-hardness and/or
https://en.wikipedia.org/wiki/List_of_NP-complete_problems .

9. Mar 2, 2017

Kaura

So would the local maximum be 4 at (0, 2) ???

10. Mar 3, 2017

Ray Vickson

What do YOU think?

11. Mar 5, 2017

Kaura

I am 96.8842% positive with a percent error of +/- 4.2263%

12. Mar 6, 2017

ehild

It is not local maximum, but absolute maximum on the domain. You have the only stationary point of the function at x=1, y=0, and it proved to be minimum.


text:
# calculus homework help... sketching a graph of f

• Nov 12th 2012, 06:00 PM
asilvester635
calculus homework help... sketching a graph of f
The figure shows the graph of f" . Sketch agraph of f. (The answer is not unique.
Attachment 25679
• Nov 12th 2012, 06:09 PM
jakncoke
Re: calculus homework help... sketching a graph of f
How about $f(x) = 3x^2 - \frac{x^3}{3}$

$f'(x) = 6x - x^2$

$f''(x) = 6 - 2x$ which is the graph in ur picture
• Nov 12th 2012, 06:13 PM
MarkFL
Re: calculus homework help... sketching a graph of f
Quote:

Originally Posted by jakncoke
How about $f(x) = 3x^2 - \frac{x^3}{3}$

$f'(x) = 6x - x^2$

$f''(x) = 6 - 2x$ which is the graph in ur picture

I don't think the OP is supposed to use integration of obtain a member of the family of curves, but rather to use the implications of the given graph. Also, this topic has been posted twice.
• Nov 17th 2012, 05:41 PM
asilvester635
Re: calculus homework help... sketching a graph of f
jakncoke how did you get f(x) = 3x^2 - x^3/3?


text:
Kattis

# Unique Snowflakes

Photo by Vlasta Juríček

Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a machine that captures snowflakes as they fall, and serializes them into a stream of snowflakes that flow, one by one, into a package. Once the package is full, it is closed and shipped to be sold.

The marketing motto for the company is "bags of uniqueness." To live up to the motto, every snowflake in a package must be different from the others. Unfortunately, this is easier said than done, because in reality, many of the snowflakes flowing through the machine are identical. Emily would like to know the size of the largest possible package of unique snowflakes that can be created. The machine can start filling the package at any time, but once it starts, all snowflakes flowing from the machine must go into the package until the package is completed and sealed.

## Input

The first line of input contains one integer specifying the number of test cases to follow. Each test case begins with a line containing an integer $n$, the number of snowflakes processed by the machine. The following $n$ lines each contain an integer (in the range 0 to $10^9$, inclusive) uniquely identifying a snowflake. Two snowflakes are identified by the same integer if and only if they are identical. The input will contain no more than one million total snowflakes.

## Output

For each test case output a line containing single integer, the maximum number of unique snowflakes that can be in a package – the length of the longest contiguous segment of unique snowflakes.

Sample Input 1 Sample Output 1
1
5
1
2
3
2
1

3


text:
# Constant square difference partition point

Partition a line segment so that the difference between the square on the greater part and the square on the lesser part is constant.

In the figure, point K splits AD into AK and KD, such that $AK^2 - KD^2 = AC^2$, AC is of fixed length.

Can this be achieve by compass and straight edge?

-
Googling tells me that a square on a part refers to a square positioned in the plane with a given line segment as one of its sides. I'm still not sure what you mean by the difference between two of these squares being constant. (Constant with respect to what?) – anon Sep 19 '11 at 7:53
If the length of the segment is $a$, and you are given $b$, are you asking to find $c$ so that $(a-c)^2-c^2=b?$ – Ross Millikan Sep 19 '11 at 9:08
@RossMillikan, exactly. – qed Sep 19 '11 at 11:20

If the length of the segment is a, and you are given b, we are asked to find c so that $(a−c)^2−c^2=b=a^2-2ac$ This gives $c=\frac{a^2-b}{2a},$ which is constructible.
That should be just $a^2 - 2ac$ without the $-2c^2$. – Rahul Sep 19 '11 at 11:32
To construct $a^2$ draw a triangle with two sides $1$ and $a$, then construct a similar triangle with $a$ corresponding to $a$. Then you can just subtract $b$ and divide by $a$ again using similar triangles. – Ross Millikan Sep 19 '11 at 12:12


text:
# 4.3: Exothermic and Endothermic Processes

## Units of Heat

Heat flow is measured in one of two common units: the calorie and the joule. The joule $$\left( \text{J} \right)$$ is the SI unit of energy. The calorie is familiar because it is commonly used when referring to the amount of energy contained within food. A calorie $$\left( \text{cal} \right)$$ is the quantity of heat required to raise the temperature of 1 gram of water by $$1^\text{o} \text{C}$$. For example, raising the temperature of $$100 \: \text{g}$$ of water from $$20^\text{o} \text{C}$$ to $$22^\text{o} \text{C}$$ would require $$100 \times 2 = 200 \: \text{cal}$$.

Calories contained within food are actually kilocalories $$\left( \text{kcal} \right)$$. In other words, if a certain snack contains 85 food calories, it actually contains $$85 \: \text{kcal}$$ or $$85,000 \: \text{cal}$$. In order to make the distinction, the dietary calorie is written with a capital C.

$1 \: \text{kilocalorie} = 1 \: \text{Calorie} = 1000 \: \text{calories}$

To say that the snack "contains" 85 Calories means that $$85 \: \text{kcal}$$ of energy are released when that snack is processed by the human body.

Heat changes in chemical reactions are typically measured in joules rather than calories. The conversion between a joule and a calorie is shown below.

$1 \: \text{J} = 0.2390 \: \text{cal or} \: 1 \: \text{cal} = 4.184 \: \text{J}$

We can calculate the amount of heat released in kilojoules when a 400 Calorie hamburger is digested:

$400. \: \text{Cal} = 400. \: \text{kcal} \times \frac{4.184 \: \text{kJ}}{1 \: \text{kcal}} = 1.67 \times 10^3 \: \text{kJ}$

## Summary

• Common units for heat include Joules (J)  and calories (cal); 1 cal = 1.184 J
• 1 food Calorie (Cal) = 1000 cal


text:
# How do you factor x^3-x^2-x+x?

${x}^{2} \left(x + 1\right)$
$- x + x = 0$ this leaves ${x}^{3} - {x}^{2} = {x}^{2} \left(x - 1\right)$


text:
# Explore a Klarner-Rado sequence [duplicate]

One of the Klarner-Rado sequences is defined as follows:

• the first term is $$\1\$$
• for all subsequent terms, the following rule applies: if $$\x\$$ is present, so are $$\2x+1\$$ and $$\3x+1\$$
• the sequence is strictly increasing

This is A002977.

The first few terms are:

1, 3, 4, 7, 9, 10, 13, 15, 19, 21, 22, 27, ...

($$\3\$$ is present because it's $$\2\times1+1\$$, $$\4\$$ is present because it's $$\3\times1+1\$$, $$\7\$$ is present because it's $$\2\times3+1\$$, etc.)

Given $$\n\$$, you must return the $$\n\$$th element of the sequence. You may use either 0-based or 1-based indexing. (Please specify your choice in your answer.)

0-indexed example:

input = 10
output = 22

Let's see who can get less bytes...

Also featured on codewars

## marked as duplicate by Grimmy, caird coinheringaahing, Luis Mendo, Wheat Wizard, Jonathan Allan code-golf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Oct 11 at 20:10

• Why is this tagged [javascript]? Is this restricted to it? How is this related to array manipulation and linear algebra? Does "ordered with <" mean "ascending"? – my pronoun is monicareinstate Oct 11 at 11:46
• @user89702 It's not yours, so you can't post it, especially without any attribution. – my pronoun is monicareinstate Oct 11 at 12:30
• However, I do believe this is a rather interesting challenge that would be worth rephrasing properly for Code Golf. There's nothing wrong on posting a challenge about this sequence (which is A002977, btw), but you can't copy from an external site without any authorization or credits. – Arnauld Oct 11 at 12:38
• I've rephrased your post so that it better fits our standard and is not a copy of codewars anymore. Feel free to edit further if needed. – Arnauld Oct 11 at 13:36
• @Graham, if you've taken the time to work up a solution then absolutely post it to the dupe target. If your solution cannot be trivially modified to fit the dupe target then you have a case to reopen this one and you should cast your vote accordingly. – Shaggy Oct 12 at 0:38

# 05AB1E, 15 14 bytes

\$FDx>DŠ+)˜ê}sè

Try it online!

• Times out for me on TIO for inputs of 14 and above – Graham Oct 11 at 16:29
• @Graham Well this is code golf, not fastest code, so that’s not an issue. – Grimmy Oct 11 at 17:18
• @Graham, for the purposes of code golf, we may assume infinite memory & time. – Shaggy Oct 11 at 18:28
• @Grimy Thanks to you and Shaggy for this information which I had not appreciated. All solutions I have offered in the past have worked efficiently within the capabilities of my machine. This opens up some wacky impractical solutions ;) – Graham Oct 11 at 18:40

# JavaScript (ES6),  53  50 bytes

1-indexed.

n=>(g=k=>n?g(g[k]|!k++?g[n--,k*2]=g[k*3]=k:k):k)

Try it online!

### Commented

Note: On the first iteration, we have k = [''], which is zero-ish but truthy. By doing !k++, we force k to be coerced to $$\0\$$ right away (and not just before it's incremented), which makes the test work as expected.

n => (                    // n = requested index
g = k =>                // h is a recursive function taking k, starting at 0
n ?                   // if n is not equal to 0:
g(                  //   do a recursive call:
g[k] |            //     if g[k] is defined
!k++ ?            //     or k = 0 (increment k after the test):
g[n--, k * 2] = //       decrement n; set g[k * 2]
g[k * 3] = k    //       and g[k * 3] and pass k
:                 //     else:
k               //       just pass k
)                   //   end of recursive call
:                     // else:
k                   //   stop recursion and return k
)                       // initial call to g with k = [''] (zero-ish)

# JavaScript (ES6), 65 bytes

I thought the '11'[k/x-2] trick was neat, but overall this initial approach is far too long.

0-indexed.

n=>(g=k=>a[n]||g(-~k,a.some(x=>'11'[k/x-2])&&a.push(k+1)))(a=[1])

Try it online!

### Commented

n => (                  // n = requested index
g = k =>              // g is a recursive function taking k (starting at 1)
a[n] ||             // if a[n] is defined, return it and stop
g(                  // otherwise, do a recursive call:
-~k,              //   with k + 1
a.some(x =>       //   if there exists some x in a[]
'11'[k / x - 2] //   such that k / x is either 2 or 3 ...
)                 //
&& a.push(k + 1)  //   ... then push k + 1 in a[]
)                   // end of recursive call
)(a = [1])              // initial call to g with k = a = [1]

# R, 57 bytes

n=scan();for(i in 1:n)T=sort(unique(c(T,T%o%2:3+1)));T[n]

Try it online!

1-based index.

# APL+WIN, 54 bytes

Index origin 1

Prompts for the index of required value. Given the response that I received from Grimy and Shaggy that I can assume infinite memory and time then it is trivial to modify this function to work with a series up to the limit of your machine by increasing the value 20 in the function below. This version is limited to index position 1901981

m←1⋄(⍎∊20⍴⊂'m←(0≠1,-2-/m)/m←m[⍋m←m,∊1+m×¨⊂2 3]⋄')⋄m[⎕]

For some reason this function will not run on Dyalog Classic in TIO which is what I usually use.

On my machine 1 => 1, 11 => 22 and 61 => 237 (checked on http://oeis.org)

# JavaScript (ES6), 99 bytes

x=>eval("a=[i=1],a.b=a.includes;while(i++,c=i-1,x)a.b(i)||!a.b(c/2)&&!a.b(c/3)||(a.push(i),x--);c")

# Python 3, 73 bytes

f=lambda n,i=0,k=[1]:(i==n)*k[i]or f(n,i+1,sorted(k+[2*k[i]+1,3*k[i]+1]))

Try it online!


text:
# 9.10. Traversal and the for Loop: By Item¶

A lot of computations involve processing a collection one item at a time. For strings this means that we would like to process one character at a time. Often we start at the beginning, select each character in turn, do something to it, and continue until the end. This pattern of processing is called a traversal.

We have previously seen that the for statement can iterate over the items of a sequence (a list of names in the case below).

Recall that the loop variable takes on each value in the sequence of names. The body is performed once for each name. The same was true for the sequence of integers created by the range function.

Since a string is simply a sequence of characters, the for loop iterates over each character automatically.

The loop variable achar is automatically reassigned each character in the string “Go Spot Go”. We will refer to this type of sequence iteration as iteration by item. Note that it is only possible to process the characters one at a time from left to right.

strings-10-1: How many times is the word HELLO printed by the following statements?

s = "python rocks"
for ch in s:
print("HELLO")

• 10
• Iteration by item will process once for each item in the sequence.
• 11
• The blank is part of the sequence.
• 12
• Yes, there are 12 characters, including the blank.
• Error, the for statement needs to use the range function.
• The for statement can iterate over a sequence item by item.

strings-10-2: How many times is the word HELLO printed by the following statements?

s = "python rocks"
for ch in s[3:8]:
print("HELLO")

• 4
• Slice returns a sequence that can be iterated over.
• 5
• Yes, The blank is part of the sequence returned by slice
• 6
• Check the result of s[3:8]. It does not include the item at index 8.
• Error, the for statement cannot use slice.
• Slice returns a sequence.
Next Section - 9.11. Traversal and the for Loop: By Index


text:
# Why do some equations or inequalities have no solution?

I've seen some equations and inequalities that have no solution. Examples of these are$$3m+4=3m-9$$$$128y-10\lt128y-25$$$$10t+45\ge2(5t+23)$$The third example evaluates to$$10t+45\ge10t+46$$using the Distributive Property. Maybe they have no solution because the coefficients of the variables are the same on both sides on each example, but the constants don't make sense on both sides according to the symbols in between the expressions. I hope I'm on the right track about why these have no solutions! I have a good taste in your answers!

• I don't know why this things disturbs you? There are a lot of equations and inequalities that have no solutions. – brick Oct 28 '14 at 23:06

Have a look here for Inequality Properties, it is important to grasp the concepts early for this.

Basically, you can say, if:

$10t+45\geq10t+46$

Then, by subtracting $10t$ from both sides:

$10t+45-10t\geq10t+46-10t$

We'd get:

$45\geq46$

Which, as we know, is a false statement. There is no value (or range of values) for $t$ to make the original inequality true.

• Well, 45 is never greater than or equal to 46, so it'll always be unequal. So, this inequality has no solution. – Mathster Oct 28 '14 at 23:36

You can clearly cancel out the terms that exists on both sides:

For example: $3m + 4 = 3m - 9$ is equivalent to $4 = -9$ which which is not true for all $m$.

Same goes for other equations/inequalities that you have mentioned.

• Yeah, that might be right, right? You just subtracted $3m$ from both sides, which gets rid of both of those terms and leaves you with 4=-9, which isn't true. – Mathster Oct 28 '14 at 23:10


text:
# Required sample size in internal audit

In applied literature about the required sample size such as "Sampling for effective internal auditing" we find formulas for the required sample size to detect a proportion of a feature or an error rate as (I cite and use the same variable names) $$n = \frac{C^2 \rho q}{P^2},$$ where $$n$$ is the required sample size, $$C$$ is the confidence level, $$P$$ is some measure of precision, $$\rho = 1-q$$ is the expected error rate.

Where do these formulas from auditing come from? I understand that their origin must be some Binomial distribution consideration with normal approximation.

Is there a publication where these sample size requirements are derived in a rigorous mathematical way? I find quite a few publications citing formulae as the above but what is a good source for at the same time a rigorous mathematical treatment and applications in audit?

I am not familiar with the literature for interal auditing, but this looks quite similar to Normal approximation/Wald confidence interval (see wikipedia) and was published in
Laplace, Pierre Simon (1812). Théorie analytique des probabilités (in French). p. 283. For a newer article about some of its problems: Brown, Lawrence D.; Cai, T. Tony; DasGupta, Anirban. Interval Estimation for a Binomial Proportion. Statist. Sci. 16 (2001), no. 2, 101--133. doi:10.1214/ss/1009213286. https://projecteuclid.org/euclid.ss/1009213286

For a specific citation for Audits somebody else might be able to help.
The formula of the Normal approximation interval is as follows : $$p=\hat{p}\pm z*\sqrt{\dfrac{p(1-p)}n}$$

if we subtract $$\hat{p}$$ and square afterwards we get: $$(p-\hat{p})²=\dfrac{z^2 *p(1-p)}n$$

Now we solve for n: $$n= \dfrac{z^2 *p(1-p)}{(p-\hat{p})²}$$

This is exactly your formula. $$z^2$$ is $$C^2$$ and $$(p-\hat{p})^2$$ is $$P^2$$ in your equation

• Thanks for this reference! Thus if I expect and error rate $p$ (e.g. $5\%$) and I want to detect differences on a sample with confidence related to the normal quantile $z$ (e.g. $95\%$ and $z = z_{0.95}$) and I tolerate some error $P = \hat{p}-p$ (e.g. $6\%-5\%$) then I need a sample size of $n$ as calculated above ... does this make sense? – Ric Oct 16 '19 at 19:17
• @Ric yes that makes sense! However, i confused the name of the interval. It is the normal approximation interval. I changed it above and also edited the correct citations. You should note, that the approximation interval tends to be less reliable for small n or extreme high or low p. (see the see the Brown et al. article above). Therefore, your estimated n might also be unreliable in these cases. – Mr Pi Oct 16 '19 at 19:37