Questions tagged [mathematics]

Mathematics is the study of quantity, structure, space, and change. Any math questions on this site should be programming related.

Mathematics is the study of quantity, structure, space, and change. Mathematicians seek out patterns, formulate new conjectures, and establish truth by rigorous deduction from appropriately chosen axioms and definitions.

Through the use of abstraction and logical reasoning, mathematics evolved from counting, calculation, measurement, and the systematic study of the shapes and motions of physical objects. Practical mathematics has been a human activity for as far back as written records exist.

Mathematics is behind all programming at some level, but math questions here should be specifically related to a programmed implementation. General math questions can be asked at Mathematics. Research level mathematics questions can be asked at MathOverflow.

43 questions
12
votes
2 answers

On an esp8266 what is faster, 64-bit math or float math?

I need to do some math with vars from an attitude sensor (acclerometers and gyroscopes) on an esp8266. int32_t math with those vars does not have enough range and the float math operations are abyssmally slow. I'm hoping to use a fixed-point format…
mark-hahn
  • 297
  • 2
  • 6
11
votes
10 answers

Different ways (and the fastest) to compute sines (and cosines) in Arduino

I am using an Arduino Uno board to compute the angles of my system (robotic arm). The angles are actually 10 bit values (0 to 1023) from the ADC, using the full range of the ADC. I am only going to be operating in the 1st quadrant (0 to 90 deg),…
10
votes
2 answers

Is there a non-float alternative to pow()?

I've scoured the LANGUAGE REFERENCE in the Arduino web-site, and I can't find a non-Float equivalent to pow() I've got to be missing something big, but for the life of me, I'm stumped! I found pow() in the FUNCTIONS column under the Math heading…
user16841
4
votes
2 answers

How are errors (not related to syntax) managed in arduino and in the AVR architecture in general?

I was just curious about how the AVR architecture manages errors that would cause a regular desktop program to crash. I'm talking about logical errors for example math problems that are undefined. Such as division by 0 and getting a square root of a…
Coder_fox
  • 686
  • 7
  • 14
4
votes
3 answers

eval() function for Arduino?

I plan to do the following: void setup(){ String term = "12 + (2 * 5)"; int result = eval(term); // eval function (from Python) Serial.println(result); // expecting 22 } However there is no eval function. Are there any alternatives?
loucket
  • 41
  • 1
  • 2
3
votes
2 answers

Rounding up and Down

My arduino is meisuring the tempature and gives values like: 28.58 Degrees Celcius. I would like to round this up to one decimal. I could make the variable one shorter by cutting the "8" off which would desplay 28.5. Yet this feels a bit like…
Anton van der Wel
  • 215
  • 1
  • 2
  • 16
3
votes
2 answers

Avoiding float math to speed up arduino

I read and heard that the floating point math is much slower than int math. And I saw a converting process in here floath math to integer math So I want to to convert my floating math calculations to integer math. Here is the code that include…
sir mordred
  • 55
  • 1
  • 5
2
votes
2 answers

How do I find the whole number (n) that when multiplied by (m) will be closest to (x)?

I've designed an apparatus that uses stepper motors, and they are linked together so that when armature A turns, it consequently moves armature B by a ratio of 1/4. In order to keep armature B in the same position, for every 4 steps stepper A takes,…
AJ_Smoothie
  • 504
  • 4
  • 13
2
votes
1 answer

Hysteresis and scaling range

Here I asked about how to add an hysteresis on ADC readings. The answer received was very good and it worked out of the box. Still I'm having troubles trying to generalize the resample function in order to map the input values to a different range…
Mark
  • 393
  • 2
  • 14
2
votes
1 answer

Remove gravity from accelerometer of MPU-6050

I am currently working with MPU-6050. Now I want to minus gravity from my accelerometer's value as we minus the offset. Here is the code: #include #include //read as rool:pitch:yaw:accX:accY:accZ MPU6050 mpu; unsigned long timer…
2
votes
2 answers

Elechouse MP3 shield play random song

Using this code to try and play a random song when someone walks by my distance sensor I get an error, the same song (track 0001) plays every time. Any advice? #include SoftwareSerial Geno(7, 8); // Rx, Tx unsigned char…
Pagaley 12
  • 21
  • 1
2
votes
0 answers

Transforming from analog output to speed and acceleration with gy-61

Maybe it's a simple question but I'm unable to get what I need. My task is this: Get the acceleration and speed of each axis of the accelerometer. I thought of something like: const int VCCPin = A0; const int xPin = A1; const int yPin =…
Allan Vital
  • 121
  • 1
1
vote
1 answer

Is it possible to use mathematical sets and their operations in arduino?

In python there is the object set that resembles a mathematical set, namely, you can remove elements from it, add elements to it, you can calculate the intersection/union between two sets, etc. Is there a library or built-in functions that have…
Schach21
  • 121
  • 3
1
vote
0 answers

Math on analog read wrong result

I'm trying to execute a math of analog read but I get some weird result.. I searched about int and floats but didn't understand.. My code is : #include SevSeg sevSeg; int bitsChange = analogRead(A0) ; float fuel = (923 - bitsChange) *…
m sayed
  • 11
  • 2
1
vote
1 answer

Hexadecimal array does not add up as expected

I have an array of hexadecimal values as given below. byte Hexa_Val[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; I want to increase this array from the end. As in, go from {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} all the way to…
C Vith
  • 133
  • 1
  • 7
1
2 3