acer

32373 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You could use the inert form %log[b] . You might also use InertForm:-Display(..,inert=false) to get that rendered in black (instead of gray).

DisplayLogQCM_ac.mw

How about specifiying the types on the (procedural) parameters in the preliminary call to codegen[makeproc]?

Eg, (notice the parameter specifications of the procedure),

   codegen[makeproc](TheList, parameters = map(`::`, [proc_params], float[8]))

Those were specified programmatically, not manually.

List of optimized equations

old_eq := [t11 = cos(R4_theta(t)), t12 = cos(R3_theta(t)), t9 = sin(R4_theta(t)), R1_theta(t) = -arctan(t9*t12/t11), t24 = cos(R1_theta(t)), t18 = sin(R1_theta(t)), t56 = t9*t18, t28 = (-t11*t24+t12*t56+1)*ra, t55 = t9*t24, t68 = (t11*t18+t12*t55)*rb, t70 = t28+t68, t69 = t68-t28, t25 = sqrt(2), t52 = t11*t12, t39 = t25*t52, t49 = t24*t25, t67 = (t18*t39+t49*t9)*ra, t10 = sin(R3_theta(t)), t5 = rb*t10*t49, t50 = t18*t25, t59 = (-t24*t39+t50*t9)*rb, t41 = t5+t59, t53 = t10*t11, t54 = 1+200*la, AF_s(t) = -(1/400)*(-400*za*t53+(400*(-s(t)-xa))*t12+((-200*rb+t54)*t12+(200*rb+t54)*t53)*t25)*t25/(t12+t53), t31 = -2*la-2*AF_s(t)+t41, t35 = -2*rb-t5+t59, t7 = ra*t10*t50, t42 = t7+t67, t43 = -t7+t67, A1_R1_theta(t) = arctan((t35+t42)/(t31+t43)), t21 = cos(A1_R1_theta(t)), t44 = la+AF_s(t), t65 = t44*t21, t15 = sin(A1_R1_theta(t)), t62 = (1/2)*t15, t37 = (1/2)*t21+t62, t64 = (t62-(1/2)*t21)*t10+t37*t52, t46 = t15+t21, t63 = (t15-t21)*t10+t46*t52, A3_R1_theta(t) = arctan((-t35+t42)/(-t31+t43)), t23 = cos(A3_R1_theta(t)), t61 = -(1/2)*t23, t58 = t15*rb, t17 = sin(A3_R1_theta(t)), t57 = t17*rb, ASF_R1_theta(t) = arctan(rb*(-2+(t56+(-t10-t52)*t24)*t25)/(t41-t44)), t13 = sin(ASF_R1_theta(t)), t19 = cos(ASF_R1_theta(t)), t48 = t13+t19, t45 = t17+t23, t36 = t61-(1/2)*t17, t34 = t46*t9, t33 = t44*t23, t32 = t37*t9, t27 = t45*t52+(t17-t23)*t10, t26 = -t36*t52+((1/2)*t17+t61)*t10, A3_R2_theta(t) = arctan(2*t70/(2*t57+2*t33+((t24*t27-t45*t56)*rb+(t18*t27+t45*t55)*ra)*t25)), A3_s(t) = -la+t70*sin(A3_R2_theta(t))+(t57+t33+((t24*t26+t36*t56)*rb+(t18*t26-t36*t55)*ra)*t25)*cos(A3_R2_theta(t)), A1_R2_theta(t) = arctan(2*t69/(-2*t58-2*t65+((t18*t34-t24*t63)*rb+(t18*t63+t24*t34)*ra)*t25)), A1_s(t) = -la-t69*sin(A1_R2_theta(t))+(t58+t65+((-t18*t32+t24*t64)*rb+(-t18*t64-t24*t32)*ra)*t25)*cos(A1_R2_theta(t)), ASF_s(t) = -la+t44*t19+(2*t13+(-t48*t56+(t48*t52+(t13-t19)*t10)*t24)*t25)*rb]

Replace functions of t in by names

vars_without_t := {seq(i = op(0, i), `in`(i, indets(old_eq, function(identical(t)))))}

