C_R

3537 Reputation

21 Badges

6 years, 60 days

MaplePrimes Activity


These are answers submitted by C_R

Maybe helpfull to find previous menu items:

?updates,Maple2025,RibbonMapping

I could not reproduce it with Maple 2025 but got an error message with 2020.

Maybe updating your driver can help. Clearly there is something with `#mo("2")` that makes the call special. 

I get decent results with 

Maybe this can help with 2015 as well

I agree with mmcdara that setting up the problem plays an important role on the complexity of results. But even with the smartest approch sometimes expressions are complex. In yours and similar cases the command

indets(g1, anything)

will generate a set of all operands. In the same way one can now create sets for other expressions and filter common subsexpressions by the command intersect

Intersect := (indets(g1, anything) intersect indets(g2, anything)) intersect indets(g3, anything);
                /                                            
  Intersect := { -2, -1, 2, 4, Ce, Cm, U, a, beta, delta, k, 
                \                                            

                       2      2   2      2          2  
    lambda, w, U[0], Ce , beta , w , U[0] , (w + Ce) , 

                     2                                 \ 
    (-delta + w + Ce) , -delta, w + Ce, -delta + w + Ce }
                                                       / 


In many cases, sums are of interest to be replaced by new names. To filter for those select is a handy command

select(type, Intersect, `+`);
                   {w + Ce, -delta + w + Ce}

I attach here my experiments Difference_two_model-rply.mw including a procedure that returns all operands in the same way as indets(...,anything) does.

If this answer is not helpfull for this question it might be for similar hard problems.

