2
I’m creating a C program to do the Newtow-Raphson method, it should automatically calculate for the person. But in one part of the method should be done the automatic substitution of values in the function as for example below:
f(x) = x 3 - 3x -1
f(1) = 1 3 - 3.1 -1
The function the user will type as a String, and the program must take this string to replace the number in the X and use as a calculation. Is there any function ready for this? I’m stuck in this part, so far I have :
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <math.h>
void painelPerguntas();
double calculoQtIteracao(double raizA, double raizB, double testeParada);
double calculoModuloAB(double raizA, double raizB);
int main(){
painelPerguntas();
}
void painelPerguntas(){
double raizA = 0, raizB = 0, testeParada = 0;
printf("RAIZ [a]: ");
scanf("%lf", &raizA);
fflush(stdin);
printf("RAIZ [B]: ");
scanf("%lf", &raizB);
fflush(stdin);
printf("PARADA: ");
scanf("%lf", &testeParada);
//CALCULO QUANTIDADE DE ITERAÇÕES
calculoQtIteracao(raizA, raizB, testeParada);
double qtIteracoes = calculoQtIteracao(raizA, raizB, testeParada);
//CALCULA |A-B|
calculoModuloAB(raizA, raizB);
//CALCULA F(A).F(C)
}
double calculoQtIteracao(double raizA, double raizB, double testeParada){
double calculo = (log10(raizB - raizA) - log10(testeParada)) / log10(2);
return round(calculo);
}
double calculoModuloAB(double raizA, double raizB){
double calculo = raizA - raizB;
if(calculo < 0){
calculo = calculo * -1;
return calculo;
}else {
return calculo;
}
}
double calculoSinal(double a, double c){
double calculoA =
}
The function
calculoSinal()
who is responsible for calculating the mathematical functionf(x) = x^3 - 3x -1
?– gato