{A1_s(t) = A1_s, A3_s(t) = A3_s, AF_s(t) = AF_s, ASF_s(t) = ASF_s, s(t) = s, A1_R1_theta(t) = A1_R1_theta, A1_R2_theta(t) = A1_R2_theta, A3_R1_theta(t) = A3_R1_theta, A3_R2_theta(t) = A3_R2_theta, ASF_R1_theta(t) = ASF_R1_theta, R1_theta(t) = R1_theta, R3_theta(t) = R3_theta, R4_theta(t) = R4_theta}

TheList := subs(vars_without_t, old_eq)

C code generation

These are the inputs

inputs := s, R4_theta, R3_theta

s, R4_theta, R3_theta

These are the outputs

outputs := A1_s, A3_s, AF_s, ASF_s

A1_s, A3_s, AF_s, ASF_s

Set parameters for Maple procedure

proc_params := la, ra, rb, xa, za, inputs, outputs

la, ra, rb, xa, za, s, R4_theta, R3_theta, A1_s, A3_s, AF_s, ASF_s

Generate a Maple procedure form an optimzied equation list

ik := codegen[makeproc](TheList, parameters = map(`::`, [proc_params], float[8]))

proc (la::(float[8]), ra::(float[8]), rb::(float[8]), xa::(float[8]), za::(float[8]), s::(float[8]), R4_theta::(float[8]), R3_theta::(float[8]), A1_s::(float[8]), A3_s::(float[8]), AF_s::(float[8]), ASF_s::(float[8])) local t10, t11, t12, t13, t15, t17, t18, t19, t21, t23, t24, t25, t26, t27, t28, t31, t32, t33, t34, t35, t36, t37, t39, t41, t42, t43, t44, t45, t46, t48, t49, t5, t50, t52, t53, t54, t55, t56, t57, t58, t59, t61, t62, t63, t64, t65, t67, t68, t69, t7, t70, t9, A1_R1_theta, A1_R2_theta, A3_R1_theta, A3_R2_theta, ASF_R1_theta, R1_theta; t11 := cos(R4_theta); t12 := cos(R3_theta); t9 := sin(R4_theta); R1_theta := -arctan(t9*t12/t11); t24 := cos(R1_theta); t18 := sin(R1_theta); t56 := t9*t18; t28 := (-t11*t24+t12*t56+1)*ra; t55 := t9*t24; t68 := (t11*t18+t12*t55)*rb; t70 := t28+t68; t69 := t68-t28; t25 := 2^(1/2); t52 := t12*t11; t39 := t25*t52; t49 := t24*t25; t67 := (t18*t39+t49*t9)*ra; t10 := sin(R3_theta); t5 := rb*t10*t49; t50 := t18*t25; t59 := (-t24*t39+t50*t9)*rb; t41 := t5+t59; t53 := t11*t10; t54 := 1+200*la; AF_s := -(1/400)*(-400*za*t53+400*(-s-xa)*t12+((-200*rb+t54)*t12+(200*rb+t54)*t53)*t25)*t25/(t12+t53); t31 := -2*la-2*AF_s+t41; t35 := -2*rb-t5+t59; t7 := ra*t10*t50; t42 := t7+t67; t43 := -t7+t67; A1_R1_theta := arctan((t35+t42)/(t31+t43)); t21 := cos(A1_R1_theta); t44 := la+AF_s; t65 := t44*t21; t15 := sin(A1_R1_theta); t62 := (1/2)*t15; t37 := (1/2)*t21+t62; t64 := (t62-(1/2)*t21)*t10+t37*t52; t46 := t15+t21; t63 := (t15-t21)*t10+t46*t52; A3_R1_theta := arctan((-t35+t42)/(-t31+t43)); t23 := cos(A3_R1_theta); t61 := -(1/2)*t23; t58 := t15*rb; t17 := sin(A3_R1_theta); t57 := t17*rb; ASF_R1_theta := arctan(rb*(-2+(t56+(-t10-t52)*t24)*t25)/(t41-t44)); t13 := sin(ASF_R1_theta); t19 := cos(ASF_R1_theta); t48 := t13+t19; t45 := t17+t23; t36 := t61-(1/2)*t17; t34 := t46*t9; t33 := t44*t23; t32 := t37*t9; t27 := t45*t52+(t17-t23)*t10; t26 := -t36*t52+((1/2)*t17+t61)*t10; A3_R2_theta := arctan(2*t70/(2*t57+2*t33+((t24*t27-t45*t56)*rb+(t18*t27+t45*t55)*ra)*t25)); A3_s := -la+t70*sin(A3_R2_theta)+(t57+t33+((t24*t26+t36*t56)*rb+(t18*t26-t36*t55)*ra)*t25)*cos(A3_R2_theta); A1_R2_theta := arctan(2*t69/(-2*t58-2*t65+((t18*t34-t24*t63)*rb+(t18*t63+t24*t34)*ra)*t25)); A1_s := -la-t69*sin(A1_R2_theta)+(t58+t65+((-t18*t32+t24*t64)*rb+(-t18*t64-t24*t32)*ra)*t25)*cos(A1_R2_theta); ASF_s := -la+t44*t19+(2*t13+(-t48*t56+(t48*t52+(t13-t19)*t10)*t24)*t25)*rb end proc

