Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following code:

c[theta_, xi_] = theta*xi + theta^xi^2;
xbar[theta_, xi_] = theta/xi +  xi^2 + theta^3;
f[x_, y_, theta_, xi_] = x*y*c[theta, xi]*theta*xi + xbar[theta, xi];

That is, I would like to define $f$ as a function $x,y,theta,xi$ using two predefined functions $c$ and $xbar$. But mathematica gives tag times is protected. How to deal with it? Many thanks!

share|improve this question
    
Evaluate Remove[c, xbar, f] before the function definitions. – Coolwater Jan 30 at 21:00

You need to make sure there are no active definitions on the constituent parameters. You can do this with ClearAll as E.Doroskevic proposes, though I imagine you will not want to clear all Global` definitions.

You can Block the Symbols in use as described in Scoping in assigning a derivative. To make this convenient I propose using the function localSet which I wrote for How to make a function like Set, but with a Block construct for the pattern names.

xi = "fail!";  
y = "bad!";

localSet[c[theta_, xi_], theta*xi + theta^xi^2]
localSet[xbar[theta_, xi_], theta/xi + xi^2 + theta^3]
localSet[f[x_, y_, theta_, xi_], x*y*c[theta, xi]*theta*xi + xbar[theta, xi]]

?f

Global`f

f[x_, y_, theta_, xi_] = theta^3 + theta/xi + xi^2 + theta x xi (theta^xi^2 + theta xi) y

Observe that the definition is correct despite the definitions on xi and y.

share|improve this answer

Try:

ClearAll["Global`*"] 

c[theta_, xi_] = theta*xi + theta^xi^2;
xbar[theta_, xi_] = theta/xi +  xi^2 + theta^3;
f[x_, y_, theta_, xi_] = x*y*c[theta, xi]*theta*xi + xbar[theta, xi];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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