필터 지우기
필터 지우기

How can I rewrite an equation written in FORTRAN file by Matlab?

조회 수: 2 (최근 30일)
ND
ND 2018년 9월 17일
댓글: Walter Roberson 2018년 9월 19일
Please, I have an equation differentiated in Matlab and transferred to a FORTRAN file. How can I get back the original equation (before differentiation) as the result written in FORTRAN file looks difficult to be arranged. Below is an example of the differentiated equation written in FORTRAN.
t3 = EX*6.412498652425423D23
t2 = t3-1.584301877890218D19
t4 = t2**2
t5 = t4+1.097400831008096D40
t6 = EX*8.224027793471572D47
t7 = t6-2.031866731401218D43
t8 = 1.0D0/sqrt(t5)
t9 = t7*t8*(1.0D0/2.0D0)
t10 = t9+6.412498652425423D23
t11 = sqrt(t5)
t12 = t3+t11-1.584301877890218D19
A0(1,1) = t10*1.0D0/t12**(2.0D0/3.0D0)*(1.0D0/3.0D0)+t10*1.0D0/t12
+**(4.0D0/3.0D0)*7.407423474671637D12
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 9월 17일
With the symbolic toolbox it is not difficult to put that together into a single expression for A0 in terms of EX, getting
2.666666666666667*(0.7479709705395701e36*EX-0.1847972026918085e32+4777683803756105.*(0.2450951276264063e41*EX^2-0.1211086947561036e37*EX+0.6690627070730690e33)^(1/2))*(0.1025999784388068e26*EX+65536.*(0.2450951276264063e41*EX^2-0.1211086947561036e37*EX+0.6690627070730690e33)^(1/2)-0.2534883004624349e21+5688901228547817.*(0.1565551428814800e21*EX+(0.2450951276264063e41*EX^2-0.1211086947561036e37*EX+0.6690627070730690e33)^(1/2)-3867924506567915.)^(1/3))/((0.2450951276264063e41*EX^2-0.1211086947561036e37*EX+0.6690627070730690e33)^(1/2)*(0.1565551428814800e21*EX+(0.2450951276264063e41*EX^2-0.1211086947561036e37*EX+0.6690627070730690e33)^(1/2)-3867924506567915.)^(5/3))
However, there is no obvious integral for that.
ND
ND 2018년 9월 18일
Thank you Walter,
Please how can I put the differentiated equation (A0) in a single expression?
Doing the integration would not be a problem, it can be done manually.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 9월 18일
Rewrite it slightly. Change the D to E. Change the to ^ .
syms EX
and then execute the code.
syms EX
t3 = EX*6.412498652425423E23
t2 = t3-1.584301877890218E19
t4 = t2^2
t5 = t4+1.097400831008096E40
t6 = EX*8.224027793471572E47
t7 = t6-2.031866731401218E43
t8 = 1.0E0/sqrt(t5)
t9 = t7*t8*(1.0E0/2.0E0)
t10 = t9+6.412498652425423E23
t11 = sqrt(t5)
t12 = t3+t11-1.584301877890218E19
A0(1,1) = t10*1.0E0/t12^(2.0E0/3.0E0)*(1.0E0/3.0E0)+t10*1.0E0/t12^(4.0E0/3.0E0)*7.407423474671637E12
The result will be an expression stored in A0. All of the numeric values will have been converted to fractions, so it will start like
((822402779347157244357116847336510700427459690496*EX - 20318667314012179466854033896368807794966528)/(8192*((641249865242542279229440*EX
For numeric integration, you could either use vpaintegral on A0 or you could use matlabFunction(A0) and use integral() with the resulting function handle. Either way you would need numeric upper and lower bounds.
  댓글 수: 7
Walter Roberson
Walter Roberson 2018년 9월 18일
I told you yesterday that the equation does not have any obvious closed form integral and you said that would not be a problem, so you should go ahead with whatever technique you had in mind at that time.
Walter Roberson
Walter Roberson 2018년 9월 19일
Numeric integration techniques have difficulty with negative EX starting at approximately -45/1000 (integrating to 0). For example by -51/1000 then using 50 digits is considered to be not enough to integrate to 0 without unacceptable loss of precision.
The equation is not quite symmetric around 0.
The equation is fairly steep near 0, but is not infinite: it peaks at about 1.904514780*10^10.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by