Mathematica table integration error

In summary, the "Mathematica table integration error" refers to issues encountered when attempting to perform integration within a table structure in Mathematica. Common problems include incorrect syntax, variable scoping issues, or the use of incompatible functions. To resolve these errors, users should ensure proper syntax, check variable definitions, and consider using functions like Table, Integrate, or Evaluate correctly to achieve the desired results.
  • #1
Youssi
6
2
TL;DR Summary
Error in Table Command: Storing Integration Results for Different Upper Bounds
I am calculating the temperature distribution and utilizing the obtained results to calculate the current distribution. In order to do this , I employ a table in which I stock all the current distribution for each value of radius . Subsequently, I aim to identify the radius corresponding to a current distribution of 0.9 with a precision of 0.01. Here are the commands I am using:

table=Table[{x,NIntegrate[2*Pi*r*σ[sol[r]]*F⁄Iarc,{r,10^(-10),x}]},{x,10^(-10),Rlimite}]
table// TableForm
desiredValue=0.9;
precision=0.01;
selectedValues=Select[table,Abs[#[[2]]-desiredValue]<precision&]
chosenX=First[selectedValues][[1]]
The command (table) provides results for only a single value, ( x is within the range of 10^-10 and Rlimite = 0.0071150228199034085). Below are the results for the command table I am utilizing:
{{1/10000000000,0.}}

So It ‘s doesn’t calculate the integral for all the values of x.

the whole program is bellow :

Code:
ClearAll["Global`*"

(*Importation des coéfficient non linéaire : conductivité thermique \

et conductivité thermique*)

Lambda =

Import["C:\\Users\\calcul\\Desktop\\1_mathematica\\condu_therm_rer.\

xlsx"][[1]];

Sigma = Import[

"C:\\Users\\calcul\\Desktop\\1_mathematica\\condu_elec.xlsx"][[1]];



(*Interpolation et création des fonctions de Lamdba et sigma*)

(*Lambda*)

\[Lambda]Interp = Interpolation[Lambda, InterpolationOrder -> 1];

(*Définir la fonction \[Lambda](t)*)

Clear[\[Lambda]];

\[Lambda][t_] := \[Lambda]Interp[t];

(*sigma*)

\[Sigma]Interp = Interpolation[Sigma, InterpolationOrder -> 1];

(*Définir la fonction \[Sigma](t)*)

Clear[\[Sigma]];

\[Sigma][t_] := \[Sigma]Interp[t];

F = 600;

Tmax = 20000;

(*sol=NDSolve[{Equ1,T'[0]==0,T[0]==10000,T[10^-2]==6000},T,{r,0,10^-2}\

][[1]];

Plot[T[r]/. \

sol,{r,0,10^-2},AxesLabel->{"r","T(r)"},PlotLabel->"Graphique de T en \

fonction de r"]*)

Rlimite = 0;

sol = NDSolveValue[{Div[\[Lambda][T[r]]*

Grad[T[r], {r, \[Theta], z}, "Cylindrical"], {r, \[Theta], z},

"Cylindrical"] + \[Sigma][T[r]]*F^2 == 0, T'[10^-10] == 0,

T[10^-10] == Tmax,

WhenEvent[T[r] <= 6500, {Rlimite = r, "StopIntegration"}]},

T, {r, 10^-10, 10^-2}];

Iarc = NIntegrate[2*\[Pi]*r*\[Sigma][sol[r]]*F, {r, 10^-10, Rlimite}]

(*plot de la dsitriution du courant en fonction du rayon de l'arc*)

Plot[NIntegrate[2*\[Pi]*r*\[Sigma][sol[r]]*F, {r, 10^-10, x}]/

Iarc, {x, 10^-10, Rlimite},

AxesLabel -> {"Rayon de l'arc[m]", "Distribution du courant "}]

(*Générer un tableau de valeurs pour différentes valeurs de x*)

table = Table[{x,

NIntegrate[2*Pi*r*\[Sigma][sol[r]]*F/Iarc, {r, 10^-10, x}]}, {x,

10^-10, Rlimite}]

(*Afficher le tableau résultant*)

table // TableForm

desiredValue = 0.9;

precision = 0.01;



(*Utiliser Select pour filtrer les résultats*)

selectedValues =

Select[table, Abs[#[[2]] - desiredValue] < precision &]



(*Si plusieurs valeurs sont proches de 0.9,vous pouvez choisir la \

première*)

chosenX = First[selectedValues][[1]]



(*Afficher le résultat*)

chosenX
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
By default the Table steps the variable by 1 unit at a time, so for {x,10^(-10),Rlimite} with Rlimite = 0.0071150228199034085, you get only x = 10^(-10) since 10^(-10) + 1 < Rlimite. You need to use something like {x,10^(-10),Rlimite,xstep} with xstep the step you want to take in x. However, my guess is that you would be better off using a logarithmic scale, so you will have to rework this a bit.

By the way, please use CODE tags to delimit code. I have edited your post accordingly.
 

FAQ: Mathematica table integration error

Why does my table integration in Mathematica return an error?

Table integration errors in Mathematica often occur due to incorrect syntax, undefined variables, or incompatible data types. Ensure that the integration limits, functions, and variables are properly defined and formatted.

How can I fix the "Integrate::ilim" error in Mathematica?

The "Integrate::ilim" error indicates an issue with the integration limits. Verify that the limits are properly specified and that the variable of integration is correctly identified. For example, use Integrate[f[x], {x, a, b}] where a and b are the integration bounds.

What should I do if Mathematica cannot evaluate my integral?

If Mathematica cannot evaluate an integral, try simplifying the integrand or using numerical integration methods like NIntegrate. Additionally, check for any singularities or discontinuities in the function that might be causing the issue.

Why do I get different results when using Table and Integrate in Mathematica?

Differences in results can arise from numerical precision or evaluation order. Ensure that the function and limits are consistent across both operations. Using higher precision settings or explicitly defining the function might help resolve discrepancies.

How can I debug complex integration errors in Mathematica?

To debug complex integration errors, break down the problem into smaller parts. Evaluate intermediate steps individually, check for syntax errors, and use Mathematica's built-in functions like Simplify and FullSimplify to understand the behavior of the integrand. Consulting the documentation and using Trace can also provide insights into the evaluation process.

Similar threads

Replies
1
Views
2K
Replies
2
Views
3K
Replies
1
Views
1K
Replies
6
Views
3K
Replies
1
Views
4K
Replies
3
Views
932
Replies
1
Views
3K
3
Replies
97
Views
20K
Back
Top