解决方案 - (E(x) - 4 * x * x)通过定点迭代。 [英] Solve eq. - (E(x) - 4*x*x) by fixed point iteration.

查看:72
本文介绍了解决方案 - (E(x) - 4 * x * x)通过定点迭代。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我试图解决方程式。 - (e(x) - 4 * x * x)通过定点迭代。我拿g(X)= x +/-(e ^ x)^(0.5)但是在运行时执行永远不会停止并运行....我为带来g(X)的根源做了什么。 />


我尝试了什么:



这里是我试图解决的问题。 - (e(x) - 4 * x * x)通过定点迭代。我拿g(X)= x +/-(e ^ x)^(0.5)但是在运行时执行永远不会停止并运行....我为带来g(X)的根源做了什么。 />

here is i trying to solve eq. - (e(x) - 4*x*x) by fixed point iteration. i took g(X) = x +/- (e^x)^(0.5) but on running the execution never stop and run on.... .what i do for bringing the roots of g(X).

What I have tried:

here is i trying to solve eq. - (e(x) - 4*x*x) by fixed point iteration. i took g(X) = x +/- (e^x)^(0.5) but on running the execution never stop and run on.... .what i do for bringing the roots of g(X).

#include<stdio.h>
#include<math.h>
double g(double x){
  double result = 0.0;
  result = x + pow(exp(x)/0.25 ,0.5);
 //result = x - (2*log(2*x));
  return result;
}
double g1(double z){
    double result1 = 0.0;
    result1 = 1 + pow(exp(z)/0.0625 , 0.5);
    //result1 = 1 - (2*pow(x,-1));
    return result1;
}
double mode(double z){
  if(z<0)
    return -z;
   else return z;
}
int main(){
  double x0,x1;
  int i=1;
  do{
  printf("Input the approximate value:(x0)\n");
  scanf("%lf",&x0);
    if(mode(g1(x0))<1){
      break;
      }
    else {
        printf("RE-input the approx. value as g'(x0) is greater than 1.\n");
        continue;
    }
  }while(1);
  x1 = g(x0);
  double abserr,ord,abserr0;
  abserr = ord = 0;
  printf("Iteration  x(i)  |g'(xi)|   f(xi)  AbsERROR   ORDER\n");
  printf("%d\t%lf\t%lf\t%lf\t%lf\t%lf\n",i,x0,mode(g1(x0)),g(x0),abserr,ord);
  while(mode(x1-x0)>0.001){
    abserr = x1-x0;
    ord = log(mode(abserr0))/log(mode(abserr));
    x0 = x1;
    x1 = g(x0);
    abserr0 = abserr;
     printf("%d\t%lf\t%lf\t%lf\t%lf\t%lf\n",i,x0,g1(x0),g(x0),abserr,ord);
   i++;
  }
  double answer = x1;
  printf("Answer = %lf\n", x1);

 return 0;
 }

推荐答案

查看 Newton-Raphson的方法 [ ^ ]用于求解方程式。
Look into Newton-Raphson's method[^] for solving equations.


这篇关于解决方案 - (E(x) - 4 * x * x)通过定点迭代。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