Is mathematics used more or logic used more in programming?

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

54 Replies - 1997 Views - Last Post: 05 January 2020 - 12:48 AM

Poll: What is used more in programming? (2 member(s) have cast votes)

Does progamming use mathematics more or logic more?

  1. Mathematics (0 votes [0.00%])

    Percentage of vote: 0.00%

  2. Logic (1 votes [50.00%] - View)

    Percentage of vote: 50.00%

  3. No (1 votes [50.00%] - View)

    Percentage of vote: 50.00%

Vote

#1 noviceFedora   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 44
  • Joined: 08-December 19

Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 02:42 AM

Every time I try to master a programming language, I'm stumped by exercises involving mathematics(even basic math). So I get frustrated and give up. My interest and curiosity keeps bringing me back to this subject, so sometimes I search for source code of software, like Linux kernel, Firefox, viruses, trojans and back root malware, and when I read these source codes, most of them only contain MACROS, C Keywords, statements & expressions used with logic, by my observation of these, I'd say, most of programming involves only symbolic logic and very little of it requires mathematics.

This is only one type of programming, I'm sure other types of programming requires mathematics, like systems programming, cryptography, graphics, machine learning, deep learning, etc.

Isn't it counterproductive in programming textbooks to emphasize on mathematics & calculations to introduce programming concepts, when most of the programming seems to require formal logic.

My math skills are a stumbling blocks for me to improve my understanding of programming. I read official C programming book and I found it very interesting, they introduce things which aren't even introduced in many other C programming books but it also has exercises which requires mathematics, same is the case with many programming textbooks.

So what is more used in programming mathematics or logic?

This post has been edited by jon.kiparsky: 03 January 2020 - 08:11 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Is mathematics used more or logic used more in programming?

#2 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7189
  • View blog
  • Posts: 24,360
  • Joined: 05-May 12

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 05:26 AM

Logic is used more in general programming. Most of computer science, though, has its foundations in mathematics, and most of the early practitioners were mathematicians, and hence this bend towards math. Math also expresses logic, but in a more abstract way, as opposed to the more mechanical or procedural way you seem to be looking for.

What book are you using? If the exercises you are trying to do are Project Euler problems, yes those are heavily leaning towards math problems. Try Rosalind which has a better mix of logic and math.
Was This Post Helpful? 0
  • +
  • -

#3 Ornstein   User is offline

  • New D.I.C Head

Reputation: 22
  • View blog
  • Posts: 43
  • Joined: 13-May 15

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 06:07 AM

You'll probably benefit more immediately from learning algorithms* than mathematics, but there are times you may require maths. As one example, I do a lot of hobbyist game dev - where maths is used extensively and the ability to understand equations is important/useful. As you also say, maths features quite heavily in some ideas in AI / machine learning, etc.

* You should be able to easily find lists of the common types of algorithms (sorting, hashing, etc) to acquaint yourself with them. You can also find challenges (e.g. on HackerRank) which will test your ability to implement them - one way or the other.

I've noticed a trend within dev circles, where a lot of self-made devs who have never studied an algorithm in their life will tell you you'll never need them. I've also worked with those people and seen them bang their heads against brick walls they could easily overcome with even some cursory knowledge of algorithms or more obscure solutions to problems and such. (I still remember the day I introduced my coworkers to the nested set model / nested intervals; it was far more profound to them than it should have been, given some of them had 10+ years experience on me at that point.)

This post has been edited by Ornstein: 30 December 2019 - 06:08 AM

Was This Post Helpful? 1
  • +
  • -

#4 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11737
  • View blog
  • Posts: 19,935
  • Joined: 19-March 11

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 09:56 AM

Quote

So what is more used in programming mathematics or logic?


Trick question - logic is a branch of math, so the answer is "yes" :)

What it sounds like you're really asking is "what do I need to work on the most?". And the answer is that it is much more important as a first step to understand the logical expression of a concept in code, and to be able to clearly express a concept in code, than to do either calculations or math in code*, but the math is going to be critical, as Ornstein says, in getting past basic entry-level programming to doing serious and interesting work. Computer science is a branch of mathematics, it depends heavily on a number of other branches, such as set theory, number theory, graph theory, combinatorics, and so forth, and the areas of engineering that people are generally excited about these days depend on further mathematical foundations. For example, data science is basically statistics, which takes you back through probability (ie, combinatorics again), and machine learning uses a ton of linear algebra, and calculus is basically assumed pretty much everywhere.
So yeah, start by thinking about logic, but if you don't bump into some math pretty soon you're probably not setting your sights high enough.


