Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <stdio.h>
- const double K = 22.5;
- const double L = 7.5;
- double A(double x);
- double B(double x);
- double Y(double a, double b);
- int main(void)
- {
- double x[3] = { 0.324, 1.426, -0.414 };
- printf("\tLab4\n");
- for (int o = 0; o < 3; o++)
- {
- if (A(x[o]) == NULL)
- {
- printf("a = invalid x, must be more than 0, where x = %lf\n", x[o]);
- }
- else {
- printf("a = %lf, where x = %lf\n", A(x[o]), x[o]);
- }
- if (B(x[o]) == NULL)
- {
- printf("b = Invalid x, must be more than 0, where x = %lf\n", x[o]);
- }
- else {
- printf("b = %lf, where x = %lf\n", B(x[o]), x[o]);
- }
- if (Y(A(x[o]), B(x[o])) == NULL)
- {
- printf("y = Invalid x, must be more than 0, where x = %lf\n", x[o]);
- }
- else {
- printf("y = %lf, where x = %lf\n", Y(A(x[o]), B(x[o])), x[o]);
- }
- }
- }
- double A(double x)
- {
- if (x > 0)
- {
- double a = pow(pow(K, -1 / 2) - L * sqrt(x + 2.84), 2);
- return a;
- }
- else {
- return NULL;
- }
- }
- double B(double x)
- {
- if (x > 0)
- {
- double b = -log10(x) + exp(x);
- return b;
- }
- else {
- return NULL;
- }
- }
- double Y(double a, double b)
- {
- if (a == 0 || b == 0)
- {
- return NULL;
- }
- else {
- if (a > b)
- {
- double y = 4 * a + 3 * b / pow(a, 2) + pow(b, 2);
- return y;
- }
- else if(a <= b)
- {
- double y = fabs(a - b);
- return y;
- }
- }
- }
Add Comment
Please, Sign In to add comment