Skip to main content
12-Amethyst
April 16, 2020
Solved

Is there a way to use clear(...) function to clear existing math function?

  • April 16, 2020
  • 2 replies
  • 4969 views

I have a function where in a form of f(x):=1*x+3. I was trying to use clear(..) function to this clear the this function[clear(f(x)] like I do with the rest of the variables. But then MathCAD gave me error red box around the and said "A variable name is required here". What exactly happens here and is there a way to fix it? Thank you!

Best answer by StuartBruff

You just need to give it the function name.

 

2020 04 16 A.png

 

Stuart

2 replies

23-Emerald V
April 16, 2020

You just need to give it the function name.

 

2020 04 16 A.png

 

Stuart

23-Emerald V
April 16, 2020
Just had a quick play with clear. Given your error message with clear(f(x)), I was kind of hoping (against hope) that there may have been a way to evaluate an expression that resulted in a "variable" name, and hence programmatically clear a variable by constructing its name.

This would be a very useful feature to have when creating temporary functions and variables. If say, the names all had the same structure, eg var_nnn (where nnn is a number), then one could have whizzed together a quick function / array+range variable / whatever and iterate over that.

However, clear breaks the normal Mathcad rules about everything being an expression, and is an imperative statement that doesn't return a value and hence can't be used as a function (or even return a value indicating it succeeded!).

(Of course, I'd also like a create function to go along with a clear function, that did the opposite and created a variable with a given name. And while I'm at it, I'd also like a function (funname ?) that returned a string with a function's name).

But I'd also like World Peace and to be on the first hyperspace-capable spaceship on it maiden voyage to Proxima Centauri ...
16-Pearl
April 16, 2020

@yoohooos,

 

Addition to the information provided by @StuartBruff the following article may also help for more clarification.

 

How to clear the numerical values defined for the variables while performing symbolic calculations in Mathcad Prime

 

Regards,

Vipul

24-Ruby III
April 16, 2020