MaplePrimes Questions

Hello!

 

I am trying to create a Fortran routine that creates and populates a large 2D array, using Maple's codegen or CodeGeneration capabilities. I would like Maple to create the Fortran code so that the column-major ordering is respected: I would like Maple to populate mat(1,1), mat(2,1), mat(n,1) before moving on to mat(1,2)... Unfortunately, codegen and CodeGeneration seem to only produce row-major code.

Any idea on how to proceed, or an option of the code generation that I would have missed?

 

Thanks for your help!

Etienne

soslve('(cosh(C + cosh(C))/cosh(C) = 2') gives me a "Waning, solutions may have ben lost" message and no answer.

Write a procedure which inverts a given 2x2 matrix ie
Given a list of 4 numbers (a,b,c,d) return numbers (x,yz,w) such that
Matrix(a,b,c,d)(Matrix(x,y,z,w)) =Identity matrix

I want to find the area of the triangle ABC with the sides are a, b, c. I tried

a:=sqrt(91)/6:

b:=sqrt(17)/2:

c:=sqrt(13)/3:

p:=(a+b+c)/2:

s:=simplify(sqrt(p*(p-a)*(p-b)*(p-c)));

How can I get the result sqrt(523)/24?

How to test  associativity?

How to determine which of below has associativity?

 

The definition x*(y*z) = (x*y)*z.

asso := -(1/2)*(x+y+sqrt(x^2+2*x*y-3*y^2))/y;
asso := -(1/4)*(2*x+y+sqrt(4*x^2+4*x*y-7*y^2))/y;
asso := -(2*x+y)/(y+z);
asso := (1/2)*(-y-z+sqrt(y^2-2*z*y+z^2-8*z*x))/z;
asso := (1/2)*(-z+sqrt(z^2-4*z*x-4*z*y))/z;

 

Question

Find t1,t2,t3,...t9 in Matrix
Matrix(3, 3, {(1, 1) = 1+t1, (1, 2) = t2, (1, 3) = t3, (2, 1) = t4, (2, 2) = 1+t5, (2, 3) = t6, (3, 1) = t7, (3, 2) = t8, (3, 3) = t9})

osys := (1/2)*(-x-x*t1-y*t2-y*t3+sqrt(x^2+2*x^2*t1+2*x*y*t2+2*x*y*t3+x^2*t1^2+2*x*t1*y*t2+2*x*t1*y*t3+y^2*t2^2+2*y^2*t2*t3+y^2*t3^2-4*x*t4*y*t9-4*x^2*t4*t7-4*x*t4*y*t8-4*y^2*t9-4*y*x*t7-4*y^2*t8-4*y^2*t5*t9-4*y*t5*x*t7-4*y^2*t5*t8-4*y^2*t6*t9-4*y*t6*x*t7-4*y^2*t6*t8))/(x*t4+y+y*t5+y*t6) = (-x+sqrt(x^2-x*y-2*y^2))/(2*y+x)
sys1 := subs(x=0, osys);
sys2 := subs(y=0, osys);
sys3 := subs(x=1, osys);
sys4 := subs(y=1, osys);
sys5 := subs(x=2, osys);
sys6 := subs(y=2, osys);
sys7 := subs(x=3, osys);
sys8 := subs(y=3, osys);
sys9 := subs(x=4, osys);
solve([sys1, sys2, sys3, sys4, sys5, sys6, sys7, sys8, sys9],[t1,t2,t3,t4,t5,t6,t7,t8,t9]);

 

since i have only one equation osys, to find t1..t9, i substitute some values into x and y to get enough equation to solve this , however, the result is not expected below

 

then i try without x= 0 or y = 0 , i failed

sys1 := subs(x=3,subs(y=2, osys));
sys2 := subs(x=5,subs(y=1, osys));
sys3 := subs(x=1,subs(y=5, osys));
sys4 := subs(x=1,subs(y=2, osys));
sys5 := subs(x=2,subs(y=5, osys));
sys6 := subs(x=5,subs(y=2, osys));
sys7 := subs(x=2,subs(y=1, osys));
sys8 := subs(x=3,subs(y=5, osys));
sys9 := subs(x=5,subs(y=3, osys));
solve([sys1, sys2, sys3, sys4, sys5, sys6, sys7, sys8, sys9],[t1,t2,t3,t4,t5,t6,t7,t8,t9]);

 

 

solution : Matrix(3, 3, {(1, 1) = 2, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 1, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1})

 t1 = 1

t2 = 0

t3 = 0

t4 = 1

t5 = 0

t6 = 1 

t7 = 0

t8 = 0

t9 = 1

Trying to write a procedure to just reduce the vales of x.. 

restart: 

proc_r:= proc(x :: numeric) 

local x0:

x := x0: 

 

#reducing the value to between -Pi and Pi

 

do 

 if ( x0 <= evalf(Pi) ) then 

  break: 

 end if: 

 

 x0 := x0 - 2*evalf(Pi)

end do: 

 