* there is a difference - calculations are about following a set of rules to produce a numerical result, math is about abstraction and patterns - understanding the math often helps to simplify a computation, but computations are not math

View PostOrnstein, on 30 December 2019 - 08:07 AM, said:

You'll probably benefit more immediately from learning algorithms* than mathematics,



Just to be clear here, algorithms are math and studying algorithms requires studying math.
Was This Post Helpful? 3
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15433
  • View blog
  • Posts: 61,830
  • Joined: 12-June 08

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 10:19 AM

View PostnoviceFedora, on 30 December 2019 - 03:42 AM, said:

[...]I'm stumped by exercises involving mathematics(even basic math).[...]

Examples?
Was This Post Helpful? 0
  • +
  • -

#6 noviceFedora   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 44
  • Joined: 08-December 19

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 06:23 PM

View Postmodi123_1, on 30 December 2019 - 10:19 AM, said:

View PostnoviceFedora, on 30 December 2019 - 03:42 AM, said:

[...]I'm stumped by exercises involving mathematics(even basic math).[...]

Examples?


Like the one I asked in my other thread in Python about how to get correct time by adding present time and wait time both entered in hours.
Martyr2 explained how using the modulus operator.

Similarly, in the official C book, there was an exercise requiring me to convert temperatures from fahrenheit to celsius and vice versa.

Many such things.

This post has been edited by noviceFedora: 30 December 2019 - 06:23 PM

Was This Post Helpful? 0
  • +
  • -

#7 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7189
  • View blog
  • Posts: 24,360
  • Joined: 05-May 12

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 06:36 PM

Those should be just basic applications of algebra that you learned in high school (or as I understand now middle school). I suspect that those assignments were written that way because they were meant to be applications of things that you should already know how to do with pencil and paper, and the aim was to get you to think like a programmer and think about translating those pencil and paper steps into instructions that a computer can follow to do the same steps.
Was This Post Helpful? 0
  • +
  • -

#8 noviceFedora   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 44
  • Joined: 08-December 19

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 06:42 PM

View PostSkydiver, on 30 December 2019 - 05:26 AM, said:

Logic is used more in general programming. Most of computer science, though, has its foundations in mathematics, and most of the early practitioners were mathematicians, and hence this bend towards math. Math also expresses logic, but in a more abstract way, as opposed to the more mechanical or procedural way you seem to be looking for.

What book are you using? If the exercises you are trying to do are Project Euler problems, yes those are heavily leaning towards math problems. Try Rosalind which has a better mix of logic and math.


Thanks for Rosalind suggestion, I didn't know about it, seems very interesting and might be helpful to me.

View PostOrnstein, on 30 December 2019 - 06:07 AM, said:

You'll probably benefit more immediately from learning algorithms* than mathematics, but there are times you may require maths. As one example, I do a lot of hobbyist game dev - where maths is used extensively and the ability to understand equations is important/useful. As you also say, maths features quite heavily in some ideas in AI / machine learning, etc.

* You should be able to easily find lists of the common types of algorithms (sorting, hashing, etc) to acquaint yourself with them. You can also find challenges (e.g. on HackerRank) which will test your ability to implement them - one way or the other.

I've noticed a trend within dev circles, where a lot of self-made devs who have never studied an algorithm in their life will tell you you'll never need them. I've also worked with those people and seen them bang their heads against brick walls they could easily overcome with even some cursory knowledge of algorithms or more obscure solutions to problems and such. (I still remember the day I introduced my coworkers to the nested set model / nested intervals; it was far more profound to them than it should have been, given some of them had 10+ years experience on me at that point.)


Thanks for this suggestion, I learned about few sorting algorithms when I was taught C but I completely forgot about them.

View Postjon.kiparsky, on 30 December 2019 - 09:56 AM, said:

Quote

So what is more used in programming mathematics or logic?


Trick question - logic is a branch of math, so the answer is "yes" :)/>/>/>

What it sounds like you're really asking is "what do I need to work on the most?". And the answer is that it is much more important as a first step to understand the logical expression of a concept in code, and to be able to clearly express a concept in code, than to do either calculations or math in code*, but the math is going to be critical, as Ornstein says, in getting past basic entry-level programming to doing serious and interesting work. Computer science is a branch of mathematics, it depends heavily on a number of other branches, such as set theory, number theory, graph theory, combinatorics, and so forth, and the areas of engineering that people are generally excited about these days depend on further mathematical foundations. For example, data science is basically statistics, which takes you back through probability (ie, combinatorics again), and machine learning uses a ton of linear algebra, and calculus is basically assumed pretty much everywhere.
So yeah, start by thinking about logic, but if you don't bump into some math pretty soon you're probably not setting your sights high enough.

