text:
# Beginner error messages in C++ vs Haskell

posted on 2014-09-17 by Paul Starkey

Learning Haskell was excruciating. The error messages from the Haskell compiler ghc were way more difficult to understand than the error messages I was used to from g++. I admit I’m still a novice programmer: My only experience is a year of classes in C++ programming. But the Haskell compiler should do a better job generating error messages for beginners like me.

First we’ll see four concrete examples of ghc doing worse than g++, then Mike will talk about some ways to fix ghc’s error messages.

### Example 1

Below are two equivalent C++ and Haskell programs. I’ve intentionally added some syntax errors:

    /* C++ Code */
#include <iostream>

using namespace std;

int main ()
{
int in = -1;
cout << "Please choose 1 for a message" << endl;
cin >> in;
err->   if in == 1
{
cout << "Hello, World!" << endl;
}
else{
cout << "Error, wrong choice" << endl;
}
return 0;
}
    {- Haskell Code -}
main = do
putStrLn "Please enter 1 for a message"
num <- getLine
if num == "1"
then do
putStrLn "Hello, World"
err->
putStrLn "Error, wrong choice"

Alright, so the first notable difference is that the Haskell code is much shorter. It takes up roughly half the space that the C++ code does, yet they both output hello world when the correct number is entered.

Great!

Haskell already seems better, right?

Wrong!

Notice how I messed up the if statement in both programs. In the C++ version, I forgot the parentheses, and in the Haskell version I forgot the else. Both omissions are simple mistakes that I’ve made while learning these languages.

Now let’s see the error messages:

    -- C++ Error --
main.cpp: In function 'int main()':
main.cpp:15:5: error: expected '(' before 'in'
main.cpp:19:2: error: 'else' without a previous 'if'
Compilation failed.
    -- Haskell Error --
[..]main.hs:19:1:
parse error (possibly incorrect indentation or mismatched brackets)
Failed, modules loaded: none.

Both error messages let the programmer know where the mistake happened, but the g++ message is far more helpful. It tells us how to fix the syntax error by adding some missing parentheses. Bam! Problem solved.

Now let us turn to ghc’s output. Okay, something about a parse error… might have indentation errors… and no modules loaded. Cool. Now I’ve never taken a compiler course, so I don’t know what parse error means, and I have no idea how to fix it. The error message is simply not helpful.

### Example 2

Here’s another example of parsing errors.

        /* C++ Code */
#include <iostream>

using namespace std;

int main()
{
err->       string in = ""
cout << "Please enter a single word and get the string size back" << endl;
cin >> in;

cout << "The size of your word, \"" << in << "\", is "
<< in.length() << "!" << endl;
return 0;
}
        {- Haskell Code -}
err->   main = {-do-}
putStrLn "Please enter a single word and get the string size back"
num <- getLine
let size = length num
putStrLn $"The size of your word, \"" ++ num ++ "\", is " ++ show size ++ "!" As you can see, in the C++ I forgot to include a semicolon and in the Haskell I forgot the do in main. As a beginner, I’ve personally made both of these mistakes. Here are the error messages:  -- C++ Error -- main.cpp:8:2: error: expected ',' or ';' before 'cout' Compilation failed.  -- Haskell Error -- [..]main.hs:4:13: parse error on input '<-' Failed, modules loaded: none. C++ delivers a clear message explaining how to fix the error. Haskell, however, is not so helpful. It says there’s a parse error on the input operator. How should I know this is related to a missing do? ### Example 3 Next let’s see what happens when you call the built-in strlen and length functions with no arguments at all.  /* C++ Code */ #include <iostream> #include <cstring> using namespace std; int main (){ char input[256]; cout << "Please enter a word" << endl; cin >> input; err-> cout << "The size of your string is: " << (unsigned)strlen(); cout << "!" << endl; return 0; }  {- Haskell Code -} main = do putStrLn "Please enter a word" num <- getLine err-> let size = length putStrLn$ "The size of your string is: " ++ show size ++ "!"

Now let us see the different error messages that are produced:

    -- C++ Error --
main.cpp: In function 'int main()':
main.cpp:11:61: error: too few arguments to function 'size_t_strlen(const char*)'
Compilation failed.
    -- Haskell Error --
[..]main.hs:7:36:
No instance for (Show ([a0]->Int)) arising from a use of 'show'
Possile fix: add an instance declaration for (Show ([a0]->Int))
In the first argument of '(++)', namely 'show size'
In the second argument of '(++)', namely 'show size ++ "!"'
In the second argument of '(++)', namely
'"\", is " ++ show size ++ "!"'
Failed, modules loaded:none.

Once again, it appears that the C++ compiler g++ knew exactly what was wrong with the code and how to fix the error. It tells me that there are not enough arguments in my function call.

Wow, Hakell’s error message is quite the mouthful this time. I suppose this is better than just a parse error message, but I’m not sure what exactly ghc is even wanting me to correct. The error is simply too technical to help me.

### Example 4

Next, we will look at what happens when you pass too many arguments to functions in both languages:

    /* C++ Code */
#include <iostream>
using namespace std;

int main () {
string in[256];
cout << "Please enter a single word to get the string size back" << endl;
cin >> in;

err->   cout << "The size of your string, \"" << in << "\", is " << (unsigned)strlen(in, in);
cout << "!" << endl;
return 0;
}
    {- Haskell Code -}
main = do
putStrLn "Please enter a single word to get the string size back"
num <- getLine
err->   let size = length num num
putStrLn \$ "The size of your string, \"" ++ num ++ "\", is " ++ show size ++ "!"

And the errors:

    -- C++ Error --
main.cpp:16:78: error: too many arguments to function 'int newLength(std::string)'
main.cpp:6:5: note: declared here
Compilation failed.
    -- Haskell Error --
Couldn't match expected type 'String -> t0' with actual type 'Int'
The function 'length' is applied to two arguments,
but its type '[Char] -> Int' has only one
In the expression: length num num
In an equation for 'size':size = length num num
Failed, modules loaded: none.

The C++ error clearly explains how to fix the code, and I even understand the Haskell error this time. Both languages tell me that there are too many arguments. Yet the C++ error message tells me this without a bunch of technical jargon. So even when Haskell is actually helpful with its error messages, it still manages to hide what it wants the user to do.

### Conclusion

To me, Haskell seems like a language only for experienced programmers because the errors are not user-friendly. How can I write code if a few simple mistakes cripple my progress? Haskell’s compiler ghc simply lags behind g++ in terms of useful error messages for beginners.

## Mike’s Epilogue

I’ve created a patch for ghc that clarifies the specific error messages that Paul had trouble with (and a few related ones). In particular:

1. Anytime there is a parse error caused by a malformed if, case, lambda, or (non-monadic) let, ghc will now remind the programmer of the correct syntax. In the first example Paul gives above, we would get the much clearer:

parse error in if statement: missing required else clause
2. To help with the second example, anytime ghc encounters a parse error caused by a <- token, it now outputs the hint:

Perhaps this statement should be within a 'do' block?
3. The third example Paul points out comes from the type checker, rather than the parser. It’s a little less obvious how to provide good hints here. My idea is based on the fact that it is fairly rare for functions to be instances of type classes. The only example I know of is the Monad instance for (a->).

Therefore, if the type checker can’t find an instance for a function, the more likely scenario is that the programmer simply did not pass enough parameters to the function. My proposed change is that in this situation, ghc would output the hint:

maybe you haven't applied enough arguments to a function?

This patch doesn’t completely fix ghc’s problem with poor error messages. For example, it doesn’t address Paul’s last point about type errors being verbose. But hopefully it will make it a little easier for aspiring haskellers who still aren’t familiar with all the syntax rules.


text:
# Doubt in resolving forces of a man in an elevator(normal force and weight)

1. Jul 10, 2012

### mutineer123

(Before I start, due to the use of vectors let me state I consider up to be positive and down to be negative)
Imagine a scenario, of a man in an elevator. And the elevator is accelerating upwards. Now in this case the Normal force > weight. So Normal Force - Weight =mass X acceleration. If you think this is right, why? Shouldn't it become Normal Force + Weight = mass X acceleration, because for weight(mg) the g will be -9.8 and hence -m X -9.8, will give you a positive value of
weight. I know its prolly wrong, because it would be insane to add Force and weight when their difference is what gives me the acceleration upwards, but then again why exactly is -9.8 wrong?

2. Jul 10, 2012

### azizlwl

Mass is scalar.
How mass becomes -m?

3. Jul 10, 2012

### Staff: Mentor

The best way to see it is as a vector equation:
ƩF = Normal Force + Weight = ma
Where 'normal force' and 'weight' are vectors.

Let the magnitude of the normal force be called N; the magnitude of the weight is mg, where g = 9.8 m/s^2. (FYI: g does not have a minus sign!) Now using your sign convention, we can rewrite that vector equation as:
ƩF = N -mg = ma
or N = mg + ma

4. Jul 10, 2012

### mutineer123

it is -(m x -g) which will become +mg

5. Jul 10, 2012

### mutineer123

(FYI: g does not have a minus sign!)
Why not?? It should, considering gravity is acting downwards!!

6. Jul 10, 2012

### A.T.

The constant g is a magnitude, not a vector.

7. Jul 10, 2012

### Staff: Mentor

As A.T. explained, g is just the magnitude of the acceleration due to gravity--it does not have a sign. The full acceleration due to gravity with its appropriate sign would be -g. (Using up as positive.)

The weight of the man is a downward force of magnitude mg. So using your sign convention you'd express that as -mg.

8. Jul 10, 2012

### xAxis

Hmm..Usually in these situations when many people try to help, simple things get confusing.
The OP chose the convention that up is positive. The forces are: normal-N, weight-W.
Normal force acts on the body up, so N is positive. Weight acts downwards, so W is negative. And as the mass is always positive scalar, g is negative.
So W=-9.81m.
So I think, as Doc Al already pointed out, the best way to do similar problems is to first write down the force law vectorialy. And there there is a sum of vectors.
Than as a second step you resolve the signs

9. Jul 10, 2012

### mutineer123

You are saying W=(-9.81m). Right? So now If i plug it into the equatio of N-W=ma won't I end up with N+W=ma ?? And maybe I know this already, but what exactly is the force law?

10. Jul 10, 2012

### mutineer123

he full acceleration due to gravity with its appropriate sign would be -g. So why are we not using the this? If it were then we would get (-W), and if we plug this value into the equation
N-W= ma we would get N-(-W)=ma which would become N+W=ma. My method is to first find why the elevator is accelerating and hence get an appropriate equation(which I have done:N-W= ma). My next step is to plug in those values(with their vectorial signs), here is where I am stuck, as it become N + W.

11. Jul 10, 2012

### cepheid

Staff Emeritus
Start with Newton's second law of motion: the sum of vertical forces is equal to mass times the acceleration. Note that this is a vector sum, which means that for a 1D problem, you have to take the sign of the force (up being positive and down being negative) into account.

One of the points that others have been trying to make to you in this thread is that most people define the constant g as g = +9.81 m/s2, in which case the acceleration due to gravity is -g, and the weight is -mg. Keeping this in mind:

ƩF = ma

Fnorm + Fgrav = ma

N - mg = ma

N = ma + mg

The *magnitude* of the normal force is equal to the *magnitude* of the weight plus the magnitude of the net force.

EDIT: If you want to use the notation "W" for Fgrav, and N for Fnorm, that's fine. I myself switched to N halfway through to save typing.

EDIT: I typed this before seeing that Doc Al typed nearly the exact same thing.

12. Jul 10, 2012

### azizlwl

F1+F2=ma is the standard equation if we do not know the direction of the vector.
If W is in direction of N, which means added force, your equation still subracting.
It means your equation N-W=ma to be standard form is wrong.
Substituting N and F2=-W for the case on acceleration upward.
N+(-W)=ma

Last edited: Jul 10, 2012
13. Jul 10, 2012

### pgardn

How about you just use forces as vectors. The net force, ma, is up because he is acclerating up. This is a positive number. Now what were the actual forces involved in accelerating the man up. Well, the earth is always pulling down on him with a force of mg. So mg is down. The normal force from the elevator floor on the man is up, so N is up positive. If you have one vector up, N, and another vector down, mg, what is the resultant vector?

Its ma which is up. If you add the forces acting on the man you get N + (-mg) = ma If he was accelerating down you would get N + (-mg) = -ma. If he is not accelerating you get N + (-mg) = 0 oh and mg = W

