MaplePrimes Questions

I have just installed jEdit. Have written 2 files.Started with "open in mode  maple". So text gets nicely coloured. Can save the files ok as .mpl. I have several questions
1) How do I make the code indent/format?

2)How should I test the code? Can jEdit show me errors? I am running jEdit and maple side by side. Save, Read, hit bug...

3)How do I format an imported .mpl from maple?

4)How do I get $include to work?

Testr1:=proc(a,b)
description "Jedit test";
local A,B;
A:=a;B:=b;
if is(A<B) then print ('smaller')
elif is(A>B) then print('bigger')
else print('cant_say')
end if;
return cos(A+B), sin(A-B),A,B;
end proc;
TestjEdit:=module()
option pagkage;
export Testr1;
$include "Testr1.mpl"
end module;
#imported file
Antisym := proc (V::{Matrix(3,3,shape = antisymmetric,algebraic), Vector(3)})
local M; description "converts vector to antisymmetric matrix and back"; if 
type(V,Vector) then M := Matrix(3,3,shape = antisymmetric); M[1,2] := -V[3]; M
[1,3] := V[2]; M[2,3] := -V[1] else M := Vector(3,[-V[2,3], V[1,3], -V[1,2]])
end if; M end proc;

restart

currentdir()

"C:\Users\Ronan\Documents\MAPLE\Rational_Trigonometry"

(1)

read "C:\\Users\\Ronan\\Documents\\jEdit\\Testr1.mpl"

proc (a, b) local A, B; description "Jedit test"; A := a; B := b; if is(A < B) then print('smaller') elif is(B < A) then print('bigger') else print('cant_say') end if; return cos(A+B), sin(A-B), A, B end proc

(2)

"print("'Testr1'")"

(3)

Testr1(2, 4)

cos(6), -sin(2), 2, 4

(4)

Testr1(x, 5)

cos(x+5), sin(-5+x), x, 5

(5)

Testr1(x, x+1)

cos(2*x+1), -sin(1), x, x+1

(6)

restart

read "C:\\Users\\Ronan\\Documents\\jEdit\\TestjEdit.mpl"

$include "Testr1.mpl";
^

Error, while reading ``C:\Users\Ronan\Documents\jEdit\TestjEdit.mpl``

 

TestjEdit:-Testr1(2, 1)

Error, `TestjEdit` does not evaluate to a module

 

``


 

Download Jedit_testing.mw
 

restart

currentdir()

"C:\Users\Ronan\Documents\MAPLE\Rational_Trigonometry"

(1)

read "C:\\Users\\Ronan\\Documents\\jEdit\\Testr1.mpl"

proc (a, b) local A, B; description "Jedit test"; A := a; B := b; if is(A < B) then print('smaller') elif is(B < A) then print('bigger') else print('cant_say') end if; return cos(A+B), sin(A-B), A, B end proc

(2)

"print("'Testr1'")"

(3)

Testr1(2, 4)

cos(6), -sin(2), 2, 4

(4)

Testr1(x, 5)

cos(x+5), sin(-5+x), x, 5

(5)

Testr1(x, x+1)

cos(2*x+1), -sin(1), x, x+1

(6)

restart

read "C:\\Users\\Ronan\\Documents\\jEdit\\TestjEdit.mpl"

$include "Testr1.mpl";
^

Error, while reading ``C:\Users\Ronan\Documents\jEdit\TestjEdit.mpl``

 

TestjEdit:-Testr1(2, 1)

Error, `TestjEdit` does not evaluate to a module

 

``


 

Download Jedit_testing.mw

 

singular(1/((x-a)*(x-b)), x);
                            {x = a}
singular(1/((x-a)*(x-2*b)), x);
                       {x = a}, {x = 2 b}

The first one clearly doesn't work as expected.

 

I wonder what the built-in algorithm is used in "fsolve". From some references, it seems to be Newton iteration. 
But fsolve succeeds to quickly find a root of multiplicity more than 1, which can't be achieved by Newton iteration. So I wonder whether there are other techniques involved? Thank you!

