# Question:Error when evaluating integration of piecewise function

## Question:Error when evaluating integration of piecewise function

Maple 16
This question is related to the Question Evaluating multi-variable integration

In the previous question, we discussed a workaround for evaluating a multi-variable integration.

For the following example

`> g := (e1, e2, e3) -> piecewise(e1+1.200000000 <= e2 and e3-2.400000000 <= e1, evalf(64.00000000*exp((-1)*8.000000000*e1^2)*exp((-1)*8.000000000*e2^2)*exp((-1)*8.000000000*e3^2)/Pi^2), 0);> > evalf(Int((x, y, z) -> g(x, y, z), [-2 .. 2, -2 .. 2, -2 .. 2]), 3);`
`Maple could start execution and do the computation.`
` `
`However, when I tried the same example with different syntax, there are errors reporeted when the integration gets evaluated:`
`Case 1:`
` `
`> a := [e1+1.200000000 <= e2, e3-2.400000000 <= e1];`
`> g := (e1, e2, e3) -> piecewise(a[1] and a[2], evalf(64.00000000*exp((-1)*8.000000000*e1^2)*exp((-1)*8.000000000*e2^2)*exp((-1)*8.000000000*e3^2)/Pi^2), 0);`
`> evalf(Int((x, y, z) -> g(x, y, z), [-2 .. 2, -2 .. 2, -2 .. 2]), 3);`
`Error, (in evalf/int) unable to store 'piecewise(e1+1.200000000 <= e2 and e3-2.400000000 <= e1, HFloat(6.484555753109632), 0)' when datatype=float[8]`
` `
`Case 2:`
`> mu := 0:                                                                                                            `
`> sigma := 0.25:                                                                                                      `
`> elist := [e1, e2, e3]:                                                                                  `
`> E := Statistics:-RandomVariable(Normal(mu, sigma)):             `
`                                                    > jointPDF := product(Statistics:-PDF(E, elist[i]), i = 1..3):`
`>f := evalf(jointPDF);`
` `
`> g := (e1, e2, e3) -> piecewise(e1+1.200000000 <= e2 and e3-2.400000000 <= e1, f, 0) end proc`
`> evalf(Int((x, y, z) -> g(x, y, z), [-2 .. 2, -2 .. 2, -2 .. 2]), 3);`
`Error, (in evalf/int) cannot handle unevaluated name `e1` in evalhf`
` `
`Here I couldn't quite understand the meaning of the error in each case. Did I miss anything here?`
﻿