## 75 Reputation

13 years, 135 days

## @denitsastaicova  Btw, the Friedma...

Btw, the Friedman-Robertson-Walker metrics are entries:

g_[[12,9,1]] to g_[[12,9,7]]

See the attached worksheet. Robertson-Walker.mw

## Thanks!...

Thank you so much for this example. I've been struggling with drawing an arrow in a 10^(-18) scale and thanks to you, I finally did it. The help is really uninformative on arrows. Or at least it's not so obvious as it may seem.

## @acer  Thanks a lot, I always forg...

Thanks a lot, I always forget that command because maple behaves usually a lot more stable. Thanks again!

## Thank you everyone for your contribution...

Thank you everyone for your contributions. They helped me a lot to figure out what exactly I wanted.

What I ended up doing is plotting with

> colorscheme=["valuesplit", z1, pal]

where "pal" looks like this:

nx:=10:

z1:=map(x->ln(x), z1):

tx:=evalf((max(z1)-op(500, sort(z1)))/nx);
cols1:=map(x->evalf([x[1], x[2], x[3]], 3), ColorTools:-NeutralSpread("Violet", nx+1)):

pal:=[-10..0, 0 .. op(500, sort(z1)), seq(parse(cat(i,"..0", i+tx)), i = op(500, sort(z1))..max(sort(z1)), tx)] =~ ["Black", "Grey", seq(parse(cat("COLOR(RGB,", cols1[i][1],",",cols1[i][2],",",cols1[i][3],")")),i=1..nx+1)]:

So basically I'm normalizing my "z" values with the ln() because they were too spread (like z1=1..800 with almost 1500 elements of z1) and then I manually set the values I don't care about (0..1) to be black, the one I don't care much to be Grey and everything else to use the NeutralSpread color palette.

I think it gives me the most informative view so far, because you can easily find out what color corresponds to what.

Again, thanks a lot to everyone.

## @acer Thanks for the detailed reply. Fr...

@acer Thanks for the detailed reply.

From what I can see from my data, it seems that only the first way produces what I want (plot on which you can easily discern the points with highest z1). But really thanks, even just the first 1, in combination with the splitvalues one is very useful for what i need.

## @vv Thanks a lot, that indeed works. I d...

@vv Thanks a lot, that indeed works. I didn't know you can do the \$t=z1\$ part :)

## Ok, here's an extremely simplified e...

Ok, here's an extremely simplified example of my system which I rounded to 3 digits of precision.

A very important difference with the non-rounded system is that in it, the imaginary part of SQ (and also of x(t)) is 10^(-17) and not 10^(-7). But otherwise, you see exactly the same problem. If you check out the imaginary part of the term I think the problem is - SQ, before the so-called "singularity" point it's 10^(-6), and after, it's 10^(-5). So it's not like we see some huge jump in the imaginary part. In the non-rounded system it's 10^(-18) and 10^(-12) respectively. In the real system (non-rounded, non-simplified), it's changes between 10^(-17)*I and 0*I, which looks very safe to me.

 > restart:
 > Digits:=15:
 > Eq:=3.000*x(t)^2*diff(y(t), t)*diff(x(t), t) + 1.000*x(t)^3*diff(y(t), t, t) = 0, diff(x(t), t) = sqrt(6)*sqrt(0.500*diff(y(t), t)^2 + ((5.000/(x(t)^3) + sqrt(-37.037 + 25.000/(x(t)^6)))^(1/3) + 3.333/(5.000/(x(t)^3) + sqrt(-37.037 + 25.000/(x(t)^6)))^(1/3))^2/4 + 3*((5.000/(x(t)^3) + sqrt(-37.037 + 25.000/(x(t)^6)))^(1/3) + 3.333/(5.000/(x(t)^3) + sqrt(-37.037 + 25.000/(x(t)^6)))^(1/3))/(4*x(t)^3))*x(t)/6
 (1)
 > IC:=y(0) = 1, D(y)(0) = 0, x(0) = 1/10
 (2)
 >
 > f_int:=1.5: Ti:=time():sol1:=dsolve(evalf({Eq,IC}), numeric,complex=true): A1:=sol1(1);A2:=sol1(f_int);
 (3)
 > sol1(0.625)
 (4)
 > sol1(0.627)
 (5)
 > SQ:=((5.000/(x(t)^3) + sqrt(-37.037 + 25.000/(x(t)^6)))^(1/3) + 3.333/(5.000/(x(t)^3) + sqrt(-37.037 + 25.000/(x(t)^6)))^(1/3))^2
 (6)
 > subs((4),SQ)
 (7)
 > subs((5),SQ)
 (8)
 > f_int:=1.5: Ti:=time():sol1:=dsolve(evalf({Eq,IC}), numeric): A1:=sol1(1);A2:=sol1(f_int);
 >
 >

## @mmcdara  Hi, thanks for replying....