* there is a difference - calculations are about following a set of rules to produce a numerical result, math is about abstraction and patterns - understanding the math often helps to simplify a computation, but computations are not math


Logic is also a branch of philosophy and they also use symbolic logic, like logical AND, OR and NOT, instead of 1 and 0, they use T and F, representing True and False. The definition of calculations you gave is pretty much the same definition I read about algorithms.

View PostOrnstein, on 30 December 2019 - 08:07 AM, said:

You'll probably benefit more immediately from learning algorithms* than mathematics,


View PostSkydiver, on 30 December 2019 - 05:26 AM, said:

Just to be clear here, algorithms are math and studying algorithms requires studying math.


When people say math, they mostly mean numerical calculations, algorithms seem to have more emphasis on symbolic logic than numerical calculations. So in a way it appears more similar to FOL or logic used in philosophy than the one used in math.

View PostSkydiver, on 30 December 2019 - 06:36 PM, said:

Those should be just basic applications of algebra that you learned in high school (or as I understand now middle school). I suspect that those assignments were written that way because they were meant to be applications of things that you should already know how to do with pencil and paper, and the aim was to get you to think like a programmer and think about translating those pencil and paper steps into instructions that a computer can follow to do the same steps.


Well, even that I don't know and it is difficult for me. The only formula I can remember from algebra is (a + b ) 2 = a2 + 2ab + b2.

This post has been edited by noviceFedora: 30 December 2019 - 06:43 PM

Was This Post Helpful? 0
  • +
  • -

#9 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12680
  • View blog
  • Posts: 45,861
  • Joined: 27-December 08

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 06:45 PM

Quote

When people say math, they mostly mean numerical calculations, algorithms seem to have more emphasis on symbolic logic than numerical calculations.


In the circles you travel, perhaps. In general, this is not true. Mathematics is about abstraction and precision, not mindless computations.


Quote

So in a way it appears more similar to FOL or logic used in philosophy than the one used in math.


I think you are splitting hairs here. Logic is a branch of mathematics, one which philosophers happen to care about. I have worked with logicians before. They prove theorems and develop theory about the foundations of mathematics and mathematical systems. While your first exposure to the area might have been through the Philosophy department, it does not mean the subject is not mathematics.


Quote

Those should be just basic applications of algebra that you learned in high school (or as I understand now middle school).


Skydiver raises a valid point. Are you struggling with the formulas and equations themselves? Could you do the calculations by hand? Or are you struggling with the implementation in your favorite programming language?

This post has been edited by macosxnerd101: 30 December 2019 - 06:48 PM

Was This Post Helpful? 2
  • +
  • -

#10 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7189
  • View blog
  • Posts: 24,360
  • Joined: 05-May 12

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 06:50 PM

On the other hand, you may have a true psychological aversion/block to looking or thinking of math. I know I suffer from it when looking at statistics formulas or integral equations. I have to concentrate hard to even get the basic gist of them. On the other hand, if I look at code that computes statistics, or applies numerical methods to do integrals, the ideas just flow freely.

I remember a long time ago that I had the hardest time understanding linear equations, until a classmate showed me how things related to each other graphically. The latter made sense to me because I'd been teaching myself how to do moire patterns on my C-64 and my friends' Apple II. Apparently, I'd been doing linear equations all that while but I just didn't know it.
Was This Post Helpful? 0
  • +
  • -

#11 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11737
  • View blog
  • Posts: 19,935
  • Joined: 19-March 11

Re: Is mathematics used more or logic used more in programming?

Posted 30 December 2019 - 08:15 PM

View PostnoviceFedora, on 30 December 2019 - 08:42 PM, said:

The definition of calculations you gave is pretty much the same definition I read about algorithms.


In a sense, this is correct. Computing a result is generally the application of an algorithm. For example, when you learned how to do long division in grade school, you learned an effective procedure which, for any legitimate input n and d, produces a correct result, namely a number x which can be multiplied by d to produce n.

So yes, the process of computation is in general the application of an algorithm. However, the study of algorithms is not simply the mindless memorization and implementation of algorithms. This would be idiotic. Take sorting for example - it's a pretty safe bet that you will never need to implement a sort routine in your life, and yet we typically spend a lot of hours looking at all of the different sorts, proving their correctness, analyzing their performance, and so on. Why do we do this? It's to help you understand how to devise algorithms for the problems you're going to have to solve - the ones which are not already baked into the languages you're going to use.