Codegeneration and customization for External C/Library Block App

CodeGeneration[C](ik, defaulttype = double)

#include <math.h>

double ik (
  double la,
  double ra,
  double rb,
  double xa,
  double za,
  double s,
  double R4_theta,
  double R3_theta,
  double A1_s,
  double A3_s,
  double AF_s,
  double ASF_s)
{
  double t10;
  double t11;
  double t12;
  double t13;
  double t15;
  double t17;
  double t18;
  double t19;
  double t21;
  double t23;
  double t24;
  double t25;
  double t26;
  double t27;
  double t28;
  double t31;
  double t32;
  double t33;
  double t34;
  double t35;
  double t36;
  double t37;
  double t39;
  double t41;
  double t42;
  double t43;
  double t44;
  double t45;
  double t46;
  double t48;
  double t49;
  double t5;
  double t50;
  double t52;
  double t53;
  double t54;
  double t55;
  double t56;
  double t57;
  double t58;
  double t59;
  double t61;
  double t62;
  double t63;
  double t64;
  double t65;
  double t67;
  double t68;
  double t69;
  double t7;
  double t70;
  double t9;
  double A1_R1_theta;
  double A1_R2_theta;
  double A3_R1_theta;
  double A3_R2_theta;
  double ASF_R1_theta;
  double R1_theta;
  t11 = cos(R4_theta);
  t12 = cos(R3_theta);
  t9 = sin(R4_theta);
  R1_theta = -atan(t9 * t12 / t11);
  t24 = cos(R1_theta);
  t18 = sin(R1_theta);
  t56 = t9 * t18;
  t28 = (-t11 * t24 + t12 * t56 + 0.1e1) * ra;
  t55 = t9 * t24;
  t68 = (t11 * t18 + t12 * t55) * rb;
  t70 = t28 + t68;
  t69 = t68 - t28;
  t25 = sqrt(0.2e1);
  t52 = t12 * t11;
  t39 = t25 * t52;
  t49 = t24 * t25;
  t67 = (t18 * t39 + t49 * t9) * ra;
  t10 = sin(R3_theta);
  t5 = rb * t10 * t49;
  t50 = t18 * t25;
  t59 = (-t24 * t39 + t50 * t9) * rb;
  t41 = t5 + t59;
  t53 = t11 * t10;
  t54 = 0.1e1 + 0.200e3 * la;
  AF_s = -(-0.400e3 * za * t53 + 0.400e3 * (-s - xa) * t12 + ((-0.200e3 * rb + t54) * t12 + (0.200e3 * rb + t54) * t53) * t25) * t25 / (t12 + t53) / 0.400e3;
  t31 = -0.2e1 * la - 0.2e1 * AF_s + t41;
  t35 = -0.2e1 * rb - t5 + t59;
  t7 = ra * t10 * t50;
  t42 = t7 + t67;
  t43 = -t7 + t67;
  A1_R1_theta = atan((t35 + t42) / (t31 + t43));
  t21 = cos(A1_R1_theta);
  t44 = la + AF_s;
  t65 = t44 * t21;
  t15 = sin(A1_R1_theta);
  t62 = t15 / 0.2e1;
  t37 = t21 / 0.2e1 + t62;
  t64 = (t62 - t21 / 0.2e1) * t10 + t37 * t52;
  t46 = t15 + t21;
  t63 = (t15 - t21) * t10 + t46 * t52;
  A3_R1_theta = atan((-t35 + t42) / (-t31 + t43));
  t23 = cos(A3_R1_theta);
  t61 = -t23 / 0.2e1;
  t58 = t15 * rb;
  t17 = sin(A3_R1_theta);
  t57 = t17 * rb;
  ASF_R1_theta = atan(rb * (-0.2e1 + (t56 + (-t10 - t52) * t24) * t25) / (t41 - t44));
  t13 = sin(ASF_R1_theta);
  t19 = cos(ASF_R1_theta);
  t48 = t13 + t19;
  t45 = t17 + t23;
  t36 = t61 - t17 / 0.2e1;
  t34 = t46 * t9;
  t33 = t44 * t23;
  t32 = t37 * t9;
  t27 = t45 * t52 + (t17 - t23) * t10;
  t26 = -t36 * t52 + (t17 / 0.2e1 + t61) * t10;
  A3_R2_theta = atan(0.2e1 * t70 / (0.2e1 * t57 + 0.2e1 * t33 + ((t24 * t27 - t45 * t56) * rb + (t18 * t27 + t45 * t55) * ra) * t25));
  A3_s = -la + t70 * sin(A3_R2_theta) + (t57 + t33 + ((t24 * t26 + t36 * t56) * rb + (t18 * t26 - t36 * t55) * ra) * t25) * cos(A3_R2_theta);
  A1_R2_theta = atan(0.2e1 * t69 / (-0.2e1 * t58 - 0.2e1 * t65 + ((t18 * t34 - t24 * t63) * rb + (t18 * t63 + t24 * t34) * ra) * t25));
  A1_s = -la - t69 * sin(A1_R2_theta) + (t58 + t65 + ((-t18 * t32 + t24 * t64) * rb + (-t18 * t64 - t24 * t32) * ra) * t25) * cos(A1_R2_theta);
  ASF_s = -la + t44 * t19 + (0.2e1 * t13 + (-t48 * t56 + (t48 * t52 + (t13 - t19) * t10) * t24) * t25) * rb;
  return(ASF_s);
}

