## 5127 Reputation

16 years, 83 days

"A map that tried to pin down a sheep trail was just credible,

but it was an optimistic map that tried to fix a the path made by the wind,

or a path made across the grass by the shadow of flying birds."

- _A Walk through H_, Peter Greenaway

## simpler, maybe better...

Considering Alejandro's comment (as 1D Maple notation input, not cut and paste as 2D Math input code)

````#mover(mi("&zeta;"),mi("~"))`;
```

is simpler than the above while producing 2D Math output that looks better than that from

````#mover(mi("&zeta;"),mi("&tilde;"))`;
```

## "so many others"?...

When you write, "so many others," are you indicating that your fellow students see this problem (often? rarely?) or that you've read about instances of the problem on this or other forums? This is the sort of issue that, even if intermittent or hard to reproduce, can be important to track down and fix.

## clarification...

@Axel Vogt

About whether n is of type posint: I was just considering that the substitution of x=sqrt(z) will not produce a formula correct for all real n and x<0.

I'm not implying that you made a claim that it would work for all x, just that it doesn't. The original poster mentions x^2=z and doesn't yet restrict x (or n) as far as I see. So unless informed otherwise that might plausibly include the case of n=3/4, x=-3 and z=9.

If n is not of type posint then a piecewise result might do, with different formula (from different substitutions) according to whether x>0 or x<0.

## clarification...

@Axel Vogt

About whether n is of type posint: I was just considering that the substitution of x=sqrt(z) will not produce a formula correct for all real n and x<0.

I'm not implying that you made a claim that it would work for all x, just that it doesn't. The original poster mentions x^2=z and doesn't yet restrict x (or n) as far as I see. So unless informed otherwise that might plausibly include the case of n=3/4, x=-3 and z=9.

If n is not of type posint then a piecewise result might do, with different formula (from different substitutions) according to whether x>0 or x<0.

And when n=3/4?

And when n=3/4?

## statistics?...

@Jorgenecochea How is that related to statistics?

@TG It worked for me, with 13.02. (Using your updated k2, and correcting 90 to 0.90 in k1.)

But Markiyan Hirnyk's more graceful method also worked. In addition, his trick gets the solution x

```> restart:

> k1:=x->piecewise(x>=0 and x<=400, 155, x>400, 155+(x-400)*0.90):
> k2:=x->piecewise(x>=0 and x<=100, 125, x>100, 125+(x-100)*0.35):

> ans:=map(convert,[solve(convert(k1(x)=k2(x),Heaviside),x)],piecewise):

> `union`(seq(`if`(type(T,piecewise),
>                 {map2(op,2,PiecewiseTools:-ToList(T))[]},{T}),T=ans))
> minus {undefined};

5900
{1300/7, ----}
11

> evalf(%);

{185.7142857, 536.3636364}

> `union`(op(map(
> proc(T)
>   local sol, z;
>   sol:=solve(T[2],{x});
>   {seq(`if`(evalb(subs(z,T[1]))=true,z,NULL), z in sol)};
> end proc,    PiecewiseTools:-ToList(combine(k1(x)-k2(x))))));

{x = 185.7142857, x = 536.3636364}

> kernelopts(version);
Maple 13.02, IBM INTEL NT, Oct 12 2009, Build ID 436951
```

@TG It worked for me, with 13.02. (Using your updated k2, and correcting 90 to 0.90 in k1.)

But Markiyan Hirnyk's more graceful method also worked. In addition, his trick gets the solution x

```> restart:

> k1:=x->piecewise(x>=0 and x<=400, 155, x>400, 155+(x-400)*0.90):
> k2:=x->piecewise(x>=0 and x<=100, 125, x>100, 125+(x-100)*0.35):

> ans:=map(convert,[solve(convert(k1(x)=k2(x),Heaviside),x)],piecewise):

> `union`(seq(`if`(type(T,piecewise),
>                 {map2(op,2,PiecewiseTools:-ToList(T))[]},{T}),T=ans))
> minus {undefined};

5900
{1300/7, ----}
11

> evalf(%);

{185.7142857, 536.3636364}

> `union`(op(map(
> proc(T)
>   local sol, z;
>   sol:=solve(T[2],{x});
>   {seq(`if`(evalb(subs(z,T[1]))=true,z,NULL), z in sol)};
> end proc,    PiecewiseTools:-ToList(combine(k1(x)-k2(x))))));

{x = 185.7142857, x = 536.3636364}