So the point of studying algorithms is not just to learn a process, like long division. It's to learn how to invent a process which computes a result you're interested in, and how to prove that your process is correct, and how to understand the computational burden it will impose on a system implementing it, and ideally how to find the optimal process and prove it to be optimal. All of this, of course, is not computation. It is math.

Quote

On the other hand, you may have a true psychological aversion/block to looking or thinking of math. I know I suffer from it when looking at statistics formulas or integral equations. I have to concentrate hard to even get the basic gist of them. On the other hand, if I look at code that computes statistics, or applies numerical methods to do integrals, the ideas just flow freely.


I would disagree with this. This is not an aversion to math, it's an aversion to the ways in which math is traditionally represented on the page. And this is quite reasonable - mathematicians use, and expect their readers to understand, a lot of opaque symbolism and jargon, all of which is helpful and comforting to them but not useful to or useable by the lay reader. This is not something that's easy to rectify, for all sorts of reasons, but the very fact that changing the representation to one you're more comfortable with makes the ideas flow freely tells us that you're perfectly capable of handling the math.
Was This Post Helpful? 2
  • +
  • -

#12 noviceFedora   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 44
  • Joined: 08-December 19

Re: Is mathematics used more or logic used more in programming?

Posted 31 December 2019 - 09:07 PM

View Postjon.kiparsky, on 30 December 2019 - 09:56 AM, said:

Trick question - logic is a branch of math, so the answer is "yes" :)/>


View Postmacosxnerd101, on 30 December 2019 - 06:45 PM, said:

In the circles you travel, perhaps. In general, this is not true.Mathematics is about abstraction and precision, not mindless computations.I think you are splitting hairs here. Logic is a branch of mathematics, one which philosophers happen to care about. I have worked with logicians before. They prove theorems and develop theory about the foundations of mathematics and mathematical systems. While your first exposure to the area might have been through the Philosophy department, it does not mean the subject is not mathematics.


I'm unable to add a screen shot of this page, but you can see here that Wikipedia also classifies Logic as part of philosophy: https://en.wikipedia.org/wiki/Logic

Maths is one subject which makes use of Logic, the way machine learning makes use of statistics.

P.S: I'm getting this: "Error The server returned an error during upload" when attaching an image.
Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12680
  • View blog
  • Posts: 45,861
  • Joined: 27-December 08

Re: Is mathematics used more or logic used more in programming?

Posted 31 December 2019 - 09:17 PM

I have a masters degree in Math and have taken a class with one of Tarski’s students. Logic is a branch of Math- regardless of what Wikipedia says. It is also quite common for fields to intersect with different disciplines. :)

In any event- this point seems important to you. How does it relate to your OP regarding programming?

This post has been edited by macosxnerd101: 31 December 2019 - 10:53 PM

Was This Post Helpful? 1
  • +
  • -

#14 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11737
  • View blog
  • Posts: 19,935
  • Joined: 19-March 11

Re: Is mathematics used more or logic used more in programming?

Posted 31 December 2019 - 10:28 PM

It's true that logic as a systematic endeavor originated in philosophy, and it is only relatively recently that it's been recognized as a branch of math, but if you spend more time doing logic and less time arguing about it, you'll notice that what you're doing is undeniably math.
Was This Post Helpful? 1
  • +
  • -

#15 noviceFedora   User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 44
  • Joined: 08-December 19

Re: Is mathematics used more or logic used more in programming?

Posted 03 January 2020 - 01:07 AM

View Postmacosxnerd101, on 31 December 2019 - 09:17 PM, said:

I have a masters degree in Math and have taken a class with one of Tarskiís students. Logic is a branch of Math- regardless of what Wikipedia says. It is also quite common for fields to intersect with different disciplines. :)/>In any event- this point seems important to you. How does it relate to your OP regarding programming?


The reason why it matters to me is because in my OP I have clearly demarcated numerical calculations and computations as mathematics, and statements and expressions as logic. You and few other users(including jon.kiparsky) have wrote that even combinations of statements and expressions are also mathematics as logic is a branch of mathematics. This removed the demarcation.

View Postjon.kiparsky, on 31 December 2019 - 10:28 PM, said:

It's true that logic as a systematic endeavor originated in philosophy, and it is only relatively recently that it's been recognized as a branch of math, but if you spend more time doing logic and less time arguing about it, you'll notice that what you're doing is undeniably math.

Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »