博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVa-10341
阅读量:4286 次
发布时间:2019-05-27

本文共 802 字,大约阅读时间需要 2 分钟。

题意:解方程

p*e-x q*sin(x) + r*cos(x) + s*tan(x) + t*x2 + u = 0

        where 0 <= x <= 1.(0 <= p,r <= 20 and -20 <= q,s,t <= 0

题目链接:

观察可得 求导可得此函数是递减函数 判断是否有解即 f(0) * f(1) <= 0

在此还要懂得运用 三角函数 ,还有求e^(-x) ,要用到exp函数求解 e^(-x) = exp(-x);

三角函数sin(x) 中x指的经过角度变化的弧度

解决此题用二分求解

#include
#include
double p,q,r,s,t,u;double f(double x){ return p*exp(-x) + q*sin(x) + r*cos(x) + s*tan(x) + t*x*x + u ;}void find(double x,double y){ double mid; while(y - x > 0.000000001) { mid =( x + y ) / 2 ; double t = f(mid) ; if(t < 0) y = mid; else x = mid ; } printf("%.4lf\n",mid);}int main(){ while(scanf("%lf%lf%lf%lf%lf%lf",&p,&q,&r,&s,&t,&u)!=EOF) { if(f(0) * f(1) > 0) printf("No solution\n"); else { find(0.0,1.0); } }}

转载地址:http://uysgi.baihongyu.com/

你可能感兴趣的文章
轮盘赌选择,原理及C++实现
查看>>
C/C++中各种类型int、long、double、char表示范围(最大最小值)
查看>>
《Python爬虫学习系列教程》学习笔记
查看>>
MIC编程(4)——MIC灵活高效的编程方式
查看>>
Apriori算法
查看>>
Python itertools模块详解
查看>>
Apriori算法简介及实现(python)
查看>>
Python中的集合:set与frozenset用法举例
查看>>
python strip()函数 介绍
查看>>
pandas库中数据结构DataFrame的绘制函数
查看>>
Latex使用小结
查看>>
使用networkx-python绘制点边图
查看>>
NetworkX Tutorial Release 1.10
查看>>
networkx使用笔记(二)之小试牛刀篇
查看>>
Python 优雅的操作字典
查看>>
Latex设置表格字体大小
查看>>
Latex公式及编号
查看>>
Python __future__ 模块
查看>>
TensorFlow入门学习(让机器/算法帮助我们作出选择)
查看>>
把项目从Python2.x移植到Python3.x的经验总结
查看>>