> kernelopts(version);
Maple 13.02, IBM INTEL NT, Oct 12 2009, Build ID 436951
```

## Warnings...

Are you satisfied that all the Warnings issued in your worksheet from dsolve/numeric are acceptable and may be safely ignored?

The halting on events might be less suspicious (you did specify halting events, after all).

But what about the warnings about stopping prematurely on account of the maxfun limit being hit?

## simplex, rightly or wrongly...

@Axel Vogt I was thinking about how many transformed n-simplexes (n-simplices?) might fit the region of interest. And I knew the volume of the n-simplex, and thought I understood the transformations of the pieces to simplexes. And I had numerically computed the original integration's result for 2-, 3-, and 4-variables, so I had some data.

The `cuhre` method of evalf@Int seemed to baulk at more than 3 variables for the extended problem (similar to what you showed, but for 4 variables). But I wrapped a 1d NCrule around an integrand as a proc which itself did the 3-variable cuhre, and with suitable epsilon got an answer that now turns out to be about 5-6 correct digits in about 90-120 sec. Along the way I noticed what look a little like non-reentracy bugs when wrapping d01ajc around cuhre.

[edited] I'll try to explain more. I wanted to get something like a simplex as the region of integration, because I knew its volume fomula. Ie. I started with the simplex, instead of ending up with it. The factorial in the answer comes from the formula for the volume of the n-simplex, not from counting how many ways to order the x,y,z all between 0 and w. Suppose we take the integrand w^2, and ask for just one ordered way for x<w, y<w, and z<w simultaneously to occur, given only the necessary conditions (for the integrand to simplify so nicely to just w^2) that x^2<w^2, y^2<w^2, and z^2<w^2. One solution is the simplex 0<z<y<x<w<1, another is 0<y<x<z<w<1, etc. Pick just one of those, instead of trying to count the orderings with combinatorics. That will comprise a sufficient condition for the former max() integrand to simplify to something which gets integrated symbolically super fast. To obtain a final formula you'd have to divide by the n-simplex volume (which has a factorial in the denominator), but multiply by number of occurences due to symmetry (powers of 2). That's the best I can do in text, sorry.

## simplex, rightly or wrongly...

@Axel Vogt I was thinking about how many transformed n-simplexes (n-simplices?) might fit the region of interest. And I knew the volume of the n-simplex, and thought I understood the transformations of the pieces to simplexes. And I had numerically computed the original integration's result for 2-, 3-, and 4-variables, so I had some data.

The `cuhre` method of evalf@Int seemed to baulk at more than 3 variables for the extended problem (similar to what you showed, but for 4 variables). But I wrapped a 1d NCrule around an integrand as a proc which itself did the 3-variable cuhre, and with suitable epsilon got an answer that now turns out to be about 5-6 correct digits in about 90-120 sec. Along the way I noticed what look a little like non-reentracy bugs when wrapping d01ajc around cuhre.

[edited] I'll try to explain more. I wanted to get something like a simplex as the region of integration, because I knew its volume fomula. Ie. I started with the simplex, instead of ending up with it. The factorial in the answer comes from the formula for the volume of the n-simplex, not from counting how many ways to order the x,y,z all between 0 and w. Suppose we take the integrand w^2, and ask for just one ordered way for x<w, y<w, and z<w simultaneously to occur, given only the necessary conditions (for the integrand to simplify so nicely to just w^2) that x^2<w^2, y^2<w^2, and z^2<w^2. One solution is the simplex 0<z<y<x<w<1, another is 0<y<x<z<w<1, etc. Pick just one of those, instead of trying to count the orderings with combinatorics. That will comprise a sufficient condition for the former max() integrand to simplify to something which gets integrated symbolically super fast. To obtain a final formula you'd have to divide by the n-simplex volume (which has a factorial in the denominator), but multiply by number of occurences due to symmetry (powers of 2). That's the best I can do in text, sorry.

## dim=3...

@Axel Vogt I wanted a section that had no more symmetry between any pair of variables. Consider a "piece"

plot3d(x^2,y=0..x,x=0..1,axes=box);

The dim=4 case is more interesting. I don't know how to write it.

## dim=3...

@Axel Vogt I wanted a section that had no more symmetry between any pair of variables. Consider a "piece"

plot3d(x^2,y=0..x,x=0..1,axes=box);

The dim=4 case is more interesting. I don't know how to write it.

## sure...

Alter the code to push the evaluated expression to a MathContainer component.