NULL

Download C_code_generation_with_CodeGeneration_ac.mw

Your current problem is due to the fact that your collatz procedure is returning NULL.

That is, calls like collatz(13) have a return value of NULL. That happens because the last line of your collatz procedure merely prints max_i. The print command itself returns NULL.

Try it with the very last line of collatz being,

   return max_i;

after (or instead of),

   print(max_i);

Here's one simple way,

   m:=Matrix([[1,2,5,6,9],[3,4,5,13,14],[1,3,4,10,11]]):
   dataplot(m^%T, style=line, gridlines=true, size=[500,"golden"]);

 

The size option is optional. (That instance of "golden" refers to the aspect ratio; I could have used approximately 0.618 instead.)

One way to accomplish that is to set the default unit(s) for which units of that same compound dimension will combine/simplify.

By default Maple's Units environments combine units to the SI standard. The SI standard unit for volume is m^3.

Maple's Units:-UseUnit command allows you to override the SI system, on a dimension-by-dimension basis.

For example,

restart

with(Units:-Simple)

Units:-UseUnit(mol/L)

c = 0.33e-1*Unit('g')/((166.0028*Unit('g'/'mol'))*(0.5e-1*Unit('l')))

c = 0.3975836552e-2*Units:-Unit(mol/L)

Download UseUnit_ex.mw

Note that the above should only affect that particular dimension, eg. amount/volume. That can be distinct from the reciprocal of that dimension, of the square of it, or something with units of mol/m^4, etc.