For the "old" Java GUI start the application below. It seems to work

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Windows 10, March 24 2025 Build ID 1909157`

(1)

Physics:-Version();

`The "Physics Updates" package is not available for the version of Maple under development`

(2)

restart;

ode:=diff(y(x),x) = (ln(y(x))^2+2*_C1)^(1/2)*y(x);
sol:=y(x) = exp((-2*_C1)^(1/2))

diff(y(x), x) = (ln(y(x))^2+2*_C1)^(1/2)*y(x)

 

y(x) = exp((-2*_C1)^(1/2))

(3)

odetest(sol,ode) assuming positive;

-(ln(exp(I*2^(1/2)*_C1^(1/2)))^2+2*_C1)^(1/2)*exp(I*2^(1/2)*_C1^(1/2))

(4)

restart;

ode:=diff(y(x),x) = (ln(y(x))^2+2*_C1)^(1/2)*y(x);
sol:=y(x) = exp((-2*_C1)^(1/2)) ;

diff(y(x), x) = (ln(y(x))^2+2*_C1)^(1/2)*y(x)

 

y(x) = exp((-2*_C1)^(1/2))

(5)

Physics:-Setup(assumingusesAssume = true):

odetest(sol,ode) assuming positive;

-(2*Im(_C1^(1/2))^2-2*2^(1/2)*Im(_C1^(1/2))*ln(exp(I*2^(1/2)*Re(_C1^(1/2))))+ln(exp(I*2^(1/2)*Re(_C1^(1/2))))^2+2*_C1)^(1/2)*exp((-2*_C1)^(1/2))

(6)

restart;

ode:=diff(y(x),x) = (ln(y(x))^2+2*_C1)^(1/2)*y(x);
sol:=y(x) = exp((-2*_C1)^(1/2)) ;

diff(y(x), x) = (ln(y(x))^2+2*_C1)^(1/2)*y(x)

 

y(x) = exp((-2*_C1)^(1/2))

(7)

Physics:-Setup(assumingusesAssume = false):

odetest(sol,ode) assuming positive;

-(ln(exp(I*2^(1/2)*_C1^(1/2)))^2+2*_C1)^(1/2)*exp(I*2^(1/2)*_C1^(1/2))

(8)
 

 

Download ode_test_with_physics_march_25_2025-reply.mw

Not sure if I understand correctly "execution cell". There are execution groups and paragraphs in Maple.

If you want to insert in document mode a new paragraph in "text mode" you can use this menu option encircled in red.

The option encircled in blue corresponds to the menu Insert -> Paragraph. I am not aware of a default that changes the behavior of Insert menu.

Similarily in worksheet mode an execution group in "text mode" is inserted that does not execute.

These buttons are a time saver. I do not see them in Maple 2025.

Try

ResponsePlot(sys, Step()) 

following the helppage of ResponsePlot. Or:

ResponsePlot(sys, 1()) 

By the way, to investigate error messages it is helpfull to upload code with the green arrow

Here is a solution assuming positive by hand. I have replaced the Y... for better readability.
Please check whether the arguments of the cosines are in degrees or radians. You have used radians.

As an alternative to use decimal numbers, you could introduce 3 more parameters for the angles and substitute them in the output of solve (for that use subs or eval).

eqw := Ytotw*(1 + cos(66.696)) = 2*(sqrt(Ylww*x) + sqrt(y*Ypw) + sqrt(Ymw*z));
eqf := Ytotf*(1 + cos(42.497)) = 2*(sqrt(Ylwf*x) + sqrt(y*Ypf) + sqrt(Ymf*z));
eqd := Ytotd*(1 + cos(30.405)) = 2*(sqrt(Ylwd*x) + sqrt(y*Ypd) + sqrt(Ymd*z));
solve([eqw, eqf, eqd], [x, y, z]) assuming positive; # does not work or takes too long

.2498809711*Ytotw = 2*(Ylww*x)^(1/2)+2*(y*Ypw)^(1/2)+2*(Ymw*z)^(1/2)

 

1.085395047*Ytotf = 2*(Ylwf*x)^(1/2)+2*(y*Ypf)^(1/2)+2*(Ymf*z)^(1/2)

 

1.531075873*Ytotd = 2*(Ylwd*x)^(1/2)+2*(y*Ypd)^(1/2)+2*(Ymd*z)^(1/2)

(1)

indets(eqw)

{Ylww, Ymw, Ypw, Ytotw, x, y, z, (Ylww*x)^(1/2), (Ymw*z)^(1/2), (y*Ypw)^(1/2)}

(2)

indets(eqf)

{Ylwf, Ymf, Ypf, Ytotf, x, y, z, (Ylwf*x)^(1/2), (Ymf*z)^(1/2), (y*Ypf)^(1/2)}

(3)

indets(eqd)

{Ylwd, Ymd, Ypd, Ytotd, x, y, z, (Ylwd*x)^(1/2), (Ymd*z)^(1/2), (y*Ypd)^(1/2)}

(4)

#assuming positve for the parameters in the rhs

eqw := W__1*(1 + cos(66.696))/2 = W__2*sqrt(x) + W__3*sqrt(y) + W__4*sqrt(z);

eqf := F__1*(1 + cos(42.497))/2 = F__2*sqrt(x) + F__3*sqrt(y) + F__4*sqrt(z);

eqd := D__1*(1 + cos(30.405))/2 = D__2*sqrt(x) + D__3*sqrt(y) + D__4*sqrt(z);;

.1249404856*W__1 = W__2*x^(1/2)+W__3*y^(1/2)+W__4*z^(1/2)

 

.5426975235*F__1 = F__2*x^(1/2)+F__3*y^(1/2)+F__4*z^(1/2)

 

.7655379365*D__1 = D__2*x^(1/2)+D__3*y^(1/2)+D__4*z^(1/2)

(5)

solve([eqw, eqf, eqd], [x, y, z]) ;

[[x = 0.1000000000e-19*(7655379365.*D__1*F__3*W__4-7655379365.*D__1*F__4*W__3-5426975235.*D__3*F__1*W__4+1249404856.*D__3*F__4*W__1+5426975235.*D__4*F__1*W__3-1249404856.*D__4*F__3*W__1)^2/(D__2*F__3*W__4-1.*D__2*F__4*W__3-1.*D__3*F__2*W__4+D__3*F__4*W__2+D__4*F__2*W__3-1.*D__4*F__3*W__2)^2, y = 0.1000000000e-19*(7655379365.*D__1*F__2*W__4-7655379365.*F__4*W__2*D__1-5426975235.*D__2*F__1*W__4+1249404856.*F__4*W__1*D__2+5426975235.*D__4*F__1*W__2-1249404856.*D__4*F__2*W__1)^2/(D__2*F__3*W__4-1.*D__2*F__4*W__3-1.*D__3*F__2*W__4+D__3*F__4*W__2+D__4*F__2*W__3-1.*D__4*F__3*W__2)^2, z = 0.1000000000e-19*(7655379365.*F__2*W__3*D__1-7655379365.*F__3*W__2*D__1-5426975235.*D__2*F__1*W__3+1249404856.*W__1*D__2*F__3+5426975235.*D__3*F__1*W__2-1249404856.*D__3*F__2*W__1)^2/(D__2*F__3*W__4-1.*D__2*F__4*W__3-1.*D__3*F__2*W__4+D__3*F__4*W__2+D__4*F__2*W__3-1.*D__4*F__3*W__2)^2]]

(6)

NULL

Download solve_with_decimal.mw

Maple provides a command for functional differentiation.

restart;

f := Int(p(w)*q(w)-lambda*q(w)^rho, w = 0 .. n)

Int(p(w)*q(w)-lambda*q(w)^rho, w = 0 .. n)

(1)

 

f_:=IntegrationTools:-Change(f,w=omega)

Int(p(omega)*q(omega)-lambda*q(omega)^rho, omega = 0 .. n)

(2)

# following eq 25 and 26 from ?Physics,Fundiff

Physics:-Fundiff(f_,q(w))

(-Heaviside(w-n)+Heaviside(w))*(p(w)-q(w)^rho*rho*lambda/q(w))

(3)

# functional derivative value at w

simplify(%) assuming w<n

Heaviside(w)*(p(w)-rho*lambda*q(w)^(-1+rho))

(4)

# functionald derivative value at w=n

limit((3),w=n,left)

Heaviside(n)*(p(n)-exp(ln(q(n))*rho)*rho*lambda/q(n))

(5)

 

Personally I feel much more comfortable interpreting the results in answers from @Rouben Rostamian and @mmcdara but maybe this is what you are looking for.

Download mw_fundiff.mw

It works flawless with 2021 and 2022. I assume that recent sincos simplifcations have introduced this regression.

Needs to be reported, IMO

With my 2024.2 version (Physics version installed in this computer is 1831 created 2024, November 21, 11:42 hours Pacific Time) the below worked

forget(all);
odetest(sol,ode,y(x));
                               0

What you are looking for is a kind of memory dump and restore. I am not aware of such an option but did you know that output with an equation label is available without executing the worksheet?

If not try the following:

Do not execute the worksheet

1

(1)

a := 1

Type here "a"NULL

Type here crtl-l and 1

Download GUI_Output.mw

I have tried

sumpro := proc(i) local a, b; a := rand(1 .. 10)(); b := rand(1 .. 10)(); print("Sum of ", a, " and ", b, " is ", a + b); end proc;
CodeGeneration:-CSharp(sumpro);
Error, (in Printer:-Print) invalid input: Printer:-Function:-Get expects its 1st argument, fname, to be of type string, but received CodeGeneration:-Names:-Name("rand")

Looks like that CodeGeneration:-CSharp cannot translate Maple library function rand to C#

You could try LLMs. Note that i is not used in your code. You can remove it.

Chat CPT:

using System;

class Program
{
    static void SumPro(int i)
    {
        // Generate random numbers between 1 and 10
        Random random = new Random();
        int a = random.Next(1, 11); // Upper bound is exclusive, so use 11 for 1 to 10
        int b = random.Next(1, 11);

        // Print the sum
        Console.WriteLine($"Sum of {a} and {b} is {a + b}");
    }

    static void Main(string[] args)
    {
        SumPro(0); // Example usage with a dummy parameter
    }
}

Gemini:

using System;

public class MapleToCSharp
{
    public static void SumPro(int i)
    {
        Random rand = new Random(); // Create a Random object outside the loop for better randomness
        int a = rand.Next(1, 11); // Generates random integers between 1 (inclusive) and 11 (exclusive), i.e., 1 to 10
        int b = rand.Next(1, 11);

        Console.WriteLine($"Sum of {a} and {b} is {a + b}"); // Use string interpolation for cleaner output
    }

    public static void Main(string[] args)
    {
        // Example usage (equivalent to calling sumpro(i) in Maple):
        SumPro(0); // The 'i' parameter isn't actually used in the Maple code, so we can pass any value.
        SumPro(1); // Call it again to show it generates different random numbers each time
    }
}

I have added a few (t) to some variables in the equations of your worksheet.
The equations were in non executable mode. I changed that to executable and applied dsolve to the equations.

Below is the solution. Since you have not given initial conditions for the variables, the solution contains integration constants c__i. Maple cannot solve the second differential equation symbolically and returns the equation unchanged. This does not mean that there is no such solution. It simply means that Maple does not provide such a solution. You have to give initial conditions for the variables, numerical values for the parameters of the equation and solve numerically with dsolve.

NULL

diff(Q1(t), t) = -k1*Q1(t)

diff(Q1(t), t) = -k1*Q1(t)

(1)

 

diff(Q2(t), t) = k1*Q1(t)+k3/Q2(t)-k2*Q2(t)-k4*Q2(t)

diff(Q2(t), t) = k1*Q1(t)+k3/Q2(t)-k2*Q2(t)-k4*Q2(t)

(2)

 

diff(Q3(t), t) = k4*Q2(t)

diff(Q3(t), t) = k4*Q2(t)

(3)

 

diff(Q4(t), t) = k2*Q2(t)-k3/Q2(t)

diff(Q4(t), t) = k2*Q2(t)-k3/Q2(t)

(4)

 

dsolve({diff(Q1(t), t) = -k1*Q1(t), diff(Q2(t), t) = k1*Q1(t)+k3/Q2(t)-k2*Q2(t)-k4*Q2(t), diff(Q3(t), t) = k4*Q2(t), diff(Q4(t), t) = k2*Q2(t)-k3/Q2(t)})

[{Q1(t) = c__3*exp(-k1*t)}, {diff(Q2(t), t) = (k1*Q1(t)*Q2(t)-k4*Q2(t)^2-k2*Q2(t)^2+k3)/Q2(t)}, {Q3(t) = Int(k4*Q2(t), t)+c__2}, {Q4(t) = Int((k2*Q2(t)^2-k3)/Q2(t), t)+c__1}]

(5)

NULL

Download System_Of_Differential_Equations_reply.mw

An example would be helpfull. Other users could compare the perfomance of your system to their system.

To start you can compare your system to this one (i7-10710U CPU @ 1.10GHz):

f := sin(x + y) - exp(x)*y = 0:
g := x^2 - y = 2:
CodeTools:-Usage(fsolve( {f, g}, {x = -1..1, y = -2..0} ));

memory used=7.79MiB, alloc change=33.00MiB, cpu time=94.00ms, real time=87.00ms, gc time=0ns

A recent processor model i9-13900H 2.6 GHz ("high" performance mobile) is about 3 times faster in cpu time. You will not get much more speed on a laptop.

The graphics card is probably not used for your problem. You can check in task manager for GPU usage.

Q1: Your setup looks good, however for a better overview on the structure of the problem it is helpfull to replace all subexpression that do not depend on the unkowns lambda[i] by new parameters (new names). Do denom(eq1) for example to see what we are dealing with. These are big expressions.

Q2: Ok

Q3:Yes, see Q1. You can for example use innert operators when defining the equations

pTRw:=((p%^T) %. R) %. w

In this case I would not use the assignemt operator (":=") to define p, R, w. Use equations for later substitution/evaluation like p=...

Concerning the problem:

You want to solve a system of polynominal equations. The equations are of 4th degree. Try for all equations and unknowns the following to investigate:

degree(simplify((eq1-lambda[1])*denom(eq1)),lambda[1])
                               4

As you posed the problem Maple assumes all parameters complex. This adds, besides the size of the equations, an addtional burden to Maple. It could be that there are symbolic solutions in the complex domain but Maple has to investigate many cases. This takes time.

Therefore, reducing the complexity of the problem by using assumptions and upfront simplification of the equations helps allot.

Maybe a soluton by hand is possible but for that we have to see the structure of the equations in the first place

1 2 3 4 5 6 7 Last Page 2 of 17