The expression is:

sqrt(Dp)*(-Dp*sqrt(s+thetac)*alpha1*pinf*s^2-2*Dp*sqrt(s+thetac)*alpha1*pinf*s*thetac-Dp*sqrt(s+thetac)*alpha1*pinf*thetac^2+A2*Dp*sqrt(s+thetac)*alpha1*s+A2*Dp*sqrt(s+thetac)*alpha1*thetac+Dc*sqrt(s+thetac)*alpha1*pinf*s^2+Dc*sqrt(s+thetac)*alpha1*pinf*s*thetac+A1*Dc*alpha1*s^2+A1*Dc*alpha1*s*thetac+A1*sqrt(Dc)*sqrt(s+thetac)*s^2+A1*sqrt(Dc)*sqrt(s+thetac)*s*thetac-A2*Dc*sqrt(s+thetac)*alpha1*s)*exp((-lh+x)*sqrt(s)/sqrt(Dp))/((s+thetac)^(3/2)*s*(Dc*s-Dp*s-Dp*thetac)*(-sqrt(Dp)*alpha1+sqrt(s)))

Is there a way to solve these equations x+y = 373320 and z = (x+y) / 0.44 - y -  y* (1 - 0.99) for x,y,z in Maple or excel?

Even if we set y = 37320 - x 

and plug that in we get z= 37320/0.44 - (37320-x) - (37320 - x) * (1-0.99) there are still two unknown z and x

Maybe some optimization?  Thanx for any input

Dear all, 

I am using a custom wrapper to access the subroutines defined in a fortran DLL. The fortran code is pretty basic: it takes three arguments, a, b, mult. Being a subroutine. it returns the result in 'mult'.

Currently, I can get the result from fortran DLL in my wrapper code. I am not able to get it back in Maple. 

My fortran code is as under: 

      subroutine multiply(a1,b1, mult1) bind (C, name="multiply")

        use iso_c_binding
        implicit none

        real (c_double), intent(in), VALUE :: a1
        real (c_double), intent(in), VALUE :: b1
        real (c_double), intent(out) :: mult1

        mult1 = a1*b1

        return
      end subroutine multiply

I tried using this subroutine from a regular C file and it works, so this code works the way it should. 

Now the custom wrapper that I use (obtained by editing the auto-generated wrapper)

/* MWRAP_multiply Wrapper
   Generated automatically by Maple 2015.0.
   Do not edit this file. */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mplshlib.h>

#include <maplec.h>

typedef void *MaplePointer;
static MKernelVector mapleKernelVec;
static ALGEB *args;

/* main - MWRAP_multiply */
//ALGEB M_DECL MWRAP_multiply( MKernelVector kv,
//	void (M_DECL *fn) ( FLOAT64 a1, FLOAT64 a2, FLOAT64 a3 ),
//	ALGEB fn_args )

ALGEB mmultiply(MKernelVector kv, ALGEB fn_args)

{
    FLOAT64 a1;
    FLOAT64 a2;
    FLOAT64 a3;

    int i;
    mapleKernelVec = kv;
    args = (ALGEB*) fn_args;

    if( MapleNumArgs(mapleKernelVec,(ALGEB)args) != 3 )
        MapleRaiseError(mapleKernelVec,"Incorrect number of arguments");

     /* float[8] */
    a1 = MapleToFloat64(mapleKernelVec,args[1]);

    /* float[8] */
    a2 = MapleToFloat64(mapleKernelVec,args[2]);

    /* float[8] */
    a3 = MapleToFloat64(mapleKernelVec,args[3]);

    //(*fn)(a1, a2, a3);
    multiply(a1, a2, &a3);

    MaplePrintf(kv, "Output from multiply %f", a3);

    return( ToMapleNULL(mapleKernelVec) );
}

Since the fortran subroutine calls are call by reference, we need to pass the address of a3, (&a3). Then I compile this to create the DLL using: 

