# include "stdio.h"
# include <iostream>
# include <cmath>
using namespace std;
//fac阶乘
int fac(int n)
{
int a=1;
while (n>0)
{
a*=n;
n--;
}
return a;
}
//Ex e的x次
double e(double x){
double y=1.0;
int n=1;
const double eps=1e-6;//提高精度10的-6
double t = x;
while(t>eps||n<10)
{
y=y+t;
n++;
t=(t*x)/n;
}
return y;
}
//sinh
double sinh(double x){
double y;
y=(e(x)-e(-x))/2;
return y;
}
//三次方程求根 牛顿迭代法
double F(double a,double b,double c,double d){
double t=1.0,t1=1.0,t2=1.0,x=1.0;
int n = 1;
while(n<20){
t=a*x*x*x+b*x*x+c*x+d;
t1=3*a*x*x+b*2*x+c;
t2=3*a*2*x+b*2;
x=x-t/t1;
n++;
}
return x;
}
//勒让德公式
double P(double x,int n){
double y = 1.0;
if(n==1)y=x;
else if(n==0)y=1;
else y=((2*n-1)*x-P(x,n-1)-(n-1)*P(x,n-2))/n;
return y;
}
int main()
{
int a, b, c,n;
double x;
cin >> a >> b >> c>>x>>n;
cout << fac(a)+fac(b)+fac(c) << endl;
cout<<sinh(x)<<endl;
cout<<F(1.0,2.0,3.0,4.0)<<endl;
cout<<P(x,n)<<endl;
system("pause");
}
勒让德公式n=0时y是1