# Defining a function though an expression

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

Plot[Funcional[
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.

• What is x? Why is it there? Apr 6, 2020 at 16:50
• $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. Apr 6, 2020 at 16:52
• 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. Apr 6, 2020 at 17:31
• Can you please post your Mathematica Code so that we can copy and paste it. Apr 6, 2020 at 19:22

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


Then,

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


makes a plot.

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?