This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: About calculation performance

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Hello.

I have run the following program using CCS10.
My goal is to find the coefficients of the least squares method (quadratic function).
However, when I do the same calculation in MATLAB, I get the answer, but I can't seem to calculate it in DSP.
When I checked the values, there was a gap in the values from the beginning.
Is it possible to eliminate this kind of discrepancy?
Please advise.

Thanks.


#include "driverlib.h"
#include "device.h"
#include "math.h"

double x[100],y[100];

void main(void)
{

    int i=0;
    double x0=0,x1=0,x2=0,x3=0,x4=0,x2y=0,x1y=0,x0y=0;

    x[1]=   2.01    ;   y[1]=   0.211   ;
    x[2]=   2.011   ;   y[2]=   0.238   ;
    x[3]=   2.012   ;   y[3]=   0.266   ;
    x[4]=   2.013   ;   y[4]=   0.295   ;
    x[5]=   2.014   ;   y[5]=   0.324   ;
    x[6]=   2.015   ;   y[6]=   0.354   ;
    x[7]=   2.016   ;   y[7]=   0.385   ;
    x[8]=   2.017   ;   y[8]=   0.416   ;
    x[9]=   2.018   ;   y[9]=   0.448   ;
    x[10]=  2.019   ;   y[10]=  0.481   ;
    x[11]=  2.02    ;   y[11]=  0.514   ;
    x[12]=  2.021   ;   y[12]=  0.549   ;
    x[13]=  2.022   ;   y[13]=  0.583   ;
    x[14]=  2.023   ;   y[14]=  0.619   ;
    x[15]=  2.024   ;   y[15]=  0.655   ;
    x[16]=  2.025   ;   y[16]=  0.692   ;
    x[17]=  2.026   ;   y[17]=  0.730   ;
    x[18]=  2.027   ;   y[18]=  0.768   ;
    x[19]=  2.028   ;   y[19]=  0.807   ;
    x[20]=  2.029   ;   y[20]=  0.847   ;
    x[21]=  2.03    ;   y[21]=  0.887   ;
    x[22]=  2.031   ;   y[22]=  0.928   ;
    x[23]=  2.032   ;   y[23]=  0.970   ;
    x[24]=  2.033   ;   y[24]=  1.013   ;
    x[25]=  2.034   ;   y[25]=  1.056   ;
    x[26]=  2.035   ;   y[26]=  1.100   ;
    x[27]=  2.036   ;   y[27]=  1.144   ;
    x[28]=  2.037   ;   y[28]=  1.190   ;
    x[29]=  2.038   ;   y[29]=  1.236   ;
    x[30]=  2.039   ;   y[30]=  1.282   ;
    x[31]=  2.04    ;   y[31]=  1.330   ;
    x[32]=  2.041   ;   y[32]=  1.378   ;
    x[33]=  2.042   ;   y[33]=  1.426   ;
    x[34]=  2.043   ;   y[34]=  1.476   ;
    x[35]=  2.044   ;   y[35]=  1.526   ;
    x[36]=  2.045   ;   y[36]=  1.577   ;
    x[37]=  2.046   ;   y[37]=  1.628   ;
    x[38]=  2.047   ;   y[38]=  1.681   ;
    x[39]=  2.048   ;   y[39]=  1.733   ;
    x[40]=  2.049   ;   y[40]=  1.787   ;
    x[41]=  2.05    ;   y[41]=  1.841   ;
    x[42]=  2.051   ;   y[42]=  1.896   ;
    x[43]=  2.052   ;   y[43]=  1.952   ;
    x[44]=  2.053   ;   y[44]=  2.008   ;
    x[45]=  2.054   ;   y[45]=  2.065   ;
    x[46]=  2.055   ;   y[46]=  2.123   ;
    x[47]=  2.056   ;   y[47]=  2.182   ;
    x[48]=  2.057   ;   y[48]=  2.241   ;
    x[49]=  2.058   ;   y[49]=  2.301   ;
    x[50]=  2.059   ;   y[50]=  2.361   ;


    for(i = 1; i <= 50; i++)
        {
            x0 = x0 + 1;
            x1 = x1 + x[i];
            x2 = x2 + pow(x[i], 2);
            x3 = x3 + pow(x[i], 3);
            x4 = x4 + pow(x[i], 4);

            x2y = x2y + y[i]*pow(x[i], 2);
            x1y = x1y + y[i]*x[i];
            x0y = x0y + y[i];
        }
    //OK
    double A1,A2,A3,B1,B2,B3,A;

    A1=x4*x2*x0;
    A2=x3*x1*x2;
    A3=x2*x1*x3;
    B1=x2*x2*x2;
    B2=x3*x3*x0;
    B3=x4*x1*x1;
    //OK
    A=A1-B1+A2-B2+A3-B3;
    //OK

//逆行列
    double g11,g12,g13,g21,g22,g23,g31,g32,g33;

    g11= (x2*x0-x1*x1)/A; g12=-(x3*x0-x2*x1)/A; g13= (x3*x1-x2*x2)/A;
    g21=-(x3*x0-x1*x2)/A; g22= (x4*x0-x2*x2)/A; g23=-(x4*x1-x2*x3)/A;
    g31= (x3*x1-x2*x2)/A; g32=-(x4*x1-x3*x2)/A; g33= (x4*x2-x3*x3)/A;
    //OK

//最小二乗法
    double p[10];
    p[0]=g11*x2y+g12*x1y+g13*x0y;
    p[1]=g21*x2y+g22*x1y+g23*x0y;
    p[2]=g31*x2y+g32*x1y+g33*x0y;



    ESTOP0;
}


  • Hi,

    Can you provide some more information about your problem? When you say there is a gap at the beginning, what are you referring to?

  • Hello.
    Thank you for your reply.

    The initial values are given in double type in lines 13 to 62 of the program.
    When compared to the register values, there is a gap starting from the fourth decimal place.
    The gap in the initial values is small, but when it comes to calculating the inverse determinant, it is very different from the calculation in MATLAB.

    Thanks.

  • Please see if the article Floating Point Optimization is helpful.  

    What version of the compiler (not CCS) is being used?  Please show the build options, exactly as the compiler sees them.  Please copy-and-paste the text, and do not use a screen shot.

    Thanks and regards,

    -George

  • Hello.
    Thank you for your reply.

    I don't have the DSP at hand, so I'll verify the article later.

    I think the compiler is "C2000 compiler".
    I'm a beginner and didn't know the build options, so I'll post it here, though it may be different.
    Thanks.

    Thank you.

    **** Build of configuration Debug for project gyouretu2 ****

    "C:\\ti\\ccs1011\\ccs\\utils\\bin\\gmake" -k -j 8 all -O

    Building file: "../gyaku2.c"
    Invoking: C2000 Compiler
    "C:/ti/ccs1011/ccs/tools/compiler/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --fp_mode=relaxed --include_path="C:/Users/watanabelab/new_workspace/gyouretu2" --include_path="C:/Users/watanabelab/new_workspace/gyouretu2/device" --include_path="C:/Users/watanabelab/new_workspace/gyouretu2/Debug" --include_path="C:/Users/watanabelab/new_workspace/gyouretu2" --include_path="C:/ti/ccs1011/C2000Ware_3_03_00_00_Software/driverlib/f2837xd/driverlib" --include_path="C:/ti/ccs1011/ccs/tools/compiler/include" --advice:performance=all --define=CPU1 -g --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi --preproc_with_compile --preproc_dependency="gyaku2.d_raw" "../gyaku2.c"
    "../gyaku2.c", line 99: warning #552-D: variable "p" was set but never used
    Finished building: "../gyaku2.c"

    Building target: "gyouretu2.out"
    Invoking: C2000 Linker
    "C:/ti/ccs1011/ccs/tools/compiler/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --fp_mode=relaxed --advice:performance=all --define=CPU1 -g --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi -z -m"gyouretu2.map" --stack_size=0x200 --warn_sections -i"C:/ti/ccs1011/ccs/tools/compiler/lib" -i"C:/ti/ccs1011/ccs/tools/compiler/include" --reread_libs --diag_wrap=off --display_error_number --xml_link_info="gyouretu2_linkInfo.xml" --rom_model -o "gyouretu2.out" "./gyaku2.obj" "./device/F2837xD_CodeStartBranch.obj" "./device/device.obj" "../2837xD_RAM_lnk_cpu1.cmd" "C:/ti/ccs1011/C2000Ware_3_03_00_00_Software/driverlib/f2837xd/driverlib/ccs/Debug/driverlib.lib" -llibc.a
    <Linking>
    Finished building target: "gyouretu2.out"

    **** Build Finished ****

    -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --fp_mode=relaxed --include_path="C:/Users/watanabelab/new_workspace/gyouretu2" --include_path="C:/Users/watanabelab/new_workspace/gyouretu2/device" --include_path="C:/Users/watanabelab/new_workspace/gyouretu2/Debug" --include_path="C:/Users/watanabelab/new_workspace/gyouretu2" --include_path="C:/ti/ccs1011/C2000Ware_3_03_00_00_Software/driverlib/f2837xd/driverlib" --include_path="C:/ti/ccs1011/ccs/tools/compiler/include" --advice:performance=all --define=CPU1 -g --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi

  • Please change --fp_mode=relaxed to --fp_mode=strict and let me know if that resolves the problem.

    Thanks and regards,

    -George

  • Hello.
    Thank you for your reply.

    I tried it, but it didn't change.

    Thank you.

    **** Build of configuration Debug for project gyouretu4 ****

    "C:\\ti\\ccs1011\\ccs\\utils\\bin\\gmake" -k -j 8 all -O

    Building file: "../gyaku4.c"
    Invoking: C2000 Compiler
    "C:/ti/ccs1011/ccs/tools/compiler/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --tmu_support=tmu0 --vcu_support=vcu2 --opt_for_speed=2 --fp_mode=strict --fp_reassoc=off --include_path="C:/Users/watanabelab/new_workspace/gyouretu4" --include_path="C:/Users/watanabelab/new_workspace/gyouretu4/device" --include_path="C:/Users/watanabelab/new_workspace/gyouretu4/Debug" --include_path="C:/Users/watanabelab/new_workspace/gyouretu4" --include_path="C:/ti/ccs1011/C2000Ware_3_03_00_00_Software/driverlib/f2837xd/driverlib" --include_path="C:/ti/ccs1011/ccs/tools/compiler/include" --advice:performance=all --define=CPU1 -g --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi --preproc_with_compile --preproc_dependency="gyaku4.d_raw" "../gyaku4.c"
    "../gyaku4.c", line 99: warning #552-D: variable "p" was set but never used
    "../gyaku4.c", line 93 (col. 23): advice #2615-D: (Performance) Use --fp_mode=relaxed to enable TMU hardware support for FP division.
    Finished building: "../gyaku4.c"

    Building target: "gyouretu4.out"
    Invoking: C2000 Linker
    "C:/ti/ccs1011/ccs/tools/compiler/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --tmu_support=tmu0 --vcu_support=vcu2 --opt_for_speed=2 --fp_mode=strict --fp_reassoc=off --advice:performance=all --define=CPU1 -g --diag_warning=225 --diag_wrap=off --display_error_number --abi=coffabi -z -m"gyouretu4.map" --stack_size=0x200 --warn_sections -i"C:/ti/ccs1011/ccs/tools/compiler/lib" -i"C:/ti/ccs1011/ccs/tools/compiler/include" --reread_libs --diag_wrap=off --display_error_number --xml_link_info="gyouretu4_linkInfo.xml" --rom_model -o "gyouretu4.out" "./gyaku4.obj" "./device/F2837xD_CodeStartBranch.obj" "./device/device.obj" "../2837xD_RAM_lnk_cpu1.cmd" "C:/ti/ccs1011/C2000Ware_3_03_00_00_Software/driverlib/f2837xd/driverlib/ccs/Debug/driverlib.lib" -llibc.a
    <Linking>
    Finished building target: "gyouretu4.out"

    **** Build Finished ****

  • Please follow these directions to determine the version of the compiler, and let me know what it is.

    I don't understand your code well enough to determine where to focus next.  Please pick one computation from your code that works incorrectly.  Create a simple test case around it.  This test case will set some variables to constant values, then perform the one problem computation.  Add comments which show the result you expect from that computation, and the result you get instead.  Note this test case does not have to run, just compile.

    Thanks and regards,

    -George

  • Hello.
    Thank you very much for your kind reply.

    The compiler version is "TI v20.8.0.STS".

    After some testing, I found that a gap was created in lines 82 to 91 of the attached program. It seems that gaps tend to occur when decimals are involved. I think this may be caused by rounding error.

    Please refer to the comments below for a comparison of the calculation results with matlab.

    Thanks.


    #include "driverlib.h"
    #include "device.h"
    #include "math.h"
    double x[100],y[100];
    void main(void)
    {
        int i=0;
        double x0=0,x1=0,x2=0,x3=0,x4=0,x2y=0,x1y=0,x0y=0;
        x[1]=   2.01    ;   y[1]=   0.21081932  ;
        x[2]=   2.011   ;   y[2]=   0.23805511  ;
        x[3]=   2.012   ;   y[3]=   0.265984531 ;
        x[4]=   2.013   ;   y[4]=   0.294607584 ;
        x[5]=   2.014   ;   y[5]=   0.323924269 ;
        x[6]=   2.015   ;   y[6]=   0.353934585 ;
        x[7]=   2.016   ;   y[7]=   0.384638533 ;
        x[8]=   2.017   ;   y[8]=   0.416036113 ;
        x[9]=   2.018   ;   y[9]=   0.448127325 ;
        x[10]=  2.019   ;   y[10]=  0.480912168 ;
        x[11]=  2.02    ;   y[11]=  0.514390643 ;
        x[12]=  2.021   ;   y[12]=  0.548562749 ;
        x[13]=  2.022   ;   y[13]=  0.583428488 ;
        x[14]=  2.023   ;   y[14]=  0.618987858 ;
        x[15]=  2.024   ;   y[15]=  0.655240859 ;
        x[16]=  2.025   ;   y[16]=  0.692187493 ;
        x[17]=  2.026   ;   y[17]=  0.729827758 ;
        x[18]=  2.027   ;   y[18]=  0.768161655 ;
        x[19]=  2.028   ;   y[19]=  0.807189183 ;
        x[20]=  2.029   ;   y[20]=  0.846910344 ;
        x[21]=  2.03    ;   y[21]=  0.887325135 ;
        x[22]=  2.031   ;   y[22]=  0.928433559 ;
        x[23]=  2.032   ;   y[23]=  0.970235614 ;
        x[24]=  2.033   ;   y[24]=  1.012731301 ;
        x[25]=  2.034   ;   y[25]=  1.05592062  ;
        x[26]=  2.035   ;   y[26]=  1.099803571 ;
        x[27]=  2.036   ;   y[27]=  1.144380153 ;
        x[28]=  2.037   ;   y[28]=  1.189650367 ;
        x[29]=  2.038   ;   y[29]=  1.235614212 ;
        x[30]=  2.039   ;   y[30]=  1.282271689 ;
        x[31]=  2.04    ;   y[31]=  1.329622798 ;
        x[32]=  2.041   ;   y[32]=  1.377667539 ;
        x[33]=  2.042   ;   y[33]=  1.426405911 ;
        x[34]=  2.043   ;   y[34]=  1.475837915 ;
        x[35]=  2.044   ;   y[35]=  1.525963551 ;
        x[36]=  2.045   ;   y[36]=  1.576782818 ;
        x[37]=  2.046   ;   y[37]=  1.628295718 ;
        x[38]=  2.047   ;   y[38]=  1.680502248 ;
        x[39]=  2.048   ;   y[39]=  1.733402411 ;
        x[40]=  2.049   ;   y[40]=  1.786996205 ;
        x[41]=  2.05    ;   y[41]=  1.841283631 ;
        x[42]=  2.051   ;   y[42]=  1.896264689 ;
        x[43]=  2.052   ;   y[43]=  1.951939378 ;
        x[44]=  2.053   ;   y[44]=  2.008307699 ;
        x[45]=  2.054   ;   y[45]=  2.065369652 ;
        x[46]=  2.055   ;   y[46]=  2.123125236 ;
        x[47]=  2.056   ;   y[47]=  2.181574452 ;
        x[48]=  2.057   ;   y[48]=  2.2407173   ;
        x[49]=  2.058   ;   y[49]=  2.30055378  ;
        x[50]=  2.059   ;   y[50]=  2.361083891 ;
        for(i = 1; i <= 50; i++)
            {
                x0 = x0 + 1;
                x1 = x1 + x[i];
                x2 = x2 + pow(x[i], 2);
                x3 = x3 + pow(x[i], 3);
                x4 = x4 + pow(x[i], 4);
                x2y = x2y + y[i]*pow(x[i], 2);
                x1y = x1y + y[i]*x[i];
                x0y = x0y + y[i];
            }
        //OK
        //Inverse matrix calculation(3x3)
        //Determinant calculation
        double A1,A2,A3,B1,B2,B3,A;
        //                          matlab             DSP
        A1=x4*x2*x0;          // A1=8867661.58111860   8867662.0
        A2=x3*x1*x2;          // A2=8866323.50134173   8866324.0
        A3=x2*x1*x3;          // A3=8866323.50134173   8866324.0
        B1=x2*x2*x2;          // B1=8865877.51064579   8865879.0
        B2=x3*x3*x0;          // B2=8867215.61736735   8867216.0
        B3=x4*x1*x1;          // B3=8867215.45578801   8867215.0
        //OK
        A=A1-B1+A2-B2+A3-B3;  // A=9.03382897377014e-07   0.0
    ////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////
        //test
        //#if 0
        A1=0,A2=0,A3=0,B1=0,B2=0,B3=0,A=0;
        x0=2,x1=4,x2=16,x3=34,x4=100;
        //                          matlab  DSP
         A1=x4*x2*x0;          // A1=3200   3200
         A2=x3*x1*x2;          // A2=2176   2176
         A3=x2*x1*x3;          // A3=2176   2176
         B1=x2*x2*x2;          // B1=4096   4096
         B2=x3*x3*x0;          // B2=2312   2312
         B3=x4*x1*x1;          // B3=1600   1600
         A=A1-B1+A2-B2+A3-B3;  // A=-432   -432
         //OK
         A1=0,A2=0,A3=0,B1=0,B2=0,B3=0,A=0;
         x0=3,x1=6.80000000000000,x2=15.6000000000000,x3=36.2240000000000,x4=85.1232000000000;
         //                         matlab  DSP
         A1=x4*x2*x0;          // A1=3983.76576000000   3983.76611
         A2=x3*x1*x2;          // A2=3842.64192000000   3842.64185
         A3=x2*x1*x3;          // A3=3842.64192000000   3842.64185
         B1=x2*x2*x2;          // B1=3796.41600000000   3796.41626
         B2=x3*x3*x0;          // B2=3936.53452800000   3936.53418
         B3=x4*x1*x1;          // B3=3936.09676800000   3936.09692
         A=A1-B1+A2-B2+A3-B3;  // A=0.00230399999918518   0.00244140625
        //#endif
         //test fin
    ///////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////
        //Inverse matrix
        double g11,g12,g13,g21,g22,g23,g31,g32,g33;
        g11= (x2*x0-x1*x1)/A; g12=-(x3*x0-x2*x1)/A; g13= (x3*x1-x2*x2)/A;
        g21=-(x3*x0-x1*x2)/A; g22= (x4*x0-x2*x2)/A; g23=-(x4*x1-x2*x3)/A;
        g31= (x3*x1-x2*x2)/A; g32=-(x4*x1-x3*x2)/A; g33= (x4*x2-x3*x3)/A;
    //least-square method
        double p[10];
        p[0]=g11*x2y+g12*x1y+g13*x0y;
        p[1]=g21*x2y+g22*x1y+g23*x0y;
        p[2]=g31*x2y+g32*x1y+g33*x0y;
        ESTOP0;
    }
  • Unfortunately, that example is much to large to work with.  Please submit something closer to this ...

    double bug_demonstration(double arg1, double arg2)
    {
        /* arg1 is 2.0 */
        /* arg2 is 3.0 */
        double result;
        
        result = arg1 * arg2;
        /* Expect result to be 6.0, but 6.1. is computed instead */
    
        return result;
    }

    Change the numbers and the computation to match one of the problems you see in your code.  But the general form and size of your example should be the same as this one.

    Please let me know the version of the compiler that is used.

    Thanks and regards,

    -George

  • #include "driverlib.h"
    #include "device.h"
    #include "math.h"
    
    int main(void)
    {
        double A1=0,A2=0,A3=0,B1=0,B2=0,B3=0,A=0;
        double x0=3,x1=6.8,x2=15.6,x3=36.224,x4=85.1232;
    
             //                         matlab              DSP
             A1=x4*x2*x0;          // A1=3983.76576000000   3983.76611
             A2=x3*x1*x2;          // A2=3842.64192000000   3842.64185
             A3=x2*x1*x3;          // A3=3842.64192000000   3842.64185
             B1=x2*x2*x2;          // B1=3796.41600000000   3796.41626
             B2=x3*x3*x0;          // B2=3936.53452800000   3936.53418
             B3=x4*x1*x1;          // B3=3936.09676800000   3936.09692
    
             A=A1-B1+A2-B2+A3-B3;  // A=0.00230399999918518   0.00244140625
        
             return 0;
    }
    

    The compiler version is "TI v20.8.0.STS".

    Thanks.

  • Please consider changing all the type double computations to type long double instead.  That may solve the problem.  But it will also take longer and use more memory.  Please let me know if this suggestion resolves the problem.

    Thanks and regards,

    -George

  • By changing all of them to long double, the accuracy of the calculation was improved. The same is true for the target program.
    It would be nice to see a little more accuracy in the target program. If you have any suggestions, I would like to try them.


    Thanks for your kind advice!!





    #include "driverlib.h" #include "device.h" #include "math.h" void main(void) { long double A1=0,A2=0,A3=0,B1=0,B2=0,B3=0,A=0; long double x0=3,x1=6.8,x2=15.6,x3=36.224,x4=85.1232; // matlab DSP A1=x4*x2*x0; // A1=3983.76576000000 3983.7658322790521 A2=x3*x1*x2; // A2=3842.64192000000 3842.642018154294 A3=x2*x1*x3; // A3=3842.64192000000 3842.642018154294 B1=x2*x2*x2; // B1=3796.41600000000 3796.4162785034246 B2=x3*x3*x0; // B2=3936.53452800000 3936.5343157500029 B3=x4*x1*x1; // B3=3936.09676800000 3936.0969639731461 A=A1-B1+A2-B2+A3-B3; // A=0.00230399999918518 0.0023103610665202723 ESTOP0; }

  • For C2000, in COFF mode, "double" is 32-bit IEEE format and "long double" is 64-bit IEEE format, so George is correct to advise you to change your variables to type "long double."  However, your constants are still of type "double."  A float constant with no suffix is of type "double."  The compiler first parses the constant as type "double," then converts the value to "long double" to initialize the "long double" values.  You can get a bit more precision by adding the "L" suffix to your floating-point constants, like so:

    long double x4 = 85.1232L;

    For example:

    #include <stdio.h>
    #include <math.h>
    
    void main()
    {
        long double double_constants_A;
        long double long_double_constants_A;
    
        {
            long double A1=0,A2=0,A3=0,B1=0,B2=0,B3=0,A=0;
            long double x0=3,x1=6.8,x2=15.6,x3=36.224,x4=85.1232;
    
            A1=x4*x2*x0;
            A2=x3*x1*x2;
            A3=x2*x1*x3;
            B1=x2*x2*x2;
            B2=x3*x3*x0;
            B3=x4*x1*x1;
    
            A=A1-B1+A2-B2+A3-B3;
    
            double_constants_A = A;
        }
    
        {
            long double A1=0,A2=0,A3=0,B1=0,B2=0,B3=0,A=0;
            long double x0=3,x1=6.8L,x2=15.6L,x3=36.224L,x4=85.1232L;
    
            A1=x4*x2*x0;
            A2=x3*x1*x2;
            A3=x2*x1*x3;
            B1=x2*x2*x2;
            B2=x3*x3*x0;
            B3=x4*x1*x1;
    
            A=A1-B1+A2-B2+A3-B3;
    
            long_double_constants_A = A;
        }
    
        printf("The version with double constants with no suffix has an error of %Le\n"
               "relative to long double constants with L suffix\n",
               fabsl(long_double_constants_A - double_constants_A)/long_double_constants_A);
    }
    

    The version with double constants with no suffix has an error of 2.760880e-03 relative to long double constants with L suffix

  • It's solved!
    Thank you for helping so polite .