void lab1::funB( double x, double y, double z )
{
double b1 = pow( fabs( y + z ), 0.2 );
double b2 = pow( fabs( z ), 1.34 );
double b3 = pow( y - z, 2 );
double b4 = 1 + ( pow( sin( z ), 2 ) );
double b5 = pow( fabs( z - y ), 3 );
double b6 = z / ( cos( pow ( x, 2 ) ) );
b = b1 / b2 + b3 / b4 + b5 / b6;
}
void lab1::funA( double x, double y, double z )
{
double a1 = sqrt( ( pow( x * x - 1, 0.3 ) ) );
double a2 = pow( ( sin( y + 2 * b ) ), 1 / 3 );
double a3 = 1 + ( x / Faktr( 1 ) ) + ( ( pow( y, 2 ) ) / Faktr( 2 ) )
+ ( ( pow( z, 3 ) ) / Faktr( 3 ) );
a = ( a1 - a2 ) / a3;
}
Не могу найти ошибку в формуле ... мозги плывут ...
[ATTACH]5348[/ATTACH]
Код из ошибкой
Код:
Полный код
Код:
// lab1.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <conio.h>
using namespace std;
class lab1
{
private:
double a,b;
public:
lab1() : a( 1 ), b( 1 ) {}
void funB( double x, double y, double z );
void funA( double x, double y, double z );
double Faktr( int n );
void showlab1( char *c, char *s )
{ cout << setw( 8 ) << c << b << s << a << endl; }
void tabX( double xp, double xk, double dx, double y, double z );
void tabXY(double xp, double xk, double dx, double yp, double yk, double dy, double z);
};
void lab1::funB( double x, double y, double z )
{
double b1 = pow( fabs( y + z ), 0.2 );
double b2 = pow( fabs( z ), 1.34 );
double b3 = pow( y - z, 2 );
double b4 = 1 + ( pow( sin( z ), 2 ) );
double b5 = pow( fabs( z - y ), 3 );
double b6 = z / ( cos( pow ( x, 2 ) ) );
b = b1 / b2 + b3 / b4 + b5 / b6;
}
void lab1::funA( double x, double y, double z )
{
double a1 = sqrt( ( pow( x * x - 1, 0.3 ) ) );
double a2 = pow( ( sin( y + 2 * b ) ), 1 / 3 );
double a3 = 1 + ( x / Faktr( 1 ) ) + ( ( pow( y, 2 ) ) / Faktr( 2 ) )
+ ( ( pow( z, 3 ) ) / Faktr( 3 ) );
a = ( a1 - a2 ) / a3;
}
double lab1::Faktr( int n )
{
double f = 1 ;
if( n > 1 )
for( int i = 2; i <= n; i++ )
f *= i;
return f;
}
void lab1::tabX( double xp, double xk, double dx, double y, double z )
{
double x = xp;
while( x < xk )
{
funB( x, y, z );
funA( x, y, z );
cout << setw( 7 ) << "x = " << x;
showlab1( "b = ",", a = " );
x += dx;
}
}
void lab1::tabXY(double xp, double xk, double dx, double yp, double yk, double dy, double z)
{
double y = yp;
while( y <= yk )
{
double x = xp;
cout << setw( 7 ) << y << "->";
while( x < xk )
{
funB( x, y, z );
funA( x, y, z );
cout << setw( 7 ) << a << " ";
x += dx;
}
y += dy;
cout << "\n";
}
}
int main(array<System::String ^> ^args)
{
setlocale( LC_ALL, "" );
cout.precision( 5 );
cout.setf( ios_base::fixed | ios_base::showpoint );
//cout << "Завдання № 1.1\n";
//double x1 = 0.48 * 8, y1 = 0.47 * 8, z1 = -1.32 * 8;
lab1 laba;
//laba.funB( x1, y1, z1 );
//laba.funA( x1, y1, z1 );
//laba.showlab1( "b = ",", a = " );
cout << "Завдання № 1.2\n";
laba.tabX( -1, 1, 0.2, 4.7, 1.32 );
//cout << "Завдання № 1.3\n";
//laba.tabXY( -1, 1, 0.2, -2, 2, 0.2, 1.32 );
system("pause");
return 0;
}
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
#include <conio.h>
using namespace std;
class lab1
{
private:
double a,b;
public:
lab1() : a( 1 ), b( 1 ) {}
void funB( double x, double y, double z );
void funA( double x, double y, double z );
double Faktr( int n );
void showlab1( char *c, char *s )
{ cout << setw( 8 ) << c << b << s << a << endl; }
void tabX( double xp, double xk, double dx, double y, double z );
void tabXY(double xp, double xk, double dx, double yp, double yk, double dy, double z);
};
void lab1::funB( double x, double y, double z )
{
double b1 = pow( fabs( y + z ), 0.2 );
double b2 = pow( fabs( z ), 1.34 );
double b3 = pow( y - z, 2 );
double b4 = 1 + ( pow( sin( z ), 2 ) );
double b5 = pow( fabs( z - y ), 3 );
double b6 = z / ( cos( pow ( x, 2 ) ) );
b = b1 / b2 + b3 / b4 + b5 / b6;
}
void lab1::funA( double x, double y, double z )
{
double a1 = sqrt( ( pow( x * x - 1, 0.3 ) ) );
double a2 = pow( ( sin( y + 2 * b ) ), 1 / 3 );
double a3 = 1 + ( x / Faktr( 1 ) ) + ( ( pow( y, 2 ) ) / Faktr( 2 ) )
+ ( ( pow( z, 3 ) ) / Faktr( 3 ) );
a = ( a1 - a2 ) / a3;
}
double lab1::Faktr( int n )
{
double f = 1 ;
if( n > 1 )
for( int i = 2; i <= n; i++ )
f *= i;
return f;
}
void lab1::tabX( double xp, double xk, double dx, double y, double z )
{
double x = xp;
while( x < xk )
{
funB( x, y, z );
funA( x, y, z );
cout << setw( 7 ) << "x = " << x;
showlab1( "b = ",", a = " );
x += dx;
}
}
void lab1::tabXY(double xp, double xk, double dx, double yp, double yk, double dy, double z)
{
double y = yp;
while( y <= yk )
{
double x = xp;
cout << setw( 7 ) << y << "->";
while( x < xk )
{
funB( x, y, z );
funA( x, y, z );
cout << setw( 7 ) << a << " ";
x += dx;
}
y += dy;
cout << "\n";
}
}
int main(array<System::String ^> ^args)
{
setlocale( LC_ALL, "" );
cout.precision( 5 );
cout.setf( ios_base::fixed | ios_base::showpoint );
//cout << "Завдання № 1.1\n";
//double x1 = 0.48 * 8, y1 = 0.47 * 8, z1 = -1.32 * 8;
lab1 laba;
//laba.funB( x1, y1, z1 );
//laba.funA( x1, y1, z1 );
//laba.showlab1( "b = ",", a = " );
cout << "Завдання № 1.2\n";
laba.tabX( -1, 1, 0.2, 4.7, 1.32 );
//cout << "Завдання № 1.3\n";
//laba.tabXY( -1, 1, 0.2, -2, 2, 0.2, 1.32 );
system("pause");
return 0;
}
[code=c++]
void lab1::funA( double x, double y, double z )
{
double a1 = sqrt( ( pow( fabs(x * x - 1), 0.3 ) ) );
double a2 = pow( ( fabs(sin( y + 2 * b ) ) ), 1 / 3 );
double a3 = 1 + ( x / Faktr( 1 ) ) + ( ( pow( y, 2 ) ) / Faktr( 2 ) )
+ ( ( pow( z, 3 ) ) / Faktr( 3 ) );
a = ( a1 - a2 ) / a3;
}
[/code]
спасибо