Hi, thanks for replying. Unfortunately, trying to separate the real and imaginary part so far leads only to a huge memory leak and well, had to be killed. So yeah, that seems not to work. The problem is that my system consists of 2 coupled ODEs and because of the sqrt, it is an implicit one. I think I see where the imaginary part comes from (solving a cubic equation), but any attempt to fix it so far hasn't worked. Adding "Re" to the parameters I think might be problematic leads to

"Could not convert to an explicit first order system due to 'RootOf'" or random complains about Re or abs.

Still, thanks for the example! If anyone can think of some clever way to add Re(f(x)) to an ODE, which won't crash the solver, I'd be very grateful.

## Yeah, just %f should be...

Yeah, just %f should be %e:

printf("%.5Ze %.5e %g",-0.123456e-18-0.123456e-15*I, 0.1334423423*10^(-15),3);

Otherwise the %f will cut the floating parts of the comples number.

Thank you, Alejandro! You and pagan really helped me :)

So, for the record, the overall routine should be something like:

A:=[-0.9123456e-9-0.123456e-17*I,0.1334423423*10^(-15),3]:
fopen(fi1,APPEND);
fprintf(fi1,"%.5Zg %.5e %g\n",op(A)):
fclose(fi1);

I guess my question was kind of trivial for the people who has programmed on C, but for me, it was a nightmare to do it without help. So, thanks.

## Yeah, just %f should be...

Yeah, just %f should be %e:

printf("%.5Ze %.5e %g",-0.123456e-18-0.123456e-15*I, 0.1334423423*10^(-15),3);

Otherwise the %f will cut the floating parts of the comples number.

Thank you, Alejandro! You and pagan really helped me :)

So, for the record, the overall routine should be something like:

A:=[-0.9123456e-9-0.123456e-17*I,0.1334423423*10^(-15),3]:
fopen(fi1,APPEND);
fprintf(fi1,"%.5Zg %.5e %g\n",op(A)):
fclose(fi1);

I guess my question was kind of trivial for the people who has programmed on C, but for me, it was a nightmare to do it without help. So, thanks.

## By the way, any idea how to...

By the way, any idea how to make the 3 numbers to be written in the same line and then to break to a new line.

The second part is easier since fprintf(f,`%a`,x,`%\n`);  in the integer part of the procedure will do the work. But how can I get the other two on the same line? I couldn't find in the help how to avoid the new line when fprintf is invoked on the top level.

## By the way, any idea how to...

By the way, any idea how to make the 3 numbers to be written in the same line and then to break to a new line.

The second part is easier since fprintf(f,`%a`,x,`%\n`);  in the integer part of the procedure will do the work. But how can I get the other two on the same line? I couldn't find in the help how to avoid the new line when fprintf is invoked on the top level.

## Yes, this works very nicely...

Yes, this works very nicely for the example I provided, however for:

A:=[-0.9123456e-9-0.123456e-17*I,0.1334423423*10^(-15),3]: writedata('terminal',A,string,T);
-0.00000-0.00000I
1.3344e-16
3

So with little experimenting, I found that

T:=proc(f,x) if type(x,float) then fprintf(f,`%.5g`,x); elif type(x,complex(float)) then fprintf(f,`%.5Ze`,x); else fprintf(f,`%a`,x); end if; NULL; end proc:

and

T:=proc(f,x) if type(x,float) then fprintf(f,`%.5g`,x); elif type(x,complex(float)) then fprintf(f,`%.5Zg`,x); else fprintf(f,`%a`,x); end if; NULL; end proc:

would print precisely the desired:

-9.12346e-10-1.23456e-18I
1.3344e-16
3

Thanks a lot for the help!

## Yes, this works very nicely...

Yes, this works very nicely for the example I provided, however for:

A:=[-0.9123456e-9-0.123456e-17*I,0.1334423423*10^(-15),3]: writedata('terminal',A,string,T);
-0.00000-0.00000I
1.3344e-16
3

So with little experimenting, I found that

T:=proc(f,x) if type(x,float) then fprintf(f,`%.5g`,x); elif type(x,complex(float)) then fprintf(f,`%.5Ze`,x); else fprintf(f,`%a`,x); end if; NULL; end proc:

and

T:=proc(f,x) if type(x,float) then fprintf(f,`%.5g`,x); elif type(x,complex(float)) then fprintf(f,`%.5Zg`,x); else fprintf(f,`%a`,x); end if; NULL; end proc:

would print precisely the desired:

-9.12346e-10-1.23456e-18I
1.3344e-16
3

Thanks a lot for the help!

## Closer, but as you notice...

Closer, but as you notice the second number is still far from the 5 digit goal. I really don't understand why it's so hard to do this. Maybe I miss the C programming knowledge, but still...

But your variant is at least fixing the problem for the complex number.

Thanks!

 1 2 Page 1 of 2
﻿