gcc -shared -fPIC -o libmmultiply.so mult.f90 mwrap_multiply.c -I /opt/maple2015/extern/include/ -L /opt/maple2015/bin.X86_64_LINUX/ -lmaplec -lgfortran

And then copying the resulting DLL (libmmultiply.so) to the Maple/bin folder. 

Then in Maple : 

mult := define_external("mmultiply",MAPLE,LIB="libmmultiply.so");

mult1 := 0.01;

mult(2., 3., mult1);
### Printed in Maple: Output from multiply 6.000000

mult1;
### Still 0.01 (we want this to be 6.0)

So, it can be seen that the fortran subroutine is successfully executed, so we get 6.0 as the output. However, this does'nt get assigned to 'mult1. The reason for this, I feel, is that the reference to the original variable 'mult1' in Maple is lost in the wrapper, and so the resulting value doesn't update 'mult1'. 

How can I get the resulting value back in Maple ? I want to get this in 'mult1', as most fortran legacy codes use the subroutine method of returning results by updating the arguments. 

Thanks 

Chintan Pathak 

I have gotten an expression:

eq21 := collect(eq20, [exp(-sqrt(s)*x/sqrt(Dp)), exp(sqrt(s)*(-lh+x)/sqrt(Dp)), exp((-2*lh+x)*sqrt(s)/sqrt(Dp)), exp((lh-x)*sqrt(s+thetac)/sqrt(Dc))], simplify);

q(x, s) = exp(-sqrt(s)*x/sqrt(Dp))*_F1(s)+sqrt(Dp)*(-Dp*sqrt(s+thetac)*alpha1*pinf*s^2-2*Dp*sqrt(s+thetac)*alpha1*pinf*s*thetac-Dp*sqrt(s+thetac)*alpha1*pinf*thetac^2+A2*Dp*sqrt(s+thetac)*alpha1*s+A2*Dp*sqrt(s+thetac)*alpha1*thetac+Dc*sqrt(s+thetac)*alpha1*pinf*s^2+Dc*sqrt(s+thetac)*alpha1*pinf*s*thetac+A1*Dc*alpha1*s^2+A1*Dc*alpha1*s*thetac+A1*sqrt(Dc)*sqrt(s+thetac)*s^2+A1*sqrt(Dc)*sqrt(s+thetac)*s*thetac-A2*Dc*sqrt(s+thetac)*alpha1*s)*exp(sqrt(s)*(-lh+x)/sqrt(Dp))/((s+thetac)^(3/2)*(-sqrt(Dp)*alpha1+sqrt(s))*s*(Dc*s-Dp*s-Dp*thetac))+(sqrt(Dp)*alpha1+sqrt(s))*_F1(s)*exp((-2*lh+x)*sqrt(s)/sqrt(Dp))/(-sqrt(Dp)*alpha1+sqrt(s))+Dc*A1*exp((lh-x)*sqrt(s+thetac)/sqrt(Dc))/((Dc*s-Dp*s-Dp*thetac)*sqrt(s+thetac))-(-pinf*s-pinf*thetac+A2)/((s+thetac)*s)

I need to further simplify the coefficient of

exp(sqrt(s)*(-lh+x)/sqrt(Dp))

Would you like to give some tips?

Thanks.

 

Can any one correct my code in module for it to work. The procedure is just add 2 and return.My_Module_Mistake.mw
 

restartaction1:-Mproc(2)

Error, `action1` does not evaluate to a module

 

action1:-Mproc(2)

Error, `action1` does not evaluate to a module

 

with(MathematicalFunctions);
action1:=module ()
        export Mproc,y;
                Mproc:= proc (n)
                        y:=n+2;                
                end proc;
end module()


 

Download My_Module_Mistake.mw

 

Hi , you all

I have another question of the day. As I get deeper in my math I find these little things popping up that I don't understand what they mean or provide for the answer

 =

Now that gamma in the denominator is what concerns me.  I haven't found any reference to this use for gamma, So , I come here to find the answer.

