If $(\mathbb{R},|.|)$ is a real line, $C$ a subset of $\mathbb{R}$ and $K(C)$ denote set of a compact subset of $C$. Define a multivalued mapping $T:C\rightarrow K(C)$. We know that a point $p\in C$ is called an enpoint of $T$ if $Tp=\{p\}$. Suppose for $x\in X$, we set $R(x,C)=\max\{|x-y|:y\in C\}$. Now let $C=[0,1]$ and $T:C\rightarrow K(C)$ be $Tx=[0,1]$. Then $p=0$ is a unique endpoint of $T$. I want to find the value by the following iteration method: $x_{0}=0.5\in C$, $a_{n}=0.8$ and set $x_{n+1}=(1-\alpha_{n})x_{n}+\alpha_{n}u_{n},$

where $u_{n}\in Tx_{n}$ such that $|u_{n}-x_{n}|=R(x_{n},Tx_{n})$. I set the following code in mathmetica:

T[x_] := T[x] = [0, x]
a[n_] := a[n] = 0.8;
x[0] = 0.5;
D(x,T[x])=max{Abs[x-y]:y\[Epsilon] T[x]};
u[n]\[Epsilon] Tx[n] such that Abs[u[n]-x[n]]=R(x[n],T[x[n]]);
x[n_] := x[n] = (1 - a[n - 1]) x[n - 1] + a[n - 1] u[n-1]
NumberForm[a1 = {Table[x[i],{i, 0, 9}]}, 5]

I know there will be several mistakes in my code to which doest run the code because Im not too much expert in mathemtica. I will thank if any one improve my code (or suggest a new method to define it) too achieve my target.

  • 1
    $\begingroup$ D is a system symbol for the (partial) derivative. ( ... , ... ) is a syntax error. [0, x] is a syntax error. Abs[x, y] makes no sense to me. The colon following it is improper use of Pattern. The phrase such that in the code suggests you need to proofread the question, unless such and that are variables being multiplied. In short, you need to spend some time with an introduction to Mathematica and learn the basic syntax and features of the language — maybe you have since Feb 28, in which case you should post revised code. Or hire a programmer to do the coding for you. $\endgroup$
    – Michael E2
    Apr 14 at 20:40
  • $\begingroup$ Dear @Michael I know that there will be several in my code. I think the code can be made using an idea mathematica.stackexchange.com/questions/113795/… $\endgroup$
    – Junaid
    Apr 14 at 21:59
  • $\begingroup$ But Im not a too much expert in mathematica that why I posted it here. $\endgroup$
    – Junaid
    Apr 14 at 22:00
  • $\begingroup$ Did you mean to define $T$ like this: $T x = [0,x]$? $\endgroup$ Apr 16 at 12:42

1 Answer 1

x0 = 0.5;
\[Alpha] = 0.8;
T = Function[x, Interval[{0, x}]];
u = Function[x, With[{ends = MinMax[T[x]]},
    ends[[Ordering[Abs[ends - x], -1][[1]]]]
 Function[x, (1 - \[Alpha]) x + \[Alpha] u[x]],
 SameTest -> (Abs[#1 - #2] < 1*^-12 &)

{0.5, 0.1, 0.02, 0.004, 0.0008, 0.00016, 0.000032, 6.4*10^-6, 1.28*10^-6, 2.56*10^-7, 5.12*10^-8, 1.024*10^-8, 2.048*10^-9, 4.096*10^-10, 8.192*10^-11, 1.6384*10^-11, 3.2768*10^-12, 6.5536*10^-13, 1.31072*10^-13}

  • $\begingroup$ Dear @Henrik the code you suggested is pretty best. However, It not run in my PC. Is there any thing missed here? $\endgroup$
    – Junaid
    Apr 20 at 3:39
  • $\begingroup$ Maybe |-> was the reason. I changed all its occurrences to Function. Please try again. $\endgroup$ Apr 20 at 3:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.