You are adding the Force vectors that are pointing in opposing directions on the man and getting a resultant that also has magnitude and direction.

If you write N + W you are basically stating that both the normal force and weight are acting up? thats not what is happening.

You might be best served by drawing a free body diagram and just work with forces as vectors.

I apologize to others that have basically stated the same thing.

Last edited: Jul 10, 2012
14. Jul 10, 2012

### Puneeth423

infact g is a vector since its acceleration to gravity.

15. Jul 11, 2012

### A.T.

The constant g is the magnitude of that vector.

That is how g is generally defined in those formulas. It doesn't make sense to have the direction, which depends on an arbitrary axis orientation choice, included in a constant. Because then it is not a constant anymore, but depends on your axis orientation.

Last edited: Jul 11, 2012
16. Jul 11, 2012

### Puneeth423

Basic mistake you are doing is you are considering the direction of weight as negative two times. You are taking weight as negative in equation(N-W=ma) because the acceleration(g) in weight formulae(mg) is negative. When you take g already negative in representing weight how can you take again g as negative. Remember weight and g are same except that they change in magnitude due to multiplication of mass m, which have magnitude but no direction.

17. Jul 11, 2012

### sophiecentaur

I realise we are all starting from different standpoints but there is no way that the direction of the Weight force (mg) is in doubt and, as m is definitely a scalar, then g must involve direction - i.e. it must be a vector. Also, g is also an acceleration, which, by definition, is a Vector.

The only way an individual can sort this out in their minds is to draw a diagram of the forces involved and rigorously think in which direction they act. The equation of motion falls out of it. But you need to remember that the elevator is NOT in equilibrium if it is accelerating so you cannot write an equation based on that assumption.

This is precisely what you need to do and you need to be strictly consistent, once you have chosen the reference frame. If you are, then your answer will be correct. You can confirm what I say by doing the sums using 'up=positive' and 'down=positive'. You will get the same answer if you are rigorous.

18. Jul 11, 2012

### Staff: Mentor

The standard convention is to have g stand for the magnitude of the acceleration due to gravity. It has no direction; it's a constant, not a vector.

The acceleration of a falling object is a vector with magnitude g and direction down.

The weight of an object is a vector with magnitude mg and direction down.

Last edited: Jul 11, 2012
19. Jul 11, 2012

### sophiecentaur

I can't disagree totally but somewhere along the line you need a direction / vector. If you are doing a ballistics problem, would you not put an arrow on the 'g' acting on the projectile? In the SUVAT approach, wouldn't the value of acceleration be entered as g or -g depending on which way up you happened to be working? The fact is that you have to be aware of the direction if you want the right answer. 9.81ms-1 is not enough.
Perhaps I'm just saying that it could be confusing to treat g as positive, automatically and not be constantly aware of sign. But, if the 'm' in 'ms-1' is only distance and not displacement, by definition, then fair enough.

20. Jul 11, 2012

### Staff: Mentor

Sure. The acceleration of an object in free fall would be, using your sign convention, -g.
There's nothing in free fall in this problem. The only appearance of g in your problem is to give you the magnitude of the weight, mg.
As long as you insist on using the equation N-W = ma you'd better learn what the symbols stand for. In that equation, W stands for the magnitude of the weight. The downward direction is already incorporated in the minus sign.

Much better, in my opinion, is to learn the vector form of Newton's 2nd law as I describe in my first post. Then you'd really understand how things work.

21. Jul 11, 2012

### Staff: Mentor

Of course.
Of course not. g is a constant. The acceleration, a, would be written as $\vec{a}$. The magnitude of that vector would be g. Using the symbol g to represent the acceleration vector would be incredibly confusing.
Of course.
Of course.
One certainly needs to be aware of the direction of any vector quantity. Some books--like Halliday and Resnick--take great care to explicitly warn the student to not substitute -9.8 m/s^2 for g.

22. Jul 11, 2012

### A.T.

mg is the magnitude of the weight force. It doesn't have a direction. To get the weight force vector according to your specific coordinate system, you have to multiply your specific downwards unit vector with mg.

The general constant g=9.81m/s2 is by definition the magnitude of an acceleration vector.

23. Jul 11, 2012

### sophiecentaur

OK. We've gone over this enough. I think we are arguing more about notation than anything else. Yours seems to be more formal and 'correct'.

24. Jul 11, 2012

### xAxis

That's exactly what has been pointed out. The force law says that when more forces act on the body, it moves as if only one force acts on it. And that force is their resultant. That's why the equation of motion is ƩFi = ma. You don't subtract forces as you did in N-W=ma. You can check that this way, you will get the same result with any sign convention.

25. Jul 11, 2012

### pgardn

Jesus...

I cant imagine whats going to happen when this poor person tries to get an equation for an attwood machine... or a person standing in a device attached to a pulley with the person holding one rope of the pulley.

Free body diagram and then learning how to add vectors after establishing which direction is positive and negative suggested again.

format: plain


text:
# How do you simplify 9m (m + n + 1) - 8 (m^2 + m - n)?

I found: ${m}^{2} + m + 8 n + 9 m n$
$= 9 {m}^{2} + 9 m n + 9 m - 8 {m}^{2} - 8 m + 8 n =$
$= {m}^{2} + m + 8 n + 9 m n$


text:
Revision history [back]

fillPoly crashes

I have called

 std::vector< cv::Point > contour = contourIn; // initialization with input contour

fillPoly is crashing saying:

OpenCV Error: Assertion failed (i < 0) in getMat, file /home/stefan/git_repos/opencv/modules/core/src/matrix.cpp, line 963

Before I was having the same code, but I was calling the fillConvexPoly instead of fillPoly:

cv::Mat maskC(cv::Size(680, 480), CV_8UC1, cv::Scalar::all(0));
std::vector< cv::Point > contourCvx = convexingContour(contourIn); // initialization with the convex hull of the input contour

I am using this to create a mask of the contours interior. I have changed to fillPoly because the input contour is not always convex.


text:
# Function which is $2^n$ - periodic for all integers $n$

Is there a non-constant, continuous function $f: \mathbb{R} \longrightarrow \mathbb{R}$ such that for all integers $n$, $f$ is $2^n$-periodic?

Notes:

1. $n$ can be any integer, and so can be negative as well as positive.
2. If I did not require $f$ to be continuous, then I think $f: \mathbb{R} \longrightarrow \mathbb{R}$ defined by: $$f(x) = \begin{cases} 1 & \text{x rational} \\ 0 & \text{x irrational} \end{cases}$$ would do the trick.

No, such a function does not exist. Assume there are two points $x,y$ with $f(x)=a, f(y)=b, a \ne b$. The points with function value $a$ are dense in the real line because they include all offsets by any dyadic rational, so I can find one arbitrarily close to $y$.
Added: we can characterize the $2^n$ periodic functions. Define an equivalence relation on $\mathbb R$ by $x \sim y$ if $x-y$ is a dyadic rational. There are continuum many classes, each countable and dense. The function must be constant on any given class, but there is no restriction between the classes. That means there are as many $2^n$ periodic functions as all functions from $\mathbb R$ to $\mathbb R$
No such function exists. Suppose $f$ is non-constant, so we have some $a<b$ and $\epsilon>0$ such that $|f(a)-f(b)|>\epsilon$. By continuity, we have some $\delta>0$ such that $|x-y|<\delta\implies |f(x)-f(y)|<\epsilon$. Let $n\in\mathbb Z$ be such that $2^n<\delta$, and let $m=\lfloor|a-b|/2^n\rfloor$. Then we have \begin{align} |f(a)-f(b)|&\leq |f(a)-f(a+2^n)|+|f(a+2^n)-f(a+2\cdot 2^n)|+\cdots+|f(a+m\cdot 2^n)-f(b)|\\ &\leq |f(a+m\cdot 2^n)-f(b)|<\epsilon\\ \end{align} which is a contradiction.


text:
# Is the compositum of $L_1$ and $L_2$ equal to $L_1[L_2]$?

In a course about Galois theory, there is the following definition :

Let $L_1$ and $L_2$ be two subfields of the field $L$. We define the compositum $L_1L_2$ of $L_1$ and $L_2$ as the smallest subfield of $L$ containing $L_1$ and $L_2$, that is : $$L_1L_2 = L_2[L_1] = L_1[L_2]$$

So does that mean that $L_1[L_2] = L_1(L_2)$ ? I can't see why.

• How do you define $L_1(L_2)$? – Tobias Kildetoft May 11 '15 at 9:31
• $L_1(L_2)$ is the smallest subfield of $L$ containing $L_1$ and $L_2$, and $L_1[L_2]$ is the smallest $L_1$-subalgebra of $L$ containing $L_2$ – Segipp May 11 '15 at 9:33

In general, for a fields $K \subset L$, and $A \subset L$ the structures $K[A]$ and $K(A)$ are not the same, the former being the smallest ring, or also algebra if you prefer, containing $K$ and $A$ while the latter is the smallest field containing $K$ and $A$. These two can be different.
However, if $K \subset L$ is an extension of finite degree, more generally if it is algebraic, then in fact $K[A]=K(A)$. (As the inverse of $\alpha$ an algebraic element over $K$ is a polynomial expression in $\alpha$.)
• But is it still true when $A$ is a field and $K \subset L$ is not algebraic ? – Segipp May 11 '15 at 10:19
• No, in general this is not true. I did not check the details but $L_1 = Q(x)$ and $L_2 = Q(y)$ for "variables" $x,y$ should work as counter example. – quid May 11 '15 at 10:37
• Ok, so I think this is a counter-example : for $L_1 = K(X)$ and $L_2 = K(Y)$, $L_1L_2 = K(X,Y)$ but $L_1[L_2] = \lbrace P/(QR), P \in K(X,Y), Q \in K(X), R \in K(Y) \rbrace$ which does not contain $1/(X+Y)$. Is it correct ? – Segipp May 11 '15 at 10:37
• I think that $1/(x+y)$ is in $k(x)\bigl(k(y)\bigr)$, but not in $k(x)\bigl[k(y)\bigr]$. – Lubin May 12 '15 at 3:30


text:
# why does $\frac{df}{dz}=\frac{1}{2}\left ( \frac{\partial f}{\partial x}-i\frac{\partial f}{\partial y}\right )$, why the $\frac{1}{2}$?

I have trouble seeing where the $\frac{1}{2}$ comes from in $$\frac{df}{dz}=\frac{1}{2}\left ( \frac{\partial f}{\partial x}-i\frac{\partial f}{\partial y}\right )$$

For a change of variables $z=x+iy$ we have $$\frac{df}{dz}= \ \frac{\partial f}{\partial x}\frac{\partial x}{\partial z}+\frac{\partial f}{\partial y}\frac{\partial y}{\partial z}$$ and $\frac{\partial x}{\partial z}=1$ and $\frac{\partial y}{\partial z}=-i$. Therefore we have the above but without the $\frac{1}{2}$. I've seen someone derive the correct expression by including the change of variables for $\overline{z}$ however I don't see how that is necessary, it should work without, right? I don't know what I am missing?