In some scenarios you may need to call simplify ( or combine(...,units) ) in order to get the units in play to be merged. That can sometimes be true even without this custom use of UseUnit.

I used Maple 2022.1 for the computation above. If you have an earlier version that behaves differently then please tag your Question appropriately.

You can also programmatically convert units to compatible alternatives. That affects a particular result (though further computation with that might result in combining back to the SI standard). This doesn't require UseUnit. For example,

restart

with(Units:-Simple)

expr := c = 0.33e-1*Unit('g')/((166.0028*Unit('g'/'mol'))*(0.5e-1*Unit('l')))

c = 3.975836552*Units:-Unit(mol/m^3)

lhs(expr) = convert(rhs(expr), units, mol/L)

c = 0.3975836552e-2*Units:-Unit(mol/L)

c = convert(0.33e-1*Unit('g')/((166.0028*Unit('g'/'mol'))*(0.5e-1*Unit('l'))), units, mol/L)

c = 0.3975836552e-2*Units:-Unit(mol/L)

Download conv_unit_ex.mw

Yet another alternative (for the RHS of the above only, I suspect, and not that whole equation) is to use the relevant right-click context-menu item to change the display unit for a particular output.

Inside a procedure you can utilize the uses facility.

That allows the procedure to access the package exports without the need to have the package loaded at the higher level. (This can also be useful if you wish to store the procedure within a .mla Library archive, so that it can be subsequently used without the need to load the package. Ie, it can run stand-alone.)

As a toy example,

p := proc(eqs::{list,seq}(`=`), L::list(name))
  local A,B;
  uses LinearAlgebra, ScientificConstants;
  A,B := GenerateMatrix(eqs,L);
  LinearSolve(A,B);
end proc:

p([x+y=4, x-y=2], [x,y]);

Vector(2, {(1) = 3, (2) = 1})

solve([x+y=4, x-y=2], [x,y]);

[[x = 3, y = 1]]

Download uses_example.mw

Some people prefer an alternative, in which the uses facility is utilized to provide a terser way to access the exports, like an abbreviation. This still allows more compact coding, but adds some legibility so that you can more easily recognize what's happening later on.

p := proc(eqs::{list,seq}(`=`), L::list(name))
  local A,B;
  uses LA=LinearAlgebra;
  A,B := LA:-GenerateMatrix(eqs,L);
  LA:-LinearSolve(A,B);
end proc:

p([x+y=4, x-y=2], [x,y]);

Vector(2, {(1) = 3, (2) = 1})

Download uses_example2.mw

Imagine a scenaro like, say,
   uses Cal=Student:-Calculus1;
so that you could have code with calls like Cal:-Roots(...) which is still reasonably terse but also understandable.

In your first example, that use of Physics:-diff causes an assignment to a remember table for top-level :-diff, which can be removed using forget.

restart;

kernelopts(version);

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

diff(conjugate(f(x)), x);

(diff(f(x), x))*(-conjugate(f(x))/f(x)+2*abs(1, f(x))/signum(f(x)))

Physics:-diff(conjugate(f(x)), x);

diff(conjugate(f(x)), x)

forget(diff);

diff(conjugate(f(x)), x);

(diff(f(x), x))*(-conjugate(f(x))/f(x)+2*abs(1, f(x))/signum(f(x)))

Download diff_forget.mw

