Home > Software engineering >  Taylor series (mclauren), after 9 or 11, compiler writes;
Taylor series (mclauren), after 9 or 11, compiler writes;

Time:10-21

My formula for sin(x) in taylor series(picture under the code). In general if i enter Start 1 and end 20 with step 2, console output '-nan' after x = 9; sin(X) and Taylor should be the same;, for example:

x = 9; sin(x) = 0.412118; taylor = 0.412118

x = 11; sin(x) = -0.99999; taylor -0.999976;

x = 13; sin(x) = 0.420167; taylor = -nan;

like this all the time; i need some help; its for my laboratory

#include <stdio.h>
#include <math.h>

int main(void) {
    float a, b, left, right, eps = 0.00001, step, x, add = 1, chis, znam, fact, sum = 0, delta;
    printf("Plese enter your start: ");
    scanf("%f", &a);
    printf("Your end: ");
    scanf("%f", &b);
    printf("and step: ");
    scanf("%f", &step);

    if (b < a || a < eps) {
        printf("Your inputs aren't correct");
        return -1;
    }

    printf("\tX\t           sin(x)\tTaylor\t   Delta\n");
    for (x = a; x < b; x  = step) {

        printf("    x =            
  • Related