@Slavon7

Проблемы с библиотекой math.h Проблемы с cos?

Не пойму почему .Я уже менял // for(float a = 0; a < 8; a + 0.5) float на int и всё равно ничего не работает.
///////////////////////////////////////////////////////////////// ! - снизу меняется флоат
main.cpp:23:42: error: no matching function for call to ‘cos(float, double)’
x=(1 - 2 * pow(cos(2 * a, 2.0))) / (2 * (tg((2 * a) - (PI / 4)))) * (pow(sin((PI / 4) + (2 * b)),2.0));

#include <iostream>
#include <math.h>


using namespace std;

int main()
{
    double y; //First
    const double PI = 3.14;
    double x;
    for(float a = 0; a < 8; a + 0.5)
        for(int b = -3; b < 11; b + 0.2){
    {
        if (b!=-3){
            if(a!=4){
        
            x=(pow(sqrt((a-b)/(b+3)),4))+(pow(sqrt((b+a)/(a-4)),4));
        }
            }
        else if(b >= -10){
            if(b < 0){

            x=(1 - 2 * pow(cos(2 * a, 2.0))) / (2 * (tg((2 * a) - (PI / 4)))) * (pow(sin((PI / 4) + (2 * b)),2.0));
       ////////////////////////////////// ^ - ошибка здесь  ////////// ^ - и здесь
 }
        }
        else if (b != a)
        {
            if(b != -a){
            x=(1/(a+b))+(((2*a)-b)/(a-b))-((a+b)/1);
        }
        }
        else
        {
            x=(sqrt(2-a))+((4*b)-3);
        }
    if(x > 12){
    y = ((sqrt(abs(12 + x) - pow(x,2.0)))/(x - 11))-((sqrt(abs(12 + x) - pow(x,2.0)))/(2*x - 9));
        cout << y;
    }
    else(x <= 12);{
       y = (1 + cos(2*x - 2*PI)+cos(4*x + 2*PI) - cos(6*x - PI))/(cos(2*PI - 2*x) + (2*x + PI) - 1)- (2*cos(2*x));
    }
        cout << y ;
    return 0;
}
}
}


main.cpp: In function ‘int main()’:
main.cpp:23:42: error: no matching function for call to ‘cos(float, double)’
             x=(1 - 2 * pow(cos(2 * a, 2.0))) / (2 * (tg((2 * a) - (PI / 4)))) * (pow(sin((PI / 4) + (2 * b)),2.0));
                                          ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/6/bits/c++config.h:507,
                 from /usr/include/c++/6/iostream:38,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:1: note: candidate: double cos(double)
 __MATHCALL (cos,, (_Mdouble_ __x));
 ^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:1: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/6/math.h:36:0,
                 from main.cpp:2:
/usr/include/c++/6/cmath:219:5: note: candidate: template constexpr typename __gnu_cxx::__enable_if::__value, double>::__type std::cos(_Tp)
     cos(_Tp __x)
     ^~~
/usr/include/c++/6/cmath:219:5: note:   template argument deduction/substitution failed:
main.cpp:23:42: note:   candidate expects 1 argument, 2 provided
             x=(1 - 2 * pow(cos(2 * a, 2.0))) / (2 * (tg((2 * a) - (PI / 4)))) * (pow(sin((PI / 4) + (2 * b)),2.0));
                                          ^
In file included from /usr/include/c++/6/math.h:36:0,
                 from main.cpp:2:
/usr/include/c++/6/cmath:211:3: note: candidate: constexpr long double std::cos(long double)
   cos(long double __x)
   ^~~
/usr/include/c++/6/cmath:211:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/6/cmath:207:3: note: candidate: constexpr float std::cos(float)
   cos(float __x)
   ^~~
/usr/include/c++/6/cmath:207:3: note:   candidate expects 1 argument, 2 provided
main.cpp:23:75: error: ‘tg’ was not declared in this scope
             x=(1 - 2 * pow(cos(2 * a, 2.0))) / (2 * (tg((2 * a) - (PI / 4)))) * (pow(sin((PI / 4) + (2 * b)),2.0));
                                                                           ^
  • Вопрос задан
  • 677 просмотров
Решения вопроса 1
GavriKos
@GavriKos
У вас похоже путанина в скобках. Косинус принимает ОДИН аргумент. А вы даете два.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 2
jcmvbkbc
@jcmvbkbc
"I'm here to consult you" © Dogbert
main.cpp:23:42: error: no matching function for call to ‘cos(float, double)’

Вот же он тебе пишет, и даже стрелочкой тыкает, что ты пропустил скобку, и вместо cos(2 * a) у тебя получилось cos(2 * a, 2.0).
Ответ написан
@foul11
Наверное должно было получится так:
x=(1 - 2 * pow(cos(2 * a), 2.0)) / (2 * (tg((2 * a) - (PI / 4)))) * (pow(sin((PI / 4) + (2 * b)),2.0));
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы