## 13010 Reputation

18 years, 190 days

## Sort the x'es...

Robert Israel beat me to it, but I'll let the following stay.

Assuming that the values x[i] are sorted increasingly, you can do

piecewise(t < x[1], hz[1], t < x[2], hz[2], t< x[3], hz[3], t < x[4], hz[4], t < x[5], hz[5],t < x[6], hz[6], t < x[7], hz[7], t< x[8], hz[8], t < x[9], hz[9], t <= x[10], hz[10]);

since piecewise checks the inequalities from the left and stops if the inequality is satisfied.

Even shorter is

piecewise(op(map(op,[seq([t<x[i],h[i]],i=1..9)])),t<=x[10],hz[10]);

where I have singled out the last one since you want <= (if you really do).

Notice that I have used t instead of x. It is not a good idea to use x as a variable name if x[i] is in use.

Preben Alsholm

## Simply too nasty...

I don't think you are missing anything.

I tried

F1:=combine(Fder):

solve(F1=0, h);
h
i.e. output is h (!). However, the expression F1 is huge. But certainly this answer is strange.
If you plot F1 you run into numerical problems, which is not surprising.

plot(F1,h=0..Pi,-1.5..1.5);

Preben Alsholm

## What are you trying to plot?...

Try executing the two sums

sum(f,i=-infinity..infinity);
sum(f(i),i=-infinity..infinity);

and ask yourself if those sums really are what you want to plot.

Preben Alsholm

## ln(0) appears...

Just one thing.

In your example the first term in the sum is p*ln(0), which prevents solve from doing anything in solve( eqn[21,2], s);

Preben Alsholm

## Problematic start...

Since

eval(rhs(eqn13),{f(z)=1,e(z)=1,z=0});
evaluates to

-6210.378246*I

i.e. an imaginary number, you may want to rethink the mathematics of the problem. Is there a wrong sign under the squareroot in eqn13?

Preben Alsholm

## Left hand side not a name...

You are trying to assign to a sequence of sums.

In the help page for assign it says that you can assign to names or functions, where 'function' means an unevalated  function call, like f(8).

Preben Alsholm

## Do the circles differently...

If I understand your intention correctly, then one solution is to draw only parts of the circles. Find find the relevant angles and use a parametric representation, as I have done below.

I have not changed much of your original code.

restart;
with(plots):
S1:=unapply(u*FresnelS(u)+((1/Pi)*cos((1/2)*Pi*u^2))-(1/Pi),u);
C1:=unapply(u*FresnelC(u)-((1/Pi)*sin((1/2)*Pi*u^2)),u);
R1:=1;
u1:=evalf(sqrt(0.4));
E1:=evalf(Pi*R1*S1(u1)+R1);
D1:=evalf(Pi*R1*C1(u1)+1);
a:=evalf(Pi*R1*(u1));
p1:=plot([1+a*FresnelC(u),a*FresnelS(u)-E1,u=0..u1]):
p2:=plot(-1.064877386,x=0..1):
p3:=plot(1.064877386,x=0..1):
p4:=plot([1+a*FresnelC(u),-a*FresnelS(u)+E1,u=0..u1]):
p5:=plot(-1.064877386,x=-1..0):
p6:=plot(1.064877386,x=-1..0):
p7:=plot([-1+(-a*FresnelC(u)),a*FresnelS(u)-E1,u=0..u1]):
p8:=plot([-1+(-a*FresnelC(u)),-a*FresnelS(u)+E1,u=0..u1]):
X:=1+a*FresnelC(u1);
t1:=fsolve(D1+R1*cos(t)=X,t);
C1:=plot([D1+R1*cos(t),R1*sin(t),t=-t1..t1]):
C2:=plot([-D1-R1*cos(t),R1*sin(t),t=-t1..t1]):
display(p7,p1,p2,p3,p4,p5,p6,p8,C1,C2,scaling=constrained);

