mathematic libraries

well i read that i can use math.h library to do some maths with arduino, tho i can not find it and download it to work inside libraries.Any help or any other libraries that can do at least the same?

You can use the functions defined in math.h. It is not an Arduino-specific library, and the IDE will include it automatically when compiling your code (along with the corresponding object files). It does not compile the code associated with math.h.

Perhaps you need to rephrase your question.

you can use all of these - avr-libc: Modules - and yes there is some math involved

let me rephrase. I want to do some maths in my code how can i do it what library do i have to #include <library.h> and how (what files in what directory)?

I want to do some maths in my code

Go right ahead.

how can i do it

Do what? What kind of "maths" do you need to do?

what library do i have to #include

The right one.

and how

Typically, using #include statements.

what files in what directory

The right ones. Since you haven't defined what you want to do, how can you expect us to help you?

well propably i am still not clear. i need to do maths with matrix and acos atan etc. i think that math.h library can cover my problem. i know that i have to #include the library. i have seen the avr library and also i have checked arduino that needs 3 files the .cpp the .h and .txt file for one library. I can not find them all for the math.h library. Can you help me find it?

I can not find them all for the math.h library

Have you checked the link I posted in reply#2?

i need to do maths with matrix and acos atan etc.

#include <math.h> takes care of acos and atan. I am not familiar with the etc() function however :wink:

There is some matrix code / library on the arduino.cc/playground [google], but for processing larger matrices the Arduino UNO may not have enough memory.

Can you give the exhaustive list of functions you need?

i need to use sin, cos, tan, stan, acos, asin, matrix, average, sum, power and square, i need to make conversion from rad to degrees so i need to use pi() that i did not found the spelling.

i have checked that i can use all trigonometric functions without math.h i can type pi()(3.14......) with PI.i can not find things about matrix, square,and power. Also it would be better if all the asin functions worked with degrees and not with rads but i can leave with it.I knew the site before making this post. I can not find the way to download the libraries.I can download the general file for unix but how can i use them for arduino.

etc is a very special function and very rear like autocomplete that i do not think i can find in arduino IDE. :slight_smile: XD

You should be aware that Arduino floating point is all 32-bit with all the precision that comes with it (IIRC, 6 significant digits except that 1.0 may turn to .999999 needing code to deal with at print time) and very slow in a no-FPU way.

Consider that Arduino does support 64-bit integers. They can be used with fixed point or variable fixed point schemes to give higher precision.

You also can store tables in AVR flash/program space. For what you want, 45 degrees of sine * 10^precision-digits and some interpolation can give you all the trig values.
Table lookup is so much faster that it was usable to computer aim big telescopes before 1960.

pi is not a function. It is a value. You can determine the value of pi from atan(1.0), or you can hardcode it to more decimal places than the Arduino can handle.

What you still haven't answered is WHY you need to do all this stuff. The Arduino doesn't sound like the right platform for you.

i need to pass a solar position equations to arduino. i needto be able to get the angles of the sun from it. i know that pi is not a function. i manage to find how to type it at the code. i want to find a library for matrix and i think i maybe succedd on that and it would be great it i could find a math library that by default gets angles in Degrees and not in rads. also how to define the decimal significant digits for the calculation results.

The smart move is to pre-calculate the aiming data into a table and store it in flash.
Your Arduino software will be both incredibly faster and incredibly smaller, not to mention have a far shorter development time.

i need to pass a solar position equations to arduino.

The Arduino is not the best platform for this. Pass the equation from what?

Conversion from radians to degrees is trivial - it should have no impact on the choice of library. You can even make little wrapper functions for your existing trig calls to handle this if you don't want to do it explicitly all over your code.

People could likely give better advice though if you could clarify what you're trying to do. Irrespective of the trig and solar calculations, what will your project be doing? what is the role of the arduino in this? Are you aligning solar panels, aiming a telescope, opening a chicken coop or (more likely) something completely different?

i can not make a table with the angles because they can not be calculated for too many hour and for all year and also there is another way of calculation that uses 4 year calculation time to do the maths so the table is not good solution. right now i just need to find a way to do the uses matrix and caclulaitons with matrixes and also a library that calculates trigonometrical functions in degrees and not in rads

well in this step i just want to get the angles of the sun with input the day the gps data and the hour. these equations are known but there is a lot of angles involved in the calculations so i think it is better if i can not find a library that calculates the trigonometrical functions in angles and not in rads to write one with functions like mycos(degrees).

You are still talking about how to implement a solution, when we haven't even agreed that you have chosen the right platform on which to implement the solution.

well i will need to control propably a servo or a dc motor with the arduino. i will use accell and gyro and also i need to be able to calculate the angles without output from sensors. either way i have to do it to arduino. so i have to find a way to make my life easier with the implemantation by finding a suitable library.

so i have to find a way to make my life easier with the implemantation by finding a suitable library.

I'm still not convinced of this, for several reasons.

First, you still have not said where the equations are coming from. Perhaps what you mean is that the Arduino needs to solve the equations based on data that it gets from sensors, rather than that the equations are read from some input source.

Second, why do you expect someone else to have done the work? Why don't YOU write the library?

Third, your idea that the results of solving the equations will be more accurate than a lookup table is possibly wrong. Primarily because we don't know what you are going to be using the results for. That you think that you probably need to control some kind of motor means that you don't have a real need for the data, yet. You haven't explained what you are doing yet.

If you really want help, you'll stop trying to tell us what you think you need to do, and start telling us what this project is really about.

well you need the big picture that is making something like a solar tracker. so i need to move motors according certain angles that will be calculated from certain equations (solar angle equations).So this is why i do not think that pre-calculation of agles for almost 8hours per day for every year with step of 5-10 minutes will work. My main question is about the library and it does not need to be so much explained.i was wondering if there is a library that uses degrees in trigonometrical function and not rads. yes you are correct i will write the library. I was just asking cause the world is too big in order to think this thing is not already done by someone.
Thank you anyway