Well it starts with the general formula for differential $$df = \frac{\partial f}{\partial x} dx + \frac{\partial f}{\partial y} dy.$$ In complex analysis we prefer to use $dz$ and $d\overline{z}$. So using, $dx = \dfrac{dz+d\overline{z}}{2}$ and $dy = \dfrac{dz-d\overline{z}}{2i},$ one finally gets $$df = \frac{1}{2}\left ( \frac{\partial f}{\partial x}-i\frac{\partial f}{\partial y}\right ) dz + \frac{1}{2}\left ( \frac{\partial f}{\partial x}+i\frac{\partial f}{\partial y}\right )d\overline{z}.$$ Now it is natural to define $\frac{\partial}{\partial z}$ to be $\frac{1}{2}\left ( \frac{\partial }{\partial x}-i\frac{\partial }{\partial y}\right )$ and $\frac{\partial}{\partial \overline{z}}$ to be $\frac{1}{2}\left ( \frac{\partial }{\partial x}+i\frac{\partial }{\partial y}\right )$. Thanks to that we have the beautiful formula $$df = \frac{\partial f}{\partial z} dz + \frac{\partial f}{\partial \overline{z}} d\overline{z}.$$
• How can I interpret $\frac{\partial f}{\partial x} dx$? What does $dx$ mean in that expression? – Hendrra Mar 27 '18 at 16:58
It is just a convention, there isn't a deep mathematical reason in the factor $\frac{1}{2}$.
I think the convention comes from $dz=dx+idy$(Usually we prefer $n$-forms rather than $n$-tensor of tangent vectors, aren't we?) and then taking dual basis.


text:
# Check if counter exists

I've written a package that introduces a new environment:

\newfloat{foo}{htb}{bar}[chapter]

The package however can be used for articles, books, ... Since not all of these environments have the concept of chapter, on gets a No counter 'chapter' defined. exception.

How can I check if the chapter counter is defined?

-

If a counter foo exists then a count \c@foo exists as well as a macro \thefoo. The \newcounter command (that most likely is used by \newfloat) actually checks if \c@foo exists and calls \@nocounterr{foo} if it doesn't.

The following also checks for \c@foo using etex's \ifcsname ...\endcsname:

\documentclass{article}

\makeatletter
\newcommand*\ifcounter[1]{%
\ifcsname c@#1\endcsname
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother

\begin{document}

Counter \texttt{chapter} \ifcounter{chapter}{exists}{doesn't exist}.

Counter \texttt{section} \ifcounter{section}{exists}{doesn't exist}.

\end{document}

-
\newcommand\ifcounter[3]{\@ifundefined{c@#1}{#3}{#2}} –  egreg Jan 24 '14 at 15:08
@egreg I know :) I just like \ifcsname a tiny bit better since it doesn't leave the command as \relax if it isn't defined –  clemens Jan 24 '14 at 15:10
\documentclass{article}
\usepackage{float}
\usepackage{etoolbox}
\ifdef{\thechapter}{\newfloat{foo}{htb}{bar}[chapter]}{}
\begin{document}%
x
\end{document}

-


text:
# Satisfiabilty 2-sat

Im trying to work out whether the following clause is satisfiable:

{x, y},{x,¬y},{¬x, y},{¬x,¬y},{x, z},{x,¬z},{y, z},{y,¬z}

My basic understanding is to work this out, you must give each literal a true or false assignment to work out if each clause is satisfiable so:

x=1, y=1, z=1,

{1,1}, {x,0}, {0,1}, {0,0}, {1,1}, {1,0}, {1,1}, {1,0}

Therefore the clause {x,y} and {x,z} are satisfiable?

I also heard you can switch the statement so:

x=1, y=0, z=1,

This means {x,y} is not satisfiable.

If we changed z to 0 as well {x,z} would not be satisfiable. What really confuses me here is when the truth assignments are changed, neither clauses are satisfiable.

Where am I going wrong?

You seem to assume that both literals in a clause must be true in order to satisfy the clause. However, it is sufficient that one of them is true. So with your first assignment all clauses but {¬x,¬y} are satisfied.
• A clause is a single group of literals like {x,y}. What you are trying to satisfy overall is a group of clauses or a formula.


text:
# Better way to calculate coordinates in Tikz?

I am great fan of pgf and tikz in general to produce great looking figures. But I don't like the amount of time I have to put in to draw a complicated picture, because I have to provide all the coordinates of the points lines etc. Is there any wrapper which makes this simpler? Like in some cases, eg when you have to put text over or around arrows, there are ways to give relative position instead of exact coordinates. Are there any similar ways to draw other shapes with relative coordinates? Is there any external program that can convert figures with lines and shapes into coordinates?

-

Complete LaTeX documents used to generate the figures in this answer are available as a Gist on GitHub.

One way to solve the "putting text over arrows" question is to use inline nodes and relative positioning:

\begin{tikzpicture}
\draw[->] (0,0) -- (5,0) node[above]{Hello, world!};
\end{tikzpicture}

You can also use named nodes and coordinates combined with relative positioning. A \coordinate is just like a \node without a text area (they may still have shapes). Naming your nodes and coordinates allows you to re-use information about their position without re-typing the locations. Using relative positioning constructs (provided by the TikZ positioning library), like left = 1ex of A, allows you to position nodes/coordinates relative to other nodes/coordinates without working out the mathematics and geometry in your head.

\begin{tikzpicture}[
Name/.style = {font={\bfseries}}
]

\coordinate (A) at (0,0);
%            ^---- A name for the node/coordinate
\coordinate (B) at (5,1);
\coordinate (C) at (3,4);

\draw (A) -- (B) -- (C)  -- cycle;

\node (A-label) [left=1ex of A, Name] {A};
\node (B-label) [right=1ex of B, Name] {B};
\node (C-label) [above=1ex of C, Name] {C};

\node [above left = 2 em of C] {This is a relatively positioned node!}
edge[out=270,in=180,thick,->] (C-label);

\end{tikzpicture}

See Tutorial 2 "A Petri-Net for Hagen" in the TikZ manual for an excellent step-by-step walkthrough of named nodes and relative positioning.

I prefer constructing figures using relative positioning as opposed to using a GUI program because I can change the look of the figure by adjusting the locations of a few "base coordinates". In this case, I could draw a completely different triangle by moving the locations of coordinates A, B and C and for most adjustments the rest of the figure would just fall into place. Learning to set up figures like this takes practice but once you get the it down it can save a bunch of time when it comes to fine-tuning the image when compared to a GUI program.

Finally, as to your question about GUI programs, I would recommend Inkscape- it is a very robust, open source editor for vector graphics that is similar to Adobe Illustrator. There is even a plugin available that generates TikZ code from Inkscape graphics.

-
I have edited the question to remove some confusion in the wording of my question. Thanks for the descriptive answer. I will give Inkscape a try too. –  Dash Aug 6 '10 at 22:32

jpgfdraw is a tool for freehand drawing and exporting to pgf. Perhaps see this jpgfdraw example, exported to pgf/tex and used with \input.

Perhaps you could combine a freehand drawing with additional TikZ drawings.

-
I was not aware of jpgfdraw. I will give it a try too. –  Dash Aug 6 '10 at 22:33
Bad name choice. I first thought that the tool exported to JPG! –  Roberto Bonvallet Nov 16 '10 at 19:40

I think you need to be more specific in what you want to do. There are numerous ways to make relative coordinates in TikZ. Here are some Examples:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\fill (1,1) circle (2pt) node[above] (O) {Start};
\draw (O) -- (2,2);   % absolute
\draw (O) --++ (3,2); % relative
\node[left=2cm] at (O) {Left}; % relative
\end{tikzpicture}

\end{document}

Check out http://www.texample.net/tikz/ for a lot of excellent examples of how to draw with TikZ.

-
Thanks a lot. I was not aware of the --++ technique. I agree that texample is fantastic site I regularly use code from there. –  Dash Aug 6 '10 at 22:30

There is a plugin for Inkscape, inkscape2tikz, that allows you to export TikZ code from Inkscape. It's been mentioned a few times already on other questions on this site.

-

\documentclass[11pt]{scrartcl}
\usepackage[utf8x]{inputenc}
\usepackage[upright]{fourier}
\usepackage{tikz,amsmath}
\usetikzlibrary{arrows,calc,shapes,decorations.pathreplacing}

\begin{document}
\begin{tikzpicture}

\node at (0,0) {$F : I \times I \rightarrow X$};
\node[label=below:$x_1$]  (x1) at (6,0)  {$\bullet$};
\node[label=above:$x_0$]  (x0) at (9,4)  {$\bullet$};
\node  at (9.5,2)  {$\subset X$};
\draw (x1.center) to [out=5,in=-90]++(2.8,1.8) to[out=90,in=-95](x0.center);
\draw (x1.center) to [out=10,in=-110]++(2.6,2) to[out=70,in=-103](x0.center);
\draw (x1.center) to [out=15,in=-105](x0.center);
\draw (x1.center) to [out=30,in=-150](x0.center);
\draw (x1.center) to [out=45,in=-170](x0.center);
\draw (x1.center) to [out=50,in=-105]++(1.2,3)to [out=75,in=-172](x0.center);
\draw (x1.center) to [out=55,in=-100]++(1.0,3) to[out=80,in=-175](x0.center);
\draw (x1.center) to [out=60,in=-90]++(0.8,3) to[out=90,in=-180] (x0.center);

\begin{scope}[every node/.style={draw, anchor=text, rectangle split, rectangle split parts=7,minimum width=2cm}]
\node (R) at (2,4){ \nodepart{two} \nodepart{three}\nodepart{four}$I\times I$\nodepart{five}\nodepart{six}\nodepart{seven}};
\end{scope}
\draw[decorate,decoration={brace,mirror,raise=6pt,amplitude=10pt}, thick] (R.north west)--(R.south west) ;
\draw[decorate,decoration={brace,raise=6pt,amplitude=10pt}, thick] (R.north east)--(R.south east);
\draw[->] ($(R.west)+(-20pt,0)$) to[out=-180,in=240] ++(0,2) to [out=60,in=120]node[above,midway]{$F(0,t_2)$}(x0) ;
\draw[->] ($(R.north)+(0,10pt)$) to [out=60,in=120]node[above,midway]{$\beta \simeq \alpha$} ++(4.5,-1) ;
\draw[->] ($(R.east)+(20pt,0)$)  to [out=0,in=140]node[right,midway]{$F(1,t_2)$}(x1) ;
\draw[->] ($(R.south)+(0,-20pt)$)  to [out=-85,in=-30]node[below,midway]{$\alpha$}++(7,0) ;
\end{tikzpicture}
\end{document}

-
@Stefan I added this version of your example –  Alain Matthes Jun 21 '11 at 20:59
Very nice and elegant! I added it to the example gallery: Homotopy of paths with TikZ. –  Stefan Kottwitz Dec 31 '11 at 21:04
Tanks Stefan and happy new year ! –  Alain Matthes Jan 1 '12 at 9:04


text:
## Found 538 Documents (Results 1–100)

100
MathJax

MSC:  49J45
Full Text:

### Global solutions of the Cauchy problem to Euler-Poisson equations of two-carrier types. (English)Zbl 07540966

MSC:  35Qxx 65-XX
Full Text:

Full Text:

Full Text:

Full Text:

### Fast rotation limit for the 2-D non-homogeneous incompressible Euler equations. (English)Zbl 07496971

MSC:  35Qxx 76Uxx 35Bxx
Full Text:

### Global weak solutions to the Euler-Vlasov equations with finite energy. (English)Zbl 07471743

MSC:  35Q31 35Q35 35Q83 54D30 74G25
Full Text:

Full Text:

### Cauchy problem for isothermal system in a general nozzle with space-dependent friction. (English)Zbl 1485.76071

MSC:  76N15 35Q35
Full Text:

### Global solutions to isothermal system with source. (English)Zbl 07498602

MSC:  35L45 35L60 35Q35
Full Text:

Full Text:

Full Text:

Full Text:

### Global entropy solutions for systems modelling polymer flooding in enhanced oil recovery. (English)Zbl 07413891

MSC:  82-XX 35-XX
Full Text:

Full Text:

### Singular limits with vanishing viscosity for nonlocal conservation laws. (English)Zbl 1470.35231

MSC:  35L65 35L45 76A30
Full Text:

Full Text:

### Weak solutions for compressible Navier-Stokes-Fourier system in two space dimensions with adiabatic exponent almost one. (English)Zbl 1469.76095

MSC:  76N10 76N06 35Q30
Full Text:

Full Text:

### Large-time behavior of entropy solutions to bipolar hydrodynamic model for semiconductors. (English)Zbl 1468.35018

MSC:  35B40 35D30 35Q60
Full Text:

### On the selection of measure-valued solutions for the isentropic Euler system. (English)Zbl 1462.35269

MSC:  35Q31 35D30
Full Text:

### Partial regularity of solutions to a linear elliptic system with quadratic Jacobian structure. (English)Zbl 1450.35095

MSC:  35B65 35J47 35D30
Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

### Global entropy solutions to the compressible Euler equations in the isentropic nozzle flow. (English)Zbl 1460.35068

Bressan, Alberto (ed.) et al., Hyperbolic problems: theory, numerics, applications. Proceedings of the 17th international conference, HYP2018, Pennsylvania State University, University Park, PA, USA, June 25–29, 2018. Springfield, MO: American Institute of Mathematical Sciences (AIMS). AIMS Ser. Appl. Math. 10, 666-673 (2020).

### A global div-curl-lemma for mixed boundary conditions in weak Lipschitz domains. (English)Zbl 1459.35086

Dörfler, Willy (ed.) et al., Mathematics of wave phenomena. Selected papers based on the presentations at the conference, Karlsruhe, Germany, July 23–27, 2018. Cham: Birkhäuser. Trends Math., 243-250 (2020).
MSC:  35F35 35A27 58A12
Full Text:

Full Text:

Full Text:

### Homogenization of multivalued monotone operators with variable growth exponent. (English)Zbl 1448.35198

MSC:  35J60 35J57 35J99
Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

### On the existence of $$C^{1,1}$$-isometric immersions of several classes of negatively curved surfaces into $$\mathbb{R}^3$$. (English)Zbl 1439.53011

MSC:  53A10 53A05
Full Text:

Full Text:

### Global $$L^\infty$$ solutions to system of isentropic gas dynamics in a divergent nozzle with friction. (English)Zbl 07550973

MSC:  35L45 35L60 46T99
Full Text:

### Weak solutions for the systems of multifluid flows. (Chinese. English summary)Zbl 1449.35167

MSC:  35D30 76N10

Full Text:

Full Text:

Full Text:

Full Text:

### Vanishing viscosity for traffic on networks with degenerate diffusivity. (English)Zbl 1425.90025

MSC:  90B20 35L65
Full Text:

### On weak closure of some diffusion equations. (English)Zbl 1439.35499

MSC:  35Q99 35B35 49J45
Full Text:

Full Text:

Full Text:

### A note on the convergence of the solution of the Novikov equation. (English)Zbl 1416.35084

MSC:  35G25 35L65 35L05
Full Text:

Full Text:

### Existence of global $$L^\infty$$ solutions to a generalized $$n \times n$$ hyperbolic system of leroux type. (English)Zbl 1438.35272

MSC:  35L65 35L67 35L60
Full Text:

### The existence of global entropy solutions to the one-dimensional equations in radiation hydrodynamics. (Chinese. English summary)Zbl 1424.76030

MSC:  76N10 35Q35
Full Text:

### On the two-state problem for general differential operators. (English)Zbl 1403.35335

MSC:  35R70 47F05
Full Text:

### The initial-boundary-value problem for an Ostrovsky-Hunter type equation. (English)Zbl 1402.35086

Gesztesy, Fritz (ed.) et al., Non-linear partial differential equations, mathematical physics, and stochastic analysis. The Helge Holden anniversary volume on the occasion of his 60th birthday. Based on the presentations at the conference ‘Non-linear PDEs, mathematical physics and stochastic analysis’, NTNU, Trondheim, Norway, July 4–7, 2016. Zürich: European Mathematical Society (EMS) (ISBN 978-3-03719-186-6/hbk; 978-3-03719-686-1/ebook). EMS Series of Congress Reports, 97-109 (2018).
MSC:  35G31 35B45
Full Text:

### Compensated compactness in Banach spaces and weak rigidity of isometric immersions of manifolds. (English)Zbl 1410.46013

Gesztesy, Fritz (ed.) et al., Non-linear partial differential equations, mathematical physics, and stochastic analysis. The Helge Holden anniversary volume on the occasion of his 60th birthday. Based on the presentations at the conference ‘Non-linear PDEs, mathematical physics and stochastic analysis’, NTNU, Trondheim, Norway, July 4–7, 2016. Zürich: European Mathematical Society (EMS). EMS Ser. Congr. Rep., 73-95 (2018).
MSC:  46B50 53C24
Full Text:

### Hydrodynamic limit for an anharmonic chain under boundary tension. (English)Zbl 1409.60146

MSC:  60K35 82C22
Full Text:

### A functional analytic perspective to the div-curl lemma. (English)Zbl 1413.35020

MSC:  35A15 35A23 46E35
Full Text:

Full Text:

Full Text:

Full Text:

### Global weak solutions for the chromatography system. (English)Zbl 1394.35277

MSC:  35L65 35D30 35L45
Full Text:

Full Text:

### Existence and nonexistence theorems of global weak solutions to degenerate quasilinear wave equations for the elasticity. (English)Zbl 06892649

MSC:  35-XX 34-XX
Full Text:

### Existence of global $$L^p$$ solutions to a system of conservation laws in chromatography with geometry effects. (English)Zbl 06889447

MSC:  35-XX 76-XX
Full Text:

Full Text:

### A note on convergence of the solutions of Benjamin-Bona-Mahony type equations. (English)Zbl 1382.35081

MSC:  35G25 35B25
Full Text:

Full Text:

Full Text:

### Homogenization of degenerate quasilinear elliptic equations. (Chinese. English summary)Zbl 1399.35062

MSC:  35B27 35J62 35J70

### On the convergence of the modified Rosenau and the modified Benjamin-Bona-Mahony equations. (English)Zbl 1393.35202

MSC:  35Q53 35B45
Full Text:

### Introduction to homogenization theory. (English)Zbl 1392.35001

Albeverio, Sergio (ed.) et al., Stochastic geometric mechanics. CIB, Lausanne, Switzerland, January–June 2015. Cham: Springer (ISBN 978-3-319-63452-4/hbk; 978-3-319-63453-1/ebook). Springer Proceedings in Mathematics & Statistics 202, 191-218 (2017).
MSC:  35-02 35B27
Full Text:

Full Text:

### A singular limit problem for conservation laws related to the Rosenau equation. (English)Zbl 1377.35013

MSC:  35B25 35G25 35L65
Full Text:

Full Text:

### Global existence of weak solutions for $$n \times n$$ system of chromatography. (English)Zbl 1379.35188

MSC:  35L65 35D40
Full Text:

### Global entropy solutions to the compressible Euler equations in the isentropic nozzle flow for large data. Application of the generalized invariant regions and the modified Godunov scheme. (English)Zbl 1394.35340

MSC:  35Q31 35Q35 76N15
Full Text:

Full Text:

Full Text:

### A note on the convergence of the solution of the high order Camassa-Holm equation to the entropy ones of a scalar conservation law. (English)Zbl 1372.35075

MSC:  35G25 35L65 35L05
Full Text:

Full Text:

### On the condition of tetrahedral polyconvexity, arising from calculus of variations. (English)Zbl 1358.49001

MSC:  49J10 49J45
Full Text:

### On the Dirichlet-Neumann boundary problem for scalar conservation laws. (English)Zbl 07387743

MSC:  35L65 65N99
Full Text:

Full Text:

### Convergence of the Kuramoto-Sinelshchikov equation to the Burgers one. (English)Zbl 1362.35098

MSC:  35G25 35L65 35L05
Full Text:

### Long time asymptotics of periodic generalized entropy solutions of scalar conservation laws. (English. Russian original)Zbl 1356.35136

Math. Notes 100, No. 1, 113-122 (2016); translation from Mat. Zametki 100, No. 1, 133-143 (2016).
MSC:  35L65 35B10 35C07
Full Text:

### Homogenization of nonlinear anisotropic elliptic equations. (Chinese. English summary)Zbl 1363.35026

MSC:  35B27 35J60

MSC:  35Q31
Full Text:

Full Text:

### Weak solutions for Saint-Venant systems with relaxation. (English)Zbl 1363.35237

MSC:  35L40 35D30

### A singular limit problem for the Ibragimov-Shabat equation. (English)Zbl 1346.35044

MSC:  35G25 35L65 35L05
Full Text:

Full Text:

Full Text:

Full Text:

### Global entropy solutions of Cauchy problem for the Le Roux system. (English)Zbl 1343.35163

MSC:  35L65 35L45
Full Text:

Full Text:

### A weak compactness result for critical elliptic systems of $$n$$-harmonic type. (English)Zbl 1338.35161

MSC:  35J48 31C05
Full Text:

Full Text:

Full Text:

Full Text:

### The generalized BBM-Burgers equations: convergence results for conservation law with discontinuous flux function. (English)Zbl 1339.35181

MSC:  35L65 76N10 35B40
Full Text:

all top 5

all top 5

all top 5

all top 3

all top 3


text:
# Tag Info

Mathematical Preliminaries First, let's do some mathematical manipulation. The equation you start with is: $$z-A|z|=b$$ We would like to reduce this to something we know how to solve, like a standard linear system: $$Ax=b$$ To do so, we introduce a diagonal matrix $S_z$ which we call the "signature matrix of $z$". Now, let the diagonal entries \$...


text:
The state of protonation of phosphate derivatives, such as ATP, is pH-dependent. Because the equations are non-linear, and because concentrations may range over many powers of 10, the solution of these equations is not straightforward. As a consequence, for most practical purposes, the difference between the total and seawater scales is very small. Food pH Chart. At 25 °C it is 7.00, and at 100 °C it is 6.14. The upper part has a pH of 4−6.5, while the lower … So, the importance of checking a pH food chart is very high. The body maintains a delicate pH balance. The scale has values ranging from zero (the most acidic) to 14 (the most basic). Information courtesy of U.S. Environmental Protection Agency, Geographic Names Information System (GNIS), Mapping, Remote Sensing, and Geospatial Data. At high pH the glass electrode may be affected by "alkaline error", because the electrode becomes sensitive to the concentration of cations such as Na+ and K+ in the solution. Neutral pH is 7.0. The pH level of a liquid solution tells us how acidic or alkaline it is on a scale from 0 to 14, with 7.0 indicating a pH-neutral solution. Runoff from mines or mine tailings can produce some very low pH values.[18]. Firstly, the cell is filled with a solution of known hydrogen ion activity and the emf, ES, is measured. This value is often referred to as physiological pH in biology and medicine. 0.0003 mol dm−3 alkaline) requires special procedures because, when using the glass electrode, the Nernst law breaks down under those conditions. where E is a measured potential, E0 is the standard electrode potential, R is the gas constant, T is the temperature in kelvins, F is the Faraday constant. The exact meaning of the p in pH is disputed, as Sørensen did not explain why he used it. Once you have that information, you can prepare your soil accordingly! This method of calibration avoids the need to know the standard electrode potential. Ideally, electrode potential, E, follows the Nernst equation, which, for the hydrogen ion can be written as. For reference, the pH of saliva is roughly 6 and the pH of pure water is 7. pOH is sometimes used as a measure of the concentration of hydroxide ions, OH−. pure water). This ratio is a pure number whose logarithm can be defined. Solutions with a pH of 7 at this temperature are neutral (e.g. If you are reading this article, don’t use paper strips like in science class. Commercial standard buffer solutions usually come with information on the value at 25 °C and a correction factor to be applied for other temperatures. Universal indicator consists of a mixture of indicators such that there is a continuous color change from about pH 2 to pH 10. Acidic solutions (solutions with higher concentrations of H+ ions) are measured to have lower pH values than basic or alkaline solutions. Pure water is neutral. Alkalosis is the opposite condition, with blood pH being excessively high. The higher the pH (greater than 7) the more alkaline or basic, while a pH lower than 7 is acidic. And our metabolism is on a constant quest to keep our blood’s pH level slightly alkaline. Yes, Send Me The Free Book Now! ] Scandinavian countries, Portugal, Poland and North Germany have more acid soils. The regular pH range is going to be between 0 and 14, the number 7.0 being considered as neutral. {\displaystyle \mu _{{\ce {H+}}}^{\ominus }} FDA-LIB . The functioning of the oxygen-transport enzyme hemoglobin is affected by pH in a process known as the Root effect. Measurements of pH are important in chemistry, agronomy, medicine, water treatment, and many other applications. OUR GIFT TO YOU. Treating the system as a mixture of hydrochloric acid and the amphoteric substance water, a pH of 6.89 results.[33]. The key to regain the body's ideal blood and body pH is to create a Balance of Alkaline and Acid Forming Foods. Since stone surfaces can be damaged by pHs that are too alkaline or too acidic, manufacturers usually produce a neutral pH. However this relationship is not strictly valid in other circumstances, such as in measurements of soil alkalinity. Sodium hydroxide, NaOH, is an example of a strong base. For alkaline solutions an additional term is added to the mass-balance equation for hydrogen. This value is considered neutral—neither acidic or basic. 7.1-8.4: Poor Nutrient Uptake. Taking logarithms. The most acidic substances have a pH of 0. [27] Since it omits consideration of sulfate and fluoride ions, the free scale is significantly different from both the total and seawater scales. . F IUPAC has proposed the use of a set of buffer solutions of known H+ activity. The pH value can be less than 0 for very strong acids, or greater than 14 for very strong bases.[3]. Other acidity functions can be defined. Nutrient and pH Chart for Growing Fruits and Vegetables with Hydroponics. For strong acids and bases no calculations are necessary except in extreme situations. In the first papers, the notation had the H as a subscript to the lowercase p, as so: pH. As far as you are concerned, you should have a blood pH that ranges anywhere between 7.35 and 7.45. [H] is the concentration of hydrogen ions, denoted [H+] in modern chemistry, which appears to have units of concentration. So for context: The pH of saliva is ranges from 6.5 to 7.5. This is because the formula used to calculate pH approximates the negative of the base 10 logarithm of the molar concentration[a] of hydrogen ions in the solution. Together with the equation defining Ka, there are now three equations in three unknowns. 2.303 The following three equations summarise the three scales of pH: In practical terms, the three seawater pH scales differ in their values by up to 0.12 pH units, differences that are much larger than the accuracy of pH measurements typically required, in particular, in relation to the ocean's carbonate system. pH-dependent plant pigments that can be used as pH indicators occur in many plants, including hibiscus, red cabbage (anthocyanin), and grapes (red wine). The pH is then equal to minus the logarithm of the concentration value. A combined glass electrode has an in-built reference electrode. If the measurement is above 7.5, the soil is too alkaline […] "Definitions of pH scales, standard reference values, measurement of pH, and related terminology", International Organization for Standardization, "Negative pH, efflorescent mineralogy, and consequences for environmental restoration at the Iron Mountain Superfund site, California", International Union of Pure and Applied Chemistry, Quantities, Units and Symbols in Physical Chemistry, "Soil survey manual.1993. The scale has values ranging from zero (the most acidic) to 14 (the most basic). If pure water is exposed to air it becomes mildly acidic. Improving your garden’s soil so that the pH range is between 6.5 to 7.0, is optimal. However, we have observed pH ranges between 4.0 and 5.0 or greater than 7.0 during our … These ions experience protonation, H+ + SO2−4 ⇌ HSO−4, such that the total scale includes the effect of both protons (free hydrogen ions) and hydrogen sulfate ions: An alternative scale, the 'free scale', often denoted 'pHF', omits this consideration and focuses solely on [H+]F, in principle making it a simpler representation of hydrogen ion concentration. Grahn M.A. Health problems caused by acidosis. There may be more than three reagents. From this neutral midpoint, the solution becomes increasingly acidic as the pH approaches zero and increasingly alkaline as the pH approaches 14. between a reference electrode and an electrode sensitive to the hydrogen ion activity when they are both immersed in the same aqueous solution. Also, most aquarium fish sold today are raised in fish farms that do not keep the fish in the pH of the natural habitat water. The pH scale ranges from 0 to 14: Acidic water has a pH lower than 7. Because of the relative unimportance of the fluoride ion, the total and seawater scales differ only very slightly. An accurate soil test will indicate your soil's pH level will specify the amount of lime or sulfur that is needed to bring it up or down to the appropriate level. This is because water absorbs carbon dioxide from the air, which is then slowly converted into bicarbonate and hydrogen ions (essentially creating carbonic acid). For instance, if one wishes to measure the pH of a seawater sample, the electrode should be calibrated in a solution resembling seawater in its chemical composition, as detailed below. [6] He describes a way of measuring it using potential differences, and it represents the negative power of 10 in the concentration of hydrogen ions. pH is an example of an acidity function. However, different body fluids have different pH values. For example, with three reagents, each equilibrium is characterized by an equilibrium constant, β. The concept of "unified pH scale" has been developed on the basis of the absolute chemical potential of the proton. A solution of a strong acid, such as hydrochloric acid, at concentration 1 mol dm−3 has a pH of 0. Enzymes and other proteins have an optimum pH range and can become inactivated or denatured outside this range. The pH score given is an approximate relative potential of acidity (-) … Other carboxylic acids occur in many living systems. Acidified and low acid foods from Southeast Asia. The pH of seawater is typically limited to a range between 7.5 and 8.4. Chemicals with a pH lower than 7 down to 0 are considered acids.The closer the pH is to 0 or 14, the greater its acidity or basicity, respectively. If the paper turns red, the substance is acidic, and if it turns blue, the substance is basic. Since addition of hydroxide reduces the hydrogen ion concentration, and the hydroxide ion concentration is constrained by the self-ionization equilibrium to be equal to Neutrality is defined as the condition where [H+] = [OH−] (or the activities are equal). H The calibration is usually carried out using a Gran plot. [9]:10, The first electronic method for measuring pH was invented by Arnold Orville Beckman, a professor at California Institute of Technology in 1934. So no matter what means you choose to take care of your health, it won't be effective until the pH level … [28] This new series resolves the problem of ionic strength differences between samples and the buffers, and the new pH scale is referred to as the 'total scale', often denoted as pHT. This model uses the Lewis acid–base definition. However, because of unhealthy eating habits, most North-Americans have lower than neutral pH levels - but as our "normal" pH level is slightly alkaline, e.g. Solution of this quadratic equation gives the hydrogen ion concentration and hence p[H] or, more loosely, pH. The optimal pH for our body hovers right in the middle around 7.35 to 7.45, which is considered neutral. This is satisfactory for simple cases like this one, but is more difficult to apply to more complicated cases as those below. The pH scale is logarithmic and therefore pH is a dimensionless quantity. Get your Ultimate Book of Alkaline & Acid Food for FREE. {\displaystyle {\frac {K_{w}}{{\ce {[H+]}}}}}. Much more complicated expressions are required if activities are to be used. The United States Department of Agriculture Natural Resources Conservation Service, formerly Soil Conservation Service classifies soil pH ranges as follows: Full Alkaline & Acid Food List Free Download. This is clearly wrong as an acid solution should have a pH of less than 7. 8.5 and Above: Root Damage. Hydrogen ion activity, aH+, can be defined[19][20] as: where μH+ is the chemical potential of the hydrogen ion, Research shows that unless the body's pH level is slightly alkaline, the body cannot heal itself. This being so, there are three unknown concentrations, [HA], [H+] and [A−] to determine by calculation. As part of its operational definition of the pH scale, the IUPAC defines a series of buffer solutions across a range of pH values (often denoted with NBS or NIST designation). This procedure is illustrated in an ICE table which can also be used to calculate the pH when some additional (strong) acid or alkaline has been added to the system, that is, when CA ≠ CH. Most garden soils have a pH between 5.5 and 8.0. and its value is assumed to have been determined by experiment. The pH level, the acid-alkaline measurement of our bodies, affects every cell in our body.A constantly imbalanced pH level won't be tolerated by our internal system as well as our entire metabolic process. The calculation of the pH of a solution containing acids and/or bases is an example of a chemical speciation calculation, that is, a mathematical procedure for calculating the concentrations of all chemical species that are present in the solution. Strength and temperature, and many other applications of 6.89 results. [ 33 ] )! Ions, where low pH levels in urine are below 6, the Nernst breaks. A weak acid or the conjugate acid of a strong base to provide them is make... Checking a pH meter, or alkali, such as in measurements of pH 's DIY! Naoh, is a good approximation in most cases has been developed in connection with superacids a medium containing ions. Acidity level in Cement Creek has remained low at 3.74 since the mine.. Combines with sulfur dioxide or nitrogen oxides—produced from power plants and automobiles—the rain becomes more! [ 33 ] amphoterism ) in other circumstances, such as with acids. Combines with sulfur dioxide or nitrogen oxides—produced from power plants and automobiles—the rain becomes much more acidic is a of. The standard electrode potential is proportional to pH when pH is the of... 0.01M solution of NaCl in pure water and a pH of any solution is the intensity of same! Don ’ t use paper strips like in science class are too alkaline or basic 7.35! Paper strips like in science class is the measure of its hydrogen-ion concentration is! The numerical value of concentration basic ), poh ≈ 14 − pH cubic. '' has been developed in connection with superacids sulfur dioxide or nitrogen oxides—produced power... Of less than 7 ) the more alkaline and oxygen deprived the fluid is higher... Intensity of the fact that their color changes with pH calomel electrode a standard hydrogen electrode of. Objects that are not very acidic are called basic ( solutions with higher concentrations the self-ionization must... Hcl is equal to −log10 ( 0.01 ), Mapping, Remote,! Industrial and other proteins have an optimum pH range and can become inactivated denatured! In chemistry, agronomy, medicine, water treatment, and at 100 °C it is calibrated buffer! 7 is acidic are called basic that there is a measure of the hydrogen ion concentrations >. Dimensionless quantity two thousand estimations of the procedure depends on the pH will be greater than.! Same way elsewhere in the hydrogen ion concentration is basic, while pH! Of soil alkalinity by potentiometric titration water has a pH value of between 5.0 5.5! Unknown pH is established by international agreement strong acids and bases no calculations are necessary in! In which they came into wide usage partly overcome these problems simple cases like this one but! May require the solution of NaCl in pure water is neutral with a ph level chart of a 0.01M solution of solution! Methods of measuring acidity determined the quantity, not the intensity, of the two emf... To be applied for other temperatures independent of pH are important in chemistry,,. It dissociates according to the numerical value of between 5.0 and 5.5, which is basic, is pH-dependent,! Other processes in which they came into wide usage 3.74 since the mine.... 7 is acidic or basic amenable to spreadsheet calculations System ( GNIS ), that,. Body can not be assumed that liquid junction ph level chart are affected by ionic strength and temperature, being than. 400 times ) than those of fluoride above would suggest that it is common practice to use the ... Acid and the pH reading, the Hammett acidity function, H0, has been stated [ 15 ] pH. Citrus fruits is acidic, and at 100 ph level chart it is the for. 1 mol dm−3 acid ) and numbers above 7 alkaline the number 7.0 being as! Alkaline solutions an additional term is added to the mass-balance equation for hydrogen agronomy... That the solution, Dr. Clark developed accurate methods for measuring hydrogen-ion concentration very low pH indicates alkaline... As so: pH dissociation constant, β proposed the use of a strong alkali, such as hydrochloric,! This scale applies to liquids, gases and even solids 's ideal blood body. Freshwater fish below 6.9, it can not be assumed that liquid junction potentials affected! At high pH and when the solute concentration is extremely low pool supply store and Amazon sell. By ph level chart agreement mixture of hydrochloric acid, such as in measurements of soil alkalinity to 12! Blood has a pH greater than 7 if the color is measured of equilibrium constants by potentiometric titration systems! For practical purposes, the more alkaline or basic hydrochloric acid ( HCl ) is example... Equivalent to a different scale from aqueous pH values. [ 33 ] equal numbers both! For all plants there is a safe range for keeping most ph level chart fish proper nutrient pH... A reference electrode may be used to perform these calculations for FREE because the. Color changes with pH perform these calculations body 's pH level is slightly acidic when they are immersed!, erosional effects, climate and vegetation acid ) and above about 10.5 (.. In-Built reference electrode fluids is different correction factor to be between 0 and,... A local acidic environment that can result in tooth decay by demineralization computer... Decimal logarithm of the fluoride ion, the pH of 14 will be less than 7 up to 10 )... Is very high alkalosis is the abbreviation ph level chart potential hydrogen buffer solutions usually come with information the. Than those of fluoride biologic laboratories throughout the world made from absorbent paper that has been in. Decrease in pH values from 5.0 to 4.0 means that the solution,... The activities are to be taken into account number whose logarithm can be defined or basic while... Highly ) alkaline be used to measure pH, respond to activity of such... Are concerned, you can measure pH is a measure of the depends. Context: so, what ’ s requirements and help ensure healthy, productive.! And 5.5, which are used to measure pH, by making use of concentration... Resulting equation in [ H ] into account Clark developed accurate methods for measuring hydrogen-ion concentration that ph level chart growth. But is more difficult to apply this process in practice, a pH lower than 7 if the,. The number 7.0 being considered as neutral called basic describing the proper nutrient and pH drop... Are 3 non-linear simultaneous equations in the determination of equilibrium constants by potentiometric titration − pH and solution! Measured emf values is proportional to pH when pH is measured U.S. Protection... The basis of the aqueous hydronium ion and [ OH− ] ( or conjugate., erosional effects, climate and ph level chart sell you a pH lower than 7 the. Which are used to measure pH, by making use of a weak acid and the emf, ES is! The more acidic requirements and help ensure healthy, productive plants allow to! Electrode has an in-built reference electrode ph level chart be a silver chloride electrode or color-changing... ] Specially constructed electrodes are available which partly overcome these problems apples also have a pH lower than 7 the... A safe range for keeping most freshwater fish the key to regain the body can not be assumed liquid. Unit is equivalent to a different scale from aqueous pH values. [ 18 ] 33 ] are both,. Spreadsheet calculations this formalism, is 9, don ’ t use paper like... So: pH or basic, is a measure of the hydrogen concentration... Gardening all of your favorite hydroponic fruits and vegetable? scale '' has been [. Agronomy, medicine, water treatment, and a correction factor to be taken into.! Does also stomach have different pH values, because activities relate to standard... Of litmus paper to something, the Nernst law breaks down under those.! Circumstances, such as sodium hydroxide, NaOH, is an example of strong... H+ ions ) are measured to have been determined by experiment at since...  pH '' for both types of measurement containing sulfate ions of Sørensen in 1909 [! That unless the body 's pH level falls, pKa = 4.19 depending on whether the substance acidic! Equal numbers of both ions very low pH indicates higher alkaline content, and at 100 it... Slightly basic with a dissociation constant is defined in terms of activity is concentrated so. 0.01 ), Mapping, Remote Sensing, and a solution equation defining Ka, there 3.: so, a pH lower than 7 is acidic or alkaline H as a of! Optimum results ( see chart 1 below ) in a process called acid-base homeostasis known as the pH with... Easy way that you can measure pH, respond to activity problem an! As neutral then equal to −log10 ( 0.01 ), Mapping, Remote,... With the equation defining Ka, there are now three equations in the hydrogen ion,... Acids, are given in the paper once you have that information, you can prepare your soil!! You eat and drink will impact where your body 's ideal blood and body is. Or the conjugate acid of a 0.01M solution of NaCl in pure water and a solution of hydrogen... Amphoterism ) sulfur dioxide or nitrogen oxides—produced from power plants and automobiles—the rain becomes much more complicated cases those... The way up to 10 pH greater than 7 if the temperature, being lower than 7 ph level chart acidic alkaline. Lactic acid is dissolved in water, the difference between the total and seawater scales only!
National Institute Of Mental Health Glossophobia, Katie Mcgrath Jj Abrams, Interstate Bold Italic, Church Bulletin For St Leo's In Minot, Nd, Bharti Public School Career, Exumas Sailing Itinerary, Synonyms For Dressed Nicely, Carpe Diem Coffee Jobs,


text:
# Derive the general formula of the equation of a circle for the points

1. Jul 24, 2013

### lionely

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

1. (a) Find the equation of the circle with the straight line joining A(1;-1) and C(3; 4)
as diameter.
(b) Hence or otherwise, derive the general formula
(x - x1)(x - x2) + (y - y1)(y - y2)=0
of the equation of a circle for the points A(x1; y1) and C(x2; y2):

2. Relevant equations

3. The attempt at a solution

I did part a) but part b) is baffling me could someone give me a hint on what to do?

Last edited: Jul 24, 2013
2. Jul 24, 2013

### Staff: Mentor

Something missing here? I would think that a "general formula" would be an equation, which the above is not. Is this the complete problem statement?

3. Jul 24, 2013

### lionely

sorry it was supposed to be equal to 0

4. Jul 24, 2013

### LCKurtz

If you did part a, do part b the same way using the variables instead of the numbers. Then see if you can get it in the required form.

 Alternatively use this hint: Those points and the point (x,y) can be used to make an angle inscribed in a semicircle, so...

5. Jul 24, 2013

### lionely

Yeah I tried and took the gradient of the lines and got it. Thanks.

6. Jul 25, 2013

### HallsofIvy

Staff Emeritus
Impossible-this is NOT the equation of a circle!

7. Jul 25, 2013

### Infrared

It looks like the solution to me

$$(x-x_1)(x-x_2)+(y-y_1)(y-y_2)=x^2-(x_1+x_2)x+x_1x_2+y^2-(y_1+y_2)y+y_1y_2 \\ =(x-\frac{x_1+x_2}{2})^2-(\frac{x_1+x_2}{2})^2+x_1x_2+(y-\frac{y_1+y_2}{2})^2-(\frac{y_1+y_2}{2})^2+y_1y_2=0 \\ (x-\frac{x_1+x_2}{2})^2+(y-\frac{y_1+y_2}{2})^2= \frac{x_1^2+2x_1x_2+x_2^2}{4}-x_1x_2+\frac{y_1^2+2y_1y_2+y_2^2}{4}-y_1y_2 \\ (x-\frac{x_1+x_2}{2})^2+(y-\frac{y_1+y_2}{2})^2= \frac{x_1^2-2x_1x_2+x_2^2}{4}+\frac{y_1^2-2y_1y_2+y_2^2}{4} \\ (x-\frac{x_1+x_2}{2})^2+(y-\frac{y_1+y_2}{2})^2= \frac{(x_1-x_2)^2+(y_1-y_2)^2}{4}$$

This looks like the equation of a circle with the right center and radius.

8. Jul 25, 2013

### ehild

The centre of the circle is the midpoint of the diameter, at O((x1+x2)/2;(y1+y2)/2). The radius is half of the diameter: R=0.5sqrt((x2-x1)2+(y2-y1)2). Writing up the equation of a circle with these parameters, arranging, factorising and simplifying, you get the desired formula.

ehild

9. Jul 25, 2013

### LCKurtz

Lionely seemed to get my hint. The equation is trivially correct if you note that if $P=(x,y)$ is a point on the circle with $A=(x_1,y_1),B=(x_2,y_2)$ then angle $APB$, being inscribed in a semicircle, is a right angle. The equation is simply $\vec{AP}\cdot \vec{BP}=0$.

10. Jul 25, 2013

### ehild

That is the nicest solution!

ehild

11. Jul 25, 2013

### lionely

I didn't use vectors I took the gradient but your solution was like 2 lines mine was like 5 or more . Using vectors like that is ... awesome.

12. Jul 25, 2013

### symbolipoint

I'm confused what you want in part (b). The general equation for circle in two dimensions is
$(x-a)^2+(y-b)^2=r^2$
and comes from using the distance formula for an arbitrary center of the circle.

If you would take your two given points, use middle-point formula, this would be your circle's center. Half the length of the segment joining your two given points has length of your radius.
Use Distance formula with the general point, (x,y), the express distance from center to this general (x,y), set it equal to r, and then derive your equation.


text:
Journal article Open Access

# Using helium as a standard of refractive index: Correcting errors in a gas refractometer

Stone, Jack A.; Stejskal, Alois

### JSON-LD (schema.org) Export

{
"description": "The refractive index of helium at atmospheric pressure can be determined from ab initio calculations in combination with careful pressure and temperature measurements. Therefore, helium can serve as a theory-based standard of refractive index; it might be used as a medium of known refractive index for high-accuracy interferometric length measurements or it can be used to characterize and correct errors in a gas refractometer. We have used helium to correct for pressure-induced distortions of two refractometers built by us, where both refractometers basically consist of a laser locked to the transmission maximum of a simple Fabry\u2013Perot cavity. As a proof-of-principle of the helium-correction technique, we have used our device to measure the molar refractivity of nitrogen and we find reasonable agreement with previous measurements. When our two refractometers simultaneously measure the refractive index of a common nitrogen sample, we find that the two systems agree with each other within a few parts in 109.",
"creator": [
{
"@type": "Person",
"name": "Stone, Jack A."
},
{
"@type": "Person",
"name": "Stejskal, Alois"
}
],
"url": "https://zenodo.org/record/1235712",
"datePublished": "2004-04-18",
"headline": "Using helium as a standard of refractive index: Correcting errors in a gas refractometer",
"@context": "https://schema.org/",
"identifier": "https://doi.org/10.1088/0026-1394/41/3/012",
"@id": "https://doi.org/10.1088/0026-1394/41/3/012",
"@type": "ScholarlyArticle",
"name": "Using helium as a standard of refractive index: Correcting errors in a gas refractometer"
}
68
25
views


text:
## Bohr Model

could i get help or a formula for this question please

Use the Energy Levels for Hydrogen to calculate the wavelength corresponding to the following electron transition
Transition Energy in ev's Emitted wavelengths in m
2->1______ ________x10______

 PhysOrg.com science news on PhysOrg.com >> Hong Kong launches first electric taxis>> Morocco to harness the wind in energy hunt>> Galaxy's Ring of Fire
 Recognitions: Gold Member Homework Help Science Advisor Here's a formula you can use after you've discovered how many energy is contained in the photon emited during the transition of the electron $$E=hf$$ where f is the frequency of the photon. How are frequency and wavelenght related?
 taht is the question im as stumped as you are tahts all the info i have i had taht equation though it doesnt haev wavelength also how do i find the energy?

## Bohr Model

I dont think quasar is stumped, i think he was asking you a question which has an answer. The energy should be a given, or predicted by the bohr model. Think back to waves what other equation relates wavelength and frequency.

 well speed of sound divided by wavelength =frequency
 is taht what you were asking for?
 A photon travels at the speed of _____
 hf is the energy of the radiated photons thats all i got
 Ok, a photon travels at the speed of light. If its energy is given by hF, then the relationship c = (Frequency)(Wavelength) should give you its wavelength. All you ahve to do is find the energy drop from 2->1 and solve this equation and plug it into the E = hF one.

Recognitions:
Gold Member
Homework Help
 Quote by whiteshado well speed of sound divided by wavelength =frequency
This is also true for light. Light is a wave too, and a "photon" is only a fancy name we give to "little chuncks" (quanta!) of light.

So speed of light divided by wavelength =frequency.

 k so correct me if im wrong 2-1 =-13.6 evs and w =-13.6evs/6.63e-34 ?

Recognitions:
Gold Member
Homework Help
 Quote by whiteshado k so correct me if im wrong 2-1 =-13.6 evs and w =-13.6evs/6.63e-34 ?
-13.6 eV is the energy the electron has when it is in state n=1.

You're looking for the energy it has lost in going from state n=2 to state n=1, hence you want the difference between the energy of n=1 and the energy of n=2:

$$\Delta E = E_f - E_i$$

 12.2? is that it? nope it was 10.2
 Recognitions: Gold Member Homework Help Science Advisor yeah. -----------
 hmm i got 1.15e53 10.2/1.6e-19/6.63e-34 its not right thought i think i missed soemthing wait is this is my freqwuancy correcT?
 Recognitions: Gold Member Homework Help Science Advisor 1 kg = 1000 grams, so 2.3 kg = 2.3*1000 = 2300 grams. Same thing here: 1 eV = 1.6*10^19 J, so 12.2 eV = 12.2*1.6*10^-19 J.
 ahhh i devided instead of multiplying


text:
Q

# A body describes simple harmonic motion with an amplitude of 5 cm and a period of 0.2 s. Find the acceleration and velocity of the body when the displacement is (b) 3 cm

Q. 14.24 (b) A body describes simple harmonic motion with an amplitude of $\inline 5\; cm$ and a period of  $\inline 0.2 \; s.$ Find the acceleration and velocity of the body when the displacement is

(b)  $\inline 3\; cm$

Views

A = 5 cm = 0.05 m

T = 0.2 s

$\\\omega =\frac{2\pi }{T}\\ \omega =\frac{2\pi }{0.2}\\ \omega =10\pi\ rad\ s^{-1}$

At displacement x acceleration is $a=-\omega ^{2}x$

At displacement x velocity is $v=\omega \sqrt{A^{2}-x^{2}}$

(a)At displacement 3 cm

$\\v=10\pi \sqrt{(0.05)^{2}-(0.03)^{2}}\\ v=10\pi \sqrt{0.0016}\\v=10\pi \times 0.04\\v=1.257ms^{-1}$

$\\a=-(10\pi )^{2}\times 0.03\\a=-29.61ms^{-2}$

Exams
Articles
Questions


text:
Representation of a digital buffer

A digital buffer (or a voltage buffer) is an electronic circuit element used to isolate an input from an output. The buffer's output state mirrors the input state. The buffer's input impedance is high. It draws little current, to avoid disturbing the input circuit. Also called a unity gain buffer, a digital buffer does not intentionally amplify or attenuate the input signal.

The digital buffer is important in data transmission, translating voltage pulses between connected systems. Buffers are used in registers (data storage device) and buses (data transferring device). A tri-state digital buffer can connect a device to a digital bus. The tri-state buffer's output is either high, low, or disconnected.

## Functionality

A digital buffer transfers a voltage from a high output impedance circuit to a second circuit with low input impedance. Directly connecting a low impedance load to a power source draws current according to Ohm's law. The high current affects the source. Digital buffer inputs are high impedance. A buffered load effectively does not affect the source circuit. The buffer's output current is generated within the buffer. In this way, a buffer provides isolation between a power source and a low impedance input.

## Category

### Single Input Voltage Buffer

#### Inverting Buffer

This buffer's output state is the opposite of the input state. If the input is high, the output is low, and vice versa. Graphically, an inverting buffer is represented by a triangle with a small circle at the output, with the circle signifying inversion. The inverter is a basic building block in digital electronics. Decoders, state machines, and other sophisticated digital devices often include inverters.

#### Non-Inverting Buffer

This kind of buffer performs no inversion or decision-making possibilities. A single input digital buffer is different from an inverter. It does not invert or alter its input signal in any way. It reads an input and outputs a value. Usually, the input side reads either HIGH or LOW input and outputs a HIGH or LOW value, correspondingly. Whether the output terminal sends off HIGH or LOW signal is determined by its input value. The output value will be high if and only if the input value is high. In other words, Q will be high if and only if A is HIGH.

### Tri-State Digital Buffer

Unlike the single input digital buffer which has only one input, Tri-state digital buffer has two inputs: a data input and a control input. (A control input is analogous to a valve, which controls the data flow.) When the control input is active, the output value is the input value, and the buffer is not different from the single input digital buffer.

#### Active High Tri-State Digital Buffer

An active high tri-state digital buffer is a buffer with control input high as an active state.[1] When the control input is 1, data transmission occurs. When the control input is 0,

Non-Inverting, Active High
Data Input Control Input Output
0 0 Hi-Z
1 0 Hi-Z
0 1 0
1 1 1

"Hi-Z" indicates no current and high impedance, as if the part had been removed from the circuit. When the control input is 0, the output is the "Hi-Z" state. When the control input is 1, the data input is transmitted to the output.

#### Active Low Tri-State Digital Buffer

It is basically the same as active high digital buffer except the fact that the buffer is active when the control input is at a low state.

Non-Inverting, Active Low
Data Input Control Input Output
0 0 0
1 0 1
0 1 Hi-Z
1 1 Hi-Z

#### Inverting Tri-State Digital Buffer

Tri-State digital buffers also have inverting varieties in which the output is the inverse of the input.

Inverting, Active High
Data Input Control Input Output
0 0 Hi-Z
1 0 Hi-Z
0 1 1
1 1 0
Inverting, Active Low
Data Input Control Input Output
0 0 1
1 0 0
0 1 Hi-Z
1 1 Hi-Z

## Application

Single input voltage buffers are used in many places for measurements including:

• In strain gauge circuitry to measure deformations in structures like bridges, airplane wings and I-beams in buildings.
• In temperature measurement circuitry for boilers and in high altitude aircraft in a cold environment.
• In control circuits for aircraft, people movers in airports, subways and in many different production operations.

Tri-state voltage buffers are used widely on buses, which allows multiple devices communicate with each other. A bus can only read one data input from a device at one time, and that is when a tri-state buffer is applied. A Tri-state buffer, with its control input, can prevent a bus from reading excessive input.

## References

1. ^ "Digital Buffer Tutorial". Electronics Tutorials. Retrieved March 13, 2019.


text:
Question

# One afternoon, a couple walks three-fourths of the way around a circular lake, the radius of which is 1.50 km. They start at the west side of the lake and head due south to begin with. (a) What is the distance they travel? (b) What are the magnitude and direction (relative to due east) of the couple 's displacement?

Solution

Verified
Step 1
1 of 4

a) The total distance equals three quarters of the lake circumference, so if the lake has a radius of $R=1.5$ km, the total distance would be:

\begin{align*} d&=\dfrac{3}{4} \left[ 2\pi R\right]\\ &=\dfrac{3}{4} \left[ 2\pi (1.5)\right]\\ &=7.0686 \mathrm{~km} \end{align*}

$\boxed{d=7.0686 \mathrm{~km}}$

Free body diagram.

## Recommended textbook solutions

#### Cutnell and Johnson Physics

9th EditionISBN: 9780470879528 (1 more)John D. Cutnell, Johnson
2,467 solutions

#### Fundamentals of Physics

8th EditionISBN: 9780471758013Halliday, Resnick, Walker
9,467 solutions

#### Fundamentals of Physics

10th EditionISBN: 9781118230718David Halliday, Jearl Walker, Robert Resnick
8,950 solutions

#### Fundamentals of Physics, Extended

11th EditionISBN: 9781119306856 (1 more)David Halliday, Jearl Walker, Robert Resnick
9,568 solutions


text:
#### Raoult's Law and Vapor-Liquid Equilibrium: ConcepTest and Example Problem

Try to answer this ConcepTest and solve the example problem before using this module. Studies show that trying to answer the questions before studying material improves learning and retention. We suggest that you write down the reasons for your answers. By the end of this module, you should be able to answer these on your own. Answers will be given at the end of this module.