(This can also be seen by examing op(4,...) of the :-diff procedure after that Physics:-diff call is made.

The second example seems more involved, and I haven't yet figured it out. It may be related to the Physics package calls within the Library routine `simpl/conjugate`.

I am unsure of the root cause of the discrepancy. You could resolve that particular inconsistency with,

   int(..., numeric, method=_Dexp)

or,

   evalf(Int(..., method=_Dexp))

Also, your integrands may be complex-valued due to floating-point (ie. approximate) coefficients along with the presence of I, the imaginary unit.

You may get rid of small floating-point imaginary artefacts in results by wrapping the results in call to fnormal.

You may get rid of 0.0*I imaginary components of a result by wrapping in a call like simplify(...,':-zero').

Eg,
   simplify( fnormal( evalf(Int(..., method=_Dexp) ), ':-zero');

I don't understand why you apply evalf to the integrands passed to the quadrature call.

Btw, while you might be deliberately trying numeric quadrature for speed (say), much of your results can be obtained using exact symbolic computations (including erf calls in results) if you use exact rationals instead of floating-point values for your parameters, etc. In at least one way that can also symbolically show that the imaginary part of your integral is exactly zero.

The following is not real-valued for purely real x. But it's not awful.

restart;

kernelopts(version);

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

with(IntegrationTools):

 

f := sin(x)/sqrt(2+sin(2*x));

sin(x)/(2+sin(2*x))^(1/2)

raw := eval(value(Change(expand(Int(f,x)), t=tan(x), t)),
            t=tan(x)):

Q := combine(simplify(convert(combine(simplify(raw,tan),
                                      radical,symbolic),
                              sincos),
                      symbolic));

-(1/2)*arctanh((2+sin(2*x))^(1/2)/(sin(x)+cos(x)))-(1/2)*arctan((-sin(x)+cos(x))/(2+sin(2*x))^(1/2))

plot([Re,Im](Q), x=-2*Pi..2*Pi);

Download intfun1.mw

I don't know how to get it as H or F in the Comments on the Question, which are real-valued for real x.

I'm not sure exactly how the names you used figure in the process.

But perhaps something like the following can be turned to your purpose.

restart;
randomize():

 

f := x -> x^2;

proc (x) options operator, arrow; x^2 end proc

ff := proc(x) option remember; f(x); end proc:

 

F := proc(f) local r;
  r := rand(1..100);
  f(r());
  f(r());
  NULL;
end proc:

 

F(ff);

 

T := op(4,eval(ff));

table( [( 46 ) = 2116, ( 62 ) = 3844 ] )

F(ff);

 

T := op(4,eval(ff));

table( [( 46 ) = 2116, ( 41 ) = 1681, ( 42 ) = 1764, ( 62 ) = 3844 ] )

ff := subsop(4=NULL, eval(ff)): # clear ff's remember-table

F(ff);

 

T := op(4,eval(ff));

table( [( 36 ) = 1296, ( 98 ) = 9604 ] )

Download memoi.mw

Here is one way:

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

interface(typesetting=extended):

A := RealRange(-2,Open(5));

RealRange(-2, Open(5))

B := RealRange(Open(0),7);

RealRange(Open(0), 7)

solve(convert(Or(x::A,x::B),relation));

RealRange(-2, 7)

solve(convert(And(x::A,x::B),relation));

RealRange(Open(0), Open(5))

solve(convert(And(x::A,Not(x::B)),relation));

RealRange(-2, 0)

Download some_set_stuff.mw

If you really want you could devise an overloaded scheme where those names union, minus, and intersection act similarly (say, by performing the operations such as I showed, underneath).

You may pass the option explicit (or explicit=true) to the solve command and obtain the explicit roots of a 4th degree polynomial directly, with a single command.

For your example, say,

    solve(Opt_effort_FOC = 0, e[n], explicit)

Inside the procedure p2 you need to use the global name :-debug as the name of the keyword option when it calls procedure p1.

p1 := proc(a, b, {debug::truefalse := false})
   print("p1", debug);
   a + b;
end proc:

p2 := proc(a, b, {debug::truefalse := false})
   print("p2", debug);
   p1(a, b, ':-debug' = true);
end proc:

p2(1, 2, 'debug' = true);

              "p2", true
              "p1", true
                  3

Otherwise your p2 is calling p1 with true=true, since inside p2
    debug = true
evaluates using the value of the p2 parameter that is also named debug.

Here is what's happening in your original. Notice the arguments that p2 passes to p1 include
   true = true
and not
   debug=true
which was what you'd expected.

restart;

p1 := proc(a, b, {debug::truefalse := false})
   print("p1", debug);
   a + b;
end proc:

p2 := proc(a, b, {debug::truefalse := false})
   print("p2", debug);
   p1(a, b, debug = true);
end proc:

trace(p1):
trace(p2):

p2(1, 2, 'debug' = true);
{--> enter p2, args = 1, 2, debug = true
                           "p2", true

{--> enter p1, args = 1, 2, true = true
                          "p1", false

                               3

<-- exit p1 (now in p2) = 3}
                               3

<-- exit p2 (now at top level) = 3}
                               3

Now observe what happens in the corrected version. Notice what arguments p2 passed to p1.

restart;

p1 := proc(a, b, {debug::truefalse := false})
   print("p1", debug);
   a + b;
end proc:

p2 := proc(a, b, {debug::truefalse := false})
   print("p2", debug);
   p1(a, b, ':-debug' = true);
end proc:

trace(p1):
trace(p2):

p2(1, 2, 'debug' = true);
{--> enter p2, args = 1, 2, debug = true
                           "p2", true

{--> enter p1, args = 1, 2, debug = true
                           "p1", true

                               3

<-- exit p1 (now in p2) = 3}
                               3

<-- exit p2 (now at top level) = 3}
                               3

By the way, I wrote as ':-debug' = true so that it would work even if the global name :-debug had also been assigned a value (at the top-level, say). Strictly speaking I didn't have to do that, since :-debug is a protected name. But for the same situation involving other (unprotected) names you could have that situation. So I wanted to illustrate to you the more robust way.

[note: See here for details I gave in your earlier Question thread, for plotting the 0-contour using interpolation of 0-height data that is computed more robustly. That seems to make this Question thread less relevant...]

You appear to be using Maple 2021, so you can use the newer Interpolation package (new in Maple 2018), which makes the task of interpolation "on-the-fly" easier.

The black-box that it returns can be subsequently polled at arbitrary x-y pairs, so you can easily use it with the contourplot command.

The problem is that you original data is quite flat for higher y-values, and the data you generated for it seems to lack enough precision to allow the 0-contour to be traced out nicely. (I alluded to this in your earlier Question thread, since I had already tried what I show below...)

In the plot below you can see that it has difficulty following the 0-contour, and slight inaccuracy in the original data can cause it to veer off the (exact) course.

Using ArrayInterpolation would not fix this issue, in and of itself. That command merely provides a mechanism to compute all the interpolated x-y target points in batch. I suspect that a good fix would require greater accuracy in the originally generated data -- which would be slower, and you earlier asked for it to be faster. It's possible that a scaling of the data to give it greater slope might be a kludge. But since the curve represents a function (in the mathematical sense) then it be more robustly found using fsolve (to find the alpha corresponding to each beta); again, see here.

restart;

kernelopts(version);

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

with(plots):

excelfile:= FileTools:-JoinPath([kernelopts(':-homedir'),
                                "mapleprimes","N_data.xlsx"]):

NN := ImportMatrix(excelfile,'source'=':-Excel'):

(m,n) := op(1,NN);

51, 51

alpha := Vector([seq(0..10.0,'numelems'=n)],'datatype'=':-float[8]'):

beta := Vector([seq(0..10.0,'numelems'=m)],'datatype'=':-float[8]'):

 

func := Interpolation:-CubicInterpolation([beta,alpha],NN):

 

contourplot(func(x,y), x=0..10, y=0..10, 'contours'=[-1e-8,0,1e-8],
            'grid'=[m*2,n*2], coloring=[red,blue],
            'view'=[0..10,0..10], 'size'=[400,400]);

Download test1_interp_acc.mw

It's not very helpful to split these detail and highly related queries across multiple Question threads. At this time the .xlsx data file is at attachment in your earlier thread, but not in this one. And the quantitative nature of that data bears on which are decent courses of action.

Please try to keep your related queries in the same thread, even if nobody yet answers all to your satisfaction.

There is a special substructure of a 2D plot which the GUI recognizes as instructions for filling a popup box when the mouse-pointer's focus lies over that particular plot feature.

You can build that into your individual plot features (curves, points,...) by using the annotation option.

See the Help page for Topic plot,annotation .

First 61 62 63 64 65 66 67 Last Page 63 of 336