do 

 if (x0 >= evalf(-Pi) ) then

  break: 

 end if:

 

 x0 := x0 + 2*evalf(Pi)

end do: 

 

#using the symmetry of sin to reduce to between -Pi/2 and Pi/2 

 

 if (x0 <= evalf(Pi/2) ) then  

 break:

end if: 

x0 := evalf(Pi) - x0:

 

if (x0 >= evalf(-Pi/2) ) then 

 break:

end if: 

x0 := evalf(-Pi) - x0:

 

return x0:

 

end proc:

 

proc_r(7);  

 

Error, (in proc_r) illegal use of a formal parameter

 

Why do i get this error message... 
How do i fix it? 

Hi there!

I wrote a piece of code which spits out the numerical datapoints (x,y(x)) corresponding to a function y(x). So that the result is accurate, I need quite a lot of data points - currently I am working with 5k.

In order to work with this function later, I interpolated it with a Spline. For instance, I would like to sample the function values on a fifferent grid, etc.. However the evaluation of this function really takes up hell of a lot of time, and the reason seems to be, that it, being a spline on 5k nodes, is simply a huge expression.

Is there a better way to do this? Are other fitting functions than a spline maybe better suited?

Thanks for help!

 

I have defined the following procedure, S(x,a,b,s), in Maple with the goal of creating an exportable two column, multi-row array, containing the least positive real root of a high order polynomial f(x,y)=0 in the 2nd column, and a parameter y in the first column.

The procedure takes four numerical arguments (x,a,b,s) and varies parameter y from the initial non-negative value of a, by stepsize s, until the value min(b,1) is reached.

Unfortunately, the output 4x2 array only has the last calculated [y,solution] entries in the first row. Successive rows are filled with zeros.

Is there anyone kind enough to point out the error in the way I have defined this procedure? Many thanks in advance. Procedure is:

S := proc (x, a, b, s
   global Ry;
   for y from a by s to b while y < 1
     do R := Array(1 .. ceil((min(b, 1)-a)/s), 1 .. 2, [[y, FindMinimalElement(select(type, [fsolve(f(x) = 0)], positive))]])
     end do;
     end proc;

I have a nested list a := [[1,2,3],[4,5,6],[7,8,9]]: and would like to apply a function f to the 1st elements in nested list, e.g. [[f(1),2,3],[f(4),5,6],[f(7),8,9]]. How can I achieve this?

Thanks in advance.

what is the difference between endomorphism and identity map?

http://mathfaculty.fullerton.edu/mathews//n2003/hornermod.html

i find a program above, 

if no general method, how about specific to convert it

if have general method, how is it?

I have defined a function by doing

 

f:= (x1,x2,x3) -> sum( [complicated expression], [summation ranges]),

 

which Maple converts to an explicit polynomial in x1,x2,x3.

 

However, it seems Maple does not quite think of f as this polynomial, but always remembers the original definition of f. How should I do in order for Maple to really define f to be this explicit polynomial?

 

 

I'm trying to animate transparency, here's are the plots:

A :=tranz-> plot3d(-2/sqrt(x^2+y^2)+5/sqrt((x-1.6)^2+y^2), x = -5 .. 5, y = -5 .. 5, view = [-5 .. 5, -5 .. 5, -5 .. 5], transparency = tranz) end proc;
B := sphere([0, 0, 0], 2*(1/10), color = magenta, style = patchnogrid):
C := sphere([1.6, 0, 0], 5*(1/10), color = green, style = patchnogrid);
E := plot3d(0, x = -5 .. 5, y = -5 .. 5, view = [-5 .. 5, -5 .. 5, -5 .. 5], style = wireframe, shading = zgrayscale):

here I am displaying them without a problem:

display(A(.5), B, C, E, scaling = constrained, view = [-5 .. 5, -5 .. 5, -5 .. 5], axes = normal)

here I am trying to animate the transparency in plot A to no avail :( :

animate(display, [A(tranz), B, C, E, scaling = constrained, view = [-5 .. 5, -5 .. 5, -5 .. 5], axes = normal], tranz = 0.1 .. 0.9)
Error, (in plot3d) expecting option transparency to be of type {"default", realcons} but received tranz

if you guys could help me find where I'm going wrong I'd be super grateful :D

thanks everyone.

Best,

-Mike

I have an equation with the following structure:

sin(a)-sin(b)=0;

Maple can solve this:

solve(%,[b]);

[[b=a]]

so it misses the 2nd solution (b=π-a). I can use the allsolutions qualifier:

solve(%,[b],allsolutions);

and now Maple returns an expression that, while correct, is really not conducive to further work without fairly massive substition work (_Z10 has to be 0 and the solutions wanted have _B10 0 and 1). In a classroom settng this is not helpful. Try as I might using the options to solve I have not found a way to make this into a list of the two solution I want without extensively mucking around with the expression. Is there any way to coerce solve to return something simpler?

I really want something like

[b=a,b=π-a]

TIA,

Mac Dude.

 

First 1469 1470 1471 1472 1473 1474 1475 Last Page 1471 of 2429