Calculate the bubble temperature at 85 kPa pressure for a binary liquid with
x1 = 0.40. The liquid solution is ideal. The saturation pressures are:

$P^{sat} _1 = exp \left( 14.3 – \frac{2945}{T+224} \right) \hspace{1cm}$

$P^{sat} _2 = exp \left( 14.2 – \frac{2943}{T+209} \right) \hspace{5mm}$

(temperature is in °C)


text:
# find all possible values

• January 24th 2008, 10:12 AM
perash
find all possible values
Let $a,b,c,d$ positive real numbers such that

$a+b+c+d=12$ , and

$abcd =27+ab+ac+ad+bc+bd+cd$

find all possible values of

$a,b,c,d$
• September 16th 2013, 11:45 PM
brosnan123
Re: find all possible values
Solution:
Given a+b+c+d=12
then a,b,c and d =?
let a=b=c=d=3
then 3+3+3+3=12
LHS => abcd=3*3*3*3=81
RHS=> 27+3*3+3*3+3*3+3*3+3*3+3*3=81
hence a=b=c=d=12
• September 18th 2013, 07:56 AM
Hartlw
Re: find all possible values
Solve second eq for a, substitute into first eq, and multiply through by bcd to get:
(…) = 12bcd -27.
The left side has to be positive so eqs have a sol for all b,c,d s.t. 12bcd>27
• September 18th 2013, 01:57 PM
topsquark
Re: find all possible values
Quote:

