Is it permissible according to halacha to do math?
If so, are all kinds of math OK?
It depends on the kind of math.
Addition and subtraction are both bad, for two reasons.
The first is due to the prohibitions of בל תוסיף and בל תגרע -- lest you add or subtract.
As if a Biblical prohibition isn't enough, there's also issues of heresy and idolatry! A plus sign looks like a cross, which is idolatry. And as for minus, that's heresy: מינות.
However, not all math is so problematic. Aderabe, it is a worth lots of mitzvahs to do trigonometry! We have תריג מצוות -- trig mitzvot.
I am surprised that people here are against addition and subtraction. In fact, the book of Genesis teaches us both!
Genesis 5 is a lesson in addition. For each of our fathers from Adam to Noah, there is his age at the birth of the first son and the number of years he leaved afterwards, and the total age, which is of course the sum of the previous two numbers. For example:
When Kenan had lived 70 years, he became the father of Mahalalel. And after he became the father of Mahalalel, Kenan lived 840 years and had other sons and daughters. Altogether, Kenan lived 910 years, and then he died.
Genesis 11 is an exercise in addition: there, only the age at the first birth and the number of years afterwards are written; we have to do the addition to get at the total age, e.g.:
When Shelah had lived 30 years, he became the father of Eber. And after he became the father of Eber, Shelah lived 403 years and had other sons and daughters.
Genesis 18 is a lesson in subtraction! In Genesis 18:18, Abraham asks:
What if the number of the righteous is five less than fifty? Will you destroy the whole city because of five people?
Abraham apparently didn't know up to that moment how to do 50 minus 5. So The Lord taught him to do the math:
If I find forty-five there," he said, "I will not destroy it."
.ומת מצוה קונה מקומו ...
... and math is a commandment [of the] One who Owns His place.
"The One who Owns His place" is an unusual appellation for God, but Yehoshua' probably chose it as a reminder that "God's place" (as it were), the Land of Israel, belongs ultimately to God (like all other land), and that He only permits inheritance thereof by people who are fitting.
Unlike in the desert, where the Israelites had had all of their material needs taken care of, in the Land of Israel, they were required to engage with the natural world themselves, applying God's commandments in the context of real life, making the resulting Jewish country a living sanctification of God's name. As we all know, the foundation of all other natural studies is math, so God made it very clear that learning it would be necessary for anyone who wants to inherit a piece of the Land of Israel.
The Tanach talks about the city of חשבון Cheshbon, an Amorite capital located in current-day Jordan, which was conquered by the Israelites as they entered Israel. (See Devarim 2:24 and Bamidbar 21:21-35, Bamidbar 32:37, Yehoshua 21:39 for some mentions.)
Clearly, therefore, we can derive that the subject of cheshbon (Hebrew for "arithmetic"), while initially perhaps feared as an enemy, is meant to be conquered by Jews... though in modern times this generally involves more studying than warfare.
Jewish ichthyologists (biologists who study fish) are especially encouraged to be mathematically well-versed, given Shir HaShirim 7:5's praise of the beauty of Cheshbon's fish ponds.
Math (מת) is numerically equivalent to עמכם רע (evil is with you) this obviously renders all forms of mathematics thoroughly forbidden. Additionally, the Torah refers to practitioners of the mathematical arts as "impure lepers" as the verse (Leviticus 13:44) states צרוע הוא טמא הוא (he is an impure leper). This is numerically equivalent to math.
However, mathematics fans know that without mathematics life wouldn't be worth living. This is explicit in the Torah as the numerical value of math (מת) is נפשי (my life or spirit). We would thus permit it on the grounds of pikkuach nefesh.
However, mathematics might be considered the cultural tool of Western culture. This is stated explicitly in the Torah as the numerical value of math (מת) is equivalent to עשו אבי אדום (Esau the progenitor of Edom) a clear reference to western cultures evil anscestor. As such studying mathematics would be akin to shmad (enforced violation of Torah), since we are in a shaas hashmad, (as mathematics are taught in schools and students are punished if they dont comply) studying mathematics would be yeihareg v'al yaavor a cardinal sin which wouldn't be subject to the exemption of pikuach nefesh.
However, all we need to prove is that Jews had mathematics first and that Esav stole it, and then mathematics would cease being yeihareg v'al yaavor and would return to being permitted under the rubric of pikuach nefesh. This is obviously the case as we know that all secular knowledge originated with Jews. Nevertheless, this is hinted to by the Torah when Yehudah and Yosef "spoke in mathematics" after Yehuda requested that Yosef allow him to tell over a "shtickl mathematics". We find this in the words בי אדני ידבר נא עבדך (Genesis 44:18) which has the numerical value of 440 which is the same as the numerical value of math.
Lest the one of little faith assert that maybe the brothers themselves stole the science of mathematics from Esav, this is impossible as their father Jacob was already adept at mathematics as the verse describes him as איש תם meaning a man of mathematics (as תם) is simply math spelled backwards. This explains what he was doing in the tents (he was studiously studying mathematics). We find further proof that tents are a Biblical reference to mathematics houses from the verse (Exod. 33:9) והיה כבא משה האהלה (And it was when Moses came to the tent) which is numerically equivalent to 440 (the value of math). Accordingly, although mathematics is forbidden, it would certainly be permitted as pikuach nefesh.
Besides for the normal allowance for mathematics there is a special mitzva on Shabbos about which it is stated (Exod. 20:8) "to sanctify it" (לקדשו) this sanctification refers to mathematics as the numerical value of לקדשו is 440, the value of mathematics.
The Gaon of Vilna taught in Kol Hator Chapter 5 part 2 that everyone should study 7 natural sciences, including:
Mathematics, astronomy, and geometry
Natural science and chemistry
Medicine and pharmacology
Logic, grammar, and syntax
Musicology and its esoteric theory
Engineering and construction
Parapsychology and the brain sciences
We can see that math is the most important one.
The prayer Nishmat Kol Chai mentions
...to bless Your Name for even one of the thousand thousand, thousands of thousands and myriad myriads of favors that You performed for our ancestors and for us.
That is 10^20, or 100,000,000,000,000,000,000 blessings. Clearly Hashem wants us to study math, as such numbers are impossible to understand without math.
Source: The Complete Artscroll Siddur, pp. 401–402
Hebrew: מאלף אלפי אלפים ורב רבי רבבות