MaplePrimes Questions

Hi,

is there a way to control the way axes tickmark numbers are formated, especially number of decimal places? I have 3 consecutive plot comands with the same options for similar functions in the same x range (and similar y range) and the thickmarks on each plot have differently formated numbers on axes:

1)

2)

3)

 

in each case I'm calling:

plot(func..., opt2d, labels = [x, U...])

the opt2d are:

fntsz2 := 14;
opt2d := (x = 90 .. 160, size = [500, 200], font = ["Arial", fntsz2], labelfont = ["Arial", fntsz2], labeldirections = [horizontal, vertical]);

I'd like to get all the plots formatted like in the 3rd case: x axis: ticks starting at min (90), numbers rounded to integers; y axis: "0" before decimal point, 2 decimal places.

 

regards

Wojtek

singular(csc(z), z);
                          {z = _Z1 Pi}
getassumptions(_Z1);
       {_Z1::(AndProp(integer, RealRange(1, infinity)))}

discont(csc(z), z);
                            {Pi _Z2}
getassumptions(_Z2);
                         {_Z2::integer}

 

I'm not sure why singular adds the condition _Z1>=1.

 

Assume I had a 2D line

how to put and draw this line into a new geometric world defined by patch?

 Can anyone help me with this problem. I am trying to solve it and its given me an error message "Error, (in dsolve/numeric/bvp) cannot determine a suitable initial profile, please specify an approximate initial solution".


 

restart

with(ODETools):

with(student):

dsolve[interactive]()

with(plots)

with(plottools)

inf := 5

unprotect('gamma')

NULL

equ1 := diff(f(eta), `$`(eta, 3))-(3/4)*f(eta)*(diff(f(eta), `$`(eta, 2)))+(1/2)*(diff(f(eta), eta))^2-theta(eta)-N*gamma(eta) = 0:

equ2 := diff(theta(eta), `$`(eta, 2))-(3/4)*f(eta)*(diff(theta(eta), eta)) = 0:

equ3 := diff(gamma(eta), `$`(eta, 2))-(3/4)*L__e*P__r*f(eta)*(diff(gamma(eta), eta)) = 0:

Bcs := f(0) = 0, (D(f))(0) = 0, theta(0) = 1, (D(f))(inf) = 0, theta(inf) = 0, gamma(0) = 1, gamma(inf) = 0

f(0) = 0, (D(f))(0) = 0, theta(0) = 1, (D(f))(5) = 0, theta(5) = 0, gamma(0) = 1, gamma(5) = 0

(1)

Parameter := [P__r = .72, N = 1, L__e = 1]:

S1 := dsolve({Bcs, subs(Parameter, equ1), subs(Parameter, equ2), subs(Parameter, equ3)}, {f(eta), gamma(eta), theta(eta)}, type = numeric)

Error, (in dsolve/numeric/bvp) cannot determine a suitable initial profile, please specify an approximate initial solution

 

``


 

Download Numerical.mw

 Looking forward to your favorable response.

Kind regard

In Maple 2017.2:

if true then print(1);print(2);print(3);print(4);print(5) end if;
                               1
                               3
                               5

 

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

 

First 820 821 822 823 824 825 826 Last Page 822 of 2308