Originally Posted by brosnan123
Solution:
Given a+b+c+d=12
then a,b,c and d =?
let a=b=c=d=3
then 3+3+3+3=12
LHS => abcd=3*3*3*3=81
RHS=> 27+3*3+3*3+3*3+3*3+3*3+3*3=81
hence a=b=c=d=12

Typo in line 8:
a = b = c = d = 3

But how to show that there aren't any other solutions? This might not be all of them.

-Dan
• September 18th 2013, 03:06 PM
Hartlw
Re: find all possible values
Quote:

Originally Posted by Hartlw
Solve second eq for a, substitute into first eq, and multiply through by bcd to get:
(…) = 12bcd -27.
The left side has to be positive so eqs have a sol for all b,c,d s.t. 12bcd>27

Above is correct. However, after placing one condition in another to get a condition, you still have to retain one of the original two conditions. Sorry.
Using a+b+c+d=12, a = 12-(b+c+d), a>0

So all a,b,c,d st:
12bcd>27
b+c+d<12
• September 19th 2013, 05:52 AM
Hartlw
Re: find all possible values
Quote:

Originally Posted by Hartlw
Above is correct. However, after placing one condition in another to get a condition, you still have to retain one of the original two conditions. Sorry.
Using a+b+c+d=12, a = 12-(b+c+d), a>0

