I defined a function called "Funcional" that if we give a function to him it will return a value that depends on $\beta$. Say for example

Funcional[Piecewise[{{0, x < 1/2}, {2*x - 3, x > 1/2}}]] = 3$\beta^2 + 16\beta^7$

Now I would like to plot this while $\beta$ varies but im guessing Mathematica is not interpreting this result of "Funcional" as a function so how can I do it so it does, my goal is to do this

  Piecewise[{{0, x < 1/2}, {2*x - 3, x > 1/2}}]], {$\beta$, 1/2, 1}]

and get the graph in function of $\beta$. Thanks in advance.

  • $\begingroup$ What is x? Why is it there? $\endgroup$
    – John Doty
    Apr 6, 2020 at 16:50
  • $\begingroup$ $x$ is there so i can defined a function in $\mathbb{R}^2$ the, way $Funcional$ works is that it is doing some integrals over a region when we give it some function so $x$ is so we have a "function" over the region. $\endgroup$
    – Someone
    Apr 6, 2020 at 16:52
  • 2
    $\begingroup$ So, your definition above (Funcional[...]=...]) is not actually the definition of Funcional. Please edit your question, and include a definition in copyable Mathematica code. If you don't know how to do that, click on the circled "?" above the edit window here. $\endgroup$
    – John Doty
    Apr 6, 2020 at 17:31
  • $\begingroup$ Can you please post your Mathematica Code so that we can copy and paste it. $\endgroup$
    – mgamer
    Apr 6, 2020 at 19:22

1 Answer 1


What you posted was not syntactically correct Mathematica code. Trying to clean it up, define:

Funcional[Piecewise[{{0, x < 1/2}, {2*x - 3, x > 1/2}}]] = 3 beta^2 + 16 beta^7


Plot[Funcional[Piecewise[{{0, x < 1/2}, {2*x - 3, x > 1/2}}]], {beta, 1/2, 1}]

makes a plot.

enter image description here

But what's happening is not what you think. Mathematica is a expression rewriting language. The definition means that when Mathematica finds an expression that is an exact match to Funcional[Piecewise[{{0, x < 1/2}, {2*x - 3, x > 1/2}}]], it will replace it with 3 beta^2 + 16 beta^7. And then, of course, you can plot that.

Since you haven't used _ in your definition, the match needs to be exact. The expression Piecewise[{{0, x < 1/2}, {2*x - 3, x > 1/2}}] has to be unevaluated: it's effectively meaningless. It could be any syntactically correct expression that cannot be evaluated. If you give x a value, it doesn't work any more.

So, what is it that you're attempting to do here?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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