Hi,
ich hoffe jemand kann mir aus meinem Dilemma helfen. Mein geschriebenes Programm kann eine bestimmte Zahl nicht mehr ausgeben weil sie zu groß ist. Ich hänge mal den gekürzten C-Code an. Als alternative habe ich es auch schon in C++ versucht, es resultiert aber der gleiche Fehler.
Wenn man in der Gleichung f1 (drittletzte Zeile) ein weiteres v (verkleinert den Wert um zwei Nullstellen) hinzufügt, kommt das Programm zum richtigen Ergebnis.....
Gruß, obscur
#include <complex>
#include <iostream>
#include <fstream>
using namespace std;
main () {
ofstream prob;
prob.open("test.txt", ios:
ut | ios::trunc);
// Defs
double kappa,theta,lambda,sigma,sigma2,rho,tau,phi,rd,rf;
double b1,b2,a,u1,u2;
int j;
double S,x,v;
kappa=2, theta=0.01, sigma=0.1, rho=0, tau=0.5, lambda=0, phi=1, tau=0.5, rd=0.0, rf=0.0, S=100, v=0.01;
a=kappa*theta;
u1=0.5;
u2=-0.5;
b1=kappa+lambda-sigma*rho;
b2=kappa+lambda;
sigma2=sigma*sigma;
x=log(S);
complex<double> h1,h2,d1,d2,g1,g2,D1,D2,C1,C2,P1,P2;
complex<long double> f1,f2;
complex<double> y1(b1,-rho*phi*sigma);
complex<double> z((-phi*phi),2*u1*phi);
complex<double> r1(0,(rd-rf)*phi*tau);
// Rechnung
d1=y1*y1-sigma2*z;
d1=sqrt(d1);
h1=(y1+d1);
g1=h1/(y1-d1);
D1=h1/sigma2*((1.0-exp(d1*tau))/1.0-g1*exp(d1*tau));
f1=exp(D1*v*v); //Hier gibts Probleme weil D1 zu groß ist
prob<< "f1 ist " << f1 << endl;
prob.close();
}
ich hoffe jemand kann mir aus meinem Dilemma helfen. Mein geschriebenes Programm kann eine bestimmte Zahl nicht mehr ausgeben weil sie zu groß ist. Ich hänge mal den gekürzten C-Code an. Als alternative habe ich es auch schon in C++ versucht, es resultiert aber der gleiche Fehler.
Wenn man in der Gleichung f1 (drittletzte Zeile) ein weiteres v (verkleinert den Wert um zwei Nullstellen) hinzufügt, kommt das Programm zum richtigen Ergebnis.....
Gruß, obscur
#include <complex>
#include <iostream>
#include <fstream>
using namespace std;
main () {
ofstream prob;
prob.open("test.txt", ios:
![Eek! :o :o](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f631.png)
// Defs
double kappa,theta,lambda,sigma,sigma2,rho,tau,phi,rd,rf;
double b1,b2,a,u1,u2;
int j;
double S,x,v;
kappa=2, theta=0.01, sigma=0.1, rho=0, tau=0.5, lambda=0, phi=1, tau=0.5, rd=0.0, rf=0.0, S=100, v=0.01;
a=kappa*theta;
u1=0.5;
u2=-0.5;
b1=kappa+lambda-sigma*rho;
b2=kappa+lambda;
sigma2=sigma*sigma;
x=log(S);
complex<double> h1,h2,d1,d2,g1,g2,D1,D2,C1,C2,P1,P2;
complex<long double> f1,f2;
complex<double> y1(b1,-rho*phi*sigma);
complex<double> z((-phi*phi),2*u1*phi);
complex<double> r1(0,(rd-rf)*phi*tau);
// Rechnung
d1=y1*y1-sigma2*z;
d1=sqrt(d1);
h1=(y1+d1);
g1=h1/(y1-d1);
D1=h1/sigma2*((1.0-exp(d1*tau))/1.0-g1*exp(d1*tau));
f1=exp(D1*v*v); //Hier gibts Probleme weil D1 zu groß ist
prob<< "f1 ist " << f1 << endl;
prob.close();
}