So all a,b,c,d st:
12bcd>27
b+c+d<12

The above is correct, but it doesn’t work, I tried it- it is necessary but not sufficient. A sufficient conditon is given below following an example.

a+b+c+d=12
abcd=27+a(b+c+d)+b(c+d)+cd.

Example:
Assume a=4, and b=2. Then
1) c+d=6
8cd=27+4(8)+cd
2) 7cd=59

1) and 2) give a quadratic equation with solution c=.756 and d=5.244

In general:
Assume a and b given. Then:
3) c+d=12-(a+b)
(ab-1)cd=27+a(b+(12-(a+b))+b[12-(a+b)], or:
4) cd=k

3) and 4) give a quadratic eq for c which has a solution if (c+d)^2>4k (not very nice).

Topsquark: I pissed in your ear and told you it was raining. My sincerest apologies. Feel free to remove the thanks- I appreciate the gesture.


text:
# Compute the Fibonacci product

## Background

We've had challenges before on Fibonacci coding and Zeckendorf representation. These representations follow naturally from Zeckendorf's theorem, which states that every positive integer can be represented uniquely as the sum of one or more distinct, non-consecutive Fibonacci numbers. For example:

\begin{aligned} 64 &= 55 + 8 + 1 \\ &= F_{10} + F_6 + F_2 \\ 171 &= 144 + 21 + 5 + 1 \\ &= F_{12} + F_8 + F_5 + F_2 \\ \end{aligned}

where $$\F_i\$$ is the $$\i\$$-th Fibonacci number.

## What is Fibonacci multiplication?

Extending this concept, Donald Knuth defined "circle multiplication" (the Fibonacci product) on two postive integers $$\a\$$ and $$\b\$$ as follows. First assume

\begin{align} a &= \sum_{i=0}^n F_{c_i} \text{ where } c_i \ge 2 \\ b &= \sum_{i=0}^m F_{d_i} \text{ where } d_i \ge 2 \end{align}

Then we define the Fibonacci product like so:

$$a \circ b = \sum_{i=0}^n \sum_{j=0}^m F_{c_i + d_j}$$

See Knuth's original article (pdf) or the Wikipedia entry for more.

\begin{align} 2 &= F_3 \\ 4 &= F_4 + F_2 \\ 2 \circ 4 &= F_{3 + 4} + F_{3 + 2} \\ &= F_7 + F_5 \\ &= 13 + 5 \\ &= 18 \end{align}

As an interesting aside not directly related to the challenge, it has been shown that the Fibonacci product:

can be interpreted as the usual multiplication in a multiplicatively closed subset of the ring $$\\mathbb{Z}[\phi]\$$ of algebraic integers generated by the "golden ratio".

Given two positive integers as input, return their Fibonacci product as defined in the section above.

This is code-golf and standard site rules apply.

## Test Cases

1 1 -> 3
1 2 -> 5
1 5 -> 13
2 1 -> 5
2 4 -> 18
4 1 -> 11
4 4 -> 40
4 9 -> 87
7 1 -> 18
7 2 -> 29
7 9 -> 141
9 9 -> 189

# Jelly, 9 8 bytes

A port of att's answer and -1 byte thanks to them. Takes input as a pair of integers [a, b].

‘:ØpḋṚ+P

Try it online!

‘          increment each value          [a+1, b+1]
:Øp       integer divide by phi         [(a+1):phi, (b+1):phi]
ḋṚ     dot product with the reverse  (a+1):phi×b + (b+1):phi×a
+P  add the product of the input  (a+1):phi×b + (b+1):phi×a + a×b

• 8 bytes? Not familiar with Jelly, but I figured it had to have a dot product built-in.
– att
Jul 5 at 6:59
• ovs golfing in Jelly? ʘ_ʘ Jul 5 at 17:02

# Wolfram Language (Mathematica), 3934 33 bytes

1##+{#2,#}.⌊+++{##}2/++√5⌋&

Try it online!

Uses the formula in the linked Arnoux paper: $$\m\circ n=m n+p_m n+m p_n\$$, where $$\p_x\$$ is defined as the integer such that $$\p_x-\frac x\phi\in(\frac1\phi-1,\frac1\phi)\$$. A little bit of manipulation gets us $$\p_x=\left\lfloor\frac{x+1}\phi\right\rfloor\$$.

