This works for Mathcad Prime 2.0 too (and may be for MP 3.0).
// ========================================
keywords::keyword_experimentally := proc(expression)
local var;
option hold; // N.B.: DOES NOT EVALUATE ITS ARGUMENTS
save optionExperimentally;
begin
checkKeywordArgs("experimentally", args(0), 1);
optionExperimentally:=TRUE;
var := coerce( expression, DOM_STRING );
result := text2expr( var );
eval( result );
end_proc:
keywords::keyword_experimentallyTagged := proc(tag, expression)
option hold; // N.B.: DOES NOT EVALUATE ITS ARGUMENTS
save optionExperimentally;
begin
checkKeywordArgs("experimentally", args(0), 1);
optionExperimentally:=TRUE;
var := coerce( expression, DOM_STRING );
result := text2expr( var );
eval( result );
end_proc:
// ========================================
This code is out of date. First, it is too bulky and slow. Second, it is numerical. Try this one better.
keywords::keyword_experimentallyTagged := proc(tag, expression)
option hold; // N.B.: DOES NOT EVALUATE ITS ARGUMENTS
save optionExperimentally;
begin
checkKeywordArgs("experimentally", args(0), 1);
optionExperimentally:=TRUE;
var := coerce( expression, DOM_STRING );
if mcutils::isString( expression )
then
result := text2expr( var );
unknownslist := mcutils::unknowns( result, All );
for u in unknownslist do
str := expr2text(u);
// Add functions names here
if str[1] = "_" or bool( str in { "sin", "cos", "tan" } )
then
// do nothing
else
result := subs( result, [ u = text2expr("mc_".u ) ] );
//fprint( Text, "log.txt", result );
end_if;
end_for;
else
var := stringlib::remove(var, "mc_");
var := stringlib::remove(var, "mcad_");
var := stringlib::subs(var, "_3A__3A_" = "::");
var := stringlib::subs(var, "_5B_" = "[");
var := stringlib::subs(var, "_5D_" = "]");
var := stringlib::subs(var, "_28_" = "(");
var := stringlib::subs(var, "_29_" = ")");
var := stringlib::subs(var, "_7B_" = "{");
var := stringlib::subs(var, "_7D_" = "}");
var := stringlib::subs(var, "_2C_" = ",");
var := stringlib::subs(var, "_5F_" = ".");
var := stringlib::subs(var, "_20_" = " ");
var := stringlib::subs(var, "_24_" = "$");
var := stringlib::subs(var, "_2F_" = "/");
var := stringlib::subs(var, "_5E_" = "^");
var := stringlib::subs(var, "_2A_" = "*");
var := stringlib::subs(var, "_3D_" = "=");
var := stringlib::subs(var, "_2B_" = "+");
var := stringlib::subs(var, "_2D_" = "-");
var := stringlib::subs(var, "_3A_" = ":");
result := text2expr( var );
end_if;
eval( result );
end_proc:
And the result:
I'm still fascinated by the posibilities this window to the MuPad engine could open.
Whats the difference between
var = coerce (expression, DOM_STRING);
and
str := expr2text(u);
apart from the variable names (expession <--> u, var <--> str) ?
Is there a documentation available or are you finding methods like mcutils::unknowns() by exploring the various source files? I understand that, while this bridge to MuPad is new to me, the knowledge about it is around in certain circles for quite a long time.
According to Valery's efforts - while it may be bulky it has the big advantage that it can be run on any installation of Mathcad. No need to explain how to modify vital files first (changing them may be against license condition) or providing modified files (which pretty sure could be a license violation).
On the other of course I agree that's better to use an already existing parser than writing a new one from scratch with limited possibilities.
Apart from files on an Mathcad calculation server, as Valery posts from time to time, I don't see the urgent need for a Mathcad text-to-expression function other than being a nice-to-have. But maybe I am missing the point.
But from what I have learned an seen here I would be interested in accessing hidden (from Mathcads view) Mupad functions. Wish I had the time to explore the possibilities.
coerce – type conversion
coerce(object, T) tries to convert object into an element of the domain T.
I like this type of conversion, because it reminds me of a similar in Maple: convert( expression, type )..
Werner Exinger wrote:
Is there a documentation available or are you finding methods like mcutils::unknowns() by exploring the various source files?
There is no documentation. Only common sense and source files. Yes, I looked at them.
According to Valery's efforts - while it may be bulky it has the big advantage that it can be run on any installation of Mathcad. No need to explain how to modify vital files first (changing them may be against license condition) or providing modified files (which pretty sure could be a license violation).
And who knows? We will do the substitution in secret. Anyway, they don't read the forum. For years people are asked to make such a possibility and where is it? In all other programs such possibility exists.
Apart from files on an Mathcad calculation server, as Valery posts from time to time, I don't see the urgent need for a Mathcad text-to-expression function other than being a nice-to-have. But maybe I am missing the point.
If the formula was obtained in another program, it is much more convenient to convert it this way than to enter manually. So it will be less mistakes.
But from what I have learned an seen here I would be interested in accessing hidden (from Mathcads view) Mupad functions. Wish I had the time to explore the possibilities.
There are a lot of functions. To use them, you must first install MuPad and try them there. But their use is different for MC15 and MP2 (MuPad Prime 2.0)
Thanks for your reply
But their use is different for MC15 and MP2 (MuPad Prime 2.0)
![]()
Oh my god, whats that again in the pic in the Prime window? They didn't change the engine, but it looks like they have changed the interface!?
Вячеслав!
По какому адресу с Вами можно связаться?
PTC use the same symbolic engine as for the MC15.
You can load functions from MuPad files.
I just see that in Prime2 every keyword has its "....tagged" counterpart and the file is approx double the size because of that. Is there any reason/explanation for that?
I've no idea about this. Just kind of checking integrity.