0

How do I calculate this dale-chall mathematical notation? or how is it converted to easier pseudo code?

I am trying to understand this concept to implement a text readability analyzer.

Is it like the following? altough ... how is what comes after 0.1579 and 0.0496 calculated?

0.1579 ( (difficult words - words) * 100 ) + 0.0496 (words - sentences)
Óscar López
  • 232,561
  • 37
  • 312
  • 386
  • What language are you going to use? Use divide operator for the fractions. Also usually you cannot omit the multiplication sign. – timrau Sep 06 '14 at 15:37
  • 1
    This question is off-topic because it is about the interpretation of basic mathematical notation, which has nothing to do with programming. – l4mpi Sep 08 '14 at 07:49
  • @EdwardZuckerberg it's not fit anywhere on the SE network AFAIK - a question "how do I interpret this mathematical notation" might be on-topic for the math.SE site, but I'm sure it wouldn't be well-received as this is an extremely basic topic which is already covered by a whole range of material on the internet (e.g. see [here](https://en.wikipedia.org/wiki/Expression_%28mathematics%29) - that was 5 seconds of googling). Not every question is welcome here, you should solve some problems by yourself. – l4mpi Sep 08 '14 at 08:06
  • 1
    I simply searched for "mathematical notation", which lead to the wikipedia page "mathematical notation", which directly links to the page I linked. It wasn't even optimal, as searching for "mathematical expression" directly results in the linked page. Both of these should have been obvious search targets for you - if you remove the _specific_ part ("dale-chall") from your title, your question reads "how to read mathematical notation". I don't know what you searched for, but googling is an important skill for any programmer and you should probably invest some work to train your google-fu. – l4mpi Sep 08 '14 at 08:13

1 Answers1

1

The given formula will be written as follows in the most common programming languages:

(0.1579 * ((difficultWords / words) * 100)) + (0.0496 * (words / sentences))

The above expression will work in Python, Ruby, Javascript, Java, C, C++, C#, etc. Notice that we use * for multiplication (you can't omit the operator) and / for division, and we add as many parentheses as needed to eliminate any ambiguities in evaluation order.

When you're actually implementing the above code you'll have to be careful with divisions - some languages (for example: Java, Python 2.x) will truncate decimals if both operands are integer values. To get around this problem you can either declare the variables difficultWords, words and sentences using a data type that allows for decimals (say, double) or you can explicitly convert the variables to a decimal data type at the time of performing the division. For example, the formula will look like this in Java:

(0.1579 * (((double) difficultWords / words) * 100)) + (0.0496 * ((double) words / sentences))
Óscar López
  • 232,561
  • 37
  • 312
  • 386
  • Interesting enough... I understood the stuff about division and multiplication. the thing that still baffles me is how `0.1579` and `0.0496` are not followed by the multiplication sign in the mathematical notation. –  Sep 06 '14 at 15:52
  • 1
    @EdwardZuckerberg that's standard mathematical notation, a number before a pair of `()` is implicitly multiplying the value. For example, a math expression like this: `2(4+5)` will have to be explicitly written like this in a programming language: `2*(4+5)` – Óscar López Sep 06 '14 at 15:55
  • 1
    Thank you for the explanation, I guess I learned something new! I'm not really a math guy, but I'm learning from experience. –  Sep 06 '14 at 15:58
  • 1
    @EdwardZuckerberg my pleasure! Recommended reading: pick a programming language, and read about its operators and operator precedence. – Óscar López Sep 06 '14 at 16:00
  • Thanks, I will definitely do that! –  Sep 06 '14 at 16:03