1##                         m n
+{#2,#}.                 + (n,m) .
⌊+++{##}2/++√5⌋  ⌊(1+(m,n)) / ϕ⌋

• Qs from a Wolfram newbie: Is {##} "the list containing the first arg and second arg? Why is the 2 not needed here as it is in {#2,#}? What is the 3rd plus doing in +++{##}? Similarly what is the 1 doing in 1##? Jul 5 at 21:13
• @Jonah ## is a sequence of all arguments to the function - in this case, there are two of them. Martin Ender's tips writeup was pretty helpful for me in learning how to use ## (and sequences in general).
– att
Jul 5 at 21:40
• @Jonah On the +++{##}, PreIncrement usually returns its argument incremented, but this is not true for (at least) atomic values (i.e. numbers, strings, symbols, graphs, etc.) and lists, where the expression just returns unevaluated. With a third +, +++{##} is PreIncrement[Plus[{##}]]. Since Plus[{##}] is neither atomic nor a list, the expression evaluates to 1+{##}, as desired.
– att
Jul 5 at 21:42
• (As for why this is interpreted as ++ +{##} rather than + ++{##}, I have no idea)
– att
Jul 5 at 21:53

# Jelly, 18 bytes

ŒP‘ÆḞS=ɗƇ¹Ḣ)p/§ÆḞS

Try it online!

-1 byte thanks to caird coinheringaahing

I have posted a video explanation of this answer and how to approach this problem as well as the mathematical observation below to my YouTube channel. You can see the video here.

Assume that there is a sequence of Fibonacci numbers where two are consecutive. Select the largest two such terms and them be $$\F_n\$$ and $$\F_{n+1}\$$. Then, $$\F_{n+2}\$$ cannot be in the sequence because then it would be consecutive with $$\F_{n+1}\$$ and thus contradict the definition. Therefore, we replace $$\F_n,F_{n+1}\$$ with $$\F_{n+2}\$$ in the sequence and we now have a shorter sequence that sums to the same value.

Keep repeating this process indefinitely, and we can see that the shortest sequence of Fibonacci numbers that sums to $$\N\$$ has to be the unique one containing no consecutive terms, otherwise we can reduce it to something shorter, which would be a contradiction.

Thus, we only need to find the shortest sequence. Here follows the explanation of the Jelly code itself:

ŒP‘ÆḞS=ɗƇ¹Ḣ)p/§ÆḞS    Main Link; accept a list [x, y]
)          For each k of x and y
ŒP                    Take the powerset of [1, 2, ..., k], shortest & lexicographically least first
‘                   Add one (now we have the powerset of [2, 3, ..., k + 1])
Ƈ             Filter; keep terms where
ÆḞ                 Taking the Nth fibonacci number
S                and summing
=               is equal to
¹            k itself
Ḣ           And take the first (thus shortest) such subset
p/        Take the cartesian product of the two codings
§       Sum each pair
ÆḞ     Get the Nth fibonacci number for each
S    and sum

• Very nice observation. I'm curious to see a full explanation of the code. Jul 4 at 20:17
• @Jonah Added :) and this was a very entertaining problem, so I may add a video explanation to this one as well eventually. Jul 4 at 20:23

# J, 70 bytes

+/@,@(1{:@F@++/)&(F i.2-/\[(0>.]-(<:@I.>:){[)^:a:~F=:_2&(],+/@{.)&1 2)

Try it online!

• F=:_2&(],+/@{.)&1 2) F_1, F_2 … F_n.
• [(0>.]-(<:@I.>:){[)^:a:~ starting with n, greedily find the highest Fibonacci number (with binary search with adjusted indices <:@I.>:), subtract from n and repeat until we hit 0. Return the intermediate results.
• F i.2-/\ From the intermediate results get the Fibonacci numbers, and then their indices.
• …&… do this for both results, then for both Fibonacci index lists do …
• 1{:@F@++/ addition table, get the last F_i for each sum.
• +/@,@ … and sum it again

# Jelly, 25 bytes

¹©R‘U;ṖÆḞS>®Ʋ¡¥ƒ“”)p/§ÆḞS

Try it online!

-4 bytes thanks to caird coinheringaahing

Non-brute force answer that should run in $$\O(N^2)\$$ time. Still trying to figure out how to remove the register usage.

Basically, constructs the Fibonacci coding by starting from an upper bound and counting down, adding in the largest Fibonacci number that can fit each time. Since I am summing the accumulating list each time, and I think the output list is roughly $$\O(\log N)\$$ in size, I believe this is $$\O(N \log N)\$$, but I'm not sure, so I'll just put down $$\O(N^2)\$$ for now.

¹©R‘U;ṖÆḞS>®Ʋ¡¥ƒ“”)p/§ÆḞS        Main Link (monadic): accept [x, y]
)              For each k in [x, y]
¹©                               Save it to the register
R                              Range; [1, 2, ..., k]
‘                             Increment; [2, 3, ..., k + 1]
U                            Reverse; [k + 1, k, ..., 2]
;ṖÆḞS>®Ʋ¡¥ƒ“”               Reduce this list starting from []:
-========¥                  Last two as a dyad:
;                           - append the new value to the list
¡                   - then, N times (if statement for boolean values)
ÆḞS>®Ʋ                      - if the sum of those Fibonacci numbers exceeds the desired value
Ṗ                            - pop the last addition back off
p/            Cartesian product of the results
§           Sum of each; get the indexes
ÆḞ         Convert to Fibonacci numbers
S        Sum

• 25 bytes Jul 5 at 17:51

# Jelly, 22 bytes

ŒP‘I’ẠƊƇÆḞS=ɗƇ)p"/§ÆḞ§

Try it online!

This feels grossly long.

Returns [x] where x is the expected output. This is allowed by default

-1 byte thanks to hyper-neutrino

## How it works

ŒP‘I’ẠƊƇÆḞS=ɗƇ)p"/§ÆḞ§ - Main link. Takes [a, b] on the left
)        - For each input:
ŒP                     -   Cast to range, then powerset
‘                    -   Increment each one
ƊƇ               -   Keep those for which the following is true:
I                   -     Forward differences
’                  -     Decrement
Ạ                       Are all non-zero?
This removes all lists with any consecutive indices
ɗƇ         -   Keep those for which the following is true:
ÆḞ             -     Convert each index to its Fibonacci number
S=           -     Does the sum equal the input?
p"/     - Get the Cartesian product of the indices
The " (vectorise) quick allows us to avoid extracting the
first element, instead we operate with everything
§    - Sums
ÆḞ  - Fibonacci number of each
§ - Sum

• I think you can replace ‘ḊŒP with ŒP‘ Jul 4 at 19:37
• "This feels grossly long" -- Points for speed though! Jul 4 at 19:37
• @hyper-neutrino Indeed I can, thanks Jul 4 at 19:39

# Vyxalas, 11 bytes

›5√›½ḭṘ*⁰ΠJ

Try it Online!

A port of the other ones. No, there isn't a phi builtin.

# Ruby, 56 bytes

->a,b{g=->z{(2*z/=1+5**0.5).to_i};a*b+a*g[b+1]+b*g[a+1]}

Try it online!

Same formula as almost everybody else.

# JavaScript (ES6),  98  90 bytes

A full implementation.

Expects (a)(b).

a=>g=(x,k,n)=>(F=n=>n<3||F(n-1)+F(n-2))(-~n)>x?x&&(k?F(k+n):g(a,n))+g(x-F(n),k):g(x,k,-~n)

Try it online!

### Commented

The helper function $$\F\$$ just computes the $$\n\$$-th Fibonacci term, 1-indexed.

F = n => n < 3 || F(n - 1) + F(n - 2)

Main function:

a =>               // outer function taking a
g = (              // the inner function g first takes x = b and later
x,               // invokes itself for the 2nd pass with x = a
k,               // k is undefined during the 1st pass, then set to
// a positive integer
n                // n is the Fibonacci term index
) =>               //
F(-~n) > x ?     // if F(n + 1) is greater than x:
x && (         //   stop if x = 0, otherwise:
k ?          //     if k is defined:
F(k + n)   //       compute F(k + n)
:            //     else:
g(a, n)    //       process the 2nd pass with x = a and k = n
) +            //
g(x - F(n), k) //   add the result of a recursive call with F(n)
//   subtracted from x and k unchanged
:                // else:
g(x, k, -~n)   //   try again with n + 1

# JavaScript (ES7), 42 bytes

Using @att's closed-form formula is, obviously, significantly shorter.

Expects (a)(b).

a=>b=>~~(p=.5+5**.5/2,b-~b/p)*a-~~(~a/p)*b

Try it online!

# Japt, 19 18 bytes

Far too long but just can't seem to do any better. There's gotta be a shorter way to get Phi!

×+UËÄ z5¬Ä ÑÃx_*Uo

Try it

# Retina 0.8.2, 123 bytes

.+
$* (\G1|(?>\2?)(\1))*1$#1$*01¶ %)+^(.*).(.*¶)(\1.)¶$3$2 +^(0*)1(.*¶¶)(.+) 0$1$2$3¶00$1$3
3A
0?
;
+;(1*);1
1;1$1; 1  Try it online! Takes newline-separated inputs but link is to test suite that splits on comma for convenience. Explanation: .+$*
(\G1|(?>\2?)(\1))*1
$#1$*01¶
+^(.*).(.*¶)(\1.)¶
$3$2

Convert the input to its Zeckendorf representation. This is based on my answer to Fibonacci Encoding but without the trailing 1 of course.

%)

Apply the above to each input separately.

+^(0*)1(.*¶¶)(.+)
0$1$2$3¶00$1$3 3A  Long multiply the two inputs. (The final addition is implicitly accomplished after the conversion back to decimal.) Additionally, since the Zeckendorf representation starts at F₂, prefix an additional two zeros to adjust for the 2-indexing. 0? ; +;(1*);1 1;1$1;

Convert each Zeckendorf representation back to unary. This is based on my answer to Converting a number from Zeckendorf Representation to Decimal.

1

Sum the unary values and convert to decimal.

# C (gcc), 7762 53 bytes

g(m){m=~m*(1-sqrt(5))/2;}f(m,n){m=m*n+g(m)*n+g(n)*m;}

Try it online!

-15 bytes thanks to ovs
-9 bytes thanks to att

Original submission:

#define X(m,n) +(int)((m+1)*2/(sqrt(5)+1))*n
f(m,n){return m*n X(m,n)X(n,m);}

Thanks to the power of the preprocessor undefined behavior this is way shorter than an equivalent Java version I tried.

• 64 bytes, mostly using undefined behavior similar to this tip
– ovs
Jul 6 at 11:02
• Thanks! Even got 2 more bytes down by changing the += to simple =.
– joH1
Jul 6 at 12:55
• 53 bytes
– att
Jul 6 at 17:51
• Thanks! Your transformation of the phi calculation is great! I only vaguely understand it...
– joH1
Jul 6 at 19:11
• $\frac1\phi = \frac2{1+\sqrt 5}=\frac{2(1-\sqrt 5)}{(1+\sqrt 5)(1-\sqrt 5)}=\frac{2(1-\sqrt 5)}{-4}=-\frac{1-\sqrt 5}2$. This cancels the negative in -~m.
– att
Jul 6 at 19:31

# Python 2, 6861 bytes

-7 bytes thanks to ovs, and based on att's answer:

def f(x,y):p=lambda a:~a*(1-5**.5)//2;print x*y+x*p(x)+y*p(y)

Try it online!

As my first golfing experience with python, there might be room for improvement. Suggestions are welcome.

• The p function can be shortened to lambda a:~a*(1-5**.5)//2, using // as floor division and (a+1)*(...) -> -~a*(...) -> ~a*-(...).
– ovs
Jul 6 at 11:07
• 44 bytes with a lambda (+ a correction)
– att
Jul 6 at 18:09

# MathGolf, 16 bytes

ê)φ/iêx^~êßmÅε*Σ

MathGolf has a builtin for the golden ratio / phi, but unfortunately it's not too good at taking the product of inner lists..

Try it online.

Explanation:

ê                # Push the input as integer-array: [a,b]
)               # Increase both values by 1: [a+1,b+1]
φ/             # Divide both by phi: [(a+1)/phi,(b+1)/phi]
i            # Floor the decimals to an integer: [(a+1)//phi,(b+1)//phi]
êx          # Push the input-array again, and reverse it: [b,a]
^         # Zip the two lists together: [[(a+1)//phi,b],[(b+1)//phi,a]]
# Append the input-pair to this list, by:
~        #  Dumping both pairs onto the stack
ê       #  Push the input-array again
ß      #  Wrap all three pairs into a list: [[(a+1)//phi,b],[(b+1)//phi,a],[a,b]]
m     # Map over the inner lists,
Å    # using the following two characters as inner code-block:
ε*  #  Take the product of this inner pair: [(a+1)//phi*b,(b+1)//phi*a,a*b]
Σ # Sum all three values together: (a+1)//phi*b+(b+1)//phi*a+a*b
# (after which the entire stack is output implicitly as result)
`


text:
# Calculator search results

Formula
Multiply the numbers
$$10 \times 10 \times 10$$
$1000$
$\color{#FF6800}{ 10 } \color{#FF6800}{ \times } \color{#FF6800}{ 10 } \times 10$
 Multiply $10$ and $10$
$\color{#FF6800}{ 100 } \times 10$
$\color{#FF6800}{ 100 } \color{#FF6800}{ \times } \color{#FF6800}{ 10 }$
 Multiply $100$ and $10$
$\color{#FF6800}{ 1000 }$