Thanks Bill

I am importing an excel worksheet xlsx file in to a datafile. Though the formatting in excel is perfect with 3 decimals, the data table stores many values in 14 decimals. How do I convert? What is the command? Can any one help me.

I enclose the doc and excel file for reference and use. I tried in many ways, but failed to convert.MP1_Data.xlsxDoubt_NumberFormat_in_DataTable.mw
 

NULL

 

``

27.90

(1)

BTE := evalf(2.3)*Import("E:/A_PhD2017/MP1_Data.xlsx", "Brake_Thermal_Efficiency")

``

``


 

Download Doubt_NumberFormat_in_DataTable.mw

 

 =  =

In the above output I  am geting trig functions. This is taking the derivative of f(x).  I would like to keep the answer in rational output

ie.

Hey!

 

I have the following Diff. EQ. which I wish to solve:

 

EQ:=(3*x)*(diff(y(t),t,t)+y(t)=0

 

Where y(t) = sum(c[n]*x^n,n=0..infinity)

 

The result should be the following c[n+1] = -c[n]/(3*(n+1))

 

How would I solve this in Maple? Is there any package which can do this? Thank you! 

how to calculate potential energy in terms of gauss curvature?

In this expression,

q(x, s) = -(-(-thetac*s^(3/2)-s^(5/2)+(s^2+s*thetac)*alpha1*sqrt(Dp))*Dc*A1*exp((lh-x)*sqrt(s+thetac)/sqrt(Dc))+((alpha1*(s+thetac)*(-pinf*s-pinf*thetac+A2)*Dp^(3/2)+s*sqrt(Dp)*(A1*(s+thetac)*sqrt(Dc)-Dc*alpha1*(-pinf*s-pinf*thetac+A2)))*sqrt(s+thetac)+A1*sqrt(Dp)*s*Dc*alpha1*(s+thetac))*exp(sqrt(s)*(-lh+x)/sqrt(Dp))-(-_F1(s)*(-s*alpha1*(s+thetac)^2*Dp^(3/2)-s^(3/2)*Dp*thetac^2+thetac*(Dc-2*Dp)*s^(5/2)+(Dc-Dp)*s^(7/2)+sqrt(Dp)*s^2*Dc*alpha1*(s+thetac))*exp((-2*lh+x)*sqrt(s)/sqrt(Dp))+_F1(s)*(-s*alpha1*(s+thetac)^2*Dp^(3/2)-thetac*(Dc-2*Dp)*s^(5/2)+(-Dc+Dp)*s^(7/2)+s^(3/2)*Dp*thetac^2+sqrt(Dp)*s^2*Dc*alpha1*(s+thetac))*exp(-sqrt(s)*x/sqrt(Dp))+alpha1*(s+thetac)*(-pinf*s-pinf*thetac+A2)*Dp^(3/2)+(-pinf*(Dc-2*Dp)*thetac+A2*(Dc-Dp))*s^(3/2)-pinf*(Dc-Dp)*s^(5/2)-s*alpha1*Dc*(-pinf*s-pinf*thetac+A2)*sqrt(Dp)-sqrt(s)*Dp*thetac*(-pinf*thetac+A2))*sqrt(s+thetac))/((s+thetac)^(3/2)*s*((Dc-Dp)*s-Dp*thetac)*(sqrt(Dp)*alpha1-sqrt(s)))

 

I want to simplify the coeffcients of

exp((lh-x)*sqrt(s+thetac)/sqrt(Dc)), exp(sqrt(s)*(-lh+x)/sqrt(Dp)), exp((-2*lh+x)*sqrt(s)/sqrt(Dp)), exp(-sqrt(s)*x/sqrt(Dp)).

 

 

 

I have a big matrix 1000*1000, How Maple could declare the number (corresponding row and coulumn) of element that is maximum?

Suppose the element (113,987) of my matrix has the maximum value, which command returns (113,987)?

 

First 940 941 942 943 944 945 946 Last Page 942 of 2428