Preben Alsholm

## Yet another way...

You already got some excellent solutions.

Here is another.

eq:=diff(y(x),x,x)+y(x)^2*x^2=x^2;
a:=[-0.6,-0.4,2.4,3.4];
sol:=y1->subs(dsolve({eq,y(0)=0,D(y)(0)=y1},numeric,output=listprocedure),y(x)):
#sol(y1) is the numerical procedure for evaluating y(x) (with D(y)(0)=y1), so that
sol(-0.6)(0.12345);
#will return the value of y(0.12345)
#and
plot([seq(sol(a[i]),i=1..4)],0..2);
# will plot the 4 different solutions in one plot.

Preben Alsholm

## Homework...

Do you expect us to do your homework?

(Excuse me if I was mistaken).

Preben Alsholm

## Same index in two different sums...

Two sums inside each other are using the same summation index. This leads to questions of interpretation.

If you change the expression to

f := Sum( exp(-beta*(2*x2-1)-alpha*(2*x2-1))
/ Sum( Sum( exp(-beta*(4*x0*x1-2*x0-2*x1+1)-alpha*(2*x0-1)), x1=0..1 ),
x0=0..1 ),
x2=0..1 );
where I have replaced x0 in three places by x2 the interpretation is clear and there is no problem.

Preben Alsholm

## Use subs...

subs(solutions,P);

will give you -6.960403739*10^(-13).

Preben Alsholm

## Use dsolve/numeric with infinity = 20...

You could use dsolve/numeric with infinity = 20 (or whatever):

m := 1;
de := diff(y(x), x, x, x)+((m+1)*(1/2))*y(x)*(diff(y(x), x, x))+m*(1-(diff(y(x), x))^2) = 0;
L:=dsolve({de,y(0) = 0, D(y)(0) = 0, D(y)(20) = 1},numeric);
plots:-odeplot(L,[x,y(x)],x=0..8);

The graphs on your photo are not graphs of y(x), but you can use odeplot to plot functions of y(x) also.

Preben Alsholm

## Missing 'and' and commas ...

You need 'and' between the boolean expressions. Also a few commas in the print statements were forgotten.

Here is the corrected version:

local det;
det:=b^2-4*a*c;
if a=0 and b=0 and c=0 then print( "All x is solution")
elif a=0 and b=0 and c<>0 then print ("No solution")
elif a=0 and b<>0 and c<>0 then print("One solution:",x=-c/b)
elif det>0 then print("Two real solutions:",x1=(-b+sqrt(det))/(2*a),x2=(-b-sqrt(det))/(2*a))
elif (det<0) then print("Two complex solutions:",x1=(-b+sqrt(det))/(2*a),x2=(-b-sqrt(det))/(2*a))
else print("Two identical solutions:",x=-b/(2*a))
end if;
end proc;

Be aware that your procedure is designed for numerical input only. Thus quad(r,s,t); doesn't work unless r, s, and t are assigned numerical values.

Preben Alsholm

## Random hermitian matrices...

Here is one way,

with(LinearAlgebra):
G:=RandomTools:-Generate(complex(distribution(Normal(0,.5))), makeproc=true);
Gd:=RandomTools:-Generate(distribution(Normal(0,.5)), makeproc=true);
A:=RandomMatrix(3,3,generator=G,outputoptions=[shape=hermitian]);
B:=RandomMatrix(3,3,generator=Gd,outputoptions=[shape=diagonal]);
C:=A+B;
Eigenvalues(C);

Preben Alsholm

## Looks like an exercise I...

Looks like an exercise I could have given my first semester students.
Maple sees xysin as a variable name, xysin(x-y) is an application of the function xysin to x-y.
Maple doesn't know any function by that name, so cannot plot it.

You need two multiplication signs.

Why grid = [2,2]?

Preben Alsholm

 First 153 154 155 